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))
1464 wd->pinch.level = 1.0;
1466 wd->zoom_animator = NULL;
1467 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1468 return ECORE_CALLBACK_CANCEL;
1472 Evas_Coord x, y, w, h;
1473 float half_w, half_h;
1475 evas_object_geometry_get(data, &x, &y, &w, &h);
1476 half_w = (float)w * 0.5;
1477 half_h = (float)h * 0.5;
1479 wd->pinch.level = t;
1480 wd->pinch.cx = x + half_w;
1481 wd->pinch.cy = y + half_h;
1482 if (wd->calc_job) ecore_job_del(wd->calc_job);
1483 wd->calc_job = ecore_job_add(_calc_job, wd);
1484 return ECORE_CALLBACK_RENEW;
1489 _long_press(void *data)
1491 Widget_Data *wd = elm_widget_data_get(data);
1492 if (!wd) return ECORE_CALLBACK_CANCEL;
1493 wd->long_timer = NULL;
1494 evas_object_smart_callback_call(data, SIG_LONGPRESSED, &wd->ev);
1495 return ECORE_CALLBACK_CANCEL;
1499 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1501 ELM_CHECK_WIDTYPE(data, widtype);
1502 Widget_Data *wd = elm_widget_data_get(data);
1503 Evas_Event_Mouse_Down *ev = event_info;
1506 ev0 = get_event_object(data, 0);
1508 ev0 = create_event_object(data, obj, 0);
1511 ev0->hold_timer = NULL;
1512 ev0->prev.x = ev->output.x;
1513 ev0->prev.y = ev->output.y;
1516 if (ev->button != 1) return;
1517 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1518 else wd->on_hold = EINA_FALSE;
1519 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1520 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, ev);
1522 evas_object_smart_callback_call(data, SIG_PRESS, ev);
1523 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1524 wd->ev.output.x = ev->output.x;
1525 wd->ev.output.y = ev->output.y;
1526 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1530 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1532 Evas_Event_Mouse_Move *move = event_info;
1535 ev0 = get_event_object(data, 0);
1537 ev0->prev.x = move->cur.output.x;
1538 ev0->prev.y = move->cur.output.y;
1542 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1544 ELM_CHECK_WIDTYPE(data, widtype);
1545 Widget_Data *wd = elm_widget_data_get(data);
1546 Evas_Event_Mouse_Up *ev = event_info;
1551 ev0 = get_event_object(data, 0);
1554 mdevice = get_multi_device(data);
1557 if (ev0->hold_timer)
1559 ecore_timer_del(ev0->hold_timer);
1560 ev0->hold_timer = NULL;
1562 elm_smart_scroller_hold_set(wd->scr, 0);
1563 elm_smart_scroller_freeze_set(wd->scr, 0);
1567 ev1 = get_event_object(data, mdevice);
1569 ev1->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev1);
1571 destroy_event_object(data, ev0);
1575 if (ev->button != 1) return;
1576 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1577 else wd->on_hold = EINA_FALSE;
1580 ecore_timer_del(wd->long_timer);
1581 wd->long_timer = NULL;
1583 if (!wd->on_hold) evas_object_smart_callback_call(data, SIG_CLICKED, ev);
1584 wd->on_hold = EINA_FALSE;
1588 _mouse_multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1590 ELM_CHECK_WIDTYPE(data, widtype);
1591 Widget_Data *wd = elm_widget_data_get(data);
1593 Evas_Event_Multi_Down *down = event_info;
1595 elm_smart_scroller_hold_set(wd->scr, 1);
1596 elm_smart_scroller_freeze_set(wd->scr, 1);
1598 ev = create_event_object(data, obj, down->device);
1601 DBG("Failed : create_event_object");
1606 ev->hold_timer = NULL;
1607 ev->start.x = ev->prev.x = down->output.x;
1608 ev->start.y = ev->prev.y = down->output.y;
1609 ev->pinch_start_dis = 0;
1610 wd->pinch.level = 1.0;
1611 wd->pinch.diff = 1.0;
1616 ecore_timer_del(wd->long_timer);
1617 wd->long_timer = NULL;
1623 _mouse_multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1625 ELM_CHECK_WIDTYPE(data, widtype);
1626 Widget_Data *wd = elm_widget_data_get(data);
1627 Evas_Event_Multi_Move *move = event_info;
1629 double t, tt, a, a_diff;
1633 ev = get_event_object(data, move->device);
1636 ev0 = get_event_object(data, 0);
1639 if (wd->multi_count >= 1)
1641 Evas_Coord x, y, w, h;
1642 float half_w, half_h;
1644 evas_object_geometry_get(data, &x, &y, &w, &h);
1645 half_w = (float)w * 0.5;
1646 half_h = (float)h * 0.5;
1647 dis_new = get_distance(ev0->prev.x, ev0->prev.y, ev->prev.x, ev->prev.y);
1649 if (!ev->pinch_start_dis) ev->pinch_start_dis = dis_new;
1652 ev->pinch_dis = dis_new;
1653 tt = wd->pinch.diff;
1654 wd->pinch.diff = (double)(ev->pinch_dis - ev->pinch_start_dis);
1655 t = (wd->pinch.diff * 0.01) + 1.0;
1656 if ((!wd->zoom) || ((wd->zoom + (int)t - 1) <= map_sources_tab[wd->source].zoom_min) ||
1657 ((wd->zoom + (int)t - 1) >= map_sources_tab[wd->source].zoom_max) ||
1658 (t > PINCH_ZOOM_MAX) || (t < PINCH_ZOOM_MIN))
1660 wd->pinch.diff = tt;
1665 wd->pinch.level = (wd->pinch.diff * 0.01) + 1.0;
1666 wd->pinch.cx = x + half_w;
1667 wd->pinch.cy = y + half_h;
1670 a = (double)(ev->prev.y - ev0->prev.y) / (double)(ev->prev.x - ev0->prev.x);
1671 if (!wd->rotate.a) wd->rotate.a = a;
1675 a_diff = wd->rotate.a - a;
1676 if (a_diff > 0) wd->rotate.d -= 1.0;
1677 else if (a_diff < 0) wd->rotate.d += 1.0;
1679 wd->rotate.cx = x + half_w;
1680 wd->rotate.cy = y + half_h;
1683 if (wd->calc_job) ecore_job_del(wd->calc_job);
1684 wd->calc_job = ecore_job_add(_calc_job, wd);
1688 ev->prev.x = move->cur.output.x;
1689 ev->prev.y = move->cur.output.y;
1693 _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1695 ELM_CHECK_WIDTYPE(data, widtype);
1696 Widget_Data *wd = elm_widget_data_get(data);
1697 Evas_Event_Multi_Up *up = event_info;
1704 if (wd->calc_job) ecore_job_del(wd->calc_job);
1705 if (wd->zoom_animator)
1707 ecore_animator_del(wd->zoom_animator);
1708 wd->zoom_animator = NULL;
1711 wd->paused = EINA_TRUE;
1712 if (wd->pinch.diff >= 0.0) t = wd->pinch.diff * 0.01;
1713 else if (wd->pinch.diff < 0.0) t = -1.0 / ((wd->pinch.diff * 0.01) + 1.0);
1714 elm_map_zoom_set(data, wd->zoom + (int)ceil(t));
1715 wd->pinch.level = 1.0;
1719 ev = get_event_object(data, up->device);
1722 DBG("Cannot get multi device");
1726 ev0 = get_event_object(data, 0);
1728 ev0->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev0);
1733 ecore_timer_del(ev->hold_timer);
1734 ev->hold_timer = NULL;
1737 destroy_event_object(data, ev);
1740 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
1743 _hold_timer_cb(void *data)
1747 ev0->hold_timer = NULL;
1748 return ECORE_CALLBACK_CANCEL;
1752 _rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1754 Widget_Data *wd = elm_widget_data_get(data);
1757 evas_object_geometry_get(wd->rect, &x, &y, &w, &h);
1758 evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h);
1759 evas_object_resize(wd->rect, w, h);
1760 evas_object_move(wd->rect, x, y);
1764 _del_hook(Evas_Object *obj)
1766 Elm_Map_Group_Class *group_clas;
1767 Elm_Map_Marker_Class *marker_clas;
1768 Widget_Data *wd = elm_widget_data_get(obj);
1774 Ecore_Event_Handler *h;
1780 EINA_LIST_FREE(wd->groups_clas, group_clas)
1782 if (group_clas->style)
1783 eina_stringshare_del(group_clas->style);
1787 EINA_LIST_FREE(wd->markers_clas, marker_clas)
1789 if (marker_clas->style)
1790 eina_stringshare_del(marker_clas->style);
1794 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
1796 destroy_event_object(obj, ev);
1799 EINA_LIST_FOREACH(wd->route, l, r)
1801 EINA_LIST_FREE(r->path, p)
1806 EINA_LIST_FREE(r->waypoint, w)
1808 if (w->point) eina_stringshare_del(w->point);
1812 EINA_LIST_FREE(r->nodes, n)
1814 if (n->pos.address) eina_stringshare_del(n->pos.address);
1818 EINA_LIST_FREE(r->handlers, h)
1820 ecore_event_handler_del(h);
1823 if (r->con_url) ecore_con_url_free(r->con_url);
1824 if (r->info.nodes) eina_stringshare_del(r->info.nodes);
1825 if (r->info.waypoints) eina_stringshare_del(r->info.waypoints);
1828 EINA_LIST_FREE(wd->names, na)
1830 if (na->address) free(na->address);
1831 if (na->handler) ecore_event_handler_del(na->handler);
1834 ecore_file_remove(na->ud.fname);
1836 na->ud.fname = NULL;
1840 if (wd->calc_job) ecore_job_del(wd->calc_job);
1841 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1842 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
1843 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1844 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj);
1845 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
1846 if (wd->ua) eina_hash_free(wd->ua);
1852 _del_pre_hook(Evas_Object *obj)
1854 Marker_Group *group;
1855 Elm_Map_Marker *marker;
1857 Eina_Bool free_marker = EINA_TRUE;
1859 Widget_Data *wd = elm_widget_data_get(obj);
1863 for (i = 0; i < ZOOM_MAX + 1; i++)
1865 if (!wd->markers[i]) continue;
1866 Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
1867 Eina_Matrixsparse_Cell *cell;
1869 EINA_ITERATOR_FOREACH(it, cell)
1871 l = eina_matrixsparse_cell_data_get(cell);
1872 EINA_LIST_FREE(l, group)
1874 EINA_LIST_FREE(group->markers, marker)
1876 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1877 _bubble_sc_hits_changed_cb, group);
1878 if (free_marker) free(marker);
1882 free_marker = EINA_FALSE;
1884 eina_iterator_free(it);
1885 eina_matrixsparse_free(wd->markers[i]);
1888 evas_object_del(wd->sep_maps_markers);
1889 evas_object_del(wd->pan_smart);
1890 wd->pan_smart = NULL;
1894 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
1896 Widget_Data *wd = elm_widget_data_get(obj);
1898 if (elm_widget_focus_get(obj))
1900 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
1901 evas_object_focus_set(wd->obj, EINA_TRUE);
1905 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
1906 evas_object_focus_set(wd->obj, EINA_FALSE);
1911 _theme_hook(Evas_Object *obj)
1913 Widget_Data *wd = elm_widget_data_get(obj);
1915 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
1916 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
1921 _sizing_eval(Evas_Object *obj)
1923 Widget_Data *wd = elm_widget_data_get(obj);
1924 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
1926 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
1927 evas_object_size_hint_min_set(obj, minw, minh);
1928 evas_object_size_hint_max_set(obj, maxw, maxh);
1932 _calc_job(void *data)
1934 Widget_Data *wd = data;
1935 Evas_Coord minw, minh;
1942 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
1944 double tz = wd->zoom;
1946 elm_map_zoom_set(wd->obj, tz);
1949 if ((minw != wd->minw) || (minh != wd->minh))
1953 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
1954 _sizing_eval(wd->obj);
1956 wd->calc_job = NULL;
1957 evas_object_smart_changed(wd->pan_smart);
1961 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1963 Pan *sd = evas_object_smart_data_get(obj);
1965 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1968 evas_object_smart_changed(obj);
1972 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1974 Pan *sd = evas_object_smart_data_get(obj);
1976 if (x) *x = sd->wd->pan_x;
1977 if (y) *y = sd->wd->pan_y;
1981 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1983 Pan *sd = evas_object_smart_data_get(obj);
1986 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1987 ow = sd->wd->minw - ow;
1989 oh = sd->wd->minh - oh;
1996 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
2003 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2005 Pan *sd = evas_object_smart_data_get(obj);
2007 if (w) *w = sd->wd->minw;
2008 if (h) *h = sd->wd->minh;
2012 _pan_add(Evas_Object *obj)
2015 Evas_Object_Smart_Clipped_Data *cd;
2017 cd = evas_object_smart_data_get(obj);
2019 sd = calloc(1, sizeof(Pan));
2021 sd->__clipped_data = *cd;
2023 evas_object_smart_data_set(obj, sd);
2027 _pan_del(Evas_Object *obj)
2029 Pan *sd = evas_object_smart_data_get(obj);
2035 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2037 Pan *sd = evas_object_smart_data_get(obj);
2040 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2041 if ((ow == w) && (oh == h)) return;
2042 sd->wd->resized = 1;
2043 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2044 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2048 _pan_calculate(Evas_Object *obj)
2050 Pan *sd = evas_object_smart_data_get(obj);
2051 Evas_Coord ox, oy, ow, oh;
2055 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2056 rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2057 EINA_LIST_FOREACH(sd->wd->grids, l, g)
2059 if (sd->wd->pinch.level == 1.0) grid_load(sd->wd->obj, g);
2060 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2061 marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2062 if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2067 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2069 Pan *sd = evas_object_smart_data_get(obj);
2071 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2072 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2076 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2078 Widget_Data *wd = elm_widget_data_get(obj);
2080 elm_smart_scroller_hold_set(wd->scr, 1);
2084 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2086 Widget_Data *wd = elm_widget_data_get(obj);
2088 elm_smart_scroller_hold_set(wd->scr, 0);
2092 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2094 Widget_Data *wd = elm_widget_data_get(obj);
2096 elm_smart_scroller_freeze_set(wd->scr, 1);
2100 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2102 Widget_Data *wd = elm_widget_data_get(obj);
2104 elm_smart_scroller_freeze_set(wd->scr, 0);
2108 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2110 evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
2114 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2116 evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
2120 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2122 Widget_Data *wd = elm_widget_data_get(data);
2123 wd->center_on.enabled = EINA_FALSE;
2124 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2128 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2130 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2134 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2136 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
2141 _group_object_create(Marker_Group *group)
2143 const char *style = "radio";
2144 Evas_Object *icon = NULL;
2146 if (group->obj) return;
2147 if ((!group->clas->priv.objs_notused) || (eina_list_count(group->markers) == 1))
2149 //set icon and style
2150 if (eina_list_count(group->markers) == 1)
2152 Elm_Map_Marker *m = eina_list_data_get(group->markers);
2154 style = m->clas->style;
2156 if (m->clas->func.icon_get)
2157 icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
2159 group->delete_object = EINA_TRUE;
2163 if (group->clas->style)
2164 style = group->clas->style;
2166 if (group->clas->func.icon_get)
2167 icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
2169 group->delete_object = EINA_FALSE;
2172 group->obj = elm_layout_add(group->wd->obj);
2173 elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
2175 if (icon) elm_layout_content_set(group->obj, "elm.icon", icon);
2177 evas_object_smart_member_add(group->obj, group->wd->pan_smart);
2178 elm_widget_sub_object_add(group->wd->obj, group->obj);
2179 evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
2181 if (!group->delete_object)
2182 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2186 group->delete_object = EINA_FALSE;
2188 group->obj = eina_list_data_get(group->clas->priv.objs_notused);
2189 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2190 group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
2191 evas_object_show(group->obj);
2194 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
2195 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
2197 group->update_nbelems = EINA_TRUE;
2198 group->update_resize = EINA_TRUE;
2199 group->update_raise = EINA_TRUE;
2201 if (group->open) _group_bubble_create(group);
2205 _group_object_free(Marker_Group *group)
2207 if (!group->obj) return;
2208 if (!group->delete_object)
2210 group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
2211 group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
2212 evas_object_hide(group->obj);
2214 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
2215 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
2218 evas_object_del(group->obj);
2221 _group_bubble_free(group);
2225 _group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2227 Marker_Group *group = data;
2229 if (!evas_object_above_get(group->rect)) return;
2230 evas_object_raise(group->bubble);
2231 evas_object_raise(group->sc);
2232 evas_object_raise(group->rect);
2236 _group_bubble_create(Marker_Group *group)
2238 if (group->bubble) return;
2240 group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
2241 group->bubble = edje_object_add(evas_object_evas_get(group->obj));
2242 _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
2243 elm_widget_style_get(group->wd->obj));
2244 evas_object_smart_member_add(group->bubble,
2246 elm_widget_sub_object_add(group->wd->obj, group->bubble);
2248 _group_bubble_content_free(group);
2249 if (!_group_bubble_content_update(group))
2251 //no content, we can delete the bubble
2252 _group_bubble_free(group);
2256 group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
2257 evas_object_color_set(group->rect, 0, 0, 0, 0);
2258 evas_object_repeat_events_set(group->rect, EINA_TRUE);
2259 evas_object_smart_member_add(group->rect, group->wd->obj);
2260 elm_widget_sub_object_add(group->wd->obj, group->rect);
2262 evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
2264 _group_bubble_place(group);
2267 static void _bubble_sc_hits_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2269 _group_bubble_place(data);
2273 _group_bubble_content_update(Marker_Group *group)
2276 Elm_Map_Marker *marker;
2279 if (!group->bubble) return 1;
2283 group->sc = elm_scroller_add(group->bubble);
2284 elm_widget_style_set(group->sc, "map_bubble");
2285 elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
2286 elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
2287 elm_scroller_bounce_set(group->sc, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
2288 edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
2289 evas_object_show(group->sc);
2290 evas_object_smart_member_add(group->sc,
2292 elm_widget_sub_object_add(group->wd->obj, group->sc);
2294 group->bx = elm_box_add(group->bubble);
2295 evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2296 evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
2297 elm_box_horizontal_set(group->bx, EINA_TRUE);
2298 evas_object_show(group->bx);
2300 elm_scroller_content_set(group->sc, group->bx);
2302 evas_object_event_callback_add(group->sc, EVAS_CALLBACK_RESIZE,
2303 _bubble_sc_hits_changed_cb, group);
2306 EINA_LIST_FOREACH(group->markers, l, marker)
2308 if (i >= group->wd->markers_max_num) break;
2309 if ((!marker->content) && (marker->clas->func.get))
2310 marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
2311 else if (marker->content)
2312 elm_box_unpack(group->bx, marker->content);
2313 if (marker->content)
2315 elm_box_pack_end(group->bx, marker->content);
2323 _group_bubble_content_free(Marker_Group *group)
2326 Elm_Map_Marker *marker;
2328 if (!group->sc) return;
2329 EINA_LIST_FOREACH(group->markers, l, marker)
2331 if ((marker->content) && (marker->clas->func.del))
2332 marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
2333 else if (marker->content)
2334 evas_object_del(marker->content);
2335 marker->content = NULL;
2337 evas_object_del(group->sc);
2342 _group_bubble_free(Marker_Group *group)
2344 if (!group->bubble) return;
2345 group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
2346 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2347 _bubble_sc_hits_changed_cb, group);
2348 evas_object_del(group->bubble);
2349 evas_object_del(group->rect);
2350 group->bubble = NULL;
2351 _group_bubble_content_free(group);
2355 _group_bubble_place(Marker_Group *group)
2358 Evas_Coord xx, yy, ww, hh;
2361 if ((!group->bubble) || (!group->obj)) return;
2363 evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
2364 edje_object_size_min_calc(group->bubble, NULL, &hh);
2366 s = edje_object_data_get(group->bubble, "size_w");
2367 if (s) ww = atoi(s);
2369 xx = x + w / 2 - ww / 2;
2372 evas_object_move(group->bubble, xx, yy);
2373 evas_object_resize(group->bubble, ww, hh);
2374 obj_rotate_zoom(group->wd, group->bubble);
2375 evas_object_show(group->bubble);
2377 evas_object_move(group->rect, xx, yy);
2378 evas_object_resize(group->rect, ww, hh);
2379 obj_rotate_zoom(group->wd, group->rect);
2380 evas_object_show(group->rect);
2384 _group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2386 Marker_Group *group = data;
2387 Elm_Map_Marker *marker = eina_list_data_get(group->markers);
2388 if (!marker) return;
2389 group->bringin = EINA_TRUE;
2390 elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
2394 _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2396 Marker_Group *group = data;
2400 group->bringin = EINA_FALSE;
2406 group->open = EINA_FALSE;
2407 _group_bubble_free(group);
2410 group->open = EINA_TRUE;
2411 _group_bubble_create(group);
2415 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
2420 Evas_Coord step_x = 0;
2421 Evas_Coord step_y = 0;
2424 Evas_Coord page_x = 0;
2425 Evas_Coord page_y = 0;
2427 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
2428 Evas_Event_Key_Down *ev = event_info;
2429 Widget_Data *wd = elm_widget_data_get(obj);
2430 if (!wd) return EINA_FALSE;
2431 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
2433 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
2434 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
2435 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
2436 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
2438 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
2442 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
2446 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
2450 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
2454 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
2457 y -= -(page_y * v_h) / 100;
2461 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
2464 y += -(page_y * v_h) / 100;
2468 else if (!strcmp(ev->keyname, "KP_Add"))
2470 zoom = elm_map_zoom_get(obj);
2472 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2473 elm_map_zoom_set(obj, zoom);
2476 else if (!strcmp(ev->keyname, "KP_Subtract"))
2478 zoom = elm_map_zoom_get(obj);
2480 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2481 elm_map_zoom_set(obj, zoom);
2484 else return EINA_FALSE;
2486 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2487 elm_smart_scroller_child_pos_set(wd->scr, x, y);
2493 cb_dump_name_attrs(void *data, const char *key, const char *value)
2495 Name_Dump *dump = (Name_Dump*)data;
2496 if (!dump) return EINA_FALSE;
2498 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
2499 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
2506 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2508 Route_Dump *dump = data;
2509 if (!dump) return EINA_FALSE;
2513 case EINA_SIMPLE_XML_OPEN:
2514 case EINA_SIMPLE_XML_OPEN_EMPTY:
2518 attrs = eina_simple_xml_tag_attributes_find(value, length);
2521 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
2522 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
2523 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
2524 else dump->id = ROUTE_XML_NONE;
2528 case EINA_SIMPLE_XML_DATA:
2530 char *buf = malloc(length);
2531 if (!buf) return EINA_FALSE;
2532 snprintf(buf, length, "%s", value);
2533 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
2534 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2535 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2547 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2549 Name_Dump *dump = data;
2550 if (!dump) return EINA_FALSE;
2554 case EINA_SIMPLE_XML_OPEN:
2555 case EINA_SIMPLE_XML_OPEN_EMPTY:
2558 attrs = eina_simple_xml_tag_attributes_find(value, length);
2561 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT)-1)) dump->id = NAME_XML_NAME;
2562 else dump->id = NAME_XML_NONE;
2564 eina_simple_xml_attributes_parse
2565 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
2569 case EINA_SIMPLE_XML_DATA:
2571 char *buf = malloc(length + 1);
2572 if (!buf) return EINA_FALSE;
2573 snprintf(buf, length + 1, "%s", value);
2574 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2586 _parse_kml(void *data)
2588 Elm_Map_Route *r = (Elm_Map_Route*)data;
2589 if (!r && !r->ud.fname) return;
2593 unsigned int ele, idx;
2597 Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL};
2599 f = fopen(r->ud.fname, "rb");
2604 fseek(f, 0, SEEK_END);
2610 fseek(f, 0, SEEK_SET);
2614 if (fread(buf, 1, sz, f))
2616 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump);
2623 if (dump.distance) r->info.distance = dump.distance;
2624 if (dump.description)
2626 eina_stringshare_replace(&r->info.waypoints, dump.description);
2627 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2628 r->info.waypoint_count = ele;
2629 for (idx = 0 ; idx < ele ; idx++)
2631 Route_Waypoint *wp = ELM_NEW(Route_Waypoint);
2635 wp->point = eina_stringshare_add(str[idx]);
2636 DBG("%s", str[idx]);
2637 r->waypoint = eina_list_append(r->waypoint, wp);
2646 else WRN("description is not found !");
2648 if (dump.coordinates)
2650 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2651 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2652 r->info.node_count = ele;
2653 for (idx = 0 ; idx < ele ; idx++)
2655 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2656 Route_Node *n = ELM_NEW(Route_Node);
2663 DBG("%lf:%lf", lon, lat);
2664 n->pos.address = NULL;
2665 r->nodes = eina_list_append(r->nodes, n);
2667 path = evas_object_line_add(evas_object_evas_get(r->wd->obj));
2668 evas_object_smart_member_add(path, r->wd->pan_smart);
2669 r->path = eina_list_append(r->path, path);
2682 _parse_name(void *data)
2684 Elm_Map_Name *n = (Elm_Map_Name*)data;
2685 if (!n && !n->ud.fname) return;
2689 Name_Dump dump = {0, NULL, 0.0, 0.0};
2691 f = fopen(n->ud.fname, "rb");
2696 fseek(f, 0, SEEK_END);
2702 fseek(f, 0, SEEK_SET);
2706 if (fread(buf, 1, sz, f))
2708 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
2717 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
2718 n->address = strdup(dump.address);
2726 _route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
2728 Ecore_Con_Event_Url_Complete *ev = event;
2729 Elm_Map_Route *r = (Elm_Map_Route*)data;
2730 Widget_Data *wd = r->wd;
2732 if ((!r) || (!ev)) return EINA_TRUE;
2733 Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url);
2734 ecore_con_url_data_set(r->con_url, NULL);
2735 if (r!=rr) return EINA_TRUE;
2737 if (r->ud.fd) fclose(r->ud.fd);
2742 Evas_Coord ox, oy, ow, oh;
2743 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
2744 route_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
2746 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2747 "elm,state,busy,stop", "elm");
2748 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
2753 _name_complete_cb(void *data, int ev_type __UNUSED__, void *event)
2755 Ecore_Con_Event_Url_Complete *ev = event;
2756 Elm_Map_Name *n = (Elm_Map_Name*)data;
2757 Widget_Data *wd = n->wd;
2759 if ((!n) || (!ev)) return EINA_TRUE;
2760 Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url);
2761 ecore_con_url_data_set(n->con_url, NULL);
2762 if (n!=nn) return EINA_TRUE;
2764 if (n->ud.fd) fclose(n->ud.fd);
2767 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2768 "elm,state,busy,stop", "elm");
2769 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
2773 static Elm_Map_Name *
2774 _utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat)
2776 Widget_Data *wd = elm_widget_data_get(obj);
2777 if (!wd) return NULL;
2782 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
2783 if (!name) return NULL;
2785 snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE);
2793 name->con_url = ecore_con_url_new(NULL);
2794 name->ud.fname = strdup(buf);
2795 INF("xml file : %s", name->ud.fname);
2797 name->ud.fd = fdopen(fd, "w+");
2798 if ((!name->con_url) || (!name->ud.fd))
2800 ecore_con_url_free(name->con_url);
2806 name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name);
2807 name->method = method;
2808 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
2809 else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL;
2813 source = map_sources_tab[wd->source].name_url_cb(wd->obj, method, address, lon, lat);
2814 INF("name url = %s", source);
2816 wd->names = eina_list_append(wd->names, name);
2817 ecore_con_url_url_set(name->con_url, source);
2818 ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd));
2819 ecore_con_url_data_set(name->con_url, name);
2821 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2822 "elm,state,busy,start", "elm");
2823 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL);
2824 ecore_con_url_get(name->con_url);
2825 if (source) free(source);
2831 static int idnum = 1;
2834 * Add a new Map object
2836 * @param parent The parent object
2837 * @return The new object or NULL if it cannot be created
2842 elm_map_add(Evas_Object *parent)
2846 Evas_Coord minw, minh;
2848 static Evas_Smart *smart = NULL;
2849 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
2851 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2853 ELM_SET_WIDTYPE(widtype, "map");
2854 elm_widget_type_set(obj, "map");
2855 elm_widget_sub_object_add(parent, obj);
2856 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2857 elm_widget_data_set(obj, wd);
2858 elm_widget_del_hook_set(obj, _del_hook);
2859 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2860 elm_widget_theme_hook_set(obj, _theme_hook);
2861 elm_widget_can_focus_set(obj, EINA_TRUE);
2862 elm_widget_event_hook_set(obj, _event_hook);
2864 wd->scr = elm_smart_scroller_add(e);
2865 elm_smart_scroller_widget_set(wd->scr, obj);
2866 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
2867 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
2868 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
2869 elm_widget_resize_object_set(obj, wd->scr);
2871 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
2872 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
2873 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
2874 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
2875 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
2877 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
2879 wd->api = module(obj);
2880 if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
2884 wd->markers_max_num = 30;
2885 wd->source = ELM_MAP_SOURCE_MAPNIK;
2886 wd->pinch.level = 1.0;
2888 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2889 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2890 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2891 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2895 static Evas_Smart_Class sc;
2897 evas_object_smart_clipped_smart_set(&_pan_sc);
2899 sc.name = "elm_map_pan";
2900 sc.version = EVAS_SMART_CLASS_VERSION;
2903 sc.resize = _pan_resize;
2904 sc.move = _pan_move;
2905 sc.calculate = _pan_calculate;
2906 smart = evas_smart_class_new(&sc);
2910 wd->pan_smart = evas_object_smart_add(e, smart);
2911 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2915 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2916 _pan_set, _pan_get, _pan_max_get,
2917 _pan_min_get, _pan_child_size_get);
2919 wd->rect = evas_object_rectangle_add(e);
2920 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_RESIZE,
2921 _rect_resize_cb, obj);
2922 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
2924 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_MOVE,
2926 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
2928 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_DOWN,
2929 _mouse_multi_down, obj);
2930 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_MOVE,
2931 _mouse_multi_move, obj);
2932 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP,
2933 _mouse_multi_up, obj);
2935 evas_object_smart_member_add(wd->rect, wd->pan_smart);
2936 elm_widget_sub_object_add(obj, wd->rect);
2937 evas_object_show(wd->rect);
2938 evas_object_color_set(wd->rect, 0, 0, 0, 0);
2941 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
2942 wd->id = ((int)getpid() << 16) | idnum;
2947 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2949 evas_object_size_hint_min_set(obj, minw, minh);
2951 wd->paused = EINA_TRUE;
2952 elm_map_zoom_set(obj, 0);
2953 wd->paused = EINA_FALSE;
2957 wd->calc_job = ecore_job_add(_calc_job, wd);
2959 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
2960 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
2962 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2963 // TODO: and save some bytes, making descriptions per-class and not instance!
2964 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2966 if (!ecore_file_download_protocol_available("http://"))
2968 ERR("Ecore must be built with curl support for the map widget!");
2974 * Set the zoom level of the map
2976 * This sets the zoom level. 0 is the world map and 18 is the maximum zoom.
2978 * @param obj The map object
2979 * @param zoom The zoom level to set
2984 elm_map_zoom_set(Evas_Object *obj, int zoom)
2986 ELM_CHECK_WIDTYPE(obj, widtype);
2987 Widget_Data *wd = elm_widget_data_get(obj);
2989 Grid *g, *g_zoom = NULL;
2990 Evas_Coord rx, ry, rw, rh;
2994 int zoom_changed = 0, started = 0;
2996 if ((!wd) || (wd->zoom_animator)) return;
2997 if (zoom < 0 ) zoom = 0;
2998 if (zoom > map_sources_tab[wd->source].zoom_max)
2999 zoom = map_sources_tab[wd->source].zoom_max;
3000 if (zoom < map_sources_tab[wd->source].zoom_min)
3001 zoom = map_sources_tab[wd->source].zoom_min;
3003 if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT;
3004 else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN;
3005 else wd->zoom_method = ZOOM_METHOD_NONE;
3007 wd->size.ow = wd->size.w;
3008 wd->size.oh = wd->size.h;
3009 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
3010 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3012 EINA_LIST_FOREACH(wd->route, lr, r)
3016 EINA_LIST_FOREACH(r->path, l, p)
3018 evas_object_hide(p);
3023 if (wd->mode == ELM_MAP_ZOOM_MODE_MANUAL)
3025 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3026 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3028 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3035 while (cumulw <= rw)
3044 while (cumulh <= rh)
3057 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3058 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3060 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3067 while (cumulw <= rw)
3076 while (cumulh <= rh)
3089 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3090 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3093 EINA_LIST_FOREACH(wd->grids, l, g)
3095 if (g->zoom == wd->zoom)
3101 g = grid_create(obj);
3104 if (eina_list_count(wd->grids) > 1)
3106 g_zoom = eina_list_last(wd->grids)->data;
3107 wd->grids = eina_list_remove(wd->grids, g_zoom);
3108 grid_clear(obj, g_zoom);
3111 wd->grids = eina_list_prepend(wd->grids, g);
3115 EINA_LIST_FREE(wd->grids, g)
3123 wd->t_start = ecore_loop_time_get();
3124 wd->t_end = wd->t_start + _elm_config->zoom_friction;
3131 if (!wd->zoom_animator)
3133 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
3135 if (wd->nosmooth == 1) _smooth_update(obj);
3139 if (wd->zoom_animator)
3141 if (!_zoom_anim(obj))
3143 ecore_animator_del(wd->zoom_animator);
3144 wd->zoom_animator = NULL;
3147 if (wd->calc_job) ecore_job_del(wd->calc_job);
3148 wd->calc_job = ecore_job_add(_calc_job, wd);
3152 evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
3153 if (!wd->zoom_animator)
3154 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3158 evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
3162 * Get the zoom level of the map
3164 * This returns the current zoom level of the map object. Note that if
3165 * you set the fill mode to other than ELM_MAP_ZOOM_MODE_MANUAL
3166 * (which is the default), the zoom level may be changed at any time by the
3167 * map object itself to account for map size and map viewpoer size
3169 * @param obj The map object
3170 * @return The current zoom level
3175 elm_map_zoom_get(const Evas_Object *obj)
3177 ELM_CHECK_WIDTYPE(obj, widtype) 1.0;
3178 Widget_Data *wd = elm_widget_data_get(obj);
3179 if (!wd) return 1.0;
3186 * This sets the zoom mode to manual or one of several automatic levels.
3187 * Manual (ELM_MAP_ZOOM_MODE_MANUAL) means that zoom is set manually by
3188 * elm_map_zoom_set() and will stay at that level until changed by code
3189 * or until zoom mode is changed. This is the default mode.
3190 * The Automatic modes will allow the map object to automatically
3191 * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT) will
3192 * adjust zoom so the map fits inside the scroll frame with no pixels
3193 * outside this area. ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but
3194 * 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.
3196 * @param obj The map object
3197 * @param mode The desired mode
3202 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
3204 ELM_CHECK_WIDTYPE(obj, widtype);
3205 Widget_Data *wd = elm_widget_data_get(obj);
3207 if (wd->mode == mode) return;
3210 double tz = wd->zoom;
3212 elm_map_zoom_set(wd->obj, tz);
3219 * This gets the current zoom mode of the map object
3221 * @param obj The map object
3222 * @return The current zoom mode
3226 EAPI Elm_Map_Zoom_Mode
3227 elm_map_zoom_mode_get(const Evas_Object *obj)
3229 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
3230 Widget_Data *wd = elm_widget_data_get(obj);
3231 if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
3236 * Centers the map at @p lon @p lat using an animation to scroll.
3238 * @param obj The map object
3239 * @param lon Longitude to center at
3240 * @param lon Latitude to center at
3245 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
3247 ELM_CHECK_WIDTYPE(obj, widtype);
3248 Widget_Data *wd = elm_widget_data_get(obj);
3252 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3253 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3258 if (wd->zoom_animator)
3261 if (!wd->nosmooth) _smooth_update(obj);
3262 ecore_animator_del(wd->zoom_animator);
3263 wd->zoom_animator = NULL;
3265 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3267 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
3269 wd->center_on.enabled = EINA_TRUE;
3270 wd->center_on.lon = lon;
3271 wd->center_on.lat = lat;
3275 * Move the map to the current coordinates.
3277 * This move the map to the current coordinates. The map will be centered on these coordinates.
3279 * @param obj The map object
3280 * @param lat The latitude.
3281 * @param lon The longitude.
3286 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
3288 ELM_CHECK_WIDTYPE(obj, widtype);
3289 Widget_Data *wd = elm_widget_data_get(obj);
3293 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3294 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3299 if (wd->zoom_animator)
3302 ecore_animator_del(wd->zoom_animator);
3303 wd->zoom_animator = NULL;
3305 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3307 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
3309 wd->center_on.enabled = EINA_TRUE;
3310 wd->center_on.lon = lon;
3311 wd->center_on.lat = lat;
3315 * Get the current coordinates of the map.
3317 * This gets the current coordinates of the map object.
3319 * @param obj The map object
3320 * @param lat The latitude.
3321 * @param lon The longitude.
3326 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
3328 ELM_CHECK_WIDTYPE(obj, widtype);
3329 Widget_Data *wd = elm_widget_data_get(obj);
3330 Evas_Coord sx, sy, sw, sh;
3333 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
3334 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
3338 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
3342 * Set the paused state for map
3344 * This sets the paused state to on (1) or off (0) for map. The default
3345 * is off. This will stop zooming using animation change zoom levels and
3346 * change instantly. This will stop any existing animations that are running.
3348 * @param obj The map object
3349 * @param paused The pause state to set
3354 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
3356 ELM_CHECK_WIDTYPE(obj, widtype);
3357 Widget_Data *wd = elm_widget_data_get(obj);
3359 if (wd->paused == !!paused) return;
3360 wd->paused = paused;
3363 if (wd->zoom_animator)
3365 ecore_animator_del(wd->zoom_animator);
3366 wd->zoom_animator = NULL;
3368 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3374 * Set the paused state for the markers
3376 * This sets the paused state to on (1) or off (0) for the markers. The default
3377 * is off. This will stop displaying the markers during change zoom levels. Set
3378 * to on if you have a large number of markers.
3380 * @param obj The map object
3381 * @param paused The pause state to set
3386 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
3388 ELM_CHECK_WIDTYPE(obj, widtype);
3389 Widget_Data *wd = elm_widget_data_get(obj);
3391 if (wd->paused_markers == !!paused) return;
3392 wd->paused_markers = paused;
3396 * Get the paused state for map
3398 * This gets the current paused state for the map object.
3400 * @param obj The map object
3401 * @return The current paused state
3406 elm_map_paused_get(const Evas_Object *obj)
3408 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3409 Widget_Data *wd = elm_widget_data_get(obj);
3410 if (!wd) return EINA_FALSE;
3415 * Get the paused state for the markers
3417 * This gets the current paused state for the markers object.
3419 * @param obj The map object
3420 * @return The current paused state
3425 elm_map_paused_markers_get(const Evas_Object *obj)
3427 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3428 Widget_Data *wd = elm_widget_data_get(obj);
3429 if (!wd) return EINA_FALSE;
3430 return wd->paused_markers;
3434 * Get the information of downloading status
3436 * This gets the current downloading status for the map object.
3438 * @param obj The map object
3439 * @param try_num the number of download trying map
3440 * @param finish_num the number of downloaded map
3446 elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
3448 ELM_CHECK_WIDTYPE(obj, widtype);
3449 Widget_Data *wd = elm_widget_data_get(obj);
3454 *try_num = wd->try_num;
3459 *finish_num = wd->finish_num;
3463 * Convert a pixel coordinate (x,y) into a geographic coordinate (longitude, latitude).
3465 * @param obj The map object
3466 * @param x the coordinate
3467 * @param y the coordinate
3468 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
3469 * @param lon the longitude correspond to x
3470 * @param lat the latitude correspond to y
3475 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
3477 Widget_Data *wd = elm_widget_data_get(obj);
3478 int zoom = floor(log(size/256) / log(2));
3480 if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
3481 if ((wd->api) && (wd->api->obj_convert_coord_into_geo))
3482 if (wd->api->obj_convert_coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
3486 *lon = x / (double)size * 360.0 - 180;
3490 double n = ELM_PI - 2.0 * ELM_PI * y / size;
3491 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
3496 * Convert a geographic coordinate (longitude, latitude) into a pixel coordinate (x, y).
3498 * @param obj The map object
3499 * @param lon the longitude
3500 * @param lat the latitude
3501 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
3502 * @param x the coordinate correspond to the longitude
3503 * @param y the coordinate correspond to the latitude
3508 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
3510 Widget_Data *wd = elm_widget_data_get(obj);
3511 int zoom = floor(log(size/256) / log(2));
3513 if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
3514 if ((wd->api) && (wd->api->obj_convert_geo_into_coord))
3515 if (wd->api->obj_convert_geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
3518 *x = floor((lon + 180.0) / 360.0 * size);
3520 *y = floor((1.0 - log( tan(lat * ELM_PI/180.0) + 1.0 / cos(lat * ELM_PI/180.0)) / ELM_PI) / 2.0 * size);
3524 * Convert a geographic coordinate (longitude, latitude) into a name (address).
3526 * @param obj The map object
3527 * @param lon the longitude
3528 * @param lat the latitude
3530 * @return name the address
3535 elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat)
3537 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3538 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat);
3542 * Convert a name (address) into a geographic coordinate (longitude, latitude).
3544 * @param obj The map object
3545 * @param name the address
3546 * @param lat the latitude correspond to y
3548 * @return name the address
3553 elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address)
3555 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3556 if (!address) return NULL;
3557 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0);
3561 * Convert a pixel coordinate into a roated pixcel coordinate.
3563 * @param obj The map object
3564 * @param x x to rotate.
3565 * @param y y to rotate.
3566 * @param cx rotation's center horizontal position.
3567 * @param cy rotation's center vertical position.
3568 * @param degree amount of degrees from 0.0 to 360.0 to rotate arount Z axis.
3569 * @param xx rotated x.
3570 * @param yy rotated y.
3575 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)
3577 if ((!xx) || (!yy)) return;
3579 double r = (degree * M_PI) / 180.0;
3580 double tx, ty, ttx, tty;
3587 tx = ttx + (ty * cos(r + M_PI_2));
3588 ty = tty + (ty * sin(r + M_PI_2));
3595 * Add a marker on the map
3597 * @param obj The map object
3598 * @param lon the longitude
3599 * @param lat the latitude
3600 * @param clas the class to use
3601 * @param clas_group the class group
3602 * @param data the data passed to the callbacks
3604 * @return The marker object
3608 EAPI Elm_Map_Marker *
3609 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
3613 Marker_Group *group;
3614 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3615 Widget_Data *wd = elm_widget_data_get(obj);
3623 if (!wd) return NULL;
3624 EINA_SAFETY_ON_NULL_RETURN_VAL(clas_group, NULL);
3625 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, NULL);
3627 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
3630 marker->clas = clas;
3631 marker->clas_group = clas_group;
3632 marker->longitude = lon;
3633 marker->latitude = lat;
3634 marker->data = data;
3636 tabi[1] = tabi[4] = tabi[6] = -1;
3637 tabi[2] = tabi[0] = tabi[7] = 0;
3638 tabi[3] = tabi[5] = tabi[8] = 1;
3640 tabj[1] = tabj[2] = tabj[3] = -1;
3641 tabj[4] = tabj[0] = tabj[5] = 0;
3642 tabj[6] = tabj[7] = tabj[8] = 1;
3644 if (!clas_group->priv.set)
3647 if (marker->clas_group && marker->clas_group->style)
3648 style = marker->clas_group->style;
3650 o = edje_object_add(evas_object_evas_get(obj));
3651 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3652 s = edje_object_data_get(o, "size_w");
3653 if (s) clas_group->priv.edje_w = atoi(s);
3654 else clas_group->priv.edje_w = 0;
3655 s = edje_object_data_get(o, "size_h");
3656 if (s) clas_group->priv.edje_h = atoi(s);
3657 else clas_group->priv.edje_h = 0;
3658 s = edje_object_data_get(o, "size_max_w");
3659 if (s) clas_group->priv.edje_max_w = atoi(s);
3660 else clas_group->priv.edje_max_w = 0;
3661 s = edje_object_data_get(o, "size_max_h");
3662 if (s) clas_group->priv.edje_max_h = atoi(s);
3663 else clas_group->priv.edje_max_h = 0;
3666 clas_group->priv.set = EINA_TRUE;
3669 if (!clas->priv.set)
3672 if (marker->clas && marker->clas->style)
3673 style = marker->clas->style;
3675 o = edje_object_add(evas_object_evas_get(obj));
3676 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3677 s = edje_object_data_get(o, "size_w");
3678 if (s) clas->priv.edje_w = atoi(s);
3679 else clas->priv.edje_w = 0;
3680 s = edje_object_data_get(o, "size_h");
3681 if (s) clas->priv.edje_h = atoi(s);
3682 else clas->priv.edje_h = 0;
3685 clas->priv.set = EINA_TRUE;
3688 for (i = clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
3690 elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
3691 &(marker->x[i]), &(marker->y[i]));
3693 //search in the matrixsparse the region where the marker will be
3694 mpi = marker->x[i] / wd->tsize;
3695 mpj = marker->y[i] / wd->tsize;
3697 if (!wd->markers[i])
3699 int size = pow(2.0, i);
3700 wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
3704 if (i <= clas_group->zoom_grouped)
3706 for (j = 0, group = NULL; j < 9 && !group; j++)
3708 EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
3711 if (group->clas == marker->clas_group
3712 && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
3713 marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
3714 group->x-group->w/4, group->y-group->h/4, group->w, group->h))
3716 group->markers = eina_list_append(group->markers, marker);
3717 group->update_nbelems = EINA_TRUE;
3718 group->update_resize = EINA_TRUE;
3720 group->sum_x += marker->x[i];
3721 group->sum_y += marker->y[i];
3722 group->x = group->sum_x / eina_list_count(group->markers);
3723 group->y = group->sum_y / eina_list_count(group->markers);
3725 group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
3726 * eina_list_count(group->markers);
3727 group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
3728 * eina_list_count(group->markers);
3729 if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
3730 if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
3732 if (group->obj && eina_list_count(group->markers) == 2)
3734 _group_object_free(group);
3735 _group_object_create(group);
3738 _group_bubble_content_update(group);
3747 group = calloc(1, sizeof(Marker_Group));
3749 group->sum_x = marker->x[i];
3750 group->sum_y = marker->y[i];
3751 group->x = marker->x[i];
3752 group->y = marker->y[i];
3753 group->w = clas_group->priv.edje_w;
3754 group->h = clas_group->priv.edje_h;
3755 group->clas = clas_group;
3757 group->markers = eina_list_append(group->markers, marker);
3758 group->update_nbelems = EINA_TRUE;
3759 group->update_resize = EINA_TRUE;
3761 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3765 l = eina_list_append(NULL, group);
3766 eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
3767 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3771 l = eina_matrixsparse_cell_data_get(group->cell);
3772 l = eina_list_append(l, group);
3773 eina_matrixsparse_cell_data_set(group->cell, l);
3776 marker->groups[i] = group;
3781 Evas_Coord ox, oy, ow, oh;
3782 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3783 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3790 * Remove a marker from the map
3792 * @param marker The marker to remove
3797 elm_map_marker_remove(Elm_Map_Marker *marker)
3803 EINA_SAFETY_ON_NULL_RETURN(marker);
3806 for (i = marker->clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
3808 marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
3809 if (!eina_list_count(marker->groups[i]->markers))
3811 groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
3812 groups = eina_list_remove(groups, marker->groups[i]);
3813 eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
3815 _group_object_free(marker->groups[i]);
3816 _group_bubble_free(marker->groups[i]);
3817 free(marker->groups[i]);
3821 marker->groups[i]->sum_x -= marker->x[i];
3822 marker->groups[i]->sum_y -= marker->y[i];
3824 marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
3825 marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
3827 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
3828 + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
3829 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
3830 + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
3831 if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
3832 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
3833 if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
3834 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
3836 if ((marker->groups[i]->obj) && (eina_list_count(marker->groups[i]->markers) == 1))
3838 _group_object_free(marker->groups[i]);
3839 _group_object_create(marker->groups[i]);
3844 if ((marker->content) && (marker->clas->func.del))
3845 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
3846 else if (marker->content)
3847 evas_object_del(marker->content);
3853 Evas_Coord ox, oy, ow, oh;
3854 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3855 marker_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3860 * Get the current coordinates of the marker.
3862 * @param marker marker.
3863 * @param lat The latitude.
3864 * @param lon The longitude.
3869 elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat)
3871 EINA_SAFETY_ON_NULL_RETURN(marker);
3872 if (lon) *lon = marker->longitude;
3873 if (lat) *lat = marker->latitude;
3877 * Move the map to the coordinate of the marker.
3879 * @param marker The marker where the map will be center.
3884 elm_map_marker_bring_in(Elm_Map_Marker *marker)
3886 EINA_SAFETY_ON_NULL_RETURN(marker);
3887 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
3891 * Move the map to the coordinate of the marker.
3893 * @param marker The marker where the map will be center.
3898 elm_map_marker_show(Elm_Map_Marker *marker)
3900 EINA_SAFETY_ON_NULL_RETURN(marker);
3901 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
3905 * Move and zoom the map to display a list of markers.
3907 * The map will be centered on the center point of the markers in the list. Then
3908 * the map will be zoomed in order to fit the markers using the maximum zoom which
3909 * allows display of all the markers.
3911 * @param markers The list of markers (list of Elm_Map_Marker *)
3916 elm_map_markers_list_show(Eina_List *markers)
3921 Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
3922 Evas_Coord rw, rh, xc, yc;
3925 EINA_SAFETY_ON_NULL_RETURN(markers);
3927 EINA_LIST_FOREACH(markers, l, marker)
3931 if ((!m_min_lon) || (marker->longitude < m_min_lon->longitude))
3934 if ((!m_max_lon) || (marker->longitude > m_max_lon->longitude))
3937 if ((!m_min_lat) || (marker->latitude > m_min_lat->latitude))
3940 if ((!m_max_lat) || (marker->latitude < m_max_lat->latitude))
3944 lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
3945 lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
3947 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3948 for (zoom = map_sources_tab[wd->source].zoom_max; zoom>map_sources_tab[wd->source].zoom_min; zoom--)
3950 Evas_Coord size = pow(2.0, zoom)*wd->tsize;
3951 elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
3953 if ((m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2)
3954 && (m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2)
3955 && (m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2)
3956 && (m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2))
3960 elm_map_geo_region_show(wd->obj, lon, lat);
3961 elm_map_zoom_set(wd->obj, zoom);
3965 * Set the maximum numbers of markers display in a group.
3967 * A group can have a long list of markers, consequently the creation of the content
3968 * of the bubble can be very slow. In order to avoid this, a maximum number of items
3969 * is displayed in a bubble. By default this number is 30.
3971 * @param obj The map object.
3972 * @param max The maximum numbers of items displayed in a bubble.
3977 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
3979 ELM_CHECK_WIDTYPE(obj, widtype);
3980 Widget_Data *wd = elm_widget_data_get(obj);
3982 wd->markers_max_num = max;
3986 * Return the evas object getting from the ElmMapMarkerGetFunc callback
3988 * @param marker The marker.
3989 * @return Return the evas object if it exists, else NULL.
3994 elm_map_marker_object_get(const Elm_Map_Marker *marker)
3996 EINA_SAFETY_ON_NULL_RETURN_VAL(marker, NULL);
3997 return marker->content;
4003 * @param marker The marker.
4008 elm_map_marker_update(Elm_Map_Marker *marker)
4010 EINA_SAFETY_ON_NULL_RETURN(marker);
4011 if (marker->content)
4013 if (marker->clas->func.del)
4014 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4016 evas_object_del(marker->content);
4017 marker->content = NULL;
4018 _group_bubble_content_update(marker->groups[marker->wd->zoom]);
4023 * Close all opened bubbles
4025 * @param obj The map object
4030 elm_map_bubbles_close(Evas_Object *obj)
4032 ELM_CHECK_WIDTYPE(obj, widtype);
4033 Widget_Data *wd = elm_widget_data_get(obj);
4034 Marker_Group *group;
4035 Eina_List *l, *l_next;
4037 EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
4038 _group_bubble_free(group);
4043 * Create a group class.
4045 * Each marker must be associated to a group class. Marker with the same group are grouped if they are close.
4046 * The group class defines the style of the marker when a marker is grouped to others markers.
4048 * @param obj The map object
4049 * @return Returns the new group class
4053 EAPI Elm_Map_Group_Class *
4054 elm_map_group_class_new(Evas_Object *obj)
4056 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4057 Widget_Data *wd = elm_widget_data_get(obj);
4058 if (!wd) return NULL;
4059 Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
4060 clas->zoom_grouped = ZOOM_MAX;
4061 wd->groups_clas = eina_list_append(wd->groups_clas, clas);
4066 * Set the style of a group class (radio, radio2 or empty)
4068 * @param clas the group class
4069 * @param style the new style
4074 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
4076 EINA_SAFETY_ON_NULL_RETURN(clas);
4077 eina_stringshare_replace(&clas->style, style);
4081 * Set the icon callback of a group class.
4083 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
4085 * @param clas the group class
4086 * @param icon_get the callback to create the icon
4091 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
4093 EINA_SAFETY_ON_NULL_RETURN(clas);
4094 clas->func.icon_get = icon_get;
4098 * Set the data associated to the group class (radio, radio2 or empty)
4100 * @param clas the group class
4101 * @param data the new user data
4106 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
4108 EINA_SAFETY_ON_NULL_RETURN(clas);
4113 * Set the zoom from where the markers are displayed.
4115 * Markers will not be displayed for a zoom less than @ref zoom
4117 * @param clas the group class
4118 * @param zoom the zoom
4123 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
4125 EINA_SAFETY_ON_NULL_RETURN(clas);
4126 clas->zoom_displayed = zoom;
4130 * Set the zoom from where the markers are no more grouped.
4132 * @param clas the group class
4133 * @param zoom the zoom
4138 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
4140 EINA_SAFETY_ON_NULL_RETURN(clas);
4141 clas->zoom_grouped = zoom;
4145 * Set if the markers associated to the group class @clas are hidden or not.
4146 * If @ref hide is true the markers will be hidden.
4148 * @param clas the group class
4149 * @param hide if true the markers will be hidden, else they will be displayed.
4154 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
4156 ELM_CHECK_WIDTYPE(obj, widtype);
4157 Widget_Data *wd = elm_widget_data_get(obj);
4159 EINA_SAFETY_ON_NULL_RETURN(clas);
4160 if (clas->hide == hide) return;
4164 Evas_Coord ox, oy, ow, oh;
4165 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
4166 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4172 * Create a marker class.
4174 * Each marker must be associated to a class.
4175 * The class defines the style of the marker when a marker is displayed alone (not grouped).
4177 * @param obj The map object
4178 * @return Returns the new class
4182 EAPI Elm_Map_Marker_Class *
4183 elm_map_marker_class_new(Evas_Object *obj)
4185 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4186 Widget_Data *wd = elm_widget_data_get(obj);
4187 if (!wd) return NULL;
4188 Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
4189 wd->markers_clas = eina_list_append(wd->markers_clas, clas);
4194 * Set the style of a class (radio, radio2 or empty)
4196 * @param clas the group class
4197 * @param style the new style
4202 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
4204 EINA_SAFETY_ON_NULL_RETURN(clas);
4205 eina_stringshare_replace(&clas->style, style);
4209 * Set the icon callback of a class.
4211 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
4213 * @param clas the group class
4214 * @param icon_get the callback to create the icon
4219 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
4221 EINA_SAFETY_ON_NULL_RETURN(clas);
4222 clas->func.icon_get = icon_get;
4227 * Set the callback of the content of the bubble.
4229 * When the user click on a marker, a bubble is displayed with a content.
4230 * The callback @ref get musst return this content. It can be NULL.
4232 * @param clas the group class
4233 * @param get the callback to create the content
4238 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
4240 EINA_SAFETY_ON_NULL_RETURN(clas);
4241 clas->func.get = get;
4245 * Set the callback of the content of delete the object created by the callback "get".
4247 * If this callback is defined the user will have to delete (or not) the object inside.
4248 * If the callback is not defined the object will be destroyed with evas_object_del()
4250 * @param clas the group class
4251 * @param del the callback to delete the content
4256 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
4258 EINA_SAFETY_ON_NULL_RETURN(clas);
4259 clas->func.del = del;
4263 * Set the source of the map.
4265 * Elm_Map retrieves the image which composed the map from a web service. This web service can
4266 * be set with this method. A different service can return a different maps with different
4267 * information and it can use different zoom value.
4269 * @param clas the group class
4270 * @param source the new source
4275 elm_map_source_set(Evas_Object *obj, Elm_Map_Sources source)
4277 ELM_CHECK_WIDTYPE(obj, widtype);
4278 Widget_Data *wd = elm_widget_data_get(obj);
4282 if (wd->source == source ) return;
4283 if (!map_sources_tab[source].url_cb) return;
4284 _elm_config_sub_init();
4286 EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid);
4288 wd->source = source;
4292 if (map_sources_tab[wd->source].zoom_max < zoom)
4293 zoom = map_sources_tab[wd->source].zoom_max;
4294 if (map_sources_tab[wd->source].zoom_min > zoom)
4295 zoom = map_sources_tab[wd->source].zoom_min;
4297 elm_map_zoom_set(obj, zoom);
4301 * Set the source of the route.
4303 * @param clas the group class
4304 * @param source the new source
4309 elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
4311 ELM_CHECK_WIDTYPE(obj, widtype);
4312 Widget_Data *wd = elm_widget_data_get(obj);
4314 wd->source = source;
4318 * Get the current source
4320 * @param obj the map object
4321 * @return Returns the maximum zoom of the source
4325 EAPI Elm_Map_Sources
4326 elm_map_source_get(const Evas_Object *obj)
4328 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_SOURCE_MAPNIK;
4329 Widget_Data *wd = elm_widget_data_get(obj);
4330 if (!wd) return ELM_MAP_SOURCE_MAPNIK;
4335 * Get the current route source
4337 * @param obj the map object
4338 * @return Returns the source of the route
4342 EAPI Elm_Map_Route_Sources
4343 elm_map_route_source_get(const Evas_Object *obj)
4345 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS;
4346 Widget_Data *wd = elm_widget_data_get(obj);
4347 if (!wd) return ELM_MAP_ROUTE_SOURCE_YOURS;
4348 return wd->route_source;
4352 * Set the API of a custom source.
4354 * A custom web service can be associated to the source ELM_MAP_SOURCE_CUSTOM_(1..7).
4356 * @param source the source ID (ELM_MAP_SOURCE_CUSTOM_(1..7))
4357 * @param name the name of the source
4358 * @param zoom_min the minimum zoom of the source, must be >= 0
4359 * @param zoom_max the maximum zoom of the source, must be <= ZOOM_MAX
4360 * @param url_cb the callback used to create the url from where a tile (png or jpeg file) is downloaded.
4365 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)
4367 EINA_SAFETY_ON_NULL_RETURN(name);
4368 EINA_SAFETY_ON_NULL_RETURN(url_cb);
4369 map_sources_tab[source].name = name;
4370 map_sources_tab[source].zoom_min = zoom_min;
4371 map_sources_tab[source].zoom_max = zoom_max;
4372 map_sources_tab[source].url_cb = url_cb;
4373 map_sources_tab[source].route_url_cb = route_url_cb;
4374 map_sources_tab[source].name_url_cb = name_url_cb;
4378 * Get the maximum zoom of the source.
4380 * @param source the source
4381 * @return Returns the maximum zoom of the source
4386 elm_map_source_zoom_max_get(Elm_Map_Sources source)
4388 return map_sources_tab[source].zoom_max;
4392 * Get the minimum zoom of the source.
4394 * @param source the source
4395 * @return Returns the minimum zoom of the source
4400 elm_map_source_zoom_min_get(Elm_Map_Sources source)
4402 return map_sources_tab[source].zoom_min;
4406 * Get the name of a source.
4408 * @param source the source
4409 * @return Returns the name of the source
4414 elm_map_source_name_get(Elm_Map_Sources source)
4416 return map_sources_tab[source].name;
4420 * Set the user agent of the widget map.
4422 * @param obj The map object
4423 * @param user_agent the user agent of the widget map
4428 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
4430 ELM_CHECK_WIDTYPE(obj, widtype);
4431 Widget_Data *wd = elm_widget_data_get(obj);
4434 if (!wd->user_agent) wd->user_agent = eina_stringshare_add(user_agent);
4435 else eina_stringshare_replace(&wd->user_agent, user_agent);
4437 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4438 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4442 * Get the user agent of the widget map.
4444 * @param obj The map object
4445 * @return The user agent of the widget map
4450 elm_map_user_agent_get(Evas_Object *obj)
4452 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4453 Widget_Data *wd = elm_widget_data_get(obj);
4455 if (!wd) return NULL;
4456 return wd->user_agent;
4460 * Add a route on the map
4462 * @param obj The map object
4463 * @param type the type if transport
4464 * @param method the routing method
4465 * @param flon the start longitude
4466 * @param flat the start latitude
4467 * @param tlon the destination longitude
4468 * @param tlat the destination latitude
4470 * @return The Route object
4474 EAPI Elm_Map_Route *
4475 elm_map_route_add(Evas_Object *obj,
4476 Elm_Map_Route_Type type,
4477 Elm_Map_Route_Method method,
4483 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4484 Widget_Data *wd = elm_widget_data_get(obj);
4485 if (!wd) return EINA_FALSE;
4488 char *type_name = NULL;
4490 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4491 if (!route) return NULL;
4493 snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE);
4501 route->con_url = ecore_con_url_new(NULL);
4502 route->ud.fname = strdup(buf);
4503 INF("xml file : %s", route->ud.fname);
4505 route->ud.fd = fdopen(fd, "w+");
4506 if ((!route->con_url) || (!route->ud.fd))
4508 ecore_con_url_free(route->con_url);
4514 route->color.r = 255;
4517 route->color.a = 255;
4518 route->handlers = eina_list_append
4519 (route->handlers, (void *)ecore_event_handler_add
4520 (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route));
4522 route->inbound = EINA_FALSE;
4524 route->method = method;
4532 case ELM_MAP_ROUTE_TYPE_MOTOCAR:
4533 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4535 case ELM_MAP_ROUTE_TYPE_BICYCLE:
4536 type_name = strdup(ROUTE_TYPE_BICYCLE);
4538 case ELM_MAP_ROUTE_TYPE_FOOT:
4539 type_name = strdup(ROUTE_TYPE_FOOT);
4545 source = map_sources_tab[wd->source].route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4546 INF("route url = %s", source);
4548 wd->route = eina_list_append(wd->route, route);
4550 ecore_con_url_url_set(route->con_url, source);
4551 ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd));
4552 ecore_con_url_data_set(route->con_url, route);
4553 ecore_con_url_get(route->con_url);
4554 if (type_name) free(type_name);
4555 if (source) free(source);
4557 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4558 "elm,state,busy,start", "elm");
4559 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL);
4564 * Remove a route from the map
4566 * @param route The route to remove
4572 elm_map_route_remove(Elm_Map_Route *route)
4574 EINA_SAFETY_ON_NULL_RETURN(route);
4579 Ecore_Event_Handler *h;
4581 EINA_LIST_FREE(route->path, p)
4586 EINA_LIST_FREE(route->waypoint, w)
4588 if (w->point) eina_stringshare_del(w->point);
4592 EINA_LIST_FREE(route->nodes, n)
4594 if (n->pos.address) eina_stringshare_del(n->pos.address);
4598 EINA_LIST_FREE(route->handlers, h)
4600 ecore_event_handler_del(h);
4603 if (route->ud.fname)
4605 ecore_file_remove(route->ud.fname);
4606 free(route->ud.fname);
4607 route->ud.fname = NULL;
4612 * Set the option used for the background color
4614 * @param route The route object
4620 * This sets the color used for the route
4625 elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a)
4627 EINA_SAFETY_ON_NULL_RETURN(route);
4635 * Get the option used for the background color
4637 * @param route The route object
4646 elm_map_route_color_get(Elm_Map_Route *route, int *r, int *g , int *b, int *a)
4648 EINA_SAFETY_ON_NULL_RETURN(route);
4649 if (r) *r = route->color.r;
4650 if (g) *g = route->color.g;
4651 if (b) *b = route->color.b;
4652 if (a) *a = route->color.a;
4656 * Get the information of route distance
4658 * @param route the route object
4659 * @return Returns the distance of route (unit : km)
4664 elm_map_route_distance_get(Elm_Map_Route *route)
4666 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
4667 return route->info.distance;
4671 * Get the information of route nodes
4673 * @param route the route object
4674 * @return Returns the nodes of route
4680 elm_map_route_node_get(Elm_Map_Route *route)
4682 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4683 return route->info.nodes;
4687 * Get the information of route waypoint
4689 * @param route the route object
4690 * @return Returns the waypoint of route
4696 elm_map_route_waypoint_get(Elm_Map_Route *route)
4698 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4699 return route->info.waypoints;
4703 * Get the information of address
4705 * @param name the name object
4706 * @return Returns the address of name
4711 elm_map_name_address_get(Elm_Map_Name *name)
4713 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
4714 return name->address;
4718 * Get the current coordinates of the name.
4720 * This gets the current coordinates of the name object.
4722 * @param obj The name object
4723 * @param lat The latitude.
4724 * @param lon The longitude.
4729 elm_map_name_region_get(Elm_Map_Name *name, double *lon, double *lat)
4731 EINA_SAFETY_ON_NULL_RETURN(name);
4732 if (lon) *lon = name->lon;
4733 if (lat) *lat = name->lat;
4737 * Remove a name from the map
4739 * @param name The name to remove
4744 elm_map_name_remove(Elm_Map_Name *name)
4746 EINA_SAFETY_ON_NULL_RETURN(name);
4749 free(name->address);
4750 name->address = NULL;
4754 ecore_event_handler_del(name->handler);
4755 name->handler = NULL;
4759 ecore_file_remove(name->ud.fname);
4760 free(name->ud.fname);
4761 name->ud.fname = NULL;
4766 * Set the rotate degree of the map
4768 * @param obj The map object
4769 * @param angle amount of degrees from 0.0 to 360.0 to rotate arount Z axis.
4770 * @param cx rotation's center horizontal position.
4771 * @param cy rotation's center vertical position.
4776 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
4778 ELM_CHECK_WIDTYPE(obj, widtype);
4779 Widget_Data *wd = elm_widget_data_get(obj);
4781 wd->rotate.d = degree;
4784 wd->calc_job = ecore_job_add(_calc_job, wd);
4788 * Get the rotate degree of the map
4790 * @param obj The map object
4791 * @return amount of degrees from 0.0 to 360.0 to rotate arount Z axis.
4792 * @param cx rotation's center horizontal position.
4793 * @param cy rotation's center vertical position.
4798 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
4800 ELM_CHECK_WIDTYPE(obj, widtype);
4801 Widget_Data *wd = elm_widget_data_get(obj);
4803 if (degree) *degree = wd->rotate.d;
4804 if (cx) *cx = wd->rotate.cx;
4805 if (cy) *cy = wd->rotate.cy;
4809 _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4812 snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
4818 _osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4821 snprintf(buf, sizeof(buf),
4822 "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
4828 _cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4831 snprintf(buf, sizeof(buf),
4832 "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
4838 _maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4841 snprintf(buf, sizeof(buf),
4842 "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
4848 _custom1_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4854 _custom2_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4860 _custom3_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4866 _custom4_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4872 _custom5_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4878 _custom6_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
4884 _module_url_cb(Evas_Object *obj, int x, int y, int zoom)
4887 Widget_Data *wd = elm_widget_data_get(obj);
4888 if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
4889 if ((wd->api) && (wd->api->obj_url_request))
4890 buf = wd->api->obj_url_request(obj, x, y, zoom);
4892 if (!buf) buf = strdup("");
4897 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4900 snprintf(buf, sizeof(buf),
4901 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
4902 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
4907 // TODO: fix monav api
4909 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4912 snprintf(buf, sizeof(buf),
4913 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
4914 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
4920 // TODO: fix ors api
4922 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4925 snprintf(buf, sizeof(buf),
4926 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
4927 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
4933 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__)
4938 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__)
4943 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__)
4948 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__)
4953 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__)
4958 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__)
4963 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__)
4965 // TODO: make example route module
4971 _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
4973 Widget_Data *wd = elm_widget_data_get(obj);
4974 if (!wd) return strdup("");
4976 unsigned int ele, idx;
4978 char search_url[PATH_MAX];
4980 if (method == ELM_MAP_NAME_METHOD_SEARCH)
4982 search_url[0] = '\0';
4983 str = eina_str_split_full(name, " ", 0, &ele);
4984 for (idx = 0 ; idx < ele ; idx++)
4986 eina_strlcat(search_url, str[idx], sizeof(search_url));
4987 if (!(idx == (ele-1))) eina_strlcat(search_url, "+", sizeof(search_url));
4989 snprintf(buf, sizeof(buf), "%s/search?q=%s&format=xml&polygon=0&addressdetails=0", NAME_NOMINATIM_URL, search_url);
4991 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);
4992 else strcpy(buf, "");
4998 _name_custom1_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
5004 _name_custom2_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
5010 _name_custom3_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
5016 _name_custom4_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
5022 _name_custom5_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
5028 _name_custom6_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)