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 _Event Event;
65 typedef struct _Route_Node Route_Node;
66 typedef struct _Route_Waypoint Route_Waypoint;
67 typedef struct _Url_Data Url_Data;
68 typedef struct _Route_Dump Route_Dump;
69 typedef struct _Name_Dump Name_Dump;
71 #define DEST_DIR_ZOOM_PATH "/tmp/elm_map/%d/%d/"
72 #define DEST_DIR_PATH DEST_DIR_ZOOM_PATH"%d/"
73 #define DEST_FILE_PATH "%s%d.png"
74 #define DEST_ROUTE_XML_FILE "/tmp/elm_map-route-XXXXXX"
75 #define DEST_NAME_XML_FILE "/tmp/elm_map-name-XXXXXX"
77 #define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php"
78 #define ROUTE_TYPE_MOTORCAR "motocar"
79 #define ROUTE_TYPE_BICYCLE "bicycle"
80 #define ROUTE_TYPE_FOOT "foot"
81 #define YOURS_DISTANCE "distance"
82 #define YOURS_DESCRIPTION "description"
83 #define YOURS_COORDINATES "coordinates"
85 // TODO: fix monav & ors url
86 #define ROUTE_MONAV_URL "http://"
87 #define ROUTE_ORS_URL "http:///"
89 #define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org"
90 #define NOMINATIM_RESULT "result"
91 #define NOMINATIM_PLACE "place"
92 #define NOMINATIM_ATTR_LON "lon"
93 #define NOMINATIM_ATTR_LAT "lat"
95 #define PINCH_ZOOM_MIN 0.1
96 #define PINCH_ZOOM_MAX 5.0
99 // Currently the size of a tile must be 256*256
100 // and the size of the map must be pow(2.0, z)*tile_size
101 typedef struct _Map_Sources_Tab
106 ElmMapModuleUrlFunc url_cb;
107 Elm_Map_Route_Sources route_source;
108 ElmMapModuleRouteUrlFunc route_url_cb;
109 ElmMapModuleNameUrlFunc name_url_cb;
110 ElmMapModuleGeoIntoCoordFunc geo_into_coord;
111 ElmMapModuleCoordIntoGeoFunc coord_into_geo;
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);
122 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
124 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
125 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
127 static char *_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat);
129 static Map_Sources_Tab default_map_sources_tab[] =
131 {"Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
132 {"Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
133 {"CycleMap", 0, 17, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
134 {"Maplint", 12, 16, _maplint_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
139 Ecore_Con_Url *con_url;
145 struct _Elm_Map_Marker_Class
150 struct _Elm_Map_Marker_Class_Func {
151 ElmMapMarkerGetFunc get;
152 ElmMapMarkerDelFunc del; //if NULL the object will be destroyed with evas_object_del()
153 ElmMapMarkerIconGetFunc icon_get;
156 struct { //this part is private, do not modify these values
158 Evas_Coord edje_w, edje_h;
162 struct _Elm_Map_Marker
165 Elm_Map_Marker_Class *clas;
166 Elm_Map_Group_Class *clas_group;
167 double longitude, latitude;
170 Evas_Coord x[ZOOM_MAX+1], y[ZOOM_MAX+1];
173 Marker_Group *groups[ZOOM_MAX+1];
175 Evas_Object *content;
178 struct _Elm_Map_Group_Class
182 int zoom_displayed; // display the group if the zoom is >= to zoom_display
183 int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
187 ElmMapGroupIconGetFunc icon_get;
190 struct { //this part is private, do not modify these values
192 Evas_Coord edje_w, edje_h;
193 Evas_Coord edje_max_w, edje_max_h;
195 Eina_List *objs_used;
196 Eina_List *objs_notused;
203 Eina_Matrixsparse_Cell *cell;
204 Elm_Map_Group_Class *clas;
207 long long sum_x, sum_y;
211 Evas_Object *obj, *bubble, *sc, *bx, *rect;
213 Eina_Bool bringin : 1;
214 Eina_Bool update_nbelems : 1;
215 Eina_Bool update_resize : 1;
216 Eina_Bool update_raise : 1;
217 Eina_Bool delete_object : 1;
220 struct _Elm_Map_Route
226 Ecore_Con_Url *con_url;
231 double flon, flat, tlon, tlat;
233 Eina_List *nodes, *path;
240 const char *waypoints;
241 double distance; /* unit : km */
254 Eina_Bool inbound : 1;
268 struct _Route_Waypoint
279 Ecore_Con_Url *con_url;
284 Ecore_Event_Handler *handler;
297 Eina_Bool download : 1;
299 Ecore_File_Download_Job *job;
306 int tsize; // size of tile (tsize x tsize pixels)
307 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
308 int iw, ih; // size of image in pixels
309 int w, h; // size of grid image in pixels (represented by grid)
310 int gw, gh; // size of grid in tiles
311 Eina_Matrixsparse *grid;
318 Evas_Object *pan_smart;
320 Evas_Object *sep_maps_markers; //map objects are below this object and marker objects are on top
322 Evas_Coord pan_x, pan_y, minw, minh;
327 Elm_Map_Zoom_Mode mode;
330 Ecore_Timer *scr_timer;
331 Ecore_Timer *long_timer;
332 Ecore_Animator *zoom_animator;
343 Evas_Coord x, y ,w ,h;
349 Eina_Bool resized : 1;
350 Eina_Bool on_hold : 1;
351 Eina_Bool paused : 1;
352 Eina_Bool paused_markers : 1;
359 Ecore_Job *markers_place_job;
360 Eina_Matrixsparse *markers[ZOOM_MAX+1];
361 Eina_List *cells_displayed; // list of Eina_Matrixsparse_Cell
362 Evas_Coord markers_max_num;
363 int marker_max_w, marker_max_h;
365 Eina_List *opened_bubbles; //opened bubbles, list of Map_Group *
367 Eina_List *groups_clas; // list of Elm_Map_Group_Class*
368 Eina_List *markers_clas; // list of Elm_Map_Markers_Class*
370 Elm_Map_Route_Sources route_source;
371 Eina_List *s_event_list;
376 const char *user_agent;
378 Evas_Event_Mouse_Down ev;
397 Ecore_Timer *wheel_timer;
398 Eina_Bool wheel_disabled : 1;
401 Eina_List *map_sources_tab;
402 const char *source_name;
403 const char **source_names;
408 Evas_Object_Smart_Clipped_Data __clipped_data;
424 Evas_Coord x, y, w, h;
427 Ecore_Timer *hold_timer;
442 enum _Route_Xml_Attribute
446 ROUTE_XML_DESCRIPTION,
447 ROUTE_XML_COORDINATES,
449 } Route_Xml_Attibute;
459 enum _Name_Xml_Attribute
476 static const char *widtype = NULL;
478 static const char SIG_CHANGED[] = "changed";
479 static const char SIG_CLICKED[] = "clicked";
480 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
481 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
482 static const char SIG_LOAD_DETAIL[] = "load,detail";
483 static const char SIG_LONGPRESSED[] = "longpressed";
484 static const char SIG_PRESS[] = "press";
485 static const char SIG_SCROLL[] = "scroll";
486 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
487 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
488 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
489 static const char SIG_ZOOM_START[] = "zoom,start";
490 static const char SIG_ZOOM_STOP[] = "zoom,stop";
491 static const char SIG_DOWNLOADED[] = "downloaded";
492 static const char SIG_ROUTE_LOAD[] = "route,load";
493 static const char SIG_ROUTE_LOADED[] = "route,loaded";
494 static const char SIG_NAME_LOAD[] = "name,load";
495 static const char SIG_NAME_LOADED[] = "name,loaded";
496 static const Evas_Smart_Cb_Description _signals[] = {
499 {SIG_CLICKED_DOUBLE, ""},
500 {SIG_LOADED_DETAIL, ""},
501 {SIG_LOAD_DETAIL, ""},
502 {SIG_LONGPRESSED, ""},
505 {SIG_SCROLL_DRAG_START, ""},
506 {SIG_SCROLL_DRAG_STOP, ""},
507 {SIG_ZOOM_CHANGE, ""},
508 {SIG_ZOOM_START, ""},
510 {SIG_DOWNLOADED, ""},
511 {SIG_ROUTE_LOAD, ""},
512 {SIG_ROUTE_LOADED, ""},
514 {SIG_NAME_LOADED, ""},
518 static void _pan_calculate(Evas_Object *obj);
520 static Eina_Bool _hold_timer_cb(void *data);
521 static Eina_Bool _wheel_timer_cb(void *data);
522 static void _rect_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
523 static void _del_hook(Evas_Object *obj);
524 static void _theme_hook(Evas_Object *obj);
525 static void _on_focus_hook(void *data, Evas_Object *obj);
526 static void _sizing_eval(Evas_Object *obj);
527 static void _calc_job(void *data);
528 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
529 Evas_Callback_Type type, void *event_info);
530 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);
531 static void grid_clear(Evas_Object *obj, Grid *g);
532 static Grid *grid_create(Evas_Object *obj);
533 static void grid_load(Evas_Object *obj, Grid *g);
536 static void _group_object_create(Marker_Group *group);
537 static void _group_object_free(Marker_Group *group);
538 static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
539 static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
540 static void _group_bubble_create(Marker_Group *group);
541 static void _group_bubble_free(Marker_Group *group);
542 static void _group_bubble_place(Marker_Group *group);
544 static int _group_bubble_content_update(Marker_Group *group);
545 static void _group_bubble_content_free(Marker_Group *group);
546 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);
547 static void _bubble_sc_hits_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
549 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
550 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
551 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
553 static void _mouse_multi_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
554 static void _mouse_multi_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
555 static void _mouse_multi_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
557 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);
560 get_multi_device(Evas_Object *obj)
562 Widget_Data *wd = elm_widget_data_get(obj);
566 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
568 if (ev->device) return ev->device;
574 get_distance(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
578 return sqrt((dx * dx) + (dy * dy));
582 create_event_object(void *data, Evas_Object *obj, int device)
584 Widget_Data *wd = elm_widget_data_get(data);
585 Event *ev = calloc(1, sizeof(Event));
587 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, NULL);
591 evas_object_geometry_get(obj, &ev->x, &ev->y, &ev->w, &ev->h);
592 wd->s_event_list = eina_list_append(wd->s_event_list, ev);
597 get_event_object(void *data, int device)
599 Widget_Data *wd = elm_widget_data_get(data);
603 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
605 if (ev->device == device) break;
612 destroy_event_object(void *data, Event *ev)
614 Widget_Data *wd = elm_widget_data_get(data);
615 EINA_SAFETY_ON_NULL_RETURN(ev);
617 wd->s_event_list = eina_list_remove(wd->s_event_list, ev);
620 ecore_timer_del(ev->hold_timer);
621 ev->hold_timer = NULL;
627 module_list_cb(Eina_Module *m, void *data)
629 ELM_CHECK_WIDTYPE(data, widtype) EINA_FALSE;
630 Widget_Data *wd = elm_widget_data_get(data);
632 ElmMapModuleSourceFunc source;
633 ElmMapModuleZoomMinFunc zoom_min;
634 ElmMapModuleZoomMaxFunc zoom_max;
635 ElmMapModuleUrlFunc url;
636 ElmMapModuleRouteSourceFunc route_source;
637 ElmMapModuleRouteUrlFunc route_url;
638 ElmMapModuleNameUrlFunc name_url;
639 ElmMapModuleGeoIntoCoordFunc geo_into_coord;
640 ElmMapModuleCoordIntoGeoFunc coord_into_geo;
643 if (!wd) return EINA_FALSE;
645 file = eina_module_file_get(m);
646 if (!eina_module_load(m))
648 ERR("could not load module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
652 source = eina_module_symbol_get(m, "map_module_source_get");
653 zoom_min = eina_module_symbol_get(m, "map_module_zoom_min_get");
654 zoom_max = eina_module_symbol_get(m, "map_module_zoom_max_get");
655 url = eina_module_symbol_get(m, "map_module_url_get");
656 route_source = eina_module_symbol_get(m, "map_module_route_source_get");
657 route_url = eina_module_symbol_get(m, "map_module_route_url_get");
658 name_url = eina_module_symbol_get(m, "map_module_name_url_get");
659 geo_into_coord = eina_module_symbol_get(m, "map_module_geo_into_coord");
660 coord_into_geo = eina_module_symbol_get(m, "map_module_coord_into_geo");
661 if ((!source) || (!zoom_min) || (!zoom_max) || (!url) || (!route_source) || (!route_url) || (!name_url) || (!geo_into_coord) || (!coord_into_geo))
663 ERR("could not find map_module_source_get() in module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
664 eina_module_unload(m);
667 s = calloc(1, sizeof(Map_Sources_Tab));
668 EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE);
670 s->zoom_min = zoom_min();
671 s->zoom_max = zoom_max();
673 s->route_source = route_source();
674 s->route_url_cb = route_url;
675 s->name_url_cb = name_url;
676 s->geo_into_coord = geo_into_coord;
677 s->coord_into_geo = coord_into_geo;
678 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
684 module_init(void *data)
686 ELM_CHECK_WIDTYPE(data, widtype);
687 Widget_Data *wd = elm_widget_data_get(data);
690 wd->modules = eina_module_list_get(wd->modules, MODULES_PATH, 1, &module_list_cb, data);
694 source_init(void *data)
696 ELM_CHECK_WIDTYPE(data, widtype);
697 Widget_Data *wd = elm_widget_data_get(data);
703 for (idx = 0; idx < 4; idx++)
705 s = calloc(1, sizeof(Map_Sources_Tab));
706 EINA_SAFETY_ON_NULL_RETURN(s);
707 s->name = default_map_sources_tab[idx].name;
708 s->zoom_min = default_map_sources_tab[idx].zoom_min;
709 s->zoom_max = default_map_sources_tab[idx].zoom_max;
710 s->url_cb = default_map_sources_tab[idx].url_cb;
711 s->route_source = default_map_sources_tab[idx].route_source;
712 s->route_url_cb = default_map_sources_tab[idx].route_url_cb;
713 s->name_url_cb = default_map_sources_tab[idx].name_url_cb;
714 s->geo_into_coord = default_map_sources_tab[idx].geo_into_coord;
715 s->coord_into_geo = default_map_sources_tab[idx].coord_into_geo;
716 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
720 int n = eina_list_count(wd->map_sources_tab);
721 wd->source_names = malloc(sizeof(char *) * (n + 1));
722 if (!wd->source_names)
724 ERR("init source names failed.");
728 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
730 wd->source_names[idx] = strdup(s->name);
731 INF("source : %s", wd->source_names[idx]);
734 wd->source_names[idx] = NULL;
738 obj_rotate_zoom(void *data, Evas_Object *obj)
740 ELM_CHECK_WIDTYPE(data, widtype);
741 Widget_Data *wd = elm_widget_data_get(data);
742 if ((!wd->pinch.cx) && (!wd->pinch.cy))
744 wd->pinch.cx = wd->rotate.cx;
745 wd->pinch.cy = wd->rotate.cy;
748 Evas_Map *map = evas_map_new(4);
751 evas_map_util_points_populate_from_object_full(map, obj, 0);
752 evas_map_util_zoom(map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy);
753 evas_map_util_rotate(map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
754 evas_object_map_enable_set(obj, EINA_TRUE);
755 evas_object_map_set(obj, map);
760 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)
762 ELM_CHECK_WIDTYPE(obj, widtype);
763 Widget_Data *wd = elm_widget_data_get(obj);
764 Eina_List *lr, *lp, *ln;
773 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
775 EINA_LIST_FOREACH(wd->route, lr, r)
777 EINA_LIST_FOREACH(r->path, lp, p)
779 evas_object_polygon_points_clear(p);
782 evas_object_geometry_get(wd->rect, &rx, &ry, NULL, NULL);
783 nodes = eina_list_count(r->nodes);
785 EINA_LIST_FOREACH(r->nodes, ln, n)
787 if ((!wd->zoom) || ((n->idx) &&
788 ((n->idx % (int)ceil((double)nodes/(double)size*100.0))))) continue;
791 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
792 if ((x >= px - ow) && (x <= (px + ow*2)) &&
793 (y >= py - oh) && (y <= (py + oh*2)))
798 p = eina_list_nth(r->path, n->idx);
799 a = (double)(y - r->y) / (double)(x - r->x);
800 if ((abs(a) >= 1) || (r->x == x))
802 evas_object_polygon_point_add(p, r->x - 3, r->y);
803 evas_object_polygon_point_add(p, r->x + 3, r->y);
804 evas_object_polygon_point_add(p, x + 3, y);
805 evas_object_polygon_point_add(p, x - 3, y);
809 evas_object_polygon_point_add(p, r->x, r->y - 3);
810 evas_object_polygon_point_add(p, r->x, r->y + 3);
811 evas_object_polygon_point_add(p, x, y + 3);
812 evas_object_polygon_point_add(p, x, y - 3);
815 evas_object_color_set(p, r->color.r, r->color.g, r->color.b, r->color.a);
816 evas_object_raise(p);
817 obj_rotate_zoom(obj, p);
822 else r->inbound = EINA_FALSE;
826 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
827 if ((x >= px - ow) && (x <= (px + ow*2)) &&
828 (y >= py - oh) && (y <= (py + oh*2)))
832 r->inbound = EINA_TRUE;
834 else r->inbound = EINA_FALSE;
837 r->inbound = EINA_FALSE;
842 rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
844 ELM_CHECK_WIDTYPE(obj, widtype);
845 Widget_Data *wd = elm_widget_data_get(obj);
846 Evas_Coord ax, ay, gw, gh, hh, ww;
849 evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh);
856 if ((ww == gw) && (hh == gh)) return;
858 if (ow > gw) ax = (ow - gw) / 2;
859 if (oh > gh) ay = (oh - gh) / 2;
860 evas_object_move(wd->rect,
863 evas_object_resize(wd->rect, gw, gh);
867 wd->show.show = EINA_FALSE;
868 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
873 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)
875 ELM_CHECK_WIDTYPE(obj, widtype);
876 Widget_Data *wd = elm_widget_data_get(obj);
877 Evas_Coord ax, ay, gw, gh, tx, ty;
878 Eina_List *l, *markers;
879 Eina_Matrixsparse_Cell *cell;
884 int g_xx, g_yy, g_hh, g_ww;
887 if (g != eina_list_data_get(wd->grids)) return;
893 if (ow > gw) ax = (ow - gw) / 2;
894 if (oh > gh) ay = (oh - gh) / 2;
896 if (wd->zoom != wd->marker_zoom)
898 EINA_LIST_FREE(wd->cells_displayed, cell)
900 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
902 if (group->obj) _group_object_free(group);
906 wd->marker_zoom = wd->zoom;
908 if ((wd->paused_markers)
909 && ((wd->size.nw != wd->size.w) || (wd->size.nh != wd->size.h)) )
912 g_xx = wd->pan_x / wd->tsize;
913 if (g_xx < 0) g_xx = 0;
914 g_yy = wd->pan_y / wd->tsize;
915 if (g_yy < 0) g_yy = 0;
916 g_ww = (ow / wd->tsize) + 1;
917 if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
918 g_hh = (oh / wd->tsize) + 1;
919 if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
921 //hide groups no more displayed
922 EINA_LIST_FREE(wd->cells_displayed, cell)
924 eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x);
925 if ((y < g_yy) || (y > g_yy + g_hh) || (x < g_xx) || (x > g_xx + g_ww))
927 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
929 if (group->obj) _group_object_free(group);
934 if (!wd->marker_zoom)
940 for (y = g_yy; y <= g_yy + g_hh; y++)
942 for (x = g_xx; x <= g_xx + g_ww; x++)
944 if (!wd->markers[wd->zoom]) continue;
945 eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell);
947 wd->cells_displayed = eina_list_append(wd->cells_displayed, cell);
948 markers = eina_matrixsparse_cell_data_get(cell);
949 EINA_LIST_FOREACH(markers, l, group)
951 if (!group->markers) continue;
952 if (group->clas->zoom_displayed > wd->zoom) continue;
959 if (eina_list_count(group->markers) == 1)
961 Elm_Map_Marker *m = eina_list_data_get(group->markers);
962 ww = m->clas->priv.edje_w;
963 hh = m->clas->priv.edje_h;
969 if ((gw != g->w) && (g->w > 0))
972 xx = ((long long )gw * xx) / g->w;
973 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
975 if ((gh != g->h) && (g->h > 0))
978 yy = ((long long)gh * yy) / g->h;
979 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
982 if ((!group->clas->hide)
983 && (xx-px+ax+ox >= ox) && (xx-px+ax+ox<= ox+ow)
984 && (yy-py+ay+oy >= oy) && (yy-py+ay+oy<= oy+oh))
986 if (!group->obj) _group_object_create(group);
988 if (group->update_nbelems)
990 group->update_nbelems = EINA_FALSE;
991 if (eina_list_count(group->markers) > 1)
993 snprintf(buf, sizeof(buf), "%d", eina_list_count(group->markers));
994 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
997 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", "");
999 evas_object_move(group->obj,
1000 xx - px + ax + ox - ww/2,
1001 yy - py + ay + oy - hh/2);
1002 if ((!wd->paused_markers) || (group->update_resize))
1004 group->update_resize = EINA_FALSE;
1005 evas_object_resize(group->obj, ww, hh);
1006 obj_rotate_zoom(obj, group->obj);
1008 if (group->update_raise)
1010 group->update_raise = EINA_FALSE;
1011 evas_object_raise(group->obj);
1012 obj_rotate_zoom(obj, group->obj);
1013 evas_object_show(group->obj);
1015 if (group->bubble) _group_bubble_place(group);
1017 else if (group->obj)
1019 _group_object_free(group);
1027 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)
1029 ELM_CHECK_WIDTYPE(obj, widtype);
1030 Widget_Data *wd = elm_widget_data_get(obj);
1031 Evas_Coord ax, ay, gw, gh, tx, ty;
1039 if (ow > gw) ax = (ow - gw) / 2;
1040 if (oh > gh) ay = (oh - gh) / 2;
1042 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1043 Eina_Matrixsparse_Cell *cell;
1045 EINA_ITERATOR_FOREACH(it, cell)
1047 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1053 if ((gw != g->w) && (g->w > 0))
1056 xx = ((long long )gw * xx) / g->w;
1057 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1059 if ((gh != g->h) && (g->h > 0))
1062 yy = ((long long)gh * yy) / g->h;
1063 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1065 evas_object_move(gi->img,
1069 evas_object_resize(gi->img, ww, hh);
1071 obj_rotate_zoom(obj, gi->img);
1072 /*evas_object_move(gi->txt,
1076 evas_object_resize(gi->txt, ww, hh);
1079 eina_iterator_free(it);
1083 grid_clear(Evas_Object *obj, Grid *g)
1085 ELM_CHECK_WIDTYPE(obj, widtype);
1086 Widget_Data *wd = elm_widget_data_get(obj);
1090 if (!g->grid) return;
1092 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1093 Eina_Matrixsparse_Cell *cell;
1095 snprintf(buf, sizeof(buf), DEST_DIR_ZOOM_PATH, wd->id, g->zoom);
1096 ecore_file_recursive_rm(buf);
1098 EINA_ITERATOR_FOREACH(it, cell)
1100 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1101 evas_object_del(gi->img);
1102 //evas_object_del(gi->txt);
1106 gi->want = EINA_FALSE;
1108 if (!wd->preload_num)
1110 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1111 "elm,state,busy,stop", "elm");
1112 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
1118 DBG("DOWNLOAD abort %s", gi->file);
1119 ecore_file_download_abort(gi->job);
1120 ecore_file_remove(gi->file);
1125 eina_stringshare_del(gi->file);
1129 eina_matrixsparse_free(g->grid);
1130 eina_iterator_free(it);
1137 _tile_update(Grid_Item *gi)
1139 gi->want = EINA_FALSE;
1140 gi->download = EINA_FALSE;
1141 evas_object_image_file_set(gi->img, gi->file, NULL);
1142 if (evas_object_image_load_error_get(gi->img) != EVAS_LOAD_ERROR_NONE)
1143 ecore_file_remove(gi->file);
1145 obj_rotate_zoom(gi->wd->obj, gi->img);
1146 evas_object_show(gi->img);
1148 //evas_object_text_text_set(gi->txt, gi->file);
1149 //evas_object_show(gi->txt);
1151 gi->have = EINA_TRUE;
1152 gi->wd->preload_num--;
1153 if (!gi->wd->preload_num)
1155 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
1156 "elm,state,busy,stop", "elm");
1157 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
1163 _tile_downloaded(void *data, const char *file __UNUSED__, int status)
1165 Grid_Item *gi = data;
1167 gi->download = EINA_FALSE;
1170 DBG("DOWNLOAD done %s", gi->file);
1171 if ((gi->want) && (!status)) _tile_update(gi);
1175 DBG("Download failed %s (%d) ", gi->file, status);
1176 ecore_file_remove(gi->file);
1179 gi->wd->finish_num++;
1181 evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL);
1185 grid_create(Evas_Object *obj)
1187 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1188 Widget_Data *wd = elm_widget_data_get(obj);
1189 Map_Sources_Tab *s = NULL, *ss;
1193 if (!wd) return NULL;
1194 g = calloc(1, sizeof(Grid));
1197 g->tsize = wd->tsize;
1200 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
1202 if (!strcmp(ss->name, wd->source_name))
1208 if (!s) return NULL;
1209 if (g->zoom > s->zoom_max) return NULL;
1210 if (g->zoom < s->zoom_min) return NULL;
1212 int size = pow(2.0, wd->zoom);
1216 g->w = g->tsize * g->gw;
1217 g->h = g->tsize * g->gh;
1219 g->grid = eina_matrixsparse_new(g->gh, g->gw, NULL, NULL);
1225 grid_load(Evas_Object *obj, Grid *g)
1227 ELM_CHECK_WIDTYPE(obj, widtype);
1228 Widget_Data *wd = elm_widget_data_get(obj);
1231 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
1233 Eina_Matrixsparse_Cell *cell;
1235 Map_Sources_Tab *s = NULL, *ss;
1239 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
1241 if (!strcmp(ss->name, wd->source_name))
1249 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
1250 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
1255 if ((gw <= 0) || (gh <= 0)) return;
1258 if ((gw != g->w) && (g->w > 0))
1259 size = ((long long)gw * size) / g->w;
1260 if (size < (g->tsize / 2)) return; // else we will load to much tiles
1262 it = eina_matrixsparse_iterator_new(g->grid);
1264 EINA_ITERATOR_FOREACH(it, cell)
1266 gi = eina_matrixsparse_cell_data_get(cell);
1273 if ((gw != g->w) && (g->w > 0))
1276 xx = ((long long )gw * xx) / g->w;
1277 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1279 if ((gh != g->h) && (g->h > 0))
1282 yy = ((long long)gh * yy) / g->h;
1283 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1286 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
1287 yy - wd->pan_y + oy,
1289 cvx, cvy, cvw, cvh))
1293 evas_object_hide(gi->img);
1294 //evas_object_hide(gi->txt);
1295 evas_object_image_file_set(gi->img, NULL, NULL);
1296 gi->want = EINA_FALSE;
1297 gi->have = EINA_FALSE;
1301 DBG("DOWNLOAD abort %s", gi->file);
1302 ecore_file_download_abort(gi->job);
1303 ecore_file_remove(gi->file);
1307 gi->download = EINA_FALSE;
1309 if (!wd->preload_num)
1311 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1312 "elm,state,busy,stop", "elm");
1313 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL,
1320 evas_object_hide(gi->img);
1321 //evas_object_hide(gi->txt);
1322 evas_object_image_preload(gi->img, 1);
1323 evas_object_image_file_set(gi->img, NULL, NULL);
1324 gi->have = EINA_FALSE;
1325 gi->want = EINA_FALSE;
1329 eina_iterator_free(it);
1331 xx = wd->pan_x / size;
1334 yy = wd->pan_y / size;
1338 if (xx + ww >= g->gw) ww = g->gw - xx - 1;
1341 if (yy + hh >= g->gh) hh = g->gh - yy - 1;
1343 for (y = yy; y <= yy + hh; y++)
1345 for (x = xx; x <= xx + ww; x++)
1347 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
1349 if ((!gi) && (g != eina_list_data_get(wd->grids)))
1354 gi = calloc(1, sizeof(Grid_Item));
1355 gi->src.x = x * g->tsize;
1356 gi->src.y = y * g->tsize;
1357 gi->src.w = g->tsize;
1358 gi->src.h = g->tsize;
1360 gi->out.x = gi->src.x;
1361 gi->out.y = gi->src.y;
1362 gi->out.w = gi->src.w;
1363 gi->out.h = gi->src.h;
1367 gi->img = evas_object_image_add(evas_object_evas_get(obj));
1368 evas_object_image_scale_hint_set
1369 (gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1370 evas_object_image_filled_set(gi->img, 1);
1372 evas_object_smart_member_add(gi->img, wd->pan_smart);
1373 elm_widget_sub_object_add(obj, gi->img);
1374 evas_object_pass_events_set(gi->img, EINA_TRUE);
1375 evas_object_stack_below(gi->img, wd->sep_maps_markers);
1377 /* gi->txt = evas_object_text_add(evas_object_evas_get(obj));
1378 evas_object_text_font_set(gi->txt, "Vera", 12);
1379 evas_object_color_set(gi->txt, 100, 100, 100, 255);
1380 evas_object_smart_member_add(gi->txt,
1382 elm_widget_sub_object_add(obj, gi->txt);
1383 evas_object_pass_events_set(gi->txt, EINA_TRUE);
1385 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
1388 if ((!gi->have) && (!gi->download))
1390 char buf[PATH_MAX], buf2[PATH_MAX];
1393 gi->want = EINA_TRUE;
1395 snprintf(buf, sizeof(buf), DEST_DIR_PATH, wd->id, g->zoom, x);
1396 if (!ecore_file_exists(buf))
1397 ecore_file_mkpath(buf);
1399 snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y);
1401 source = s->url_cb(obj, x, y, g->zoom);
1402 if ((!source) || (strlen(source)==0)) continue;
1404 eina_stringshare_replace(&gi->file, buf2);
1406 if ((ecore_file_exists(buf2)) || (g == eina_list_data_get(wd->grids)))
1408 gi->download = EINA_TRUE;
1410 if (wd->preload_num == 1)
1412 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1413 "elm,state,busy,start", "elm");
1414 evas_object_smart_callback_call(obj,
1419 if (ecore_file_exists(buf2))
1423 DBG("DOWNLOAD %s \t in %s", source, buf2);
1424 ecore_file_download_full(source, buf2, _tile_downloaded, NULL, gi, &(gi->job), wd->ua);
1426 DBG("Can't start to download %s", buf);
1431 if (source) free(source);
1435 obj_rotate_zoom(obj, gi->img);
1436 evas_object_show(gi->img);
1443 grid_clearall(Evas_Object *obj)
1445 ELM_CHECK_WIDTYPE(obj, widtype);
1446 Widget_Data *wd = elm_widget_data_get(obj);
1450 EINA_LIST_FREE(wd->grids, g)
1458 _smooth_update(Evas_Object *obj)
1460 ELM_CHECK_WIDTYPE(obj, widtype);
1461 Widget_Data *wd = elm_widget_data_get(obj);
1466 EINA_LIST_FOREACH(wd->grids, l, g)
1468 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1469 Eina_Matrixsparse_Cell *cell;
1471 EINA_ITERATOR_FOREACH(it, cell)
1473 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1474 evas_object_image_smooth_scale_set(gi->img, (!wd->nosmooth));
1476 eina_iterator_free(it);
1481 _grid_raise(Grid *g)
1483 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1484 Eina_Matrixsparse_Cell *cell;
1486 g->wd->size.w = g->w;
1487 g->wd->size.h = g->h;
1489 EINA_ITERATOR_FOREACH(it, cell)
1491 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1492 evas_object_raise(gi->img);
1493 //evas_object_raise(gi->txt);
1495 eina_iterator_free(it);
1499 _scr_timeout(void *data)
1501 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1502 Widget_Data *wd = elm_widget_data_get(data);
1504 if (!wd) return ECORE_CALLBACK_CANCEL;
1506 if (!wd->nosmooth) _smooth_update(data);
1507 wd->scr_timer = NULL;
1508 return ECORE_CALLBACK_CANCEL;
1512 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1514 ELM_CHECK_WIDTYPE(data, widtype);
1515 Widget_Data *wd = elm_widget_data_get(data);
1521 if (wd->nosmooth == 1) _smooth_update(data);
1523 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1524 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
1528 zoom_do(Evas_Object *obj)
1530 ELM_CHECK_WIDTYPE(obj, widtype);
1531 Widget_Data *wd = elm_widget_data_get(obj);
1532 Evas_Coord xx, yy, ow, oh;
1535 wd->size.w = wd->size.nw;
1536 wd->size.h = wd->size.nh;
1538 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
1540 if (wd->center_on.enabled)
1542 elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy);
1548 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
1549 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
1554 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
1556 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
1558 wd->show.show = EINA_TRUE;
1564 if (wd->calc_job) ecore_job_del(wd->calc_job);
1565 wd->calc_job = ecore_job_add(_calc_job, wd);
1569 _zoom_anim(void *data)
1571 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1572 Evas_Object *obj = data;
1573 Widget_Data *wd = elm_widget_data_get(obj);
1575 if (!wd) return ECORE_CALLBACK_CANCEL;
1576 if (wd->zoom_method == ZOOM_METHOD_IN) wd->t += 0.1 ;
1577 else if (wd->zoom_method == ZOOM_METHOD_OUT) wd->t -= 0.1;
1581 return ECORE_CALLBACK_CANCEL;
1584 if ((wd->t >= 2.0) || (wd->t <= 0.5))
1586 wd->zoom_animator = NULL;
1587 wd->pinch.level = 1.0;
1589 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1590 return ECORE_CALLBACK_CANCEL;
1592 else if (wd->t != 1.0)
1594 Evas_Coord x, y, w, h;
1595 float half_w, half_h;
1596 evas_object_geometry_get(data, &x, &y, &w, &h);
1597 half_w = (float)w * 0.5;
1598 half_h = (float)h * 0.5;
1599 wd->pinch.cx = x + half_w;
1600 wd->pinch.cy = y + half_h;
1601 wd->pinch.level = wd->t;
1602 if (wd->calc_job) ecore_job_del(wd->calc_job);
1603 wd->calc_job = ecore_job_add(_calc_job, wd);
1605 return ECORE_CALLBACK_RENEW;
1609 _long_press(void *data)
1611 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1612 Widget_Data *wd = elm_widget_data_get(data);
1614 if (!wd) return ECORE_CALLBACK_CANCEL;
1615 wd->long_timer = NULL;
1616 evas_object_smart_callback_call(data, SIG_LONGPRESSED, &wd->ev);
1617 return ECORE_CALLBACK_CANCEL;
1621 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1623 ELM_CHECK_WIDTYPE(data, widtype);
1624 Widget_Data *wd = elm_widget_data_get(data);
1625 Evas_Event_Mouse_Down *ev = event_info;
1629 ev0 = get_event_object(data, 0);
1631 ev0 = create_event_object(data, obj, 0);
1634 ev0->hold_timer = NULL;
1635 ev0->prev.x = ev->output.x;
1636 ev0->prev.y = ev->output.y;
1638 if (ev->button != 1) return;
1639 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1640 else wd->on_hold = EINA_FALSE;
1641 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1642 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, ev);
1644 evas_object_smart_callback_call(data, SIG_PRESS, ev);
1645 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1646 wd->ev.output.x = ev->output.x;
1647 wd->ev.output.y = ev->output.y;
1648 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1652 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1654 Evas_Event_Mouse_Move *move = event_info;
1657 ev0 = get_event_object(data, 0);
1659 ev0->prev.x = move->cur.output.x;
1660 ev0->prev.y = move->cur.output.y;
1664 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1666 ELM_CHECK_WIDTYPE(data, widtype);
1667 Widget_Data *wd = elm_widget_data_get(data);
1670 Evas_Event_Mouse_Up *ev = event_info;
1675 ev0 = get_event_object(data, 0);
1678 mdevice = get_multi_device(data);
1681 if (ev0->hold_timer)
1683 ecore_timer_del(ev0->hold_timer);
1684 ev0->hold_timer = NULL;
1686 elm_smart_scroller_hold_set(wd->scr, 0);
1687 elm_smart_scroller_freeze_set(wd->scr, 0);
1691 ev1 = get_event_object(data, mdevice);
1693 ev1->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev1);
1695 destroy_event_object(data, ev0);
1698 if (ev->button != 1) return;
1699 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1700 else wd->on_hold = EINA_FALSE;
1703 ecore_timer_del(wd->long_timer);
1704 wd->long_timer = NULL;
1706 if (!wd->on_hold) evas_object_smart_callback_call(data, SIG_CLICKED, ev);
1707 wd->on_hold = EINA_FALSE;
1711 _mouse_multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1713 ELM_CHECK_WIDTYPE(data, widtype);
1714 Widget_Data *wd = elm_widget_data_get(data);
1716 Evas_Event_Multi_Down *down = event_info;
1718 elm_smart_scroller_hold_set(wd->scr, 1);
1719 elm_smart_scroller_freeze_set(wd->scr, 1);
1721 ev = create_event_object(data, obj, down->device);
1724 DBG("Failed : create_event_object");
1729 ev->hold_timer = NULL;
1730 ev->start.x = ev->prev.x = down->output.x;
1731 ev->start.y = ev->prev.y = down->output.y;
1732 ev->pinch_start_dis = 0;
1733 wd->pinch.level = 1.0;
1734 wd->pinch.diff = 1.0;
1739 ecore_timer_del(wd->long_timer);
1740 wd->long_timer = NULL;
1746 _mouse_multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1748 ELM_CHECK_WIDTYPE(data, widtype);
1749 Widget_Data *wd = elm_widget_data_get(data);
1750 Evas_Event_Multi_Move *move = event_info;
1751 Map_Sources_Tab *s = NULL, *ss;
1754 double t, tt, a, a_diff;
1759 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
1761 if (!strcmp(ss->name, wd->source_name))
1769 ev = get_event_object(data, move->device);
1772 ev0 = get_event_object(data, 0);
1775 if (wd->multi_count >= 1)
1777 Evas_Coord x, y, w, h;
1778 float half_w, half_h;
1780 evas_object_geometry_get(data, &x, &y, &w, &h);
1781 half_w = (float)w * 0.5;
1782 half_h = (float)h * 0.5;
1783 dis_new = get_distance(ev0->prev.x, ev0->prev.y, ev->prev.x, ev->prev.y);
1785 if (!ev->pinch_start_dis) ev->pinch_start_dis = dis_new;
1788 ev->pinch_dis = dis_new;
1789 tt = wd->pinch.diff;
1790 wd->pinch.diff = (double)(ev->pinch_dis - ev->pinch_start_dis);
1791 t = (wd->pinch.diff * 0.01) + 1.0;
1792 if ((!wd->zoom) || ((wd->zoom + (int)t - 1) <= s->zoom_min) ||
1793 ((wd->zoom + (int)t - 1) >= s->zoom_max) ||
1794 (t > PINCH_ZOOM_MAX) || (t < PINCH_ZOOM_MIN))
1796 wd->pinch.diff = tt;
1801 wd->pinch.level = (wd->pinch.diff * 0.01) + 1.0;
1802 wd->pinch.cx = x + half_w;
1803 wd->pinch.cy = y + half_h;
1806 a = (double)(ev->prev.y - ev0->prev.y) / (double)(ev->prev.x - ev0->prev.x);
1807 if (!wd->rotate.a) wd->rotate.a = a;
1810 a_diff = wd->rotate.a - a;
1811 if (a_diff > 0) wd->rotate.d -= 1.0;
1812 else if (a_diff < 0) wd->rotate.d += 1.0;
1814 wd->rotate.cx = x + half_w;
1815 wd->rotate.cy = y + half_h;
1818 if (wd->calc_job) ecore_job_del(wd->calc_job);
1819 wd->calc_job = ecore_job_add(_calc_job, wd);
1823 ev->prev.x = move->cur.output.x;
1824 ev->prev.y = move->cur.output.y;
1828 _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1830 ELM_CHECK_WIDTYPE(data, widtype);
1831 Widget_Data *wd = elm_widget_data_get(data);
1832 Evas_Event_Multi_Up *up = event_info;
1839 if (wd->calc_job) ecore_job_del(wd->calc_job);
1840 if (wd->zoom_animator)
1842 ecore_animator_del(wd->zoom_animator);
1843 wd->zoom_animator = NULL;
1846 wd->paused = EINA_TRUE;
1847 if (wd->pinch.diff >= 0.0) t = wd->pinch.diff * 0.01;
1848 else if (wd->pinch.diff < 0.0) t = -1.0 / ((wd->pinch.diff * 0.01) + 1.0);
1849 elm_map_zoom_set(data, wd->zoom + (int)ceil(t));
1850 wd->pinch.level = 1.0;
1854 ev = get_event_object(data, up->device);
1857 DBG("Cannot get multi device");
1861 ev0 = get_event_object(data, 0);
1863 ev0->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev0);
1868 ecore_timer_del(ev->hold_timer);
1869 ev->hold_timer = NULL;
1872 destroy_event_object(data, ev);
1876 _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1878 ELM_CHECK_WIDTYPE(data, widtype);
1879 Widget_Data *wd = elm_widget_data_get(data);
1880 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
1881 Evas_Coord x, y, w, h;
1882 float half_w, half_h;
1883 evas_object_geometry_get(data, &x, &y, &w, &h);
1884 half_w = (float)w * 0.5;
1885 half_h = (float)h * 0.5;
1887 if (!wd->wheel_zoom) wd->wheel_zoom = 1.0;
1890 wd->zoom_method = ZOOM_METHOD_OUT;
1891 wd->wheel_zoom -= 0.05;
1892 if (wd->wheel_zoom <= PINCH_ZOOM_MIN) wd->wheel_zoom = PINCH_ZOOM_MIN;
1896 wd->zoom_method = ZOOM_METHOD_IN;
1897 wd->wheel_zoom += 0.2;
1898 if (wd->wheel_zoom >= PINCH_ZOOM_MAX) wd->wheel_zoom = PINCH_ZOOM_MAX;
1901 wd->pinch.level = wd->wheel_zoom;
1902 wd->pinch.cx = x + half_w;
1903 wd->pinch.cy = y + half_h;
1904 if (wd->calc_job) ecore_job_del(wd->calc_job);
1905 wd->calc_job = ecore_job_add(_calc_job, wd);
1907 if (wd->wheel_timer) ecore_timer_del(wd->wheel_timer);
1908 wd->wheel_timer = ecore_timer_add(0.35, _wheel_timer_cb, data);
1912 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
1915 _hold_timer_cb(void *data)
1919 ev0->hold_timer = NULL;
1920 return ECORE_CALLBACK_CANCEL;
1924 _wheel_timer_cb(void *data)
1926 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1927 Widget_Data *wd = elm_widget_data_get(data);
1930 wd->wheel_timer = NULL;
1931 if (wd->zoom_method == ZOOM_METHOD_IN) zoom = (int)ceil(wd->wheel_zoom - 1.0);
1932 else if (wd->zoom_method == ZOOM_METHOD_OUT) zoom = (int)floor((-1.0 / wd->wheel_zoom) + 1.0);
1933 else return ECORE_CALLBACK_CANCEL;
1934 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
1935 elm_map_zoom_set(data, wd->zoom + zoom);
1936 wd->wheel_zoom = 0.0;
1937 return ECORE_CALLBACK_CANCEL;
1941 _rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1943 ELM_CHECK_WIDTYPE(data, widtype);
1944 Widget_Data *wd = elm_widget_data_get(data);
1947 evas_object_geometry_get(wd->rect, &x, &y, &w, &h);
1948 evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h);
1949 evas_object_resize(wd->rect, w, h);
1950 evas_object_move(wd->rect, x, y);
1954 _del_hook(Evas_Object *obj)
1956 ELM_CHECK_WIDTYPE(obj, widtype);
1957 Widget_Data *wd = elm_widget_data_get(obj);
1958 Elm_Map_Group_Class *group_clas;
1959 Elm_Map_Marker_Class *marker_clas;
1965 Ecore_Event_Handler *h;
1970 EINA_LIST_FREE(wd->groups_clas, group_clas)
1972 if (group_clas->style)
1973 eina_stringshare_del(group_clas->style);
1977 EINA_LIST_FREE(wd->markers_clas, marker_clas)
1979 if (marker_clas->style)
1980 eina_stringshare_del(marker_clas->style);
1984 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
1986 destroy_event_object(obj, ev);
1989 EINA_LIST_FOREACH(wd->route, l, r)
1991 EINA_LIST_FREE(r->path, p)
1996 EINA_LIST_FREE(r->waypoint, w)
1998 if (w->point) eina_stringshare_del(w->point);
2002 EINA_LIST_FREE(r->nodes, n)
2004 if (n->pos.address) eina_stringshare_del(n->pos.address);
2008 EINA_LIST_FREE(r->handlers, h)
2010 ecore_event_handler_del(h);
2013 if (r->con_url) ecore_con_url_free(r->con_url);
2014 if (r->info.nodes) eina_stringshare_del(r->info.nodes);
2015 if (r->info.waypoints) eina_stringshare_del(r->info.waypoints);
2018 EINA_LIST_FREE(wd->names, na)
2020 if (na->address) free(na->address);
2021 if (na->handler) ecore_event_handler_del(na->handler);
2024 ecore_file_remove(na->ud.fname);
2026 na->ud.fname = NULL;
2030 if (wd->source_names) free(wd->source_names);
2031 if (wd->calc_job) ecore_job_del(wd->calc_job);
2032 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
2033 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
2034 if (wd->long_timer) ecore_timer_del(wd->long_timer);
2035 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
2036 if (wd->ua) eina_hash_free(wd->ua);
2042 _del_pre_hook(Evas_Object *obj)
2044 ELM_CHECK_WIDTYPE(obj, widtype);
2045 Widget_Data *wd = elm_widget_data_get(obj);
2046 Marker_Group *group;
2047 Elm_Map_Marker *marker;
2049 Eina_Bool free_marker = EINA_TRUE;
2054 for (i = 0; i < ZOOM_MAX + 1; i++)
2056 if (!wd->markers[i]) continue;
2057 Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
2058 Eina_Matrixsparse_Cell *cell;
2060 EINA_ITERATOR_FOREACH(it, cell)
2062 l = eina_matrixsparse_cell_data_get(cell);
2063 EINA_LIST_FREE(l, group)
2065 EINA_LIST_FREE(group->markers, marker)
2067 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2068 _bubble_sc_hits_changed_cb, group);
2069 if (free_marker) free(marker);
2073 free_marker = EINA_FALSE;
2075 eina_iterator_free(it);
2076 eina_matrixsparse_free(wd->markers[i]);
2079 evas_object_del(wd->sep_maps_markers);
2080 evas_object_del(wd->pan_smart);
2081 wd->pan_smart = NULL;
2085 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
2087 ELM_CHECK_WIDTYPE(obj, widtype);
2088 Widget_Data *wd = elm_widget_data_get(obj);
2091 if (elm_widget_focus_get(obj))
2093 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
2094 evas_object_focus_set(wd->obj, EINA_TRUE);
2098 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
2099 evas_object_focus_set(wd->obj, EINA_FALSE);
2104 _theme_hook(Evas_Object *obj)
2106 ELM_CHECK_WIDTYPE(obj, widtype);
2107 Widget_Data *wd = elm_widget_data_get(obj);
2110 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
2111 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
2116 _sizing_eval(Evas_Object *obj)
2118 ELM_CHECK_WIDTYPE(obj, widtype);
2119 Widget_Data *wd = elm_widget_data_get(obj);
2120 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
2123 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
2124 evas_object_size_hint_min_set(obj, minw, minh);
2125 evas_object_size_hint_max_set(obj, maxw, maxh);
2129 _calc_job(void *data)
2131 Widget_Data *wd = data;
2132 Evas_Coord minw, minh;
2140 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
2142 double tz = wd->zoom;
2144 elm_map_zoom_set(wd->obj, tz);
2147 if ((minw != wd->minw) || (minh != wd->minh))
2151 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
2152 _sizing_eval(wd->obj);
2154 wd->calc_job = NULL;
2155 evas_object_smart_changed(wd->pan_smart);
2159 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2161 Pan *sd = evas_object_smart_data_get(obj);
2163 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2166 evas_object_smart_changed(obj);
2170 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2172 Pan *sd = evas_object_smart_data_get(obj);
2174 if (x) *x = sd->wd->pan_x;
2175 if (y) *y = sd->wd->pan_y;
2179 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2181 Pan *sd = evas_object_smart_data_get(obj);
2184 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2185 ow = sd->wd->minw - ow;
2187 oh = sd->wd->minh - oh;
2194 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
2201 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2203 Pan *sd = evas_object_smart_data_get(obj);
2205 if (w) *w = sd->wd->minw;
2206 if (h) *h = sd->wd->minh;
2210 _pan_add(Evas_Object *obj)
2213 Evas_Object_Smart_Clipped_Data *cd;
2215 cd = evas_object_smart_data_get(obj);
2217 sd = calloc(1, sizeof(Pan));
2219 sd->__clipped_data = *cd;
2221 evas_object_smart_data_set(obj, sd);
2225 _pan_del(Evas_Object *obj)
2227 Pan *sd = evas_object_smart_data_get(obj);
2233 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2235 Pan *sd = evas_object_smart_data_get(obj);
2238 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2239 if ((ow == w) && (oh == h)) return;
2240 sd->wd->resized = 1;
2241 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2242 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2246 _pan_calculate(Evas_Object *obj)
2248 Pan *sd = evas_object_smart_data_get(obj);
2249 Evas_Coord ox, oy, ow, oh;
2253 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2254 rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2255 EINA_LIST_FOREACH(sd->wd->grids, l, g)
2257 if (sd->wd->pinch.level == 1.0) grid_load(sd->wd->obj, g);
2258 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2259 marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2260 if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2265 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2267 Pan *sd = evas_object_smart_data_get(obj);
2269 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2270 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2274 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2276 ELM_CHECK_WIDTYPE(obj, widtype);
2277 Widget_Data *wd = elm_widget_data_get(obj);
2280 elm_smart_scroller_hold_set(wd->scr, 1);
2284 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2286 ELM_CHECK_WIDTYPE(obj, widtype);
2287 Widget_Data *wd = elm_widget_data_get(obj);
2290 elm_smart_scroller_hold_set(wd->scr, 0);
2294 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2296 ELM_CHECK_WIDTYPE(obj, widtype);
2297 Widget_Data *wd = elm_widget_data_get(obj);
2300 elm_smart_scroller_freeze_set(wd->scr, 1);
2304 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2306 ELM_CHECK_WIDTYPE(obj, widtype);
2307 Widget_Data *wd = elm_widget_data_get(obj);
2310 elm_smart_scroller_freeze_set(wd->scr, 0);
2314 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2316 evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
2320 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2322 evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
2326 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2328 Widget_Data *wd = elm_widget_data_get(data);
2329 wd->center_on.enabled = EINA_FALSE;
2330 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2334 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2336 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2340 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2342 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
2347 _group_object_create(Marker_Group *group)
2349 const char *style = "radio";
2350 Evas_Object *icon = NULL;
2352 if (group->obj) return;
2353 if ((!group->clas->priv.objs_notused) || (eina_list_count(group->markers) == 1))
2355 //set icon and style
2356 if (eina_list_count(group->markers) == 1)
2358 Elm_Map_Marker *m = eina_list_data_get(group->markers);
2360 style = m->clas->style;
2362 if (m->clas->func.icon_get)
2363 icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
2365 group->delete_object = EINA_TRUE;
2369 if (group->clas->style)
2370 style = group->clas->style;
2372 if (group->clas->func.icon_get)
2373 icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
2375 group->delete_object = EINA_FALSE;
2378 group->obj = elm_layout_add(group->wd->obj);
2379 elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
2381 if (icon) elm_layout_content_set(group->obj, "elm.icon", icon);
2383 evas_object_smart_member_add(group->obj, group->wd->pan_smart);
2384 elm_widget_sub_object_add(group->wd->obj, group->obj);
2385 evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
2387 if (!group->delete_object)
2388 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2392 group->delete_object = EINA_FALSE;
2394 group->obj = eina_list_data_get(group->clas->priv.objs_notused);
2395 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2396 group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
2397 evas_object_show(group->obj);
2400 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
2401 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
2403 group->update_nbelems = EINA_TRUE;
2404 group->update_resize = EINA_TRUE;
2405 group->update_raise = EINA_TRUE;
2407 if (group->open) _group_bubble_create(group);
2411 _group_object_free(Marker_Group *group)
2413 if (!group->obj) return;
2414 if (!group->delete_object)
2416 group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
2417 group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
2418 evas_object_hide(group->obj);
2420 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
2421 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
2424 evas_object_del(group->obj);
2427 _group_bubble_free(group);
2431 _group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2433 Marker_Group *group = data;
2435 if (!evas_object_above_get(group->rect)) return;
2436 evas_object_raise(group->bubble);
2437 evas_object_raise(group->sc);
2438 evas_object_raise(group->rect);
2442 _group_bubble_create(Marker_Group *group)
2444 if (group->bubble) return;
2446 group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
2447 group->bubble = edje_object_add(evas_object_evas_get(group->obj));
2448 _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
2449 elm_widget_style_get(group->wd->obj));
2450 evas_object_smart_member_add(group->bubble,
2452 elm_widget_sub_object_add(group->wd->obj, group->bubble);
2454 _group_bubble_content_free(group);
2455 if (!_group_bubble_content_update(group))
2457 //no content, we can delete the bubble
2458 _group_bubble_free(group);
2462 group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
2463 evas_object_color_set(group->rect, 0, 0, 0, 0);
2464 evas_object_repeat_events_set(group->rect, EINA_TRUE);
2465 evas_object_smart_member_add(group->rect, group->wd->obj);
2466 elm_widget_sub_object_add(group->wd->obj, group->rect);
2468 evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
2470 _group_bubble_place(group);
2473 static void _bubble_sc_hits_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2475 _group_bubble_place(data);
2479 _group_bubble_content_update(Marker_Group *group)
2482 Elm_Map_Marker *marker;
2485 if (!group->bubble) return 1;
2489 group->sc = elm_scroller_add(group->bubble);
2490 elm_widget_style_set(group->sc, "map_bubble");
2491 elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
2492 elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
2493 elm_scroller_bounce_set(group->sc, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
2494 edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
2495 evas_object_show(group->sc);
2496 evas_object_smart_member_add(group->sc,
2498 elm_widget_sub_object_add(group->wd->obj, group->sc);
2500 group->bx = elm_box_add(group->bubble);
2501 evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2502 evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
2503 elm_box_horizontal_set(group->bx, EINA_TRUE);
2504 evas_object_show(group->bx);
2506 elm_scroller_content_set(group->sc, group->bx);
2508 evas_object_event_callback_add(group->sc, EVAS_CALLBACK_RESIZE,
2509 _bubble_sc_hits_changed_cb, group);
2512 EINA_LIST_FOREACH(group->markers, l, marker)
2514 if (i >= group->wd->markers_max_num) break;
2515 if ((!marker->content) && (marker->clas->func.get))
2516 marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
2517 else if (marker->content)
2518 elm_box_unpack(group->bx, marker->content);
2519 if (marker->content)
2521 elm_box_pack_end(group->bx, marker->content);
2529 _group_bubble_content_free(Marker_Group *group)
2532 Elm_Map_Marker *marker;
2534 if (!group->sc) return;
2535 EINA_LIST_FOREACH(group->markers, l, marker)
2537 if ((marker->content) && (marker->clas->func.del))
2538 marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
2539 else if (marker->content)
2540 evas_object_del(marker->content);
2541 marker->content = NULL;
2543 evas_object_del(group->sc);
2548 _group_bubble_free(Marker_Group *group)
2550 if (!group->bubble) return;
2551 group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
2552 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2553 _bubble_sc_hits_changed_cb, group);
2554 evas_object_del(group->bubble);
2555 evas_object_del(group->rect);
2556 group->bubble = NULL;
2557 _group_bubble_content_free(group);
2561 _group_bubble_place(Marker_Group *group)
2564 Evas_Coord xx, yy, ww, hh;
2567 if ((!group->bubble) || (!group->obj)) return;
2569 evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
2570 edje_object_size_min_calc(group->bubble, NULL, &hh);
2572 s = edje_object_data_get(group->bubble, "size_w");
2573 if (s) ww = atoi(s);
2575 xx = x + w / 2 - ww / 2;
2578 evas_object_move(group->bubble, xx, yy);
2579 evas_object_resize(group->bubble, ww, hh);
2580 obj_rotate_zoom(group->wd, group->bubble);
2581 evas_object_show(group->bubble);
2583 evas_object_move(group->rect, xx, yy);
2584 evas_object_resize(group->rect, ww, hh);
2585 obj_rotate_zoom(group->wd, group->rect);
2586 evas_object_show(group->rect);
2590 _group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2592 Marker_Group *group = data;
2593 Elm_Map_Marker *marker = eina_list_data_get(group->markers);
2594 if (!marker) return;
2595 group->bringin = EINA_TRUE;
2596 elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
2600 _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2602 Marker_Group *group = data;
2606 group->bringin = EINA_FALSE;
2612 group->open = EINA_FALSE;
2613 _group_bubble_free(group);
2616 group->open = EINA_TRUE;
2617 _group_bubble_create(group);
2621 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
2623 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2624 Widget_Data *wd = elm_widget_data_get(obj);
2628 Evas_Coord step_x = 0;
2629 Evas_Coord step_y = 0;
2632 Evas_Coord page_x = 0;
2633 Evas_Coord page_y = 0;
2635 if (!wd) return EINA_FALSE;
2636 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
2637 Evas_Event_Key_Down *ev = event_info;
2638 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
2640 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
2641 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
2642 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
2643 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
2645 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
2649 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
2653 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
2657 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
2661 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
2664 y -= -(page_y * v_h) / 100;
2668 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
2671 y += -(page_y * v_h) / 100;
2675 else if (!strcmp(ev->keyname, "KP_Add"))
2677 zoom = elm_map_zoom_get(obj) + 1;
2678 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2679 elm_map_zoom_set(obj, zoom);
2682 else if (!strcmp(ev->keyname, "KP_Subtract"))
2684 zoom = elm_map_zoom_get(obj) - 1;
2685 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2686 elm_map_zoom_set(obj, zoom);
2689 else return EINA_FALSE;
2691 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2692 elm_smart_scroller_child_pos_set(wd->scr, x, y);
2698 cb_dump_name_attrs(void *data, const char *key, const char *value)
2700 Name_Dump *dump = (Name_Dump*)data;
2701 if (!dump) return EINA_FALSE;
2703 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
2704 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
2711 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2713 Route_Dump *dump = data;
2714 if (!dump) return EINA_FALSE;
2718 case EINA_SIMPLE_XML_OPEN:
2719 case EINA_SIMPLE_XML_OPEN_EMPTY:
2723 attrs = eina_simple_xml_tag_attributes_find(value, length);
2726 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
2727 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
2728 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
2729 else dump->id = ROUTE_XML_NONE;
2733 case EINA_SIMPLE_XML_DATA:
2735 char *buf = malloc(length);
2736 if (!buf) return EINA_FALSE;
2737 snprintf(buf, length, "%s", value);
2738 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
2739 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2740 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2752 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2754 Name_Dump *dump = data;
2755 if (!dump) return EINA_FALSE;
2759 case EINA_SIMPLE_XML_OPEN:
2760 case EINA_SIMPLE_XML_OPEN_EMPTY:
2763 attrs = eina_simple_xml_tag_attributes_find(value, length);
2766 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT)-1)) dump->id = NAME_XML_NAME;
2767 else dump->id = NAME_XML_NONE;
2769 eina_simple_xml_attributes_parse
2770 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
2774 case EINA_SIMPLE_XML_DATA:
2776 char *buf = malloc(length + 1);
2777 if (!buf) return EINA_FALSE;
2778 snprintf(buf, length + 1, "%s", value);
2779 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2791 _parse_kml(void *data)
2793 Elm_Map_Route *r = (Elm_Map_Route*)data;
2794 if (!r && !r->ud.fname) return;
2798 unsigned int ele, idx;
2802 Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL};
2804 f = fopen(r->ud.fname, "rb");
2809 fseek(f, 0, SEEK_END);
2815 fseek(f, 0, SEEK_SET);
2819 if (fread(buf, 1, sz, f))
2821 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump);
2828 if (dump.distance) r->info.distance = dump.distance;
2829 if (dump.description)
2831 eina_stringshare_replace(&r->info.waypoints, dump.description);
2832 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2833 r->info.waypoint_count = ele;
2834 for (idx = 0 ; idx < ele ; idx++)
2836 Route_Waypoint *wp = ELM_NEW(Route_Waypoint);
2840 wp->point = eina_stringshare_add(str[idx]);
2841 DBG("%s", str[idx]);
2842 r->waypoint = eina_list_append(r->waypoint, wp);
2851 else WRN("description is not found !");
2853 if (dump.coordinates)
2855 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2856 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2857 r->info.node_count = ele;
2858 for (idx = 0 ; idx < ele ; idx++)
2860 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2861 Route_Node *n = ELM_NEW(Route_Node);
2868 DBG("%lf:%lf", lon, lat);
2869 n->pos.address = NULL;
2870 r->nodes = eina_list_append(r->nodes, n);
2872 path = evas_object_polygon_add(evas_object_evas_get(r->wd->obj));
2873 evas_object_smart_member_add(path, r->wd->pan_smart);
2874 r->path = eina_list_append(r->path, path);
2887 _parse_name(void *data)
2889 Elm_Map_Name *n = (Elm_Map_Name*)data;
2890 if (!n && !n->ud.fname) return;
2894 Name_Dump dump = {0, NULL, 0.0, 0.0};
2896 f = fopen(n->ud.fname, "rb");
2901 fseek(f, 0, SEEK_END);
2907 fseek(f, 0, SEEK_SET);
2911 if (fread(buf, 1, sz, f))
2913 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
2922 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
2923 n->address = strdup(dump.address);
2931 _route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
2933 Ecore_Con_Event_Url_Complete *ev = event;
2934 Elm_Map_Route *r = (Elm_Map_Route*)data;
2935 Widget_Data *wd = r->wd;
2937 if ((!r) || (!ev)) return EINA_TRUE;
2938 Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url);
2939 ecore_con_url_data_set(r->con_url, NULL);
2940 if (r!=rr) return EINA_TRUE;
2942 if (r->ud.fd) fclose(r->ud.fd);
2947 Evas_Coord ox, oy, ow, oh;
2948 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
2949 route_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
2951 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2952 "elm,state,busy,stop", "elm");
2953 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
2958 _name_complete_cb(void *data, int ev_type __UNUSED__, void *event)
2960 Ecore_Con_Event_Url_Complete *ev = event;
2961 Elm_Map_Name *n = (Elm_Map_Name*)data;
2962 Widget_Data *wd = n->wd;
2964 if ((!n) || (!ev)) return EINA_TRUE;
2965 Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url);
2966 ecore_con_url_data_set(n->con_url, NULL);
2967 if (n!=nn) return EINA_TRUE;
2969 if (n->ud.fd) fclose(n->ud.fd);
2972 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2973 "elm,state,busy,stop", "elm");
2974 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
2978 static Elm_Map_Name *
2979 _utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat)
2981 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2982 Widget_Data *wd = elm_widget_data_get(obj);
2983 Map_Sources_Tab *s = NULL, *ss;
2989 if (!wd) return NULL;
2990 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
2992 if (!strcmp(ss->name, wd->source_name))
2998 if (!s) return NULL;
3000 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
3001 if (!name) return NULL;
3003 snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE);
3011 name->con_url = ecore_con_url_new(NULL);
3012 name->ud.fname = strdup(buf);
3013 INF("xml file : %s", name->ud.fname);
3015 name->ud.fd = fdopen(fd, "w+");
3016 if ((!name->con_url) || (!name->ud.fd))
3018 ecore_con_url_free(name->con_url);
3024 name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name);
3025 name->method = method;
3026 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
3027 else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL;
3031 source = s->name_url_cb(wd->obj, method, address, lon, lat);
3032 INF("name url = %s", source);
3034 wd->names = eina_list_append(wd->names, name);
3035 ecore_con_url_url_set(name->con_url, source);
3036 ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd));
3037 ecore_con_url_data_set(name->con_url, name);
3039 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3040 "elm,state,busy,start", "elm");
3041 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL);
3042 ecore_con_url_get(name->con_url);
3043 if (source) free(source);
3049 static int idnum = 1;
3052 * Add a new Map object
3054 * @param parent The parent object
3055 * @return The new object or NULL if it cannot be created
3060 elm_map_add(Evas_Object *parent)
3064 Evas_Coord minw, minh;
3066 static Evas_Smart *smart = NULL;
3067 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
3069 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3071 ELM_SET_WIDTYPE(widtype, "map");
3072 elm_widget_type_set(obj, "map");
3073 elm_widget_sub_object_add(parent, obj);
3074 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3075 elm_widget_data_set(obj, wd);
3076 elm_widget_del_hook_set(obj, _del_hook);
3077 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3078 elm_widget_theme_hook_set(obj, _theme_hook);
3079 elm_widget_can_focus_set(obj, EINA_TRUE);
3080 elm_widget_event_hook_set(obj, _event_hook);
3082 wd->scr = elm_smart_scroller_add(e);
3083 elm_smart_scroller_widget_set(wd->scr, obj);
3084 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
3085 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
3086 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
3087 elm_widget_resize_object_set(obj, wd->scr);
3088 elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE);
3090 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3091 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3092 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3093 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3094 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
3096 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
3101 wd->markers_max_num = 30;
3102 wd->source_name = eina_stringshare_add("Mapnik");
3103 wd->pinch.level = 1.0;
3105 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3106 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3107 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3108 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3112 static Evas_Smart_Class sc;
3114 evas_object_smart_clipped_smart_set(&_pan_sc);
3116 sc.name = "elm_map_pan";
3117 sc.version = EVAS_SMART_CLASS_VERSION;
3120 sc.resize = _pan_resize;
3121 sc.move = _pan_move;
3122 sc.calculate = _pan_calculate;
3123 smart = evas_smart_class_new(&sc);
3127 wd->pan_smart = evas_object_smart_add(e, smart);
3128 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3132 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3133 _pan_set, _pan_get, _pan_max_get,
3134 _pan_min_get, _pan_child_size_get);
3136 wd->rect = evas_object_rectangle_add(e);
3137 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_RESIZE,
3138 _rect_resize_cb, obj);
3139 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
3141 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_MOVE,
3143 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
3145 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_DOWN,
3146 _mouse_multi_down, obj);
3147 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_MOVE,
3148 _mouse_multi_move, obj);
3149 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP,
3150 _mouse_multi_up, obj);
3151 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL,
3152 _mouse_wheel_cb, obj);
3154 evas_object_smart_member_add(wd->rect, wd->pan_smart);
3155 elm_widget_sub_object_add(obj, wd->rect);
3156 evas_object_show(wd->rect);
3157 evas_object_color_set(wd->rect, 0, 0, 0, 0);
3160 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
3161 wd->id = ((int)getpid() << 16) | idnum;
3166 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3168 evas_object_size_hint_min_set(obj, minw, minh);
3170 wd->paused = EINA_TRUE;
3171 elm_map_zoom_set(obj, 0);
3172 wd->paused = EINA_FALSE;
3176 wd->calc_job = ecore_job_add(_calc_job, wd);
3178 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
3179 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
3181 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3182 // TODO: and save some bytes, making descriptions per-class and not instance!
3183 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3185 if (!ecore_file_download_protocol_available("http://"))
3187 ERR("Ecore must be built with curl support for the map widget!");
3193 * Set the zoom level of the map
3195 * This sets the zoom level. 0 is the world map and 18 is the maximum zoom.
3197 * @param obj The map object
3198 * @param zoom The zoom level to set
3203 elm_map_zoom_set(Evas_Object *obj, int zoom)
3205 ELM_CHECK_WIDTYPE(obj, widtype);
3206 Widget_Data *wd = elm_widget_data_get(obj);
3207 Map_Sources_Tab *s = NULL, *ss;
3209 Grid *g, *g_zoom = NULL;
3210 Evas_Coord rx, ry, rw, rh;
3214 int zoom_changed = 0, started = 0;
3216 if ((!wd) || (wd->zoom_animator)) return;
3217 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
3219 if (!strcmp(ss->name, wd->source_name))
3227 if (zoom < 0 ) zoom = 0;
3228 if (zoom > s->zoom_max) zoom = s->zoom_max;
3229 if (zoom < s->zoom_min) zoom = s->zoom_min;
3231 if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT;
3232 else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN;
3233 else wd->zoom_method = ZOOM_METHOD_NONE;
3235 wd->size.ow = wd->size.w;
3236 wd->size.oh = wd->size.h;
3237 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
3238 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3240 EINA_LIST_FOREACH(wd->route, lr, r)
3244 EINA_LIST_FOREACH(r->path, l, p)
3246 evas_object_polygon_points_clear(p);
3251 if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3258 while (cumulw <= rw)
3267 while (cumulh <= rh)
3281 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3288 while (cumulw <= rw)
3297 while (cumulh <= rh)
3311 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3312 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3314 EINA_LIST_FOREACH(wd->grids, l, g)
3316 if (g->zoom == wd->zoom)
3322 g = grid_create(obj);
3325 if (eina_list_count(wd->grids) > 1)
3327 g_zoom = eina_list_last(wd->grids)->data;
3328 wd->grids = eina_list_remove(wd->grids, g_zoom);
3329 grid_clear(obj, g_zoom);
3332 wd->grids = eina_list_prepend(wd->grids, g);
3336 EINA_LIST_FREE(wd->grids, g)
3345 if ((wd->size.w > 0) && (wd->size.h > 0))
3347 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow;
3348 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.oh;
3352 wd->size.spos.x = 0.5;
3353 wd->size.spos.y = 0.5;
3355 if (rw > wd->size.ow) wd->size.spos.x = 0.5;
3356 if (rh > wd->size.oh) wd->size.spos.y = 0.5;
3357 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
3358 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
3366 if (!wd->zoom_animator)
3368 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
3370 if (wd->nosmooth == 1) _smooth_update(obj);
3374 if (wd->zoom_animator)
3376 if (!_zoom_anim(obj))
3378 ecore_animator_del(wd->zoom_animator);
3379 wd->zoom_animator = NULL;
3382 if (wd->calc_job) ecore_job_del(wd->calc_job);
3383 wd->calc_job = ecore_job_add(_calc_job, wd);
3387 evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
3388 if (!wd->zoom_animator)
3389 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3393 evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
3397 * Get the zoom level of the map
3399 * This returns the current zoom level of the map object. Note that if
3400 * you set the fill mode to other than ELM_MAP_ZOOM_MODE_MANUAL
3401 * (which is the default), the zoom level may be changed at any time by the
3402 * map object itself to account for map size and map viewpoer size
3404 * @param obj The map object
3405 * @return The current zoom level
3410 elm_map_zoom_get(const Evas_Object *obj)
3412 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3413 Widget_Data *wd = elm_widget_data_get(obj);
3422 * This sets the zoom mode to manual or one of several automatic levels.
3423 * Manual (ELM_MAP_ZOOM_MODE_MANUAL) means that zoom is set manually by
3424 * elm_map_zoom_set() and will stay at that level until changed by code
3425 * or until zoom mode is changed. This is the default mode.
3426 * The Automatic modes will allow the map object to automatically
3427 * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT will
3428 * adjust zoom so the map fits inside the scroll frame with no pixels
3429 * outside this area. ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but
3430 * 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.
3432 * @param obj The map object
3433 * @param mode The desired mode
3438 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
3440 ELM_CHECK_WIDTYPE(obj, widtype);
3441 Widget_Data *wd = elm_widget_data_get(obj);
3444 if (wd->mode == mode) return;
3447 double tz = wd->zoom;
3449 elm_map_zoom_set(wd->obj, tz);
3456 * This gets the current zoom mode of the map object
3458 * @param obj The map object
3459 * @return The current zoom mode
3463 EAPI Elm_Map_Zoom_Mode
3464 elm_map_zoom_mode_get(const Evas_Object *obj)
3466 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
3467 Widget_Data *wd = elm_widget_data_get(obj);
3469 if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
3474 * Centers the map at @p lon @p lat using an animation to scroll.
3476 * @param obj The map object
3477 * @param lon Longitude to center at
3478 * @param lon Latitude to center at
3483 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
3485 ELM_CHECK_WIDTYPE(obj, widtype);
3486 Widget_Data *wd = elm_widget_data_get(obj);
3490 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3491 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3496 if (wd->zoom_animator)
3499 if (!wd->nosmooth) _smooth_update(obj);
3500 ecore_animator_del(wd->zoom_animator);
3501 wd->zoom_animator = NULL;
3503 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3505 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
3507 wd->center_on.enabled = EINA_TRUE;
3508 wd->center_on.lon = lon;
3509 wd->center_on.lat = lat;
3513 * Move the map to the current coordinates.
3515 * This move the map to the current coordinates. The map will be centered on these coordinates.
3517 * @param obj The map object
3518 * @param lat The latitude.
3519 * @param lon The longitude.
3524 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
3526 ELM_CHECK_WIDTYPE(obj, widtype);
3527 Widget_Data *wd = elm_widget_data_get(obj);
3531 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3532 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3537 if (wd->zoom_animator)
3540 ecore_animator_del(wd->zoom_animator);
3541 wd->zoom_animator = NULL;
3543 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3545 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
3547 wd->center_on.enabled = EINA_TRUE;
3548 wd->center_on.lon = lon;
3549 wd->center_on.lat = lat;
3553 * Get the current coordinates of the map.
3555 * This gets the current coordinates of the map object.
3557 * @param obj The map object
3558 * @param lat The latitude.
3559 * @param lon The longitude.
3564 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
3566 ELM_CHECK_WIDTYPE(obj, widtype);
3567 Widget_Data *wd = elm_widget_data_get(obj);
3568 Evas_Coord sx, sy, sw, sh;
3571 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
3572 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
3576 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
3580 * Set the paused state for map
3582 * This sets the paused state to on (1) or off (0) for map. The default
3583 * is off. This will stop zooming using animation change zoom levels and
3584 * change instantly. This will stop any existing animations that are running.
3586 * @param obj The map object
3587 * @param paused The pause state to set
3592 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
3594 ELM_CHECK_WIDTYPE(obj, widtype);
3595 Widget_Data *wd = elm_widget_data_get(obj);
3598 if (wd->paused == !!paused) return;
3599 wd->paused = paused;
3602 if (wd->zoom_animator)
3604 ecore_animator_del(wd->zoom_animator);
3605 wd->zoom_animator = NULL;
3607 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3613 * Set the paused state for the markers
3615 * This sets the paused state to on (1) or off (0) for the markers. The default
3616 * is off. This will stop displaying the markers during change zoom levels. Set
3617 * to on if you have a large number of markers.
3619 * @param obj The map object
3620 * @param paused The pause state to set
3625 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
3627 ELM_CHECK_WIDTYPE(obj, widtype);
3628 Widget_Data *wd = elm_widget_data_get(obj);
3631 if (wd->paused_markers == !!paused) return;
3632 wd->paused_markers = paused;
3636 * Get the paused state for map
3638 * This gets the current paused state for the map object.
3640 * @param obj The map object
3641 * @return The current paused state
3646 elm_map_paused_get(const Evas_Object *obj)
3648 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3649 Widget_Data *wd = elm_widget_data_get(obj);
3651 if (!wd) return EINA_FALSE;
3656 * Get the paused state for the markers
3658 * This gets the current paused state for the markers object.
3660 * @param obj The map object
3661 * @return The current paused state
3666 elm_map_paused_markers_get(const Evas_Object *obj)
3668 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3669 Widget_Data *wd = elm_widget_data_get(obj);
3671 if (!wd) return EINA_FALSE;
3672 return wd->paused_markers;
3676 * Get the information of downloading status
3678 * This gets the current downloading status for the map object.
3680 * @param obj The map object
3681 * @param try_num the number of download trying map
3682 * @param finish_num the number of downloaded map
3688 elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
3690 ELM_CHECK_WIDTYPE(obj, widtype);
3691 Widget_Data *wd = elm_widget_data_get(obj);
3696 *try_num = wd->try_num;
3701 *finish_num = wd->finish_num;
3705 * Convert a pixel coordinate (x,y) into a geographic coordinate (longitude, latitude).
3707 * @param obj The map object
3708 * @param x the coordinate
3709 * @param y the coordinate
3710 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
3711 * @param lon the longitude correspond to x
3712 * @param lat the latitude correspond to y
3717 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
3719 ELM_CHECK_WIDTYPE(obj, widtype);
3720 Widget_Data *wd = elm_widget_data_get(obj);
3721 Map_Sources_Tab *s = NULL, *ss;
3725 int zoom = floor(log(size/256) / log(2));
3726 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
3728 if (!strcmp(ss->name, wd->source_name))
3734 if ((s) && (s->coord_into_geo))
3736 if (s->coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
3741 *lon = x / (double)size * 360.0 - 180;
3745 double n = ELM_PI - 2.0 * ELM_PI * y / size;
3746 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
3751 * Convert a geographic coordinate (longitude, latitude) into a pixel coordinate (x, y).
3753 * @param obj The map object
3754 * @param lon the longitude
3755 * @param lat the latitude
3756 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
3757 * @param x the coordinate correspond to the longitude
3758 * @param y the coordinate correspond to the latitude
3763 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
3765 ELM_CHECK_WIDTYPE(obj, widtype);
3766 Widget_Data *wd = elm_widget_data_get(obj);
3767 Map_Sources_Tab *s = NULL, *ss;
3771 int zoom = floor(log(size/256) / log(2));
3772 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
3774 if (!strcmp(ss->name, wd->source_name))
3780 if ((s) && (s->geo_into_coord))
3782 if (s->geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
3786 *x = floor((lon + 180.0) / 360.0 * size);
3788 *y = floor((1.0 - log( tan(lat * ELM_PI/180.0) + 1.0 / cos(lat * ELM_PI/180.0)) / ELM_PI) / 2.0 * size);
3792 * Convert a geographic coordinate (longitude, latitude) into a name (address).
3794 * @param obj The map object
3795 * @param lon the longitude
3796 * @param lat the latitude
3798 * @return name the address
3803 elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat)
3805 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3806 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat);
3810 * Convert a name (address) into a geographic coordinate (longitude, latitude).
3812 * @param obj The map object
3813 * @param name the address
3814 * @param lat the latitude correspond to y
3816 * @return name the address
3821 elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address)
3823 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3824 if (!address) return NULL;
3825 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0);
3829 * Convert a pixel coordinate into a roated pixcel coordinate.
3831 * @param obj The map object
3832 * @param x x to rotate.
3833 * @param y y to rotate.
3834 * @param cx rotation's center horizontal position.
3835 * @param cy rotation's center vertical position.
3836 * @param degree amount of degrees from 0.0 to 360.0 to rotate arount Z axis.
3837 * @param xx rotated x.
3838 * @param yy rotated y.
3843 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)
3845 if ((!xx) || (!yy)) return;
3847 double r = (degree * M_PI) / 180.0;
3848 double tx, ty, ttx, tty;
3855 tx = ttx + (ty * cos(r + M_PI_2));
3856 ty = tty + (ty * sin(r + M_PI_2));
3863 * Add a marker on the map
3865 * @param obj The map object
3866 * @param lon the longitude
3867 * @param lat the latitude
3868 * @param clas the class to use
3869 * @param clas_group the class group
3870 * @param data the data passed to the callbacks
3872 * @return The marker object
3876 EAPI Elm_Map_Marker *
3877 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
3879 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3880 Widget_Data *wd = elm_widget_data_get(obj);
3883 Marker_Group *group;
3891 if (!wd) return NULL;
3892 EINA_SAFETY_ON_NULL_RETURN_VAL(clas_group, NULL);
3893 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, NULL);
3895 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
3898 marker->clas = clas;
3899 marker->clas_group = clas_group;
3900 marker->longitude = lon;
3901 marker->latitude = lat;
3902 marker->data = data;
3904 tabi[1] = tabi[4] = tabi[6] = -1;
3905 tabi[2] = tabi[0] = tabi[7] = 0;
3906 tabi[3] = tabi[5] = tabi[8] = 1;
3908 tabj[1] = tabj[2] = tabj[3] = -1;
3909 tabj[4] = tabj[0] = tabj[5] = 0;
3910 tabj[6] = tabj[7] = tabj[8] = 1;
3912 if (!clas_group->priv.set)
3915 if (marker->clas_group && marker->clas_group->style)
3916 style = marker->clas_group->style;
3918 o = edje_object_add(evas_object_evas_get(obj));
3919 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3920 s = edje_object_data_get(o, "size_w");
3921 if (s) clas_group->priv.edje_w = atoi(s);
3922 else clas_group->priv.edje_w = 0;
3923 s = edje_object_data_get(o, "size_h");
3924 if (s) clas_group->priv.edje_h = atoi(s);
3925 else clas_group->priv.edje_h = 0;
3926 s = edje_object_data_get(o, "size_max_w");
3927 if (s) clas_group->priv.edje_max_w = atoi(s);
3928 else clas_group->priv.edje_max_w = 0;
3929 s = edje_object_data_get(o, "size_max_h");
3930 if (s) clas_group->priv.edje_max_h = atoi(s);
3931 else clas_group->priv.edje_max_h = 0;
3934 clas_group->priv.set = EINA_TRUE;
3937 if (!clas->priv.set)
3940 if (marker->clas && marker->clas->style)
3941 style = marker->clas->style;
3943 o = edje_object_add(evas_object_evas_get(obj));
3944 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3945 s = edje_object_data_get(o, "size_w");
3946 if (s) clas->priv.edje_w = atoi(s);
3947 else clas->priv.edje_w = 0;
3948 s = edje_object_data_get(o, "size_h");
3949 if (s) clas->priv.edje_h = atoi(s);
3950 else clas->priv.edje_h = 0;
3953 clas->priv.set = EINA_TRUE;
3956 for (i = clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
3958 elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
3959 &(marker->x[i]), &(marker->y[i]));
3961 //search in the matrixsparse the region where the marker will be
3962 mpi = marker->x[i] / wd->tsize;
3963 mpj = marker->y[i] / wd->tsize;
3965 if (!wd->markers[i])
3967 int size = pow(2.0, i);
3968 wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
3972 if (i <= clas_group->zoom_grouped)
3974 for (j = 0, group = NULL; j < 9 && !group; j++)
3976 EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
3979 if (group->clas == marker->clas_group
3980 && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
3981 marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
3982 group->x-group->w/4, group->y-group->h/4, group->w, group->h))
3984 group->markers = eina_list_append(group->markers, marker);
3985 group->update_nbelems = EINA_TRUE;
3986 group->update_resize = EINA_TRUE;
3988 group->sum_x += marker->x[i];
3989 group->sum_y += marker->y[i];
3990 group->x = group->sum_x / eina_list_count(group->markers);
3991 group->y = group->sum_y / eina_list_count(group->markers);
3993 group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
3994 * eina_list_count(group->markers);
3995 group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
3996 * eina_list_count(group->markers);
3997 if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
3998 if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
4000 if (group->obj && eina_list_count(group->markers) == 2)
4002 _group_object_free(group);
4003 _group_object_create(group);
4006 _group_bubble_content_update(group);
4015 group = calloc(1, sizeof(Marker_Group));
4017 group->sum_x = marker->x[i];
4018 group->sum_y = marker->y[i];
4019 group->x = marker->x[i];
4020 group->y = marker->y[i];
4021 group->w = clas_group->priv.edje_w;
4022 group->h = clas_group->priv.edje_h;
4023 group->clas = clas_group;
4025 group->markers = eina_list_append(group->markers, marker);
4026 group->update_nbelems = EINA_TRUE;
4027 group->update_resize = EINA_TRUE;
4029 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
4033 l = eina_list_append(NULL, group);
4034 eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
4035 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
4039 l = eina_matrixsparse_cell_data_get(group->cell);
4040 l = eina_list_append(l, group);
4041 eina_matrixsparse_cell_data_set(group->cell, l);
4044 marker->groups[i] = group;
4049 Evas_Coord ox, oy, ow, oh;
4050 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
4051 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4058 * Remove a marker from the map
4060 * @param marker The marker to remove
4065 elm_map_marker_remove(Elm_Map_Marker *marker)
4071 EINA_SAFETY_ON_NULL_RETURN(marker);
4074 for (i = marker->clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
4076 marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
4077 if (!eina_list_count(marker->groups[i]->markers))
4079 groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
4080 groups = eina_list_remove(groups, marker->groups[i]);
4081 eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
4083 _group_object_free(marker->groups[i]);
4084 _group_bubble_free(marker->groups[i]);
4085 free(marker->groups[i]);
4089 marker->groups[i]->sum_x -= marker->x[i];
4090 marker->groups[i]->sum_y -= marker->y[i];
4092 marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
4093 marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
4095 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
4096 + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
4097 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
4098 + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
4099 if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
4100 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
4101 if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
4102 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
4104 if ((marker->groups[i]->obj) && (eina_list_count(marker->groups[i]->markers) == 1))
4106 _group_object_free(marker->groups[i]);
4107 _group_object_create(marker->groups[i]);
4112 if ((marker->content) && (marker->clas->func.del))
4113 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4114 else if (marker->content)
4115 evas_object_del(marker->content);
4121 Evas_Coord ox, oy, ow, oh;
4122 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
4123 marker_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4128 * Get the current coordinates of the marker.
4130 * @param marker marker.
4131 * @param lat The latitude.
4132 * @param lon The longitude.
4137 elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat)
4139 EINA_SAFETY_ON_NULL_RETURN(marker);
4140 if (lon) *lon = marker->longitude;
4141 if (lat) *lat = marker->latitude;
4145 * Move the map to the coordinate of the marker.
4147 * @param marker The marker where the map will be center.
4152 elm_map_marker_bring_in(Elm_Map_Marker *marker)
4154 EINA_SAFETY_ON_NULL_RETURN(marker);
4155 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
4159 * Move the map to the coordinate of the marker.
4161 * @param marker The marker where the map will be center.
4166 elm_map_marker_show(Elm_Map_Marker *marker)
4168 EINA_SAFETY_ON_NULL_RETURN(marker);
4169 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
4173 * Move and zoom the map to display a list of markers.
4175 * The map will be centered on the center point of the markers in the list. Then
4176 * the map will be zoomed in order to fit the markers using the maximum zoom which
4177 * allows display of all the markers.
4179 * @param markers The list of markers (list of Elm_Map_Marker *)
4184 elm_map_markers_list_show(Eina_List *markers)
4189 Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
4190 Evas_Coord rw, rh, xc, yc;
4192 Map_Sources_Tab *s = NULL, *ss;
4194 EINA_SAFETY_ON_NULL_RETURN(markers);
4195 EINA_LIST_FOREACH(markers, l, marker)
4199 if ((!m_min_lon) || (marker->longitude < m_min_lon->longitude))
4202 if ((!m_max_lon) || (marker->longitude > m_max_lon->longitude))
4205 if ((!m_min_lat) || (marker->latitude > m_min_lat->latitude))
4208 if ((!m_max_lat) || (marker->latitude < m_max_lat->latitude))
4212 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
4214 if (!strcmp(ss->name, wd->source_name))
4222 lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
4223 lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
4225 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
4226 for (zoom = s->zoom_max; zoom>s->zoom_min; zoom--)
4228 Evas_Coord size = pow(2.0, zoom)*wd->tsize;
4229 elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
4231 if ((m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2)
4232 && (m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2)
4233 && (m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2)
4234 && (m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2))
4238 elm_map_geo_region_show(wd->obj, lon, lat);
4239 elm_map_zoom_set(wd->obj, zoom);
4243 * Set the maximum numbers of markers display in a group.
4245 * A group can have a long list of markers, consequently the creation of the content
4246 * of the bubble can be very slow. In order to avoid this, a maximum number of items
4247 * is displayed in a bubble. By default this number is 30.
4249 * @param obj The map object.
4250 * @param max The maximum numbers of items displayed in a bubble.
4255 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
4257 ELM_CHECK_WIDTYPE(obj, widtype);
4258 Widget_Data *wd = elm_widget_data_get(obj);
4261 wd->markers_max_num = max;
4265 * Return the evas object getting from the ElmMapMarkerGetFunc callback
4267 * @param marker The marker.
4268 * @return Return the evas object if it exists, else NULL.
4273 elm_map_marker_object_get(const Elm_Map_Marker *marker)
4275 EINA_SAFETY_ON_NULL_RETURN_VAL(marker, NULL);
4276 return marker->content;
4282 * @param marker The marker.
4287 elm_map_marker_update(Elm_Map_Marker *marker)
4289 EINA_SAFETY_ON_NULL_RETURN(marker);
4290 if (marker->content)
4292 if (marker->clas->func.del)
4293 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4295 evas_object_del(marker->content);
4296 marker->content = NULL;
4297 _group_bubble_content_update(marker->groups[marker->wd->zoom]);
4302 * Close all opened bubbles
4304 * @param obj The map object
4309 elm_map_bubbles_close(Evas_Object *obj)
4311 ELM_CHECK_WIDTYPE(obj, widtype);
4312 Widget_Data *wd = elm_widget_data_get(obj);
4313 Marker_Group *group;
4314 Eina_List *l, *l_next;
4317 EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
4318 _group_bubble_free(group);
4322 * Create a group class.
4324 * Each marker must be associated to a group class. Marker with the same group are grouped if they are close.
4325 * The group class defines the style of the marker when a marker is grouped to others markers.
4327 * @param obj The map object
4328 * @return Returns the new group class
4332 EAPI Elm_Map_Group_Class *
4333 elm_map_group_class_new(Evas_Object *obj)
4335 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4336 Widget_Data *wd = elm_widget_data_get(obj);
4338 if (!wd) return NULL;
4339 Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
4340 clas->zoom_grouped = ZOOM_MAX;
4341 wd->groups_clas = eina_list_append(wd->groups_clas, clas);
4346 * Set the style of a group class (radio, radio2 or empty)
4348 * @param clas the group class
4349 * @param style the new style
4354 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
4356 EINA_SAFETY_ON_NULL_RETURN(clas);
4357 eina_stringshare_replace(&clas->style, style);
4361 * Set the icon callback of a group class.
4363 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
4365 * @param clas the group class
4366 * @param icon_get the callback to create the icon
4371 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
4373 EINA_SAFETY_ON_NULL_RETURN(clas);
4374 clas->func.icon_get = icon_get;
4378 * Set the data associated to the group class (radio, radio2 or empty)
4380 * @param clas the group class
4381 * @param data the new user data
4386 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
4388 EINA_SAFETY_ON_NULL_RETURN(clas);
4393 * Set the zoom from where the markers are displayed.
4395 * Markers will not be displayed for a zoom less than @ref zoom
4397 * @param clas the group class
4398 * @param zoom the zoom
4403 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
4405 EINA_SAFETY_ON_NULL_RETURN(clas);
4406 clas->zoom_displayed = zoom;
4410 * Set the zoom from where the markers are no more grouped.
4412 * @param clas the group class
4413 * @param zoom the zoom
4418 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
4420 EINA_SAFETY_ON_NULL_RETURN(clas);
4421 clas->zoom_grouped = zoom;
4425 * Set if the markers associated to the group class @clas are hidden or not.
4426 * If @ref hide is true the markers will be hidden.
4428 * @param clas the group class
4429 * @param hide if true the markers will be hidden, else they will be displayed.
4434 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
4436 ELM_CHECK_WIDTYPE(obj, widtype);
4437 Widget_Data *wd = elm_widget_data_get(obj);
4440 EINA_SAFETY_ON_NULL_RETURN(clas);
4441 if (clas->hide == hide) return;
4445 Evas_Coord ox, oy, ow, oh;
4446 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
4447 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4453 * Create a marker class.
4455 * Each marker must be associated to a class.
4456 * The class defines the style of the marker when a marker is displayed alone (not grouped).
4458 * @param obj The map object
4459 * @return Returns the new class
4463 EAPI Elm_Map_Marker_Class *
4464 elm_map_marker_class_new(Evas_Object *obj)
4466 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4467 Widget_Data *wd = elm_widget_data_get(obj);
4469 if (!wd) return NULL;
4470 Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
4471 wd->markers_clas = eina_list_append(wd->markers_clas, clas);
4476 * Set the style of a class (radio, radio2 or empty)
4478 * @param clas the group class
4479 * @param style the new style
4484 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
4486 EINA_SAFETY_ON_NULL_RETURN(clas);
4487 eina_stringshare_replace(&clas->style, style);
4491 * Set the icon callback of a class.
4493 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
4495 * @param clas the group class
4496 * @param icon_get the callback to create the icon
4501 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
4503 EINA_SAFETY_ON_NULL_RETURN(clas);
4504 clas->func.icon_get = icon_get;
4509 * Set the callback of the content of the bubble.
4511 * When the user click on a marker, a bubble is displayed with a content.
4512 * The callback @ref get musst return this content. It can be NULL.
4514 * @param clas the group class
4515 * @param get the callback to create the content
4520 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
4522 EINA_SAFETY_ON_NULL_RETURN(clas);
4523 clas->func.get = get;
4527 * Set the callback of the content of delete the object created by the callback "get".
4529 * If this callback is defined the user will have to delete (or not) the object inside.
4530 * If the callback is not defined the object will be destroyed with evas_object_del()
4532 * @param clas the group class
4533 * @param del the callback to delete the content
4538 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
4540 EINA_SAFETY_ON_NULL_RETURN(clas);
4541 clas->func.del = del;
4545 * Get the list of the sources.
4547 * @param obj The map object
4548 * @return sources the source list
4554 elm_map_source_names_get(const Evas_Object *obj)
4556 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4557 Widget_Data *wd = elm_widget_data_get(obj);
4559 if (!wd) return NULL;
4560 return wd->source_names;
4564 * Set the source of the map.
4566 * Elm_Map retrieves the image which composed the map from a web service. This web service can
4567 * be set with this method. A different service can return a different maps with different
4568 * information and it can use different zoom value.
4570 * @param obj the map object
4571 * @param source the new source
4576 elm_map_source_name_set(Evas_Object *obj, const char *source_name)
4578 ELM_CHECK_WIDTYPE(obj, widtype);
4579 Widget_Data *wd = elm_widget_data_get(obj);
4580 Map_Sources_Tab *s = NULL, *ss;
4586 if (!strcmp(wd->source_name, source_name)) return;
4587 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
4589 if (!strcmp(ss->name, wd->source_name))
4597 if (!s->url_cb) return;
4599 EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid);
4601 eina_stringshare_replace(&wd->source_name, source_name);
4605 if (s->zoom_max < zoom)
4607 if (s->zoom_min > zoom)
4610 elm_map_zoom_set(obj, zoom);
4614 * Get the name of a source.
4616 * @param source the source
4617 * @return Returns the name of the source
4622 elm_map_source_name_get(const Evas_Object *obj)
4624 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4625 Widget_Data *wd = elm_widget_data_get(obj);
4626 Map_Sources_Tab *s = NULL, *ss;
4629 if (!wd) return NULL;
4630 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
4632 if (!strcmp(ss->name, wd->source_name))
4638 if (!s) return NULL;
4644 * Set the source of the route.
4646 * @param clas the group class
4647 * @param source the new source
4652 elm_map_route_source_name_set(Evas_Object *obj, char *source_name)
4654 ELM_CHECK_WIDTYPE(obj, widtype);
4655 Widget_Data *wd = elm_widget_data_get(obj);
4658 eina_stringshare_replace(&wd->source_name, source_name);
4662 * Get the current route source
4664 * @param obj the map object
4665 * @return Returns the source of the route
4669 EAPI Elm_Map_Route_Sources
4670 elm_map_route_source_get(const Evas_Object *obj)
4672 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS;
4673 Widget_Data *wd = elm_widget_data_get(obj);
4675 if (!wd) return ELM_MAP_ROUTE_SOURCE_YOURS;
4676 return wd->route_source;
4680 * Get the maximum zoom of the source.
4682 * @param source the source
4683 * @return Returns the maximum zoom of the source
4688 elm_map_source_zoom_max_get(const Evas_Object *obj)
4690 ELM_CHECK_WIDTYPE(obj, widtype) 18;
4691 Widget_Data *wd = elm_widget_data_get(obj);
4692 Map_Sources_Tab *s = NULL, *ss;
4696 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
4698 if (!strcmp(ss->name, wd->source_name))
4710 * Get the minimum zoom of the source.
4712 * @param source the source
4713 * @return Returns the minimum zoom of the source
4718 elm_map_source_zoom_min_get(const Evas_Object *obj)
4720 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4721 Widget_Data *wd = elm_widget_data_get(obj);
4722 Map_Sources_Tab *s = NULL, *ss;
4726 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
4728 if (!strcmp(ss->name, wd->source_name))
4740 * Set the user agent of the widget map.
4742 * @param obj The map object
4743 * @param user_agent the user agent of the widget map
4748 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
4750 ELM_CHECK_WIDTYPE(obj, widtype);
4751 Widget_Data *wd = elm_widget_data_get(obj);
4754 if (!wd->user_agent) wd->user_agent = eina_stringshare_add(user_agent);
4755 else eina_stringshare_replace(&wd->user_agent, user_agent);
4757 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4758 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4762 * Get the user agent of the widget map.
4764 * @param obj The map object
4765 * @return The user agent of the widget map
4770 elm_map_user_agent_get(const Evas_Object *obj)
4772 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4773 Widget_Data *wd = elm_widget_data_get(obj);
4775 if (!wd) return NULL;
4776 return wd->user_agent;
4780 * Add a route on the map
4782 * @param obj The map object
4783 * @param type the type if transport
4784 * @param method the routing method
4785 * @param flon the start longitude
4786 * @param flat the start latitude
4787 * @param tlon the destination longitude
4788 * @param tlat the destination latitude
4790 * @return The Route object
4794 EAPI Elm_Map_Route *
4795 elm_map_route_add(Evas_Object *obj,
4796 Elm_Map_Route_Type type,
4797 Elm_Map_Route_Method method,
4803 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4804 Widget_Data *wd = elm_widget_data_get(obj);
4805 Map_Sources_Tab *s = NULL, *ss;
4809 char *type_name = NULL;
4812 if (!wd) return NULL;
4813 EINA_LIST_FOREACH(wd->map_sources_tab, l, ss)
4815 if (!strcmp(ss->name, wd->source_name))
4821 if (!s) return NULL;
4823 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4824 if (!route) return NULL;
4826 snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE);
4834 route->con_url = ecore_con_url_new(NULL);
4835 route->ud.fname = strdup(buf);
4836 INF("xml file : %s", route->ud.fname);
4838 route->ud.fd = fdopen(fd, "w+");
4839 if ((!route->con_url) || (!route->ud.fd))
4841 ecore_con_url_free(route->con_url);
4847 route->color.r = 255;
4850 route->color.a = 255;
4851 route->handlers = eina_list_append
4852 (route->handlers, (void *)ecore_event_handler_add
4853 (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route));
4855 route->inbound = EINA_FALSE;
4857 route->method = method;
4865 case ELM_MAP_ROUTE_TYPE_MOTOCAR:
4866 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4868 case ELM_MAP_ROUTE_TYPE_BICYCLE:
4869 type_name = strdup(ROUTE_TYPE_BICYCLE);
4871 case ELM_MAP_ROUTE_TYPE_FOOT:
4872 type_name = strdup(ROUTE_TYPE_FOOT);
4878 source = s->route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4879 INF("route url = %s", source);
4881 wd->route = eina_list_append(wd->route, route);
4883 ecore_con_url_url_set(route->con_url, source);
4884 ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd));
4885 ecore_con_url_data_set(route->con_url, route);
4886 ecore_con_url_get(route->con_url);
4887 if (type_name) free(type_name);
4888 if (source) free(source);
4890 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4891 "elm,state,busy,start", "elm");
4892 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL);
4897 * Remove a route from the map
4899 * @param route The route to remove
4905 elm_map_route_remove(Elm_Map_Route *route)
4907 EINA_SAFETY_ON_NULL_RETURN(route);
4912 Ecore_Event_Handler *h;
4914 EINA_LIST_FREE(route->path, p)
4919 EINA_LIST_FREE(route->waypoint, w)
4921 if (w->point) eina_stringshare_del(w->point);
4925 EINA_LIST_FREE(route->nodes, n)
4927 if (n->pos.address) eina_stringshare_del(n->pos.address);
4931 EINA_LIST_FREE(route->handlers, h)
4933 ecore_event_handler_del(h);
4936 if (route->ud.fname)
4938 ecore_file_remove(route->ud.fname);
4939 free(route->ud.fname);
4940 route->ud.fname = NULL;
4945 * Set the option used for the background color
4947 * @param route The route object
4953 * This sets the color used for the route
4958 elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a)
4960 EINA_SAFETY_ON_NULL_RETURN(route);
4968 * Get the option used for the background color
4970 * @param route The route object
4979 elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a)
4981 EINA_SAFETY_ON_NULL_RETURN(route);
4982 if (r) *r = route->color.r;
4983 if (g) *g = route->color.g;
4984 if (b) *b = route->color.b;
4985 if (a) *a = route->color.a;
4989 * Get the information of route distance
4991 * @param route the route object
4992 * @return Returns the distance of route (unit : km)
4997 elm_map_route_distance_get(const Elm_Map_Route *route)
4999 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
5000 return route->info.distance;
5004 * Get the information of route nodes
5006 * @param route the route object
5007 * @return Returns the nodes of route
5013 elm_map_route_node_get(const Elm_Map_Route *route)
5015 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
5016 return route->info.nodes;
5020 * Get the information of route waypoint
5022 * @param route the route object
5023 * @return Returns the waypoint of route
5029 elm_map_route_waypoint_get(const Elm_Map_Route *route)
5031 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
5032 return route->info.waypoints;
5036 * Get the information of address
5038 * @param name the name object
5039 * @return Returns the address of name
5044 elm_map_name_address_get(const Elm_Map_Name *name)
5046 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
5047 return name->address;
5051 * Get the current coordinates of the name.
5053 * This gets the current coordinates of the name object.
5055 * @param obj The name object
5056 * @param lat The latitude
5057 * @param lon The longitude
5062 elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
5064 EINA_SAFETY_ON_NULL_RETURN(name);
5065 if (lon) *lon = name->lon;
5066 if (lat) *lat = name->lat;
5070 * Remove a name from the map
5072 * @param name The name to remove
5077 elm_map_name_remove(Elm_Map_Name *name)
5079 EINA_SAFETY_ON_NULL_RETURN(name);
5082 free(name->address);
5083 name->address = NULL;
5087 ecore_event_handler_del(name->handler);
5088 name->handler = NULL;
5092 ecore_file_remove(name->ud.fname);
5093 free(name->ud.fname);
5094 name->ud.fname = NULL;
5099 * Set the rotate degree of the map
5101 * @param obj The map object
5102 * @param angle amount of degrees from 0.0 to 360.0 to rotate arount Z axis
5103 * @param cx rotation's center horizontal position
5104 * @param cy rotation's center vertical position
5109 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
5111 ELM_CHECK_WIDTYPE(obj, widtype);
5112 Widget_Data *wd = elm_widget_data_get(obj);
5115 wd->rotate.d = degree;
5118 wd->calc_job = ecore_job_add(_calc_job, wd);
5122 * Get the rotate degree of the map
5124 * @param obj The map object
5125 * @return amount of degrees from 0.0 to 360.0 to rotate arount Z axis
5126 * @param cx rotation's center horizontal position
5127 * @param cy rotation's center vertical position
5132 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
5134 ELM_CHECK_WIDTYPE(obj, widtype);
5135 Widget_Data *wd = elm_widget_data_get(obj);
5138 if (degree) *degree = wd->rotate.d;
5139 if (cx) *cx = wd->rotate.cx;
5140 if (cy) *cy = wd->rotate.cy;
5144 * Set the wheel control state of the map
5146 * @param obj The map object
5147 * @param disabled status of wheel control
5152 elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
5154 ELM_CHECK_WIDTYPE(obj, widtype);
5155 Widget_Data *wd = elm_widget_data_get(obj);
5158 if ((!wd->wheel_disabled) && (disabled))
5159 evas_object_event_callback_del_full(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
5160 else if ((wd->wheel_disabled) && (!disabled))
5161 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
5162 wd->wheel_disabled = !!disabled;
5166 * Get the wheel control state of the map
5168 * @param obj The map object
5169 * @return Returns the status of wheel control
5174 elm_map_wheel_disabled_get(const Evas_Object *obj)
5176 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5177 Widget_Data *wd = elm_widget_data_get(obj);
5179 if (!wd) return EINA_FALSE;
5180 return wd->wheel_disabled;
5184 _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5187 snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
5193 _osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5196 snprintf(buf, sizeof(buf),
5197 "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
5203 _cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5206 snprintf(buf, sizeof(buf),
5207 "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
5213 _maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5216 snprintf(buf, sizeof(buf),
5217 "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
5222 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5225 snprintf(buf, sizeof(buf),
5226 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
5227 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
5232 // TODO: fix monav api
5234 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5237 snprintf(buf, sizeof(buf),
5238 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
5239 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
5245 // TODO: fix ors api
5247 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5250 snprintf(buf, sizeof(buf),
5251 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
5252 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
5259 _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
5261 ELM_CHECK_WIDTYPE(obj, widtype) strdup("");
5262 Widget_Data *wd = elm_widget_data_get(obj);
5264 unsigned int ele, idx;
5265 char search_url[PATH_MAX];
5268 if (!wd) return strdup("");
5269 if (method == ELM_MAP_NAME_METHOD_SEARCH)
5271 search_url[0] = '\0';
5272 str = eina_str_split_full(name, " ", 0, &ele);
5273 for (idx = 0 ; idx < ele ; idx++)
5275 eina_strlcat(search_url, str[idx], sizeof(search_url));
5276 if (!(idx == (ele-1))) eina_strlcat(search_url, "+", sizeof(search_url));
5278 snprintf(buf, sizeof(buf), "%s/search?q=%s&format=xml&polygon=0&addressdetails=0", NAME_NOMINATIM_URL, search_url);
5280 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);
5281 else strcpy(buf, "");