1 #include <Elementary.h>
10 * This is a widget specifically for displaying the map. It uses basically
11 * OpenStreetMap provider. but it can be added custom providers.
13 * Signals that you can add callbacks for are:
15 * "clicked" - This is called when a user has clicked the map without dragging
18 * "press" - This is called when a user has pressed down on the map.
20 * "longpressed" - This is called when a user has pressed down on the map for
21 * a long time without dragging around.
23 * "clicked,double" - This is called when a user has double-clicked the map.
25 * "load,detail" - Map detailed data load begins.
27 * "loaded,detail" - This is called when all parts of the map are loaded.
29 * "zoom,start" - Zoom animation started.
31 * "zoom,stop" - Zoom animation stopped.
33 * "zoom,change" - Zoom changed when using an auto zoom mode.
35 * "scroll" - the content has been scrolled (moved)
37 * "scroll,anim,start" - scrolling animation has started
39 * "scroll,anim,stop" - scrolling animation has stopped
41 * "scroll,drag,start" - dragging the contents around has started
43 * "scroll,drag,stop" - dragging the contents around has stopped
45 * "downloaded" - This is called when map images are downloaded
47 * "route,load" - This is called when route request begins
49 * "route,loaded" - This is called when route request ends
51 * "name,load" - This is called when name request begins
53 * "name,loaded- This is called when name request ends
59 typedef struct _Widget_Data Widget_Data;
60 typedef struct _Pan Pan;
61 typedef struct _Grid Grid;
62 typedef struct _Grid_Item Grid_Item;
63 typedef struct _Marker_Group Marker_Group;
64 typedef struct _Mod_Api Mod_Api;
65 typedef struct _Event Event;
66 typedef struct _Route_Node Route_Node;
67 typedef struct _Route_Waypoint Route_Waypoint;
68 typedef struct _Url_Data Url_Data;
69 typedef struct _Route_Dump Route_Dump;
70 typedef struct _Name_Dump Name_Dump;
72 #define DEST_DIR_ZOOM_PATH "/tmp/elm_map/%d/%d/"
73 #define DEST_DIR_PATH DEST_DIR_ZOOM_PATH"%d/"
74 #define DEST_FILE_PATH "%s%d.png"
75 #define DEST_ROUTE_XML_FILE "/tmp/elm_map-route-XXXXXX"
76 #define DEST_NAME_XML_FILE "/tmp/elm_map-name-XXXXXX"
78 #define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php"
79 #define ROUTE_TYPE_MOTORCAR "motocar"
80 #define ROUTE_TYPE_BICYCLE "bicycle"
81 #define ROUTE_TYPE_FOOT "foot"
82 #define YOURS_DISTANCE "distance"
83 #define YOURS_DESCRIPTION "description"
84 #define YOURS_COORDINATES "coordinates"
86 // TODO: fix monav & ors url
87 #define ROUTE_MONAV_URL "http://"
88 #define ROUTE_ORS_URL "http:///"
90 #define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org"
91 #define NOMINATIM_RESULT "result"
92 #define NOMINATIM_PLACE "place"
93 #define NOMINATIM_ATTR_LON "lon"
94 #define NOMINATIM_ATTR_LAT "lat"
96 #define PINCH_ZOOM_MIN 0.25
97 #define PINCH_ZOOM_MAX 3.0
100 // Currently the size of a tile must be 256*256
101 // and the size of the map must be pow(2.0, z)*tile_size
102 typedef struct _Map_Sources_Tab
104 Elm_Map_Sources source;
108 ElmMapSourceURLFunc url_cb;
109 Elm_Map_Route_Sources route_source;
110 ElmMapRouteSourceURLFunc route_url_cb;
111 ElmMapNameSourceURLFunc name_url_cb;
116 //Zemm min is supposed to be 0
117 static char *_mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
118 static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
119 static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
120 static char *_maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
121 static char *_module_url_cb(Evas_Object *obj, int x, int y, int zoom);
122 static char * _custom1_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
123 static char * _custom2_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
124 static char * _custom3_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
125 static char * _custom4_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
126 static char * _custom5_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
127 static char * _custom6_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
129 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
131 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
132 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
134 static char *_route_custom1_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
135 static char *_route_custom2_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
136 static char *_route_custom3_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
137 static char *_route_custom4_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
138 static char *_route_custom5_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
139 static char *_route_custom6_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
141 static char *_route_module_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
144 static char *_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat);
145 static char *_name_custom1_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
146 static char *_name_custom2_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
147 static char *_name_custom3_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
148 static char *_name_custom4_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
149 static char *_name_custom5_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
150 static char *_name_custom6_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
152 static Map_Sources_Tab map_sources_tab[] =
154 {ELM_MAP_SOURCE_MAPNIK, "Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
155 {ELM_MAP_SOURCE_OSMARENDER, "Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
156 {ELM_MAP_SOURCE_CYCLEMAP, "Cycle Map", 0, 17, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
157 {ELM_MAP_SOURCE_MAPLINT, "Maplint", 12, 16, _maplint_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
158 {ELM_MAP_SOURCE_CUSTOM_1, "Custom 1", 0, 18, _custom1_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_1, _route_custom1_url_cb, _name_custom1_url_cb},
159 {ELM_MAP_SOURCE_CUSTOM_2, "Custom 2", 0, 18, _custom2_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_2, _route_custom2_url_cb, _name_custom2_url_cb},
160 {ELM_MAP_SOURCE_CUSTOM_3, "Custom 3", 0, 18, _custom3_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_3, _route_custom3_url_cb, _name_custom3_url_cb},
161 {ELM_MAP_SOURCE_CUSTOM_4, "Custom 4", 0, 18, _custom4_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_4, _route_custom4_url_cb, _name_custom4_url_cb},
162 {ELM_MAP_SOURCE_CUSTOM_5, "Custom 5", 0, 18, _custom5_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_5, _route_custom5_url_cb, _name_custom5_url_cb},
163 {ELM_MAP_SOURCE_CUSTOM_6, "Custom 6", 0, 18, _custom6_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_6, _route_custom6_url_cb, _name_custom6_url_cb},
164 {ELM_MAP_SOURCE_MODULE, "Module", 0, 18, _module_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb}
169 Ecore_Con_Url *con_url;
175 struct _Elm_Map_Marker_Class
180 struct _Elm_Map_Marker_Class_Func {
181 ElmMapMarkerGetFunc get;
182 ElmMapMarkerDelFunc del; //if NULL the object will be destroyed with evas_object_del()
183 ElmMapMarkerIconGetFunc icon_get;
186 struct { //this part is private, do not modify these values
188 Evas_Coord edje_w, edje_h;
192 struct _Elm_Map_Marker
195 Elm_Map_Marker_Class *clas;
196 Elm_Map_Group_Class *clas_group;
197 double longitude, latitude;
200 Evas_Coord x[ZOOM_MAX+1], y[ZOOM_MAX+1];
203 Marker_Group *groups[ZOOM_MAX+1];
205 Evas_Object *content;
208 struct _Elm_Map_Group_Class
212 int zoom_displayed; // display the group if the zoom is >= to zoom_display
213 int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
217 ElmMapGroupIconGetFunc icon_get;
220 struct { //this part is private, do not modify these values
222 Evas_Coord edje_w, edje_h;
223 Evas_Coord edje_max_w, edje_max_h;
225 Eina_List *objs_used;
226 Eina_List *objs_notused;
233 Eina_Matrixsparse_Cell *cell;
234 Elm_Map_Group_Class *clas;
237 long long sum_x, sum_y;
241 Evas_Object *obj, *bubble, *sc, *bx, *rect;
243 Eina_Bool bringin : 1;
244 Eina_Bool update_nbelems : 1;
245 Eina_Bool update_resize : 1;
246 Eina_Bool update_raise : 1;
247 Eina_Bool delete_object : 1;
250 struct _Elm_Map_Route
256 Ecore_Con_Url *con_url;
261 double flon, flat, tlon, tlat;
263 Eina_List *nodes, *path;
270 const char *waypoints;
271 double distance; /* unit : km */
284 Eina_Bool inbound : 1;
298 struct _Route_Waypoint
309 Ecore_Con_Url *con_url;
314 Ecore_Event_Handler *handler;
327 Eina_Bool download : 1;
329 Ecore_File_Download_Job *job;
336 int tsize; // size of tile (tsize x tsize pixels)
337 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
338 int iw, ih; // size of image in pixels
339 int w, h; // size of grid image in pixels (represented by grid)
340 int gw, gh; // size of grid in tiles
341 Eina_Matrixsparse *grid;
348 Evas_Object *pan_smart;
350 Evas_Object *sep_maps_markers; //map objects are below this object and marker objects are on top
352 Evas_Coord pan_x, pan_y, minw, minh;
357 Elm_Map_Zoom_Mode mode;
360 Ecore_Timer *scr_timer;
361 Ecore_Timer *long_timer;
362 Ecore_Animator *zoom_animator;
363 double t_start, t_end;
373 Evas_Coord x, y ,w ,h;
379 Eina_Bool resized : 1;
380 Eina_Bool on_hold : 1;
381 Eina_Bool paused : 1;
382 Eina_Bool paused_markers : 1;
389 Ecore_Job *markers_place_job;
390 Eina_Matrixsparse *markers[ZOOM_MAX+1];
391 Eina_List *cells_displayed; // list of Eina_Matrixsparse_Cell
392 Evas_Coord markers_max_num;
393 int marker_max_w, marker_max_h;
395 Eina_List *opened_bubbles; //opened bubbles, list of Map_Group *
397 Eina_List *groups_clas; // list of Elm_Map_Group_Class*
398 Eina_List *markers_clas; // list of Elm_Map_Markers_Class*
400 Elm_Map_Sources source;
401 Elm_Map_Route_Sources route_source;
403 Eina_List *s_event_list;
408 const char *user_agent;
410 Evas_Event_Mouse_Down ev;
432 Eina_Bool (*obj_hook) (Evas_Object *obj);
433 Eina_Bool (*obj_unhook) (Evas_Object *obj);
434 char * (*obj_url_request) (Evas_Object *obj, int x, int y, int zoom);
435 Eina_Bool (*obj_convert_coord_into_geo) (const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat);
436 Eina_Bool (*obj_convert_geo_into_coord) (const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y);
440 Evas_Object_Smart_Clipped_Data __clipped_data;
456 Evas_Coord x, y, w, h;
459 Ecore_Timer *hold_timer;
474 enum _Route_Xml_Attribute
478 ROUTE_XML_DESCRIPTION,
479 ROUTE_XML_COORDINATES,
481 } Route_Xml_Attibute;
491 enum _Name_Xml_Attribute
508 static const char *widtype = NULL;
510 static const char SIG_CHANGED[] = "changed";
511 static const char SIG_CLICKED[] = "clicked";
512 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
513 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
514 static const char SIG_LOAD_DETAIL[] = "load,detail";
515 static const char SIG_LONGPRESSED[] = "longpressed";
516 static const char SIG_PRESS[] = "press";
517 static const char SIG_SCROLL[] = "scroll";
518 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
519 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
520 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
521 static const char SIG_ZOOM_START[] = "zoom,start";
522 static const char SIG_ZOOM_STOP[] = "zoom,stop";
523 static const char SIG_DOWNLOADED[] = "downloaded";
524 static const char SIG_ROUTE_LOAD[] = "route,load";
525 static const char SIG_ROUTE_LOADED[] = "route,loaded";
526 static const char SIG_NAME_LOAD[] = "name,load";
527 static const char SIG_NAME_LOADED[] = "name,loaded";
528 static const Evas_Smart_Cb_Description _signals[] = {
531 {SIG_CLICKED_DOUBLE, ""},
532 {SIG_LOADED_DETAIL, ""},
533 {SIG_LOAD_DETAIL, ""},
534 {SIG_LONGPRESSED, ""},
537 {SIG_SCROLL_DRAG_START, ""},
538 {SIG_SCROLL_DRAG_STOP, ""},
539 {SIG_ZOOM_CHANGE, ""},
540 {SIG_ZOOM_START, ""},
542 {SIG_DOWNLOADED, ""},
543 {SIG_ROUTE_LOAD, ""},
544 {SIG_ROUTE_LOADED, ""},
546 {SIG_NAME_LOADED, ""},
550 static void _pan_calculate(Evas_Object *obj);
552 static Eina_Bool _hold_timer_cb(void *data);
553 static void _rect_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
554 static void _del_hook(Evas_Object *obj);
555 static void _theme_hook(Evas_Object *obj);
556 static void _on_focus_hook(void *data, Evas_Object *obj);
557 static void _sizing_eval(Evas_Object *obj);
558 static void _calc_job(void *data);
559 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
560 Evas_Callback_Type type, void *event_info);
561 static void grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
562 static void grid_clear(Evas_Object *obj, Grid *g);
563 static Grid *grid_create(Evas_Object *obj);
564 static void grid_load(Evas_Object *obj, Grid *g);
567 static void _group_object_create(Marker_Group *group);
568 static void _group_object_free(Marker_Group *group);
569 static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
570 static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
571 static void _group_bubble_create(Marker_Group *group);
572 static void _group_bubble_free(Marker_Group *group);
573 static void _group_bubble_place(Marker_Group *group);
575 static int _group_bubble_content_update(Marker_Group *group);
576 static void _group_bubble_content_free(Marker_Group *group);
577 static void marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
578 static void _bubble_sc_hits_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
580 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
581 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
582 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
584 static void _mouse_multi_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
585 static void _mouse_multi_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
586 static void _mouse_multi_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
588 static void route_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
591 get_multi_device(Evas_Object *obj)
593 Widget_Data *wd = elm_widget_data_get(obj);
597 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
599 if (ev->device) return ev->device;
605 get_distance(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
609 return sqrt((dx * dx) + (dy * dy));
613 create_event_object(void *data, Evas_Object *obj, int device)
615 Widget_Data *wd = elm_widget_data_get(data);
616 Event *ev = calloc(1, sizeof(Event));
618 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, NULL);
622 evas_object_geometry_get(obj, &ev->x, &ev->y, &ev->w, &ev->h);
623 wd->s_event_list = eina_list_append(wd->s_event_list, ev);
628 get_event_object(void *data, int device)
630 Widget_Data *wd = elm_widget_data_get(data);
634 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
636 if (ev->device == device) break;
643 destroy_event_object(void *data, Event *ev)
645 Widget_Data *wd = elm_widget_data_get(data);
646 EINA_SAFETY_ON_NULL_RETURN(ev);
648 wd->s_event_list = eina_list_remove(wd->s_event_list, ev);
651 ecore_timer_del(ev->hold_timer);
652 ev->hold_timer = NULL;
658 module(Evas_Object *obj __UNUSED__)
660 static Elm_Module *m = NULL;
662 if (!(m = _elm_module_find_as("map/api"))) return NULL;
664 m->api = malloc(sizeof(Mod_Api));
665 if (!m->api) return NULL;
666 ((Mod_Api *)(m->api) )->obj_hook =
667 _elm_module_symbol_get(m, "obj_hook");
668 ((Mod_Api *)(m->api) )->obj_unhook =
669 _elm_module_symbol_get(m, "obj_unhook");
670 ((Mod_Api *)(m->api) )->obj_url_request =
671 _elm_module_symbol_get(m, "obj_url_request");
672 ((Mod_Api *)(m->api) )->obj_convert_coord_into_geo =
673 _elm_module_symbol_get(m, "obj_convert_coord_into_geo");
674 ((Mod_Api *)(m->api) )->obj_convert_geo_into_coord =
675 _elm_module_symbol_get(m, "obj_convert_geo_into_coord");
681 obj_rotate_zoom(void *data, Evas_Object *obj)
683 ELM_CHECK_WIDTYPE(data, widtype);
684 Widget_Data *wd = elm_widget_data_get(data);
685 if ((!wd->pinch.cx) && (!wd->pinch.cy))
687 wd->pinch.cx = wd->rotate.cx;
688 wd->pinch.cy = wd->rotate.cy;
691 Evas_Map *map = evas_map_new(4);
694 evas_map_util_points_populate_from_object_full(map, obj, 0);
695 evas_map_util_zoom(map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy);
696 evas_map_util_rotate(map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
697 evas_object_map_enable_set(obj, EINA_TRUE);
698 evas_object_map_set(obj, map);
703 route_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py, Evas_Coord ox __UNUSED__, Evas_Coord oy __UNUSED__, Evas_Coord ow, Evas_Coord oh)
705 ELM_CHECK_WIDTYPE(obj, widtype);
706 Widget_Data *wd = elm_widget_data_get(obj);
709 Eina_List *lr, *lp, *ln;
715 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
717 EINA_LIST_FOREACH(wd->route, lr, r)
719 EINA_LIST_FOREACH(r->path, lp, p)
724 evas_object_geometry_get(wd->rect, &rx, &ry, NULL, NULL);
725 nodes = eina_list_count(r->nodes);
727 EINA_LIST_FOREACH(r->nodes, ln, n)
729 if ((!wd->zoom) || ((n->idx) &&
730 ((n->idx % (int)ceil((double)nodes/(double)size*100.0))))) continue;
733 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
734 if ((x >= px - ow) && (x <= (px + ow*2)) &&
735 (y >= py - oh) && (y <= (py + oh*2)))
740 p = eina_list_nth(r->path, n->idx);
741 evas_object_line_xy_set(p, r->x, r->y, x, y);
742 evas_object_color_set(p, r->color.r, r->color.g, r->color.b, r->color.a);
743 evas_object_raise(p);
744 obj_rotate_zoom(obj, p);
749 else r->inbound = EINA_FALSE;
753 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
754 if ((x >= px - ow) && (x <= (px + ow*2)) &&
755 (y >= py - oh) && (y <= (py + oh*2)))
759 r->inbound = EINA_TRUE;
761 else r->inbound = EINA_FALSE;
764 r->inbound = EINA_FALSE;
769 rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
771 Widget_Data *wd = elm_widget_data_get(obj);
772 Evas_Coord ax, ay, gw, gh, hh, ww;
774 evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh);
781 if ((ww == gw) && (hh == gh)) return;
783 if (ow > gw) ax = (ow - gw) / 2;
784 if (oh > gh) ay = (oh - gh) / 2;
785 evas_object_move(wd->rect,
788 evas_object_resize(wd->rect, gw, gh);
792 wd->show.show = EINA_FALSE;
793 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
798 marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
800 Widget_Data *wd = elm_widget_data_get(obj);
801 Evas_Coord ax, ay, gw, gh, tx, ty;
802 Eina_List *l, *markers;
803 Eina_Matrixsparse_Cell *cell;
808 int g_xx, g_yy, g_hh, g_ww;
811 if (g != eina_list_data_get(wd->grids)) return;
817 if (ow > gw) ax = (ow - gw) / 2;
818 if (oh > gh) ay = (oh - gh) / 2;
820 if (wd->zoom != wd->marker_zoom)
822 EINA_LIST_FREE(wd->cells_displayed, cell)
824 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
826 if (group->obj) _group_object_free(group);
830 wd->marker_zoom = wd->zoom;
832 if ((wd->paused_markers)
833 && ((wd->size.nw != wd->size.w) || (wd->size.nh != wd->size.h)) )
836 g_xx = wd->pan_x / wd->tsize;
837 if (g_xx < 0) g_xx = 0;
838 g_yy = wd->pan_y / wd->tsize;
839 if (g_yy < 0) g_yy = 0;
840 g_ww = ow / wd->tsize + 1;
841 if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
842 g_hh = oh / wd->tsize + 1;
843 if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
845 //hide groups no more displayed
846 EINA_LIST_FREE(wd->cells_displayed, cell)
848 eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x);
849 if ((y < g_yy) || (y > g_yy + g_hh) || (x < g_xx) || (x > g_xx + g_ww))
851 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
853 if (group->obj) _group_object_free(group);
858 for (y = g_yy; y <= g_yy + g_hh; y++)
860 for (x = g_xx; x <= g_xx + g_ww; x++)
862 if (!wd->markers[wd->zoom]) continue;
863 eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell);
865 wd->cells_displayed = eina_list_append(wd->cells_displayed, cell);
866 markers = eina_matrixsparse_cell_data_get(cell);
867 EINA_LIST_FOREACH(markers, l, group)
869 if (!group->markers) continue;
870 if (group->clas->zoom_displayed > wd->zoom) continue;
877 if (eina_list_count(group->markers) == 1)
879 Elm_Map_Marker *m = eina_list_data_get(group->markers);
880 ww = m->clas->priv.edje_w;
881 hh = m->clas->priv.edje_h;
887 if ((gw != g->w) && (g->w > 0))
890 xx = ((long long )gw * xx) / g->w;
891 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
893 if ((gh != g->h) && (g->h > 0))
896 yy = ((long long)gh * yy) / g->h;
897 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
900 if ((!group->clas->hide)
901 && (xx-px+ax+ox >= ox) && (xx-px+ax+ox<= ox+ow)
902 && (yy-py+ay+oy >= oy) && (yy-py+ay+oy<= oy+oh))
904 if (!group->obj) _group_object_create(group);
906 if (group->update_nbelems)
908 group->update_nbelems = EINA_FALSE;
909 if (eina_list_count(group->markers) > 1)
911 snprintf(buf, sizeof(buf), "%d", eina_list_count(group->markers));
912 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
915 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", "");
917 evas_object_move(group->obj,
918 xx - px + ax + ox - ww/2,
919 yy - py + ay + oy - hh/2);
920 if ((!wd->paused_markers) || (group->update_resize))
922 group->update_resize = EINA_FALSE;
923 evas_object_resize(group->obj, ww, hh);
924 obj_rotate_zoom(obj, group->obj);
926 if (group->update_raise)
928 group->update_raise = EINA_FALSE;
929 evas_object_raise(group->obj);
930 obj_rotate_zoom(obj, group->obj);
931 evas_object_show(group->obj);
933 if (group->bubble) _group_bubble_place(group);
937 _group_object_free(group);
945 grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
947 Widget_Data *wd = elm_widget_data_get(obj);
948 Evas_Coord ax, ay, gw, gh, tx, ty;
957 if (ow > gw) ax = (ow - gw) / 2;
958 if (oh > gh) ay = (oh - gh) / 2;
960 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
961 Eina_Matrixsparse_Cell *cell;
963 EINA_ITERATOR_FOREACH(it, cell)
965 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
971 if ((gw != g->w) && (g->w > 0))
974 xx = ((long long )gw * xx) / g->w;
975 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
977 if ((gh != g->h) && (g->h > 0))
980 yy = ((long long)gh * yy) / g->h;
981 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
983 evas_object_move(gi->img,
987 evas_object_resize(gi->img, ww, hh);
989 obj_rotate_zoom(obj, gi->img);
990 /*evas_object_move(gi->txt,
994 evas_object_resize(gi->txt, ww, hh);
997 eina_iterator_free(it);
1001 grid_clear(Evas_Object *obj, Grid *g)
1003 Widget_Data *wd = elm_widget_data_get(obj);
1007 if (!g->grid) return;
1009 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1010 Eina_Matrixsparse_Cell *cell;
1012 snprintf(buf, sizeof(buf), DEST_DIR_ZOOM_PATH, wd->id, g->zoom);
1013 ecore_file_recursive_rm(buf);
1015 EINA_ITERATOR_FOREACH(it, cell)
1017 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1018 evas_object_del(gi->img);
1019 //evas_object_del(gi->txt);
1023 gi->want = EINA_FALSE;
1025 if (!wd->preload_num)
1027 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1028 "elm,state,busy,stop", "elm");
1029 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
1035 DBG("DOWNLOAD abort %s", gi->file);
1036 ecore_file_download_abort(gi->job);
1037 ecore_file_remove(gi->file);
1042 eina_stringshare_del(gi->file);
1046 eina_matrixsparse_free(g->grid);
1047 eina_iterator_free(it);
1054 _tile_update(Grid_Item *gi)
1056 gi->want = EINA_FALSE;
1057 gi->download = EINA_FALSE;
1058 evas_object_image_file_set(gi->img, gi->file, NULL);
1059 if (evas_object_image_load_error_get(gi->img) != EVAS_LOAD_ERROR_NONE)
1060 ecore_file_remove(gi->file);
1062 obj_rotate_zoom(gi->wd->obj, gi->img);
1063 evas_object_show(gi->img);
1065 //evas_object_text_text_set(gi->txt, gi->file);
1066 //evas_object_show(gi->txt);
1068 gi->have = EINA_TRUE;
1069 gi->wd->preload_num--;
1070 if (!gi->wd->preload_num)
1072 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
1073 "elm,state,busy,stop", "elm");
1074 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
1080 _tile_downloaded(void *data, const char *file __UNUSED__, int status)
1082 Grid_Item *gi = data;
1084 gi->download = EINA_FALSE;
1087 DBG("DOWNLOAD done %s", gi->file);
1088 if ((gi->want) && (!status)) _tile_update(gi);
1092 DBG("Download failed %s (%d) ", gi->file, status);
1093 ecore_file_remove(gi->file);
1096 gi->wd->finish_num++;
1098 evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL);
1102 grid_create(Evas_Object *obj)
1104 Widget_Data *wd = elm_widget_data_get(obj);
1107 g = calloc(1, sizeof(Grid));
1110 g->tsize = wd->tsize;
1113 if (g->zoom > map_sources_tab[wd->source].zoom_max) return NULL;
1114 if (g->zoom < map_sources_tab[wd->source].zoom_min) return NULL;
1116 int size = pow(2.0, wd->zoom);
1120 g->w = g->tsize * g->gw;
1121 g->h = g->tsize * g->gh;
1123 g->grid = eina_matrixsparse_new(g->gh, g->gw, NULL, NULL);
1129 grid_load(Evas_Object *obj, Grid *g)
1131 Widget_Data *wd = elm_widget_data_get(obj);
1134 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
1136 Eina_Matrixsparse_Cell *cell;
1140 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
1141 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
1146 if ((gw <= 0) || (gh <= 0)) return;
1149 if ((gw != g->w) && (g->w > 0))
1150 size = ((long long)gw * size) / g->w;
1151 if (size < (g->tsize / 2)) return; // else we will load to much tiles
1153 it = eina_matrixsparse_iterator_new(g->grid);
1155 EINA_ITERATOR_FOREACH(it, cell)
1157 gi = eina_matrixsparse_cell_data_get(cell);
1164 if ((gw != g->w) && (g->w > 0))
1167 xx = ((long long )gw * xx) / g->w;
1168 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1170 if ((gh != g->h) && (g->h > 0))
1173 yy = ((long long)gh * yy) / g->h;
1174 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1177 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
1178 yy - wd->pan_y + oy,
1180 cvx, cvy, cvw, cvh))
1184 evas_object_hide(gi->img);
1185 //evas_object_hide(gi->txt);
1186 evas_object_image_file_set(gi->img, NULL, NULL);
1187 gi->want = EINA_FALSE;
1188 gi->have = EINA_FALSE;
1192 DBG("DOWNLOAD abort %s", gi->file);
1193 ecore_file_download_abort(gi->job);
1194 ecore_file_remove(gi->file);
1198 gi->download = EINA_FALSE;
1200 if (!wd->preload_num)
1202 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1203 "elm,state,busy,stop", "elm");
1204 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL,
1211 evas_object_hide(gi->img);
1212 //evas_object_hide(gi->txt);
1213 evas_object_image_preload(gi->img, 1);
1214 evas_object_image_file_set(gi->img, NULL, NULL);
1215 gi->have = EINA_FALSE;
1216 gi->want = EINA_FALSE;
1220 eina_iterator_free(it);
1222 xx = wd->pan_x / size;
1225 yy = wd->pan_y / size;
1229 if (xx + ww >= g->gw) ww = g->gw - xx - 1;
1232 if (yy + hh >= g->gh) hh = g->gh - yy - 1;
1234 for (y = yy; y <= yy + hh; y++)
1236 for (x = xx; x <= xx + ww; x++)
1238 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
1240 if ((!gi) && (g != eina_list_data_get(wd->grids)))
1245 gi = calloc(1, sizeof(Grid_Item));
1246 gi->src.x = x * g->tsize;
1247 gi->src.y = y * g->tsize;
1248 gi->src.w = g->tsize;
1249 gi->src.h = g->tsize;
1251 gi->out.x = gi->src.x;
1252 gi->out.y = gi->src.y;
1253 gi->out.w = gi->src.w;
1254 gi->out.h = gi->src.h;
1258 gi->img = evas_object_image_add(evas_object_evas_get(obj));
1259 evas_object_image_scale_hint_set
1260 (gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1261 evas_object_image_filled_set(gi->img, 1);
1263 evas_object_smart_member_add(gi->img, wd->pan_smart);
1264 elm_widget_sub_object_add(obj, gi->img);
1265 evas_object_pass_events_set(gi->img, EINA_TRUE);
1266 evas_object_stack_below(gi->img, wd->sep_maps_markers);
1268 /* gi->txt = evas_object_text_add(evas_object_evas_get(obj));
1269 evas_object_text_font_set(gi->txt, "Vera", 12);
1270 evas_object_color_set(gi->txt, 100, 100, 100, 255);
1271 evas_object_smart_member_add(gi->txt,
1273 elm_widget_sub_object_add(obj, gi->txt);
1274 evas_object_pass_events_set(gi->txt, EINA_TRUE);
1276 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
1279 if ((!gi->have) && (!gi->download))
1281 char buf[PATH_MAX], buf2[PATH_MAX];
1284 gi->want = EINA_TRUE;
1286 snprintf(buf, sizeof(buf), DEST_DIR_PATH, wd->id, g->zoom, x);
1287 if (!ecore_file_exists(buf))
1288 ecore_file_mkpath(buf);
1290 snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y);
1292 source = map_sources_tab[wd->source].url_cb(obj, x, y, g->zoom);
1293 if ((!source) || (strlen(source)==0)) continue;
1295 eina_stringshare_replace(&gi->file, buf2);
1297 if ((ecore_file_exists(buf2)) || (g == eina_list_data_get(wd->grids)))
1299 gi->download = EINA_TRUE;
1301 if (wd->preload_num == 1)
1303 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1304 "elm,state,busy,start", "elm");
1305 evas_object_smart_callback_call(obj,
1310 if (ecore_file_exists(buf2))
1314 DBG("DOWNLOAD %s \t in %s", source, buf2);
1315 ecore_file_download_full(source, buf2, _tile_downloaded, NULL, gi, &(gi->job), wd->ua);
1317 DBG("Can't start to download %s", buf);
1322 if (source) free(source);
1326 obj_rotate_zoom(obj, gi->img);
1327 evas_object_show(gi->img);
1334 grid_clearall(Evas_Object *obj)
1336 Widget_Data *wd = elm_widget_data_get(obj);
1340 EINA_LIST_FREE(wd->grids, g)
1348 _smooth_update(Evas_Object *obj)
1350 Widget_Data *wd = elm_widget_data_get(obj);
1355 EINA_LIST_FOREACH(wd->grids, l, g)
1357 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1358 Eina_Matrixsparse_Cell *cell;
1360 EINA_ITERATOR_FOREACH(it, cell)
1362 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1363 evas_object_image_smooth_scale_set(gi->img, (!wd->nosmooth));
1365 eina_iterator_free(it);
1370 _grid_raise(Grid *g)
1372 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1373 Eina_Matrixsparse_Cell *cell;
1375 g->wd->size.w = g->w;
1376 g->wd->size.h = g->h;
1378 EINA_ITERATOR_FOREACH(it, cell)
1380 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1381 evas_object_raise(gi->img);
1382 //evas_object_raise(gi->txt);
1384 eina_iterator_free(it);
1388 _scr_timeout(void *data)
1390 Widget_Data *wd = elm_widget_data_get(data);
1391 if (!wd) return ECORE_CALLBACK_CANCEL;
1393 if (!wd->nosmooth) _smooth_update(data);
1394 wd->scr_timer = NULL;
1395 return ECORE_CALLBACK_CANCEL;
1399 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1401 Widget_Data *wd = elm_widget_data_get(data);
1406 if (wd->nosmooth == 1) _smooth_update(data);
1408 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1409 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
1413 zoom_do(Evas_Object *obj)
1415 Widget_Data *wd = elm_widget_data_get(obj);
1416 Evas_Coord xx, yy, ow, oh;
1420 wd->size.w = wd->size.nw;
1421 wd->size.h = wd->size.nh;
1423 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
1424 elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy);
1429 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
1431 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
1433 wd->show.show = EINA_TRUE;
1439 if (wd->calc_job) ecore_job_del(wd->calc_job);
1440 wd->calc_job = ecore_job_add(_calc_job, wd);
1444 _zoom_anim(void *data)
1446 Evas_Object *obj = data;
1447 Widget_Data *wd = elm_widget_data_get(obj);
1450 if (!wd) return ECORE_CALLBACK_CANCEL;
1451 t = ecore_loop_time_get();
1454 else if (wd->t_end > wd->t_start)
1455 t = (t - wd->t_start) / (wd->t_end - wd->t_start);
1458 if (wd->zoom_method == ZOOM_METHOD_IN) t = 1.0 + (t * t);
1459 else if (wd->zoom_method == ZOOM_METHOD_OUT) t = 1.0 - (t * t);
1460 else return ECORE_CALLBACK_CANCEL;
1462 if ((t >= 2.0) || (t <= 0.5))
1465 Evas_Coord sx, sy, sw, sh;
1466 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
1467 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
1470 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, &lon, &lat);
1472 wd->pinch.level = 1.0;
1473 wd->center_on.enabled = EINA_TRUE;
1474 wd->center_on.lon = lon;
1475 wd->center_on.lat = lat;
1477 wd->zoom_animator = NULL;
1478 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1479 return ECORE_CALLBACK_CANCEL;
1483 Evas_Coord x, y, w, h;
1484 float half_w, half_h;
1486 evas_object_geometry_get(data, &x, &y, &w, &h);
1487 half_w = (float)w * 0.5;
1488 half_h = (float)h * 0.5;
1490 wd->pinch.level = t;
1491 wd->pinch.cx = x + half_w;
1492 wd->pinch.cy = y + half_h;
1493 if (wd->calc_job) ecore_job_del(wd->calc_job);
1494 wd->calc_job = ecore_job_add(_calc_job, wd);
1495 return ECORE_CALLBACK_RENEW;
1500 _long_press(void *data)
1502 Widget_Data *wd = elm_widget_data_get(data);
1503 if (!wd) return ECORE_CALLBACK_CANCEL;
1504 wd->long_timer = NULL;
1505 evas_object_smart_callback_call(data, SIG_LONGPRESSED, &wd->ev);
1506 return ECORE_CALLBACK_CANCEL;
1510 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1512 ELM_CHECK_WIDTYPE(data, widtype);
1513 Widget_Data *wd = elm_widget_data_get(data);
1514 Evas_Event_Mouse_Down *ev = event_info;
1517 ev0 = get_event_object(data, 0);
1519 ev0 = create_event_object(data, obj, 0);
1522 ev0->hold_timer = NULL;
1523 ev0->prev.x = ev->output.x;
1524 ev0->prev.y = ev->output.y;
1527 if (ev->button != 1) return;
1528 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1529 else wd->on_hold = EINA_FALSE;
1530 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1531 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, ev);
1533 evas_object_smart_callback_call(data, SIG_PRESS, ev);
1534 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1535 wd->ev.output.x = ev->output.x;
1536 wd->ev.output.y = ev->output.y;
1537 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1541 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1543 Evas_Event_Mouse_Move *move = event_info;
1546 ev0 = get_event_object(data, 0);
1548 ev0->prev.x = move->cur.output.x;
1549 ev0->prev.y = move->cur.output.y;
1553 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1555 ELM_CHECK_WIDTYPE(data, widtype);
1556 Widget_Data *wd = elm_widget_data_get(data);
1557 Evas_Event_Mouse_Up *ev = event_info;
1562 ev0 = get_event_object(data, 0);
1565 mdevice = get_multi_device(data);
1568 if (ev0->hold_timer)
1570 ecore_timer_del(ev0->hold_timer);
1571 ev0->hold_timer = NULL;
1573 elm_smart_scroller_hold_set(wd->scr, 0);
1574 elm_smart_scroller_freeze_set(wd->scr, 0);
1578 ev1 = get_event_object(data, mdevice);
1580 ev1->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev1);
1582 destroy_event_object(data, ev0);
1586 if (ev->button != 1) return;
1587 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1588 else wd->on_hold = EINA_FALSE;
1591 ecore_timer_del(wd->long_timer);
1592 wd->long_timer = NULL;
1594 if (!wd->on_hold) evas_object_smart_callback_call(data, SIG_CLICKED, ev);
1595 wd->on_hold = EINA_FALSE;
1599 _mouse_multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1601 ELM_CHECK_WIDTYPE(data, widtype);
1602 Widget_Data *wd = elm_widget_data_get(data);
1604 Evas_Event_Multi_Down *down = event_info;
1606 elm_smart_scroller_hold_set(wd->scr, 1);
1607 elm_smart_scroller_freeze_set(wd->scr, 1);
1609 ev = create_event_object(data, obj, down->device);
1612 DBG("Failed : create_event_object");
1617 ev->hold_timer = NULL;
1618 ev->start.x = ev->prev.x = down->output.x;
1619 ev->start.y = ev->prev.y = down->output.y;
1620 ev->pinch_start_dis = 0;
1621 wd->pinch.level = 1.0;
1622 wd->pinch.diff = 1.0;
1627 ecore_timer_del(wd->long_timer);
1628 wd->long_timer = NULL;
1634 _mouse_multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1636 ELM_CHECK_WIDTYPE(data, widtype);
1637 Widget_Data *wd = elm_widget_data_get(data);
1638 Evas_Event_Multi_Move *move = event_info;
1640 double t, tt, a, a_diff;
1644 ev = get_event_object(data, move->device);
1647 ev0 = get_event_object(data, 0);
1650 if (wd->multi_count >= 1)
1652 Evas_Coord x, y, w, h;
1653 float half_w, half_h;
1655 evas_object_geometry_get(data, &x, &y, &w, &h);
1656 half_w = (float)w * 0.5;
1657 half_h = (float)h * 0.5;
1658 dis_new = get_distance(ev0->prev.x, ev0->prev.y, ev->prev.x, ev->prev.y);
1660 if (!ev->pinch_start_dis) ev->pinch_start_dis = dis_new;
1663 ev->pinch_dis = dis_new;
1664 tt = wd->pinch.diff;
1665 wd->pinch.diff = (double)(ev->pinch_dis - ev->pinch_start_dis);
1666 t = (wd->pinch.diff * 0.01) + 1.0;
1667 if ((!wd->zoom) || ((wd->zoom + (int)t - 1) <= map_sources_tab[wd->source].zoom_min) ||
1668 ((wd->zoom + (int)t - 1) >= map_sources_tab[wd->source].zoom_max) ||
1669 (t > PINCH_ZOOM_MAX) || (t < PINCH_ZOOM_MIN))
1671 wd->pinch.diff = tt;
1676 wd->pinch.level = (wd->pinch.diff * 0.01) + 1.0;
1677 wd->pinch.cx = x + half_w;
1678 wd->pinch.cy = y + half_h;
1681 a = (double)(ev->prev.y - ev0->prev.y) / (double)(ev->prev.x - ev0->prev.x);
1682 if (!wd->rotate.a) wd->rotate.a = a;
1686 a_diff = wd->rotate.a - a;
1687 if (a_diff > 0) wd->rotate.d -= 1.0;
1688 else if (a_diff < 0) wd->rotate.d += 1.0;
1690 wd->rotate.cx = x + half_w;
1691 wd->rotate.cy = y + half_h;
1694 if (wd->calc_job) ecore_job_del(wd->calc_job);
1695 wd->calc_job = ecore_job_add(_calc_job, wd);
1699 ev->prev.x = move->cur.output.x;
1700 ev->prev.y = move->cur.output.y;
1704 _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1706 ELM_CHECK_WIDTYPE(data, widtype);
1707 Widget_Data *wd = elm_widget_data_get(data);
1708 Evas_Event_Multi_Up *up = event_info;
1715 if (wd->calc_job) ecore_job_del(wd->calc_job);
1716 if (wd->zoom_animator)
1718 ecore_animator_del(wd->zoom_animator);
1719 wd->zoom_animator = NULL;
1722 wd->paused = EINA_TRUE;
1723 if (wd->pinch.diff >= 0.0) t = wd->pinch.diff * 0.01;
1724 else if (wd->pinch.diff < 0.0) t = -1.0 / ((wd->pinch.diff * 0.01) + 1.0);
1725 elm_map_zoom_set(data, wd->zoom + (int)ceil(t));
1726 wd->pinch.level = 1.0;
1730 ev = get_event_object(data, up->device);
1733 DBG("Cannot get multi device");
1737 ev0 = get_event_object(data, 0);
1739 ev0->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev0);
1744 ecore_timer_del(ev->hold_timer);
1745 ev->hold_timer = NULL;
1748 destroy_event_object(data, ev);
1751 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
1754 _hold_timer_cb(void *data)
1758 ev0->hold_timer = NULL;
1759 return ECORE_CALLBACK_CANCEL;
1763 _rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1765 Widget_Data *wd = elm_widget_data_get(data);
1768 evas_object_geometry_get(wd->rect, &x, &y, &w, &h);
1769 evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h);
1770 evas_object_resize(wd->rect, w, h);
1771 evas_object_move(wd->rect, x, y);
1775 _del_hook(Evas_Object *obj)
1777 Elm_Map_Group_Class *group_clas;
1778 Elm_Map_Marker_Class *marker_clas;
1779 Widget_Data *wd = elm_widget_data_get(obj);
1785 Ecore_Event_Handler *h;
1791 EINA_LIST_FREE(wd->groups_clas, group_clas)
1793 if (group_clas->style)
1794 eina_stringshare_del(group_clas->style);
1798 EINA_LIST_FREE(wd->markers_clas, marker_clas)
1800 if (marker_clas->style)
1801 eina_stringshare_del(marker_clas->style);
1805 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
1807 destroy_event_object(obj, ev);
1810 EINA_LIST_FOREACH(wd->route, l, r)
1812 EINA_LIST_FREE(r->path, p)
1817 EINA_LIST_FREE(r->waypoint, w)
1819 if (w->point) eina_stringshare_del(w->point);
1823 EINA_LIST_FREE(r->nodes, n)
1825 if (n->pos.address) eina_stringshare_del(n->pos.address);
1829 EINA_LIST_FREE(r->handlers, h)
1831 ecore_event_handler_del(h);
1834 if (r->con_url) ecore_con_url_free(r->con_url);
1835 if (r->info.nodes) eina_stringshare_del(r->info.nodes);
1836 if (r->info.waypoints) eina_stringshare_del(r->info.waypoints);
1839 EINA_LIST_FREE(wd->names, na)
1841 if (na->address) free(na->address);
1842 if (na->handler) ecore_event_handler_del(na->handler);
1845 ecore_file_remove(na->ud.fname);
1847 na->ud.fname = NULL;
1851 if (wd->calc_job) ecore_job_del(wd->calc_job);
1852 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1853 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
1854 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1855 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj);
1856 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
1857 if (wd->ua) eina_hash_free(wd->ua);
1863 _del_pre_hook(Evas_Object *obj)
1865 Marker_Group *group;
1866 Elm_Map_Marker *marker;
1868 Eina_Bool free_marker = EINA_TRUE;
1870 Widget_Data *wd = elm_widget_data_get(obj);
1874 for (i = 0; i < ZOOM_MAX + 1; i++)
1876 if (!wd->markers[i]) continue;
1877 Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
1878 Eina_Matrixsparse_Cell *cell;
1880 EINA_ITERATOR_FOREACH(it, cell)
1882 l = eina_matrixsparse_cell_data_get(cell);
1883 EINA_LIST_FREE(l, group)
1885 EINA_LIST_FREE(group->markers, marker)
1887 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1888 _bubble_sc_hits_changed_cb, group);
1889 if (free_marker) free(marker);
1893 free_marker = EINA_FALSE;
1895 eina_iterator_free(it);
1896 eina_matrixsparse_free(wd->markers[i]);
1899 evas_object_del(wd->sep_maps_markers);
1900 evas_object_del(wd->pan_smart);
1901 wd->pan_smart = NULL;
1905 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
1907 Widget_Data *wd = elm_widget_data_get(obj);
1909 if (elm_widget_focus_get(obj))
1911 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
1912 evas_object_focus_set(wd->obj, EINA_TRUE);
1916 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
1917 evas_object_focus_set(wd->obj, EINA_FALSE);
1922 _theme_hook(Evas_Object *obj)
1924 Widget_Data *wd = elm_widget_data_get(obj);
1926 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
1927 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
1932 _sizing_eval(Evas_Object *obj)
1934 Widget_Data *wd = elm_widget_data_get(obj);
1935 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
1937 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
1938 evas_object_size_hint_min_set(obj, minw, minh);
1939 evas_object_size_hint_max_set(obj, maxw, maxh);
1943 _calc_job(void *data)
1945 Widget_Data *wd = data;
1946 Evas_Coord minw, minh;
1953 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
1955 double tz = wd->zoom;
1957 elm_map_zoom_set(wd->obj, tz);
1960 if ((minw != wd->minw) || (minh != wd->minh))
1964 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
1965 _sizing_eval(wd->obj);
1967 wd->calc_job = NULL;
1968 evas_object_smart_changed(wd->pan_smart);
1972 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1974 Pan *sd = evas_object_smart_data_get(obj);
1976 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1979 evas_object_smart_changed(obj);
1983 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1985 Pan *sd = evas_object_smart_data_get(obj);
1987 if (x) *x = sd->wd->pan_x;
1988 if (y) *y = sd->wd->pan_y;
1992 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1994 Pan *sd = evas_object_smart_data_get(obj);
1997 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1998 ow = sd->wd->minw - ow;
2000 oh = sd->wd->minh - oh;
2007 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
2014 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2016 Pan *sd = evas_object_smart_data_get(obj);
2018 if (w) *w = sd->wd->minw;
2019 if (h) *h = sd->wd->minh;
2023 _pan_add(Evas_Object *obj)
2026 Evas_Object_Smart_Clipped_Data *cd;
2028 cd = evas_object_smart_data_get(obj);
2030 sd = calloc(1, sizeof(Pan));
2032 sd->__clipped_data = *cd;
2034 evas_object_smart_data_set(obj, sd);
2038 _pan_del(Evas_Object *obj)
2040 Pan *sd = evas_object_smart_data_get(obj);
2046 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2048 Pan *sd = evas_object_smart_data_get(obj);
2051 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2052 if ((ow == w) && (oh == h)) return;
2053 sd->wd->resized = 1;
2054 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2055 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2059 _pan_calculate(Evas_Object *obj)
2061 Pan *sd = evas_object_smart_data_get(obj);
2062 Evas_Coord ox, oy, ow, oh;
2066 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2067 rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2068 EINA_LIST_FOREACH(sd->wd->grids, l, g)
2070 if (sd->wd->pinch.level == 1.0) grid_load(sd->wd->obj, g);
2071 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2072 marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2073 if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2078 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2080 Pan *sd = evas_object_smart_data_get(obj);
2082 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2083 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2087 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2089 Widget_Data *wd = elm_widget_data_get(obj);
2091 elm_smart_scroller_hold_set(wd->scr, 1);
2095 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2097 Widget_Data *wd = elm_widget_data_get(obj);
2099 elm_smart_scroller_hold_set(wd->scr, 0);
2103 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2105 Widget_Data *wd = elm_widget_data_get(obj);
2107 elm_smart_scroller_freeze_set(wd->scr, 1);
2111 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2113 Widget_Data *wd = elm_widget_data_get(obj);
2115 elm_smart_scroller_freeze_set(wd->scr, 0);
2119 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2121 evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
2125 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2127 evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
2131 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2133 Widget_Data *wd = elm_widget_data_get(data);
2134 wd->center_on.enabled = EINA_FALSE;
2135 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2139 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2141 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2145 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2147 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
2152 _group_object_create(Marker_Group *group)
2154 const char *style = "radio";
2155 Evas_Object *icon = NULL;
2157 if (group->obj) return;
2158 if ((!group->clas->priv.objs_notused) || (eina_list_count(group->markers) == 1))
2160 //set icon and style
2161 if (eina_list_count(group->markers) == 1)
2163 Elm_Map_Marker *m = eina_list_data_get(group->markers);
2165 style = m->clas->style;
2167 if (m->clas->func.icon_get)
2168 icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
2170 group->delete_object = EINA_TRUE;
2174 if (group->clas->style)
2175 style = group->clas->style;
2177 if (group->clas->func.icon_get)
2178 icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
2180 group->delete_object = EINA_FALSE;
2183 group->obj = elm_layout_add(group->wd->obj);
2184 elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
2186 if (icon) elm_layout_content_set(group->obj, "elm.icon", icon);
2188 evas_object_smart_member_add(group->obj, group->wd->pan_smart);
2189 elm_widget_sub_object_add(group->wd->obj, group->obj);
2190 evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
2192 if (!group->delete_object)
2193 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2197 group->delete_object = EINA_FALSE;
2199 group->obj = eina_list_data_get(group->clas->priv.objs_notused);
2200 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2201 group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
2202 evas_object_show(group->obj);
2205 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
2206 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
2208 group->update_nbelems = EINA_TRUE;
2209 group->update_resize = EINA_TRUE;
2210 group->update_raise = EINA_TRUE;
2212 if (group->open) _group_bubble_create(group);
2216 _group_object_free(Marker_Group *group)
2218 if (!group->obj) return;
2219 if (!group->delete_object)
2221 group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
2222 group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
2223 evas_object_hide(group->obj);
2225 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
2226 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
2229 evas_object_del(group->obj);
2232 _group_bubble_free(group);
2236 _group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2238 Marker_Group *group = data;
2240 if (!evas_object_above_get(group->rect)) return;
2241 evas_object_raise(group->bubble);
2242 evas_object_raise(group->sc);
2243 evas_object_raise(group->rect);
2247 _group_bubble_create(Marker_Group *group)
2249 if (group->bubble) return;
2251 group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
2252 group->bubble = edje_object_add(evas_object_evas_get(group->obj));
2253 _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
2254 elm_widget_style_get(group->wd->obj));
2255 evas_object_smart_member_add(group->bubble,
2257 elm_widget_sub_object_add(group->wd->obj, group->bubble);
2259 _group_bubble_content_free(group);
2260 if (!_group_bubble_content_update(group))
2262 //no content, we can delete the bubble
2263 _group_bubble_free(group);
2267 group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
2268 evas_object_color_set(group->rect, 0, 0, 0, 0);
2269 evas_object_repeat_events_set(group->rect, EINA_TRUE);
2270 evas_object_smart_member_add(group->rect, group->wd->obj);
2271 elm_widget_sub_object_add(group->wd->obj, group->rect);
2273 evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
2275 _group_bubble_place(group);
2278 static void _bubble_sc_hits_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2280 _group_bubble_place(data);
2284 _group_bubble_content_update(Marker_Group *group)
2287 Elm_Map_Marker *marker;
2290 if (!group->bubble) return 1;
2294 group->sc = elm_scroller_add(group->bubble);
2295 elm_widget_style_set(group->sc, "map_bubble");
2296 elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
2297 elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
2298 elm_scroller_bounce_set(group->sc, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
2299 edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
2300 evas_object_show(group->sc);
2301 evas_object_smart_member_add(group->sc,
2303 elm_widget_sub_object_add(group->wd->obj, group->sc);
2305 group->bx = elm_box_add(group->bubble);
2306 evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2307 evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
2308 elm_box_horizontal_set(group->bx, EINA_TRUE);
2309 evas_object_show(group->bx);
2311 elm_scroller_content_set(group->sc, group->bx);
2313 evas_object_event_callback_add(group->sc, EVAS_CALLBACK_RESIZE,
2314 _bubble_sc_hits_changed_cb, group);
2317 EINA_LIST_FOREACH(group->markers, l, marker)
2319 if (i >= group->wd->markers_max_num) break;
2320 if ((!marker->content) && (marker->clas->func.get))
2321 marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
2322 else if (marker->content)
2323 elm_box_unpack(group->bx, marker->content);
2324 if (marker->content)
2326 elm_box_pack_end(group->bx, marker->content);
2334 _group_bubble_content_free(Marker_Group *group)
2337 Elm_Map_Marker *marker;
2339 if (!group->sc) return;
2340 EINA_LIST_FOREACH(group->markers, l, marker)
2342 if ((marker->content) && (marker->clas->func.del))
2343 marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
2344 else if (marker->content)
2345 evas_object_del(marker->content);
2346 marker->content = NULL;
2348 evas_object_del(group->sc);
2353 _group_bubble_free(Marker_Group *group)
2355 if (!group->bubble) return;
2356 group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
2357 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2358 _bubble_sc_hits_changed_cb, group);
2359 evas_object_del(group->bubble);
2360 evas_object_del(group->rect);
2361 group->bubble = NULL;
2362 _group_bubble_content_free(group);
2366 _group_bubble_place(Marker_Group *group)
2369 Evas_Coord xx, yy, ww, hh;
2372 if ((!group->bubble) || (!group->obj)) return;
2374 evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
2375 edje_object_size_min_calc(group->bubble, NULL, &hh);
2377 s = edje_object_data_get(group->bubble, "size_w");
2378 if (s) ww = atoi(s);
2380 xx = x + w / 2 - ww / 2;
2383 evas_object_move(group->bubble, xx, yy);
2384 evas_object_resize(group->bubble, ww, hh);
2385 obj_rotate_zoom(group->wd, group->bubble);
2386 evas_object_show(group->bubble);
2388 evas_object_move(group->rect, xx, yy);
2389 evas_object_resize(group->rect, ww, hh);
2390 obj_rotate_zoom(group->wd, group->rect);
2391 evas_object_show(group->rect);
2395 _group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2397 Marker_Group *group = data;
2398 Elm_Map_Marker *marker = eina_list_data_get(group->markers);
2399 if (!marker) return;
2400 group->bringin = EINA_TRUE;
2401 elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
2405 _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2407 Marker_Group *group = data;
2411 group->bringin = EINA_FALSE;
2417 group->open = EINA_FALSE;
2418 _group_bubble_free(group);
2421 group->open = EINA_TRUE;
2422 _group_bubble_create(group);
2426 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
2431 Evas_Coord step_x = 0;
2432 Evas_Coord step_y = 0;
2435 Evas_Coord page_x = 0;
2436 Evas_Coord page_y = 0;
2438 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
2439 Evas_Event_Key_Down *ev = event_info;
2440 Widget_Data *wd = elm_widget_data_get(obj);
2441 if (!wd) return EINA_FALSE;
2442 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
2444 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
2445 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
2446 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
2447 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
2449 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
2453 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
2457 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
2461 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
2465 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
2468 y -= -(page_y * v_h) / 100;
2472 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
2475 y += -(page_y * v_h) / 100;
2479 else if (!strcmp(ev->keyname, "KP_Add"))
2481 zoom = elm_map_zoom_get(obj);
2483 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2484 elm_map_zoom_set(obj, zoom);
2487 else if (!strcmp(ev->keyname, "KP_Subtract"))
2489 zoom = elm_map_zoom_get(obj);
2491 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2492 elm_map_zoom_set(obj, zoom);
2495 else return EINA_FALSE;
2497 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2498 elm_smart_scroller_child_pos_set(wd->scr, x, y);
2504 cb_dump_name_attrs(void *data, const char *key, const char *value)
2506 Name_Dump *dump = (Name_Dump*)data;
2507 if (!dump) return EINA_FALSE;
2509 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
2510 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
2517 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2519 Route_Dump *dump = data;
2520 if (!dump) return EINA_FALSE;
2524 case EINA_SIMPLE_XML_OPEN:
2525 case EINA_SIMPLE_XML_OPEN_EMPTY:
2529 attrs = eina_simple_xml_tag_attributes_find(value, length);
2532 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
2533 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
2534 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
2535 else dump->id = ROUTE_XML_NONE;
2539 case EINA_SIMPLE_XML_DATA:
2541 char *buf = malloc(length);
2542 if (!buf) return EINA_FALSE;
2543 snprintf(buf, length, "%s", value);
2544 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
2545 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2546 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2558 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2560 Name_Dump *dump = data;
2561 if (!dump) return EINA_FALSE;
2565 case EINA_SIMPLE_XML_OPEN:
2566 case EINA_SIMPLE_XML_OPEN_EMPTY:
2569 attrs = eina_simple_xml_tag_attributes_find(value, length);
2572 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT)-1)) dump->id = NAME_XML_NAME;
2573 else dump->id = NAME_XML_NONE;
2575 eina_simple_xml_attributes_parse
2576 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
2580 case EINA_SIMPLE_XML_DATA:
2582 char *buf = malloc(length + 1);
2583 if (!buf) return EINA_FALSE;
2584 snprintf(buf, length + 1, "%s", value);
2585 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2597 _parse_kml(void *data)
2599 Elm_Map_Route *r = (Elm_Map_Route*)data;
2600 if (!r && !r->ud.fname) return;
2604 unsigned int ele, idx;
2608 Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL};
2610 f = fopen(r->ud.fname, "rb");
2615 fseek(f, 0, SEEK_END);
2621 fseek(f, 0, SEEK_SET);
2625 if (fread(buf, 1, sz, f))
2627 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump);
2634 if (dump.distance) r->info.distance = dump.distance;
2635 if (dump.description)
2637 eina_stringshare_replace(&r->info.waypoints, dump.description);
2638 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2639 r->info.waypoint_count = ele;
2640 for (idx = 0 ; idx < ele ; idx++)
2642 Route_Waypoint *wp = ELM_NEW(Route_Waypoint);
2646 wp->point = eina_stringshare_add(str[idx]);
2647 DBG("%s", str[idx]);
2648 r->waypoint = eina_list_append(r->waypoint, wp);
2657 else WRN("description is not found !");
2659 if (dump.coordinates)
2661 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2662 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2663 r->info.node_count = ele;
2664 for (idx = 0 ; idx < ele ; idx++)
2666 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2667 Route_Node *n = ELM_NEW(Route_Node);
2674 DBG("%lf:%lf", lon, lat);
2675 n->pos.address = NULL;
2676 r->nodes = eina_list_append(r->nodes, n);
2678 path = evas_object_line_add(evas_object_evas_get(r->wd->obj));
2679 evas_object_smart_member_add(path, r->wd->pan_smart);
2680 r->path = eina_list_append(r->path, path);
2693 _parse_name(void *data)
2695 Elm_Map_Name *n = (Elm_Map_Name*)data;
2696 if (!n && !n->ud.fname) return;
2700 Name_Dump dump = {0, NULL, 0.0, 0.0};
2702 f = fopen(n->ud.fname, "rb");
2707 fseek(f, 0, SEEK_END);
2713 fseek(f, 0, SEEK_SET);
2717 if (fread(buf, 1, sz, f))
2719 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
2728 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
2729 n->address = strdup(dump.address);
2737 _route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
2739 Ecore_Con_Event_Url_Complete *ev = event;
2740 Elm_Map_Route *r = (Elm_Map_Route*)data;
2741 Widget_Data *wd = r->wd;
2743 if ((!r) || (!ev)) return EINA_TRUE;
2744 Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url);
2745 ecore_con_url_data_set(r->con_url, NULL);
2746 if (r!=rr) return EINA_TRUE;
2748 if (r->ud.fd) fclose(r->ud.fd);
2753 Evas_Coord ox, oy, ow, oh;
2754 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
2755 route_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
2757 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2758 "elm,state,busy,stop", "elm");
2759 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
2764 _name_complete_cb(void *data, int ev_type __UNUSED__, void *event)
2766 Ecore_Con_Event_Url_Complete *ev = event;
2767 Elm_Map_Name *n = (Elm_Map_Name*)data;
2768 Widget_Data *wd = n->wd;
2770 if ((!n) || (!ev)) return EINA_TRUE;
2771 Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url);
2772 ecore_con_url_data_set(n->con_url, NULL);
2773 if (n!=nn) return EINA_TRUE;
2775 if (n->ud.fd) fclose(n->ud.fd);
2778 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2779 "elm,state,busy,stop", "elm");
2780 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
2784 static Elm_Map_Name *
2785 _utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat)
2787 Widget_Data *wd = elm_widget_data_get(obj);
2788 if (!wd) return NULL;
2793 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
2794 if (!name) return NULL;
2796 snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE);
2804 name->con_url = ecore_con_url_new(NULL);
2805 name->ud.fname = strdup(buf);
2806 INF("xml file : %s", name->ud.fname);
2808 name->ud.fd = fdopen(fd, "w+");
2809 if ((!name->con_url) || (!name->ud.fd))
2811 ecore_con_url_free(name->con_url);
2817 name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name);
2818 name->method = method;
2819 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
2820 else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL;
2824 source = map_sources_tab[wd->source].name_url_cb(wd->obj, method, address, lon, lat);
2825 INF("name url = %s", source);
2827 wd->names = eina_list_append(wd->names, name);
2828 ecore_con_url_url_set(name->con_url, source);
2829 ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd));
2830 ecore_con_url_data_set(name->con_url, name);
2832 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2833 "elm,state,busy,start", "elm");
2834 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL);
2835 ecore_con_url_get(name->con_url);
2836 if (source) free(source);
2842 static int idnum = 1;
2845 * Add a new Map object
2847 * @param parent The parent object
2848 * @return The new object or NULL if it cannot be created
2853 elm_map_add(Evas_Object *parent)
2857 Evas_Coord minw, minh;
2859 static Evas_Smart *smart = NULL;
2860 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
2862 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2864 ELM_SET_WIDTYPE(widtype, "map");
2865 elm_widget_type_set(obj, "map");
2866 elm_widget_sub_object_add(parent, obj);
2867 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2868 elm_widget_data_set(obj, wd);
2869 elm_widget_del_hook_set(obj, _del_hook);
2870 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2871 elm_widget_theme_hook_set(obj, _theme_hook);
2872 elm_widget_can_focus_set(obj, EINA_TRUE);
2873 elm_widget_event_hook_set(obj, _event_hook);
2875 wd->scr = elm_smart_scroller_add(e);
2876 elm_smart_scroller_widget_set(wd->scr, obj);
2877 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
2878 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
2879 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
2880 elm_widget_resize_object_set(obj, wd->scr);
2882 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
2883 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
2884 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
2885 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
2886 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
2888 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
2890 wd->api = module(obj);
2891 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2895 wd->markers_max_num = 30;
2896 wd->source = ELM_MAP_SOURCE_MAPNIK;
2897 wd->pinch.level = 1.0;
2899 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2900 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2901 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2902 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2906 static Evas_Smart_Class sc;
2908 evas_object_smart_clipped_smart_set(&_pan_sc);
2910 sc.name = "elm_map_pan";
2911 sc.version = EVAS_SMART_CLASS_VERSION;
2914 sc.resize = _pan_resize;
2915 sc.move = _pan_move;
2916 sc.calculate = _pan_calculate;
2917 smart = evas_smart_class_new(&sc);
2921 wd->pan_smart = evas_object_smart_add(e, smart);
2922 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2926 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2927 _pan_set, _pan_get, _pan_max_get,
2928 _pan_min_get, _pan_child_size_get);
2930 wd->rect = evas_object_rectangle_add(e);
2931 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_RESIZE,
2932 _rect_resize_cb, obj);
2933 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
2935 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_MOVE,
2937 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
2939 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_DOWN,
2940 _mouse_multi_down, obj);
2941 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_MOVE,
2942 _mouse_multi_move, obj);
2943 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP,
2944 _mouse_multi_up, obj);
2946 evas_object_smart_member_add(wd->rect, wd->pan_smart);
2947 elm_widget_sub_object_add(obj, wd->rect);
2948 evas_object_show(wd->rect);
2949 evas_object_color_set(wd->rect, 0, 0, 0, 0);
2952 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
2953 wd->id = ((int)getpid() << 16) | idnum;
2958 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2960 evas_object_size_hint_min_set(obj, minw, minh);
2962 wd->paused = EINA_TRUE;
2963 elm_map_zoom_set(obj, 0);
2964 wd->paused = EINA_FALSE;
2968 wd->calc_job = ecore_job_add(_calc_job, wd);
2970 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
2971 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
2973 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2974 // TODO: and save some bytes, making descriptions per-class and not instance!
2975 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2977 if (!ecore_file_download_protocol_available("http://"))
2979 ERR("Ecore must be built with curl support for the map widget!");
2985 * Set the zoom level of the map
2987 * This sets the zoom level. 0 is the world map and 18 is the maximum zoom.
2989 * @param obj The map object
2990 * @param zoom The zoom level to set
2995 elm_map_zoom_set(Evas_Object *obj, int zoom)
2997 ELM_CHECK_WIDTYPE(obj, widtype);
2998 Widget_Data *wd = elm_widget_data_get(obj);
3000 Grid *g, *g_zoom = NULL;
3001 Evas_Coord rx, ry, rw, rh;
3005 int zoom_changed = 0, started = 0;
3007 if ((!wd) || (wd->zoom_animator)) return;
3008 if (zoom < 0 ) zoom = 0;
3009 if (zoom > map_sources_tab[wd->source].zoom_max)
3010 zoom = map_sources_tab[wd->source].zoom_max;
3011 if (zoom < map_sources_tab[wd->source].zoom_min)
3012 zoom = map_sources_tab[wd->source].zoom_min;
3014 if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT;
3015 else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN;
3016 else wd->zoom_method = ZOOM_METHOD_NONE;
3018 wd->size.ow = wd->size.w;
3019 wd->size.oh = wd->size.h;
3020 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
3021 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3023 EINA_LIST_FOREACH(wd->route, lr, r)
3027 EINA_LIST_FOREACH(r->path, l, p)
3029 evas_object_hide(p);
3034 if (wd->mode == ELM_MAP_ZOOM_MODE_MANUAL)
3036 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3037 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3039 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3046 while (cumulw <= rw)
3055 while (cumulh <= rh)
3068 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3069 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3071 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3078 while (cumulw <= rw)
3087 while (cumulh <= rh)
3100 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3101 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3104 EINA_LIST_FOREACH(wd->grids, l, g)
3106 if (g->zoom == wd->zoom)
3112 g = grid_create(obj);
3115 if (eina_list_count(wd->grids) > 1)
3117 g_zoom = eina_list_last(wd->grids)->data;
3118 wd->grids = eina_list_remove(wd->grids, g_zoom);
3119 grid_clear(obj, g_zoom);
3122 wd->grids = eina_list_prepend(wd->grids, g);
3126 EINA_LIST_FREE(wd->grids, g)
3134 wd->t_start = ecore_loop_time_get();
3135 wd->t_end = wd->t_start + _elm_config->zoom_friction;
3142 if (!wd->zoom_animator)
3144 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
3146 if (wd->nosmooth == 1) _smooth_update(obj);
3150 if (wd->zoom_animator)
3152 if (!_zoom_anim(obj))
3154 ecore_animator_del(wd->zoom_animator);
3155 wd->zoom_animator = NULL;
3158 if (wd->calc_job) ecore_job_del(wd->calc_job);
3159 wd->calc_job = ecore_job_add(_calc_job, wd);
3163 evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
3164 if (!wd->zoom_animator)
3165 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3169 evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
3173 * Get the zoom level of the map
3175 * This returns the current zoom level of the map object. Note that if
3176 * you set the fill mode to other than ELM_MAP_ZOOM_MODE_MANUAL
3177 * (which is the default), the zoom level may be changed at any time by the
3178 * map object itself to account for map size and map viewpoer size
3180 * @param obj The map object
3181 * @return The current zoom level
3186 elm_map_zoom_get(const Evas_Object *obj)
3188 ELM_CHECK_WIDTYPE(obj, widtype) 1.0;
3189 Widget_Data *wd = elm_widget_data_get(obj);
3190 if (!wd) return 1.0;
3197 * This sets the zoom mode to manual or one of several automatic levels.
3198 * Manual (ELM_MAP_ZOOM_MODE_MANUAL) means that zoom is set manually by
3199 * elm_map_zoom_set() and will stay at that level until changed by code
3200 * or until zoom mode is changed. This is the default mode.
3201 * The Automatic modes will allow the map object to automatically
3202 * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT) will
3203 * adjust zoom so the map fits inside the scroll frame with no pixels
3204 * outside this area. ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but
3205 * ensure no pixels within the frame are left unfilled. Do not forget that the valid sizes are 2^zoom, consequently the map may be smaller than the scroller view.
3207 * @param obj The map object
3208 * @param mode The desired mode
3213 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
3215 ELM_CHECK_WIDTYPE(obj, widtype);
3216 Widget_Data *wd = elm_widget_data_get(obj);
3218 if (wd->mode == mode) return;
3221 double tz = wd->zoom;
3223 elm_map_zoom_set(wd->obj, tz);
3230 * This gets the current zoom mode of the map object
3232 * @param obj The map object
3233 * @return The current zoom mode
3237 EAPI Elm_Map_Zoom_Mode
3238 elm_map_zoom_mode_get(const Evas_Object *obj)
3240 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
3241 Widget_Data *wd = elm_widget_data_get(obj);
3242 if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
3247 * Centers the map at @p lon @p lat using an animation to scroll.
3249 * @param obj The map object
3250 * @param lon Longitude to center at
3251 * @param lon Latitude to center at
3256 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
3258 ELM_CHECK_WIDTYPE(obj, widtype);
3259 Widget_Data *wd = elm_widget_data_get(obj);
3263 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3264 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3269 if (wd->zoom_animator)
3272 if (!wd->nosmooth) _smooth_update(obj);
3273 ecore_animator_del(wd->zoom_animator);
3274 wd->zoom_animator = NULL;
3276 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3278 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
3280 wd->center_on.enabled = EINA_TRUE;
3281 wd->center_on.lon = lon;
3282 wd->center_on.lat = lat;
3286 * Move the map to the current coordinates.
3288 * This move the map to the current coordinates. The map will be centered on these coordinates.
3290 * @param obj The map object
3291 * @param lat The latitude.
3292 * @param lon The longitude.
3297 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
3299 ELM_CHECK_WIDTYPE(obj, widtype);
3300 Widget_Data *wd = elm_widget_data_get(obj);
3304 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3305 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3310 if (wd->zoom_animator)
3313 ecore_animator_del(wd->zoom_animator);
3314 wd->zoom_animator = NULL;
3316 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3318 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
3320 wd->center_on.enabled = EINA_TRUE;
3321 wd->center_on.lon = lon;
3322 wd->center_on.lat = lat;
3326 * Get the current coordinates of the map.
3328 * This gets the current coordinates of the map object.
3330 * @param obj The map object
3331 * @param lat The latitude.
3332 * @param lon The longitude.
3337 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
3339 ELM_CHECK_WIDTYPE(obj, widtype);
3340 Widget_Data *wd = elm_widget_data_get(obj);
3341 Evas_Coord sx, sy, sw, sh;
3344 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
3345 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
3349 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
3353 * Set the paused state for map
3355 * This sets the paused state to on (1) or off (0) for map. The default
3356 * is off. This will stop zooming using animation change zoom levels and
3357 * change instantly. This will stop any existing animations that are running.
3359 * @param obj The map object
3360 * @param paused The pause state to set
3365 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
3367 ELM_CHECK_WIDTYPE(obj, widtype);
3368 Widget_Data *wd = elm_widget_data_get(obj);
3370 if (wd->paused == !!paused) return;
3371 wd->paused = paused;
3374 if (wd->zoom_animator)
3376 ecore_animator_del(wd->zoom_animator);
3377 wd->zoom_animator = NULL;
3379 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3385 * Set the paused state for the markers
3387 * This sets the paused state to on (1) or off (0) for the markers. The default
3388 * is off. This will stop displaying the markers during change zoom levels. Set
3389 * to on if you have a large number of markers.
3391 * @param obj The map object
3392 * @param paused The pause state to set
3397 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
3399 ELM_CHECK_WIDTYPE(obj, widtype);
3400 Widget_Data *wd = elm_widget_data_get(obj);
3402 if (wd->paused_markers == !!paused) return;
3403 wd->paused_markers = paused;
3407 * Get the paused state for map
3409 * This gets the current paused state for the map object.
3411 * @param obj The map object
3412 * @return The current paused state
3417 elm_map_paused_get(const Evas_Object *obj)
3419 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3420 Widget_Data *wd = elm_widget_data_get(obj);
3421 if (!wd) return EINA_FALSE;
3426 * Get the paused state for the markers
3428 * This gets the current paused state for the markers object.
3430 * @param obj The map object
3431 * @return The current paused state
3436 elm_map_paused_markers_get(const Evas_Object *obj)
3438 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3439 Widget_Data *wd = elm_widget_data_get(obj);
3440 if (!wd) return EINA_FALSE;
3441 return wd->paused_markers;
3445 * Get the information of downloading status
3447 * This gets the current downloading status for the map object.
3449 * @param obj The map object
3450 * @param try_num the number of download trying map
3451 * @param finish_num the number of downloaded map
3457 elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
3459 ELM_CHECK_WIDTYPE(obj, widtype);
3460 Widget_Data *wd = elm_widget_data_get(obj);
3465 *try_num = wd->try_num;
3470 *finish_num = wd->finish_num;
3474 * Convert a pixel coordinate (x,y) into a geographic coordinate (longitude, latitude).
3476 * @param obj The map object
3477 * @param x the coordinate
3478 * @param y the coordinate
3479 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
3480 * @param lon the longitude correspond to x
3481 * @param lat the latitude correspond to y
3486 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
3488 Widget_Data *wd = elm_widget_data_get(obj);
3489 int zoom = floor(log(size/256) / log(2));
3491 if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
3492 if ((wd->api) && (wd->api->obj_convert_coord_into_geo))
3493 if (wd->api->obj_convert_coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
3497 *lon = x / (double)size * 360.0 - 180;
3501 double n = ELM_PI - 2.0 * ELM_PI * y / size;
3502 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
3507 * Convert a geographic coordinate (longitude, latitude) into a pixel coordinate (x, y).
3509 * @param obj The map object
3510 * @param lon the longitude
3511 * @param lat the latitude
3512 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
3513 * @param x the coordinate correspond to the longitude
3514 * @param y the coordinate correspond to the latitude
3519 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
3521 Widget_Data *wd = elm_widget_data_get(obj);
3522 int zoom = floor(log(size/256) / log(2));
3524 if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
3525 if ((wd->api) && (wd->api->obj_convert_geo_into_coord))
3526 if (wd->api->obj_convert_geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
3529 *x = floor((lon + 180.0) / 360.0 * size);
3531 *y = floor((1.0 - log( tan(lat * ELM_PI/180.0) + 1.0 / cos(lat * ELM_PI/180.0)) / ELM_PI) / 2.0 * size);
3535 * Convert a geographic coordinate (longitude, latitude) into a name (address).
3537 * @param obj The map object
3538 * @param lon the longitude
3539 * @param lat the latitude
3541 * @return name the address
3546 elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat)
3548 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3549 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat);
3553 * Convert a name (address) into a geographic coordinate (longitude, latitude).
3555 * @param obj The map object
3556 * @param name the address
3557 * @param lat the latitude correspond to y
3559 * @return name the address
3564 elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address)
3566 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3567 if (!address) return NULL;
3568 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0);
3572 * Convert a pixel coordinate into a roated pixcel coordinate.
3574 * @param obj The map object
3575 * @param x x to rotate.
3576 * @param y y to rotate.
3577 * @param cx rotation's center horizontal position.
3578 * @param cy rotation's center vertical position.
3579 * @param degree amount of degrees from 0.0 to 360.0 to rotate arount Z axis.
3580 * @param xx rotated x.
3581 * @param yy rotated y.
3586 elm_map_utils_rotate_coord(const Evas_Object *obj __UNUSED__, const Evas_Coord x, const Evas_Coord y, const Evas_Coord cx, const Evas_Coord cy, const double degree, Evas_Coord *xx, Evas_Coord *yy)
3588 if ((!xx) || (!yy)) return;
3590 double r = (degree * M_PI) / 180.0;
3591 double tx, ty, ttx, tty;
3598 tx = ttx + (ty * cos(r + M_PI_2));
3599 ty = tty + (ty * sin(r + M_PI_2));
3606 * Add a marker on the map
3608 * @param obj The map object
3609 * @param lon the longitude
3610 * @param lat the latitude
3611 * @param clas the class to use
3612 * @param clas_group the class group
3613 * @param data the data passed to the callbacks
3615 * @return The marker object
3619 EAPI Elm_Map_Marker *
3620 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
3624 Marker_Group *group;
3625 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3626 Widget_Data *wd = elm_widget_data_get(obj);
3634 if (!wd) return NULL;
3635 EINA_SAFETY_ON_NULL_RETURN_VAL(clas_group, NULL);
3636 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, NULL);
3638 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
3641 marker->clas = clas;
3642 marker->clas_group = clas_group;
3643 marker->longitude = lon;
3644 marker->latitude = lat;
3645 marker->data = data;
3647 tabi[1] = tabi[4] = tabi[6] = -1;
3648 tabi[2] = tabi[0] = tabi[7] = 0;
3649 tabi[3] = tabi[5] = tabi[8] = 1;
3651 tabj[1] = tabj[2] = tabj[3] = -1;
3652 tabj[4] = tabj[0] = tabj[5] = 0;
3653 tabj[6] = tabj[7] = tabj[8] = 1;
3655 if (!clas_group->priv.set)
3658 if (marker->clas_group && marker->clas_group->style)
3659 style = marker->clas_group->style;
3661 o = edje_object_add(evas_object_evas_get(obj));
3662 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3663 s = edje_object_data_get(o, "size_w");
3664 if (s) clas_group->priv.edje_w = atoi(s);
3665 else clas_group->priv.edje_w = 0;
3666 s = edje_object_data_get(o, "size_h");
3667 if (s) clas_group->priv.edje_h = atoi(s);
3668 else clas_group->priv.edje_h = 0;
3669 s = edje_object_data_get(o, "size_max_w");
3670 if (s) clas_group->priv.edje_max_w = atoi(s);
3671 else clas_group->priv.edje_max_w = 0;
3672 s = edje_object_data_get(o, "size_max_h");
3673 if (s) clas_group->priv.edje_max_h = atoi(s);
3674 else clas_group->priv.edje_max_h = 0;
3677 clas_group->priv.set = EINA_TRUE;
3680 if (!clas->priv.set)
3683 if (marker->clas && marker->clas->style)
3684 style = marker->clas->style;
3686 o = edje_object_add(evas_object_evas_get(obj));
3687 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3688 s = edje_object_data_get(o, "size_w");
3689 if (s) clas->priv.edje_w = atoi(s);
3690 else clas->priv.edje_w = 0;
3691 s = edje_object_data_get(o, "size_h");
3692 if (s) clas->priv.edje_h = atoi(s);
3693 else clas->priv.edje_h = 0;
3696 clas->priv.set = EINA_TRUE;
3699 for (i = clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
3701 elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
3702 &(marker->x[i]), &(marker->y[i]));
3704 //search in the matrixsparse the region where the marker will be
3705 mpi = marker->x[i] / wd->tsize;
3706 mpj = marker->y[i] / wd->tsize;
3708 if (!wd->markers[i])
3710 int size = pow(2.0, i);
3711 wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
3715 if (i <= clas_group->zoom_grouped)
3717 for (j = 0, group = NULL; j < 9 && !group; j++)
3719 EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
3722 if (group->clas == marker->clas_group
3723 && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
3724 marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
3725 group->x-group->w/4, group->y-group->h/4, group->w, group->h))
3727 group->markers = eina_list_append(group->markers, marker);
3728 group->update_nbelems = EINA_TRUE;
3729 group->update_resize = EINA_TRUE;
3731 group->sum_x += marker->x[i];
3732 group->sum_y += marker->y[i];
3733 group->x = group->sum_x / eina_list_count(group->markers);
3734 group->y = group->sum_y / eina_list_count(group->markers);
3736 group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
3737 * eina_list_count(group->markers);
3738 group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
3739 * eina_list_count(group->markers);
3740 if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
3741 if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
3743 if (group->obj && eina_list_count(group->markers) == 2)
3745 _group_object_free(group);
3746 _group_object_create(group);
3749 _group_bubble_content_update(group);
3758 group = calloc(1, sizeof(Marker_Group));
3760 group->sum_x = marker->x[i];
3761 group->sum_y = marker->y[i];
3762 group->x = marker->x[i];
3763 group->y = marker->y[i];
3764 group->w = clas_group->priv.edje_w;
3765 group->h = clas_group->priv.edje_h;
3766 group->clas = clas_group;
3768 group->markers = eina_list_append(group->markers, marker);
3769 group->update_nbelems = EINA_TRUE;
3770 group->update_resize = EINA_TRUE;
3772 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3776 l = eina_list_append(NULL, group);
3777 eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
3778 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3782 l = eina_matrixsparse_cell_data_get(group->cell);
3783 l = eina_list_append(l, group);
3784 eina_matrixsparse_cell_data_set(group->cell, l);
3787 marker->groups[i] = group;
3792 Evas_Coord ox, oy, ow, oh;
3793 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3794 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3801 * Remove a marker from the map
3803 * @param marker The marker to remove
3808 elm_map_marker_remove(Elm_Map_Marker *marker)
3814 EINA_SAFETY_ON_NULL_RETURN(marker);
3817 for (i = marker->clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
3819 marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
3820 if (!eina_list_count(marker->groups[i]->markers))
3822 groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
3823 groups = eina_list_remove(groups, marker->groups[i]);
3824 eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
3826 _group_object_free(marker->groups[i]);
3827 _group_bubble_free(marker->groups[i]);
3828 free(marker->groups[i]);
3832 marker->groups[i]->sum_x -= marker->x[i];
3833 marker->groups[i]->sum_y -= marker->y[i];
3835 marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
3836 marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
3838 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
3839 + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
3840 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
3841 + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
3842 if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
3843 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
3844 if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
3845 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
3847 if ((marker->groups[i]->obj) && (eina_list_count(marker->groups[i]->markers) == 1))
3849 _group_object_free(marker->groups[i]);
3850 _group_object_create(marker->groups[i]);
3855 if ((marker->content) && (marker->clas->func.del))
3856 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
3857 else if (marker->content)
3858 evas_object_del(marker->content);
3864 Evas_Coord ox, oy, ow, oh;
3865 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3866 marker_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3871 * Get the current coordinates of the marker.
3873 * @param marker marker.
3874 * @param lat The latitude.
3875 * @param lon The longitude.
3880 elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat)
3882 EINA_SAFETY_ON_NULL_RETURN(marker);
3883 if (lon) *lon = marker->longitude;
3884 if (lat) *lat = marker->latitude;
3888 * Move the map to the coordinate of the marker.
3890 * @param marker The marker where the map will be center.
3895 elm_map_marker_bring_in(Elm_Map_Marker *marker)
3897 EINA_SAFETY_ON_NULL_RETURN(marker);
3898 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
3902 * Move the map to the coordinate of the marker.
3904 * @param marker The marker where the map will be center.
3909 elm_map_marker_show(Elm_Map_Marker *marker)
3911 EINA_SAFETY_ON_NULL_RETURN(marker);
3912 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
3916 * Move and zoom the map to display a list of markers.
3918 * The map will be centered on the center point of the markers in the list. Then
3919 * the map will be zoomed in order to fit the markers using the maximum zoom which
3920 * allows display of all the markers.
3922 * @param markers The list of markers (list of Elm_Map_Marker *)
3927 elm_map_markers_list_show(Eina_List *markers)
3932 Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
3933 Evas_Coord rw, rh, xc, yc;
3936 EINA_SAFETY_ON_NULL_RETURN(markers);
3938 EINA_LIST_FOREACH(markers, l, marker)
3942 if ((!m_min_lon) || (marker->longitude < m_min_lon->longitude))
3945 if ((!m_max_lon) || (marker->longitude > m_max_lon->longitude))
3948 if ((!m_min_lat) || (marker->latitude > m_min_lat->latitude))
3951 if ((!m_max_lat) || (marker->latitude < m_max_lat->latitude))
3955 lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
3956 lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
3958 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3959 for (zoom = map_sources_tab[wd->source].zoom_max; zoom>map_sources_tab[wd->source].zoom_min; zoom--)
3961 Evas_Coord size = pow(2.0, zoom)*wd->tsize;
3962 elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
3964 if ((m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2)
3965 && (m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2)
3966 && (m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2)
3967 && (m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2))
3971 elm_map_geo_region_show(wd->obj, lon, lat);
3972 elm_map_zoom_set(wd->obj, zoom);
3976 * Set the maximum numbers of markers display in a group.
3978 * A group can have a long list of markers, consequently the creation of the content
3979 * of the bubble can be very slow. In order to avoid this, a maximum number of items
3980 * is displayed in a bubble. By default this number is 30.
3982 * @param obj The map object.
3983 * @param max The maximum numbers of items displayed in a bubble.
3988 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
3990 ELM_CHECK_WIDTYPE(obj, widtype);
3991 Widget_Data *wd = elm_widget_data_get(obj);
3993 wd->markers_max_num = max;
3997 * Return the evas object getting from the ElmMapMarkerGetFunc callback
3999 * @param marker The marker.
4000 * @return Return the evas object if it exists, else NULL.
4005 elm_map_marker_object_get(const Elm_Map_Marker *marker)
4007 EINA_SAFETY_ON_NULL_RETURN_VAL(marker, NULL);
4008 return marker->content;
4014 * @param marker The marker.
4019 elm_map_marker_update(Elm_Map_Marker *marker)
4021 EINA_SAFETY_ON_NULL_RETURN(marker);
4022 if (marker->content)
4024 if (marker->clas->func.del)
4025 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4027 evas_object_del(marker->content);
4028 marker->content = NULL;
4029 _group_bubble_content_update(marker->groups[marker->wd->zoom]);
4034 * Close all opened bubbles
4036 * @param obj The map object
4041 elm_map_bubbles_close(Evas_Object *obj)
4043 ELM_CHECK_WIDTYPE(obj, widtype);
4044 Widget_Data *wd = elm_widget_data_get(obj);
4045 Marker_Group *group;
4046 Eina_List *l, *l_next;
4048 EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
4049 _group_bubble_free(group);
4054 * Create a group class.
4056 * Each marker must be associated to a group class. Marker with the same group are grouped if they are close.
4057 * The group class defines the style of the marker when a marker is grouped to others markers.
4059 * @param obj The map object
4060 * @return Returns the new group class
4064 EAPI Elm_Map_Group_Class *
4065 elm_map_group_class_new(Evas_Object *obj)
4067 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4068 Widget_Data *wd = elm_widget_data_get(obj);
4069 if (!wd) return NULL;
4070 Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
4071 clas->zoom_grouped = ZOOM_MAX;
4072 wd->groups_clas = eina_list_append(wd->groups_clas, clas);
4077 * Set the style of a group class (radio, radio2 or empty)
4079 * @param clas the group class
4080 * @param style the new style
4085 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
4087 EINA_SAFETY_ON_NULL_RETURN(clas);
4088 eina_stringshare_replace(&clas->style, style);
4092 * Set the icon callback of a group class.
4094 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
4096 * @param clas the group class
4097 * @param icon_get the callback to create the icon
4102 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
4104 EINA_SAFETY_ON_NULL_RETURN(clas);
4105 clas->func.icon_get = icon_get;
4109 * Set the data associated to the group class (radio, radio2 or empty)
4111 * @param clas the group class
4112 * @param data the new user data
4117 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
4119 EINA_SAFETY_ON_NULL_RETURN(clas);
4124 * Set the zoom from where the markers are displayed.
4126 * Markers will not be displayed for a zoom less than @ref zoom
4128 * @param clas the group class
4129 * @param zoom the zoom
4134 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
4136 EINA_SAFETY_ON_NULL_RETURN(clas);
4137 clas->zoom_displayed = zoom;
4141 * Set the zoom from where the markers are no more grouped.
4143 * @param clas the group class
4144 * @param zoom the zoom
4149 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
4151 EINA_SAFETY_ON_NULL_RETURN(clas);
4152 clas->zoom_grouped = zoom;
4156 * Set if the markers associated to the group class @clas are hidden or not.
4157 * If @ref hide is true the markers will be hidden.
4159 * @param clas the group class
4160 * @param hide if true the markers will be hidden, else they will be displayed.
4165 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
4167 ELM_CHECK_WIDTYPE(obj, widtype);
4168 Widget_Data *wd = elm_widget_data_get(obj);
4170 EINA_SAFETY_ON_NULL_RETURN(clas);
4171 if (clas->hide == hide) return;
4175 Evas_Coord ox, oy, ow, oh;
4176 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
4177 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4183 * Create a marker class.
4185 * Each marker must be associated to a class.
4186 * The class defines the style of the marker when a marker is displayed alone (not grouped).
4188 * @param obj The map object
4189 * @return Returns the new class
4193 EAPI Elm_Map_Marker_Class *
4194 elm_map_marker_class_new(Evas_Object *obj)
4196 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4197 Widget_Data *wd = elm_widget_data_get(obj);
4198 if (!wd) return NULL;
4199 Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
4200 wd->markers_clas = eina_list_append(wd->markers_clas, clas);
4205 * Set the style of a class (radio, radio2 or empty)
4207 * @param clas the group class
4208 * @param style the new style
4213 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
4215 EINA_SAFETY_ON_NULL_RETURN(clas);
4216 eina_stringshare_replace(&clas->style, style);
4220 * Set the icon callback of a class.
4222 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
4224 * @param clas the group class
4225 * @param icon_get the callback to create the icon
4230 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
4232 EINA_SAFETY_ON_NULL_RETURN(clas);
4233 clas->func.icon_get = icon_get;
4238 * Set the callback of the content of the bubble.
4240 * When the user click on a marker, a bubble is displayed with a content.
4241 * The callback @ref get musst return this content. It can be NULL.
4243 * @param clas the group class
4244 * @param get the callback to create the content
4249 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
4251 EINA_SAFETY_ON_NULL_RETURN(clas);
4252 clas->func.get = get;
4256 * Set the callback of the content of delete the object created by the callback "get".
4258 * If this callback is defined the user will have to delete (or not) the object inside.
4259 * If the callback is not defined the object will be destroyed with evas_object_del()
4261 * @param clas the group class
4262 * @param del the callback to delete the content
4267 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
4269 EINA_SAFETY_ON_NULL_RETURN(clas);
4270 clas->func.del = del;
4274 * Set the source of the map.
4276 * Elm_Map retrieves the image which composed the map from a web service. This web service can
4277 * be set with this method. A different service can return a different maps with different
4278 * information and it can use different zoom value.
4280 * @param clas the group class
4281 * @param source the new source
4286 elm_map_source_set(Evas_Object *obj, Elm_Map_Sources source)
4288 ELM_CHECK_WIDTYPE(obj, widtype);
4289 Widget_Data *wd = elm_widget_data_get(obj);
4293 if (wd->source == source ) return;
4294 if (!map_sources_tab[source].url_cb) return;
4295 _elm_config_sub_init();
4297 EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid);
4299 wd->source = source;
4303 if (map_sources_tab[wd->source].zoom_max < zoom)
4304 zoom = map_sources_tab[wd->source].zoom_max;
4305 if (map_sources_tab[wd->source].zoom_min > zoom)
4306 zoom = map_sources_tab[wd->source].zoom_min;
4308 elm_map_zoom_set(obj, zoom);
4312 * Set the source of the route.
4314 * @param clas the group class
4315 * @param source the new source
4320 elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
4322 ELM_CHECK_WIDTYPE(obj, widtype);
4323 Widget_Data *wd = elm_widget_data_get(obj);
4325 wd->source = source;
4329 * Get the current source
4331 * @param obj the map object
4332 * @return Returns the maximum zoom of the source
4336 EAPI Elm_Map_Sources
4337 elm_map_source_get(const Evas_Object *obj)
4339 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_SOURCE_MAPNIK;
4340 Widget_Data *wd = elm_widget_data_get(obj);
4341 if (!wd) return ELM_MAP_SOURCE_MAPNIK;
4346 * Get the current route source
4348 * @param obj the map object
4349 * @return Returns the source of the route
4353 EAPI Elm_Map_Route_Sources
4354 elm_map_route_source_get(const Evas_Object *obj)
4356 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS;
4357 Widget_Data *wd = elm_widget_data_get(obj);
4358 if (!wd) return ELM_MAP_ROUTE_SOURCE_YOURS;
4359 return wd->route_source;
4363 * Set the API of a custom source.
4365 * A custom web service can be associated to the source ELM_MAP_SOURCE_CUSTOM_(1..7).
4367 * @param source the source ID (ELM_MAP_SOURCE_CUSTOM_(1..7))
4368 * @param name the name of the source
4369 * @param zoom_min the minimum zoom of the source, must be >= 0
4370 * @param zoom_max the maximum zoom of the source, must be <= ZOOM_MAX
4371 * @param url_cb the callback used to create the url from where a tile (png or jpeg file) is downloaded.
4376 elm_map_source_custom_api_set(Elm_Map_Sources source, const char *name, int zoom_min, int zoom_max, ElmMapSourceURLFunc url_cb, ElmMapRouteSourceURLFunc route_url_cb, ElmMapNameSourceURLFunc name_url_cb)
4378 EINA_SAFETY_ON_NULL_RETURN(name);
4379 EINA_SAFETY_ON_NULL_RETURN(url_cb);
4380 map_sources_tab[source].name = name;
4381 map_sources_tab[source].zoom_min = zoom_min;
4382 map_sources_tab[source].zoom_max = zoom_max;
4383 map_sources_tab[source].url_cb = url_cb;
4384 map_sources_tab[source].route_url_cb = route_url_cb;
4385 map_sources_tab[source].name_url_cb = name_url_cb;
4389 * Get the maximum zoom of the source.
4391 * @param source the source
4392 * @return Returns the maximum zoom of the source
4397 elm_map_source_zoom_max_get(Elm_Map_Sources source)
4399 return map_sources_tab[source].zoom_max;
4403 * Get the minimum zoom of the source.
4405 * @param source the source
4406 * @return Returns the minimum zoom of the source
4411 elm_map_source_zoom_min_get(Elm_Map_Sources source)
4413 return map_sources_tab[source].zoom_min;
4417 * Get the name of a source.
4419 * @param source the source
4420 * @return Returns the name of the source
4425 elm_map_source_name_get(Elm_Map_Sources source)
4427 return map_sources_tab[source].name;
4431 * Set the user agent of the widget map.
4433 * @param obj The map object
4434 * @param user_agent the user agent of the widget map
4439 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
4441 ELM_CHECK_WIDTYPE(obj, widtype);
4442 Widget_Data *wd = elm_widget_data_get(obj);
4445 if (!wd->user_agent) wd->user_agent = eina_stringshare_add(user_agent);
4446 else eina_stringshare_replace(&wd->user_agent, user_agent);
4448 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4449 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4453 * Get the user agent of the widget map.
4455 * @param obj The map object
4456 * @return The user agent of the widget map
4461 elm_map_user_agent_get(Evas_Object *obj)
4463 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4464 Widget_Data *wd = elm_widget_data_get(obj);
4466 if (!wd) return NULL;
4467 return wd->user_agent;
4471 * Add a route on the map
4473 * @param obj The map object
4474 * @param type the type if transport
4475 * @param method the routing method
4476 * @param flon the start longitude
4477 * @param flat the start latitude
4478 * @param tlon the destination longitude
4479 * @param tlat the destination latitude
4481 * @return The Route object
4485 EAPI Elm_Map_Route *
4486 elm_map_route_add(Evas_Object *obj,
4487 Elm_Map_Route_Type type,
4488 Elm_Map_Route_Method method,
4494 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4495 Widget_Data *wd = elm_widget_data_get(obj);
4496 if (!wd) return EINA_FALSE;
4499 char *type_name = NULL;
4501 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4502 if (!route) return NULL;
4504 snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE);
4512 route->con_url = ecore_con_url_new(NULL);
4513 route->ud.fname = strdup(buf);
4514 INF("xml file : %s", route->ud.fname);
4516 route->ud.fd = fdopen(fd, "w+");
4517 if ((!route->con_url) || (!route->ud.fd))
4519 ecore_con_url_free(route->con_url);
4525 route->color.r = 255;
4528 route->color.a = 255;
4529 route->handlers = eina_list_append
4530 (route->handlers, (void *)ecore_event_handler_add
4531 (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route));
4533 route->inbound = EINA_FALSE;
4535 route->method = method;
4543 case ELM_MAP_ROUTE_TYPE_MOTOCAR:
4544 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4546 case ELM_MAP_ROUTE_TYPE_BICYCLE:
4547 type_name = strdup(ROUTE_TYPE_BICYCLE);
4549 case ELM_MAP_ROUTE_TYPE_FOOT:
4550 type_name = strdup(ROUTE_TYPE_FOOT);
4556 source = map_sources_tab[wd->source].route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4557 INF("route url = %s", source);
4559 wd->route = eina_list_append(wd->route, route);
4561 ecore_con_url_url_set(route->con_url, source);
4562 ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd));
4563 ecore_con_url_data_set(route->con_url, route);
4564 ecore_con_url_get(route->con_url);
4565 if (type_name) free(type_name);
4566 if (source) free(source);
4568 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4569 "elm,state,busy,start", "elm");
4570 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL);
4575 * Remove a route from the map
4577 * @param route The route to remove
4583 elm_map_route_remove(Elm_Map_Route *route)
4585 EINA_SAFETY_ON_NULL_RETURN(route);
4590 Ecore_Event_Handler *h;
4592 EINA_LIST_FREE(route->path, p)
4597 EINA_LIST_FREE(route->waypoint, w)
4599 if (w->point) eina_stringshare_del(w->point);
4603 EINA_LIST_FREE(route->nodes, n)
4605 if (n->pos.address) eina_stringshare_del(n->pos.address);
4609 EINA_LIST_FREE(route->handlers, h)
4611 ecore_event_handler_del(h);
4614 if (route->ud.fname)
4616 ecore_file_remove(route->ud.fname);
4617 free(route->ud.fname);
4618 route->ud.fname = NULL;
4623 * Set the option used for the background color
4625 * @param route The route object
4631 * This sets the color used for the route
4636 elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a)
4638 EINA_SAFETY_ON_NULL_RETURN(route);
4646 * Get the option used for the background color
4648 * @param route The route object
4657 elm_map_route_color_get(Elm_Map_Route *route, int *r, int *g , int *b, int *a)
4659 EINA_SAFETY_ON_NULL_RETURN(route);
4660 if (r) *r = route->color.r;
4661 if (g) *g = route->color.g;
4662 if (b) *b = route->color.b;
4663 if (a) *a = route->color.a;
4667 * Get the information of route distance
4669 * @param route the route object
4670 * @return Returns the distance of route (unit : km)
4675 elm_map_route_distance_get(Elm_Map_Route *route)
4677 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
4678 return route->info.distance;
4682 * Get the information of route nodes
4684 * @param route the route object
4685 * @return Returns the nodes of route
4691 elm_map_route_node_get(Elm_Map_Route *route)
4693 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4694 return route->info.nodes;
4698 * Get the information of route waypoint
4700 * @param route the route object
4701 * @return Returns the waypoint of route
4707 elm_map_route_waypoint_get(Elm_Map_Route *route)
4709 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4710 return route->info.waypoints;
4714 * Get the information of address
4716 * @param name the name object
4717 * @return Returns the address of name
4722 elm_map_name_address_get(Elm_Map_Name *name)
4724 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
4725 return name->address;
4729 * Get the current coordinates of the name.
4731 * This gets the current coordinates of the name object.
4733 * @param obj The name object
4734 * @param lat The latitude
4735 * @param lon The longitude
4740 elm_map_name_region_get(Elm_Map_Name *name, double *lon, double *lat)
4742 EINA_SAFETY_ON_NULL_RETURN(name);
4743 if (lon) *lon = name->lon;
4744 if (lat) *lat = name->lat;
4748 * Remove a name from the map
4750 * @param name The name to remove
4755 elm_map_name_remove(Elm_Map_Name *name)
4757 EINA_SAFETY_ON_NULL_RETURN(name);
4760 free(name->address);
4761 name->address = NULL;
4765 ecore_event_handler_del(name->handler);
4766 name->handler = NULL;
4770 ecore_file_remove(name->ud.fname);
4771 free(name->ud.fname);
4772 name->ud.fname = NULL;
4777 * Set the rotate degree of the map
4779 * @param obj The map object
4780 * @param angle amount of degrees from 0.0 to 360.0 to rotate arount Z axis
4781 * @param cx rotation's center horizontal position
4782 * @param cy rotation's center vertical position
4787 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
4789 ELM_CHECK_WIDTYPE(obj, widtype);
4790 Widget_Data *wd = elm_widget_data_get(obj);
4792 wd->rotate.d = degree;
4795 wd->calc_job = ecore_job_add(_calc_job, wd);
4799 * Get the rotate degree of the map
4801 * @param obj The map object
4802 * @return amount of degrees from 0.0 to 360.0 to rotate arount Z axis
4803 * @param cx rotation's center horizontal position
4804 * @param cy rotation's center vertical position
4809 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
4811 ELM_CHECK_WIDTYPE(obj, widtype);
4812 Widget_Data *wd = elm_widget_data_get(obj);
4814 if (degree) *degree = wd->rotate.d;
4815 if (cx) *cx = wd->rotate.cx;
4816 if (cy) *cy = wd->rotate.cy;
4820 _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4823 snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
4829 _osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4832 snprintf(buf, sizeof(buf),
4833 "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
4839 _cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4842 snprintf(buf, sizeof(buf),
4843 "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
4849 _maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4852 snprintf(buf, sizeof(buf),
4853 "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
4859 _custom1_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4865 _custom2_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4871 _custom3_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4877 _custom4_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4883 _custom5_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4889 _custom6_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4895 _module_url_cb(Evas_Object *obj, int x, int y, int zoom)
4898 Widget_Data *wd = elm_widget_data_get(obj);
4899 if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
4900 if ((wd->api) && (wd->api->obj_url_request))
4901 buf = wd->api->obj_url_request(obj, x, y, zoom);
4903 if (!buf) buf = strdup("");
4908 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4911 snprintf(buf, sizeof(buf),
4912 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
4913 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
4918 // TODO: fix monav api
4920 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4923 snprintf(buf, sizeof(buf),
4924 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
4925 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
4931 // TODO: fix ors api
4933 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4936 snprintf(buf, sizeof(buf),
4937 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
4938 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
4944 static char *_route_custom1_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
4949 static char *_route_custom2_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
4954 static char *_route_custom3_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
4959 static char *_route_custom4_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
4964 static char *_route_custom5_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
4969 static char *_route_custom6_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
4974 static char *_route_module_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
4976 // TODO: make example route module
4982 _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
4984 Widget_Data *wd = elm_widget_data_get(obj);
4985 if (!wd) return strdup("");
4987 unsigned int ele, idx;
4989 char search_url[PATH_MAX];
4991 if (method == ELM_MAP_NAME_METHOD_SEARCH)
4993 search_url[0] = '\0';
4994 str = eina_str_split_full(name, " ", 0, &ele);
4995 for (idx = 0 ; idx < ele ; idx++)
4997 eina_strlcat(search_url, str[idx], sizeof(search_url));
4998 if (!(idx == (ele-1))) eina_strlcat(search_url, "+", sizeof(search_url));
5000 snprintf(buf, sizeof(buf), "%s/search?q=%s&format=xml&polygon=0&addressdetails=0", NAME_NOMINATIM_URL, search_url);
5002 else if (method == ELM_MAP_NAME_METHOD_REVERSE) snprintf(buf, sizeof(buf), "%s/reverse?format=xml&lat=%lf&lon=%lf&zoom=%d&addressdetails=0", NAME_NOMINATIM_URL, lat, lon, wd->zoom);
5003 else strcpy(buf, "");
5009 _name_custom1_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
5015 _name_custom2_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
5021 _name_custom3_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
5027 _name_custom4_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
5033 _name_custom5_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
5039 _name_custom6_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)