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_names;
404 Ecore_Timer *zoom_timer;
405 Map_Sources_Tab *src;
410 Evas_Object_Smart_Clipped_Data __clipped_data;
426 Evas_Coord x, y, w, h;
429 Ecore_Timer *hold_timer;
444 enum _Route_Xml_Attribute
448 ROUTE_XML_DESCRIPTION,
449 ROUTE_XML_COORDINATES,
451 } Route_Xml_Attibute;
461 enum _Name_Xml_Attribute
478 static const char *widtype = NULL;
480 static const char SIG_CHANGED[] = "changed";
481 static const char SIG_CLICKED[] = "clicked";
482 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
483 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
484 static const char SIG_LOAD_DETAIL[] = "load,detail";
485 static const char SIG_LONGPRESSED[] = "longpressed";
486 static const char SIG_PRESS[] = "press";
487 static const char SIG_SCROLL[] = "scroll";
488 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
489 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
490 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
491 static const char SIG_ZOOM_START[] = "zoom,start";
492 static const char SIG_ZOOM_STOP[] = "zoom,stop";
493 static const char SIG_DOWNLOADED[] = "downloaded";
494 static const char SIG_ROUTE_LOAD[] = "route,load";
495 static const char SIG_ROUTE_LOADED[] = "route,loaded";
496 static const char SIG_NAME_LOAD[] = "name,load";
497 static const char SIG_NAME_LOADED[] = "name,loaded";
498 static const Evas_Smart_Cb_Description _signals[] = {
501 {SIG_CLICKED_DOUBLE, ""},
502 {SIG_LOADED_DETAIL, ""},
503 {SIG_LOAD_DETAIL, ""},
504 {SIG_LONGPRESSED, ""},
507 {SIG_SCROLL_DRAG_START, ""},
508 {SIG_SCROLL_DRAG_STOP, ""},
509 {SIG_ZOOM_CHANGE, ""},
510 {SIG_ZOOM_START, ""},
512 {SIG_DOWNLOADED, ""},
513 {SIG_ROUTE_LOAD, ""},
514 {SIG_ROUTE_LOADED, ""},
516 {SIG_NAME_LOADED, ""},
520 static void _pan_calculate(Evas_Object *obj);
522 static Eina_Bool _hold_timer_cb(void *data);
523 static Eina_Bool _wheel_timer_cb(void *data);
524 static void _rect_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
525 static void _del_hook(Evas_Object *obj);
526 static void _theme_hook(Evas_Object *obj);
527 static void _on_focus_hook(void *data, Evas_Object *obj);
528 static void _sizing_eval(Evas_Object *obj);
529 static void _calc_job(void *data);
530 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
531 Evas_Callback_Type type, void *event_info);
532 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);
533 static void grid_clear(Evas_Object *obj, Grid *g);
534 static Grid *grid_create(Evas_Object *obj);
535 static void grid_load(Evas_Object *obj, Grid *g);
538 static void _group_object_create(Marker_Group *group);
539 static void _group_object_free(Marker_Group *group);
540 static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
541 static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
542 static void _group_bubble_create(Marker_Group *group);
543 static void _group_bubble_free(Marker_Group *group);
544 static void _group_bubble_place(Marker_Group *group);
546 static int _group_bubble_content_update(Marker_Group *group);
547 static void _group_bubble_content_free(Marker_Group *group);
548 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);
549 static void _bubble_sc_hits_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
551 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
552 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
553 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
555 static void _mouse_multi_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
556 static void _mouse_multi_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
557 static void _mouse_multi_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
559 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);
562 get_multi_device(Evas_Object *obj)
564 Widget_Data *wd = elm_widget_data_get(obj);
568 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
570 if (ev->device) return ev->device;
576 get_distance(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
580 return sqrt((dx * dx) + (dy * dy));
584 create_event_object(void *data, Evas_Object *obj, int device)
586 Widget_Data *wd = elm_widget_data_get(data);
587 Event *ev = calloc(1, sizeof(Event));
589 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, NULL);
593 evas_object_geometry_get(obj, &ev->x, &ev->y, &ev->w, &ev->h);
594 wd->s_event_list = eina_list_append(wd->s_event_list, ev);
599 get_event_object(void *data, int device)
601 Widget_Data *wd = elm_widget_data_get(data);
605 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
607 if (ev->device == device) break;
614 destroy_event_object(void *data, Event *ev)
616 Widget_Data *wd = elm_widget_data_get(data);
617 EINA_SAFETY_ON_NULL_RETURN(ev);
619 wd->s_event_list = eina_list_remove(wd->s_event_list, ev);
622 ecore_timer_del(ev->hold_timer);
623 ev->hold_timer = NULL;
629 module_list_cb(Eina_Module *m, void *data)
631 ELM_CHECK_WIDTYPE(data, widtype) EINA_FALSE;
632 Widget_Data *wd = elm_widget_data_get(data);
634 ElmMapModuleSourceFunc source;
635 ElmMapModuleZoomMinFunc zoom_min;
636 ElmMapModuleZoomMaxFunc zoom_max;
637 ElmMapModuleUrlFunc url;
638 ElmMapModuleRouteSourceFunc route_source;
639 ElmMapModuleRouteUrlFunc route_url;
640 ElmMapModuleNameUrlFunc name_url;
641 ElmMapModuleGeoIntoCoordFunc geo_into_coord;
642 ElmMapModuleCoordIntoGeoFunc coord_into_geo;
645 if (!wd) return EINA_FALSE;
647 file = eina_module_file_get(m);
648 if (!eina_module_load(m))
650 ERR("could not load module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
654 source = eina_module_symbol_get(m, "map_module_source_get");
655 zoom_min = eina_module_symbol_get(m, "map_module_zoom_min_get");
656 zoom_max = eina_module_symbol_get(m, "map_module_zoom_max_get");
657 url = eina_module_symbol_get(m, "map_module_url_get");
658 route_source = eina_module_symbol_get(m, "map_module_route_source_get");
659 route_url = eina_module_symbol_get(m, "map_module_route_url_get");
660 name_url = eina_module_symbol_get(m, "map_module_name_url_get");
661 geo_into_coord = eina_module_symbol_get(m, "map_module_geo_into_coord");
662 coord_into_geo = eina_module_symbol_get(m, "map_module_coord_into_geo");
663 if ((!source) || (!zoom_min) || (!zoom_max) || (!url) || (!route_source) || (!route_url) || (!name_url) || (!geo_into_coord) || (!coord_into_geo))
665 ERR("could not find map_module_source_get() in module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
666 eina_module_unload(m);
669 s = calloc(1, sizeof(Map_Sources_Tab));
670 EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE);
672 s->zoom_min = zoom_min();
673 s->zoom_max = zoom_max();
675 s->route_source = route_source();
676 s->route_url_cb = route_url;
677 s->name_url_cb = name_url;
678 s->geo_into_coord = geo_into_coord;
679 s->coord_into_geo = coord_into_geo;
680 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
686 module_init(void *data)
688 ELM_CHECK_WIDTYPE(data, widtype);
689 Widget_Data *wd = elm_widget_data_get(data);
692 wd->modules = eina_module_list_get(wd->modules, MODULES_PATH, 1, &module_list_cb, data);
696 source_init(void *data)
698 ELM_CHECK_WIDTYPE(data, widtype);
699 Widget_Data *wd = elm_widget_data_get(data);
705 for (idx = 0; idx < 4; idx++)
707 s = calloc(1, sizeof(Map_Sources_Tab));
708 EINA_SAFETY_ON_NULL_RETURN(s);
709 s->name = default_map_sources_tab[idx].name;
710 s->zoom_min = default_map_sources_tab[idx].zoom_min;
711 s->zoom_max = default_map_sources_tab[idx].zoom_max;
712 s->url_cb = default_map_sources_tab[idx].url_cb;
713 s->route_source = default_map_sources_tab[idx].route_source;
714 s->route_url_cb = default_map_sources_tab[idx].route_url_cb;
715 s->name_url_cb = default_map_sources_tab[idx].name_url_cb;
716 s->geo_into_coord = default_map_sources_tab[idx].geo_into_coord;
717 s->coord_into_geo = default_map_sources_tab[idx].coord_into_geo;
718 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
719 if (!idx) wd->src = s;
723 int n = eina_list_count(wd->map_sources_tab);
724 wd->source_names = malloc(sizeof(char *) * (n + 1));
725 if (!wd->source_names)
727 ERR("init source names failed.");
731 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
733 wd->source_names[idx] = strdup(s->name);
734 INF("source : %s", wd->source_names[idx]);
737 wd->source_names[idx] = NULL;
741 obj_rotate_zoom(void *data, Evas_Object *obj)
743 ELM_CHECK_WIDTYPE(data, widtype);
744 Widget_Data *wd = elm_widget_data_get(data);
745 if ((!wd->pinch.cx) && (!wd->pinch.cy))
747 wd->pinch.cx = wd->rotate.cx;
748 wd->pinch.cy = wd->rotate.cy;
751 evas_map_util_points_populate_from_object_full(wd->map, obj, 0);
752 evas_map_util_zoom(wd->map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy);
753 evas_map_util_rotate(wd->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, wd->map);
759 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)
761 ELM_CHECK_WIDTYPE(obj, widtype);
762 Widget_Data *wd = elm_widget_data_get(obj);
763 Eina_List *lr, *lp, *ln;
772 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
774 EINA_LIST_FOREACH(wd->route, lr, r)
776 EINA_LIST_FOREACH(r->path, lp, p)
778 evas_object_polygon_points_clear(p);
781 evas_object_geometry_get(wd->rect, &rx, &ry, NULL, NULL);
782 nodes = eina_list_count(r->nodes);
784 EINA_LIST_FOREACH(r->nodes, ln, n)
786 if ((!wd->zoom) || ((n->idx) &&
787 ((n->idx % (int)ceil((double)nodes/(double)size*100.0))))) continue;
790 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
791 if ((x >= px - ow) && (x <= (px + ow*2)) &&
792 (y >= py - oh) && (y <= (py + oh*2)))
797 p = eina_list_nth(r->path, n->idx);
798 a = (double)(y - r->y) / (double)(x - r->x);
799 if ((abs(a) >= 1) || (r->x == x))
801 evas_object_polygon_point_add(p, r->x - 3, r->y);
802 evas_object_polygon_point_add(p, r->x + 3, r->y);
803 evas_object_polygon_point_add(p, x + 3, y);
804 evas_object_polygon_point_add(p, x - 3, y);
808 evas_object_polygon_point_add(p, r->x, r->y - 3);
809 evas_object_polygon_point_add(p, r->x, r->y + 3);
810 evas_object_polygon_point_add(p, x, y + 3);
811 evas_object_polygon_point_add(p, x, y - 3);
814 evas_object_color_set(p, r->color.r, r->color.g, r->color.b, r->color.a);
815 evas_object_raise(p);
816 obj_rotate_zoom(obj, p);
821 else r->inbound = EINA_FALSE;
825 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
826 if ((x >= px - ow) && (x <= (px + ow*2)) &&
827 (y >= py - oh) && (y <= (py + oh*2)))
831 r->inbound = EINA_TRUE;
833 else r->inbound = EINA_FALSE;
836 r->inbound = EINA_FALSE;
841 rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
843 ELM_CHECK_WIDTYPE(obj, widtype);
844 Widget_Data *wd = elm_widget_data_get(obj);
845 Evas_Coord ax, ay, gw, gh, hh, ww;
848 evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh);
855 if ((ww == gw) && (hh == gh)) return;
857 if (ow > gw) ax = (ow - gw) / 2;
858 if (oh > gh) ay = (oh - gh) / 2;
859 evas_object_move(wd->rect,
862 evas_object_resize(wd->rect, gw, gh);
866 wd->show.show = EINA_FALSE;
867 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
872 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)
874 ELM_CHECK_WIDTYPE(obj, widtype);
875 Widget_Data *wd = elm_widget_data_get(obj);
876 Evas_Coord ax, ay, gw, gh, tx, ty;
877 Eina_List *l, *markers;
878 Eina_Matrixsparse_Cell *cell;
883 int g_xx, g_yy, g_hh, g_ww;
886 if (g != eina_list_data_get(wd->grids)) return;
892 if (ow > gw) ax = (ow - gw) / 2;
893 if (oh > gh) ay = (oh - gh) / 2;
895 if (wd->zoom != wd->marker_zoom)
897 EINA_LIST_FREE(wd->cells_displayed, cell)
899 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
901 if (group->obj) _group_object_free(group);
905 wd->marker_zoom = wd->zoom;
907 if ((wd->paused_markers)
908 && ((wd->size.nw != wd->size.w) || (wd->size.nh != wd->size.h)) )
911 g_xx = wd->pan_x / wd->tsize;
912 if (g_xx < 0) g_xx = 0;
913 g_yy = wd->pan_y / wd->tsize;
914 if (g_yy < 0) g_yy = 0;
915 g_ww = (ow / wd->tsize) + 1;
916 if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
917 g_hh = (oh / wd->tsize) + 1;
918 if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
920 //hide groups no more displayed
921 EINA_LIST_FREE(wd->cells_displayed, cell)
923 eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x);
924 if ((y < g_yy) || (y > g_yy + g_hh) || (x < g_xx) || (x > g_xx + g_ww))
926 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
928 if (group->obj) _group_object_free(group);
933 if (!wd->marker_zoom)
939 for (y = g_yy; y <= g_yy + g_hh; y++)
941 for (x = g_xx; x <= g_xx + g_ww; x++)
943 if (!wd->markers[wd->zoom]) continue;
944 eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell);
946 wd->cells_displayed = eina_list_append(wd->cells_displayed, cell);
947 markers = eina_matrixsparse_cell_data_get(cell);
948 EINA_LIST_FOREACH(markers, l, group)
950 if (!group->markers) continue;
951 if (group->clas->zoom_displayed > wd->zoom) continue;
958 if (eina_list_count(group->markers) == 1)
960 Elm_Map_Marker *m = eina_list_data_get(group->markers);
961 ww = m->clas->priv.edje_w;
962 hh = m->clas->priv.edje_h;
968 if ((gw != g->w) && (g->w > 0))
971 xx = ((long long )gw * xx) / g->w;
972 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
974 if ((gh != g->h) && (g->h > 0))
977 yy = ((long long)gh * yy) / g->h;
978 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
981 if ((!group->clas->hide)
982 && (xx-px+ax+ox >= ox) && (xx-px+ax+ox<= ox+ow)
983 && (yy-py+ay+oy >= oy) && (yy-py+ay+oy<= oy+oh))
985 if (!group->obj) _group_object_create(group);
987 if (group->update_nbelems)
989 group->update_nbelems = EINA_FALSE;
990 if (eina_list_count(group->markers) > 1)
992 snprintf(buf, sizeof(buf), "%d", eina_list_count(group->markers));
993 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
996 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", "");
998 evas_object_move(group->obj,
999 xx - px + ax + ox - ww/2,
1000 yy - py + ay + oy - hh/2);
1001 if ((!wd->paused_markers) || (group->update_resize))
1003 group->update_resize = EINA_FALSE;
1004 evas_object_resize(group->obj, ww, hh);
1005 obj_rotate_zoom(obj, group->obj);
1007 if (group->update_raise)
1009 group->update_raise = EINA_FALSE;
1010 evas_object_raise(group->obj);
1011 obj_rotate_zoom(obj, group->obj);
1012 evas_object_show(group->obj);
1014 if (group->bubble) _group_bubble_place(group);
1016 else if (group->obj)
1018 _group_object_free(group);
1026 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)
1028 ELM_CHECK_WIDTYPE(obj, widtype);
1029 Widget_Data *wd = elm_widget_data_get(obj);
1030 Evas_Coord ax, ay, gw, gh, tx, ty;
1038 if (ow > gw) ax = (ow - gw) / 2;
1039 if (oh > gh) ay = (oh - gh) / 2;
1041 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1042 Eina_Matrixsparse_Cell *cell;
1044 EINA_ITERATOR_FOREACH(it, cell)
1046 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1052 if ((gw != g->w) && (g->w > 0))
1055 xx = ((long long )gw * xx) / g->w;
1056 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1058 if ((gh != g->h) && (g->h > 0))
1061 yy = ((long long)gh * yy) / g->h;
1062 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1064 evas_object_move(gi->img,
1068 evas_object_resize(gi->img, ww, hh);
1070 obj_rotate_zoom(obj, gi->img);
1071 /*evas_object_move(gi->txt,
1075 evas_object_resize(gi->txt, ww, hh);
1078 eina_iterator_free(it);
1082 grid_clear(Evas_Object *obj, Grid *g)
1084 ELM_CHECK_WIDTYPE(obj, widtype);
1085 Widget_Data *wd = elm_widget_data_get(obj);
1089 if (!g->grid) return;
1091 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1092 Eina_Matrixsparse_Cell *cell;
1094 snprintf(buf, sizeof(buf), DEST_DIR_ZOOM_PATH, wd->id, g->zoom);
1095 ecore_file_recursive_rm(buf);
1097 EINA_ITERATOR_FOREACH(it, cell)
1099 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1100 evas_object_del(gi->img);
1101 //evas_object_del(gi->txt);
1105 gi->want = EINA_FALSE;
1107 if (!wd->preload_num)
1109 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1110 "elm,state,busy,stop", "elm");
1111 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
1117 DBG("DOWNLOAD abort %s", gi->file);
1118 ecore_file_download_abort(gi->job);
1119 ecore_file_remove(gi->file);
1124 eina_stringshare_del(gi->file);
1128 eina_matrixsparse_free(g->grid);
1129 eina_iterator_free(it);
1136 _tile_update(Grid_Item *gi)
1138 gi->want = EINA_FALSE;
1139 gi->download = EINA_FALSE;
1140 evas_object_image_file_set(gi->img, gi->file, NULL);
1141 if (evas_object_image_load_error_get(gi->img) != EVAS_LOAD_ERROR_NONE)
1142 ecore_file_remove(gi->file);
1144 obj_rotate_zoom(gi->wd->obj, gi->img);
1145 evas_object_show(gi->img);
1147 //evas_object_text_text_set(gi->txt, gi->file);
1148 //evas_object_show(gi->txt);
1150 gi->have = EINA_TRUE;
1151 gi->wd->preload_num--;
1152 if (!gi->wd->preload_num)
1154 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
1155 "elm,state,busy,stop", "elm");
1156 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
1162 _tile_downloaded(void *data, const char *file __UNUSED__, int status)
1164 Grid_Item *gi = data;
1166 gi->download = EINA_FALSE;
1169 DBG("DOWNLOAD done %s", gi->file);
1170 if ((gi->want) && (!status)) _tile_update(gi);
1174 DBG("Download failed %s (%d) ", gi->file, status);
1175 ecore_file_remove(gi->file);
1178 gi->wd->finish_num++;
1180 evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL);
1184 grid_create(Evas_Object *obj)
1186 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1187 Widget_Data *wd = elm_widget_data_get(obj);
1190 if ((!wd) || (!wd->src)) return NULL;
1191 g = calloc(1, sizeof(Grid));
1194 g->tsize = wd->tsize;
1197 if (g->zoom > wd->src->zoom_max) return NULL;
1198 if (g->zoom < wd->src->zoom_min) return NULL;
1200 int size = pow(2.0, wd->zoom);
1204 g->w = g->tsize * g->gw;
1205 g->h = g->tsize * g->gh;
1207 g->grid = eina_matrixsparse_new(g->gh, g->gw, NULL, NULL);
1213 grid_load(Evas_Object *obj, Grid *g)
1215 ELM_CHECK_WIDTYPE(obj, widtype);
1216 Widget_Data *wd = elm_widget_data_get(obj);
1219 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
1221 Eina_Matrixsparse_Cell *cell;
1224 if ((!wd) || (!wd->src)) return;
1225 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
1226 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
1231 if ((gw <= 0) || (gh <= 0)) return;
1234 if ((gw != g->w) && (g->w > 0))
1235 size = ((long long)gw * size) / g->w;
1236 if (size < (g->tsize / 2)) return; // else we will load to much tiles
1238 it = eina_matrixsparse_iterator_new(g->grid);
1240 EINA_ITERATOR_FOREACH(it, cell)
1242 gi = eina_matrixsparse_cell_data_get(cell);
1249 if ((gw != g->w) && (g->w > 0))
1252 xx = ((long long )gw * xx) / g->w;
1253 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1255 if ((gh != g->h) && (g->h > 0))
1258 yy = ((long long)gh * yy) / g->h;
1259 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1262 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
1263 yy - wd->pan_y + oy,
1265 cvx, cvy, cvw, cvh))
1269 evas_object_hide(gi->img);
1270 //evas_object_hide(gi->txt);
1271 evas_object_image_file_set(gi->img, NULL, NULL);
1272 gi->want = EINA_FALSE;
1273 gi->have = EINA_FALSE;
1277 DBG("DOWNLOAD abort %s", gi->file);
1278 ecore_file_download_abort(gi->job);
1279 ecore_file_remove(gi->file);
1283 gi->download = EINA_FALSE;
1285 if (!wd->preload_num)
1287 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1288 "elm,state,busy,stop", "elm");
1289 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL,
1296 evas_object_hide(gi->img);
1297 //evas_object_hide(gi->txt);
1298 evas_object_image_preload(gi->img, 1);
1299 evas_object_image_file_set(gi->img, NULL, NULL);
1300 gi->have = EINA_FALSE;
1301 gi->want = EINA_FALSE;
1305 eina_iterator_free(it);
1307 xx = wd->pan_x / size - 1;
1310 yy = wd->pan_y / size - 1;
1314 if (xx + ww >= g->gw) ww = g->gw - xx - 1;
1317 if (yy + hh >= g->gh) hh = g->gh - yy - 1;
1319 for (y = yy; y <= yy + hh; y++)
1321 for (x = xx; x <= xx + ww; x++)
1323 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
1325 if ((!gi) && (g != eina_list_data_get(wd->grids)))
1330 gi = calloc(1, sizeof(Grid_Item));
1331 gi->src.x = x * g->tsize;
1332 gi->src.y = y * g->tsize;
1333 gi->src.w = g->tsize;
1334 gi->src.h = g->tsize;
1336 gi->out.x = gi->src.x;
1337 gi->out.y = gi->src.y;
1338 gi->out.w = gi->src.w;
1339 gi->out.h = gi->src.h;
1343 gi->img = evas_object_image_add(evas_object_evas_get(obj));
1344 evas_object_image_scale_hint_set
1345 (gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1346 evas_object_image_filled_set(gi->img, 1);
1348 evas_object_smart_member_add(gi->img, wd->pan_smart);
1349 elm_widget_sub_object_add(obj, gi->img);
1350 evas_object_pass_events_set(gi->img, EINA_TRUE);
1351 evas_object_stack_below(gi->img, wd->sep_maps_markers);
1353 /* gi->txt = evas_object_text_add(evas_object_evas_get(obj));
1354 evas_object_text_font_set(gi->txt, "Vera", 12);
1355 evas_object_color_set(gi->txt, 100, 100, 100, 255);
1356 evas_object_smart_member_add(gi->txt,
1358 elm_widget_sub_object_add(obj, gi->txt);
1359 evas_object_pass_events_set(gi->txt, EINA_TRUE);
1361 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
1364 if ((!gi->have) && (!gi->download))
1366 char buf[PATH_MAX], buf2[PATH_MAX];
1369 gi->want = EINA_TRUE;
1371 snprintf(buf, sizeof(buf), DEST_DIR_PATH, wd->id, g->zoom, x);
1372 if (!ecore_file_exists(buf))
1373 ecore_file_mkpath(buf);
1375 snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y);
1377 source = wd->src->url_cb(obj, x, y, g->zoom);
1378 if ((!source) || (strlen(source)==0)) continue;
1380 eina_stringshare_replace(&gi->file, buf2);
1382 if ((ecore_file_exists(buf2)) || (g == eina_list_data_get(wd->grids)))
1384 gi->download = EINA_TRUE;
1386 if (wd->preload_num == 1)
1388 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1389 "elm,state,busy,start", "elm");
1390 evas_object_smart_callback_call(obj,
1395 if (ecore_file_exists(buf2))
1399 DBG("DOWNLOAD %s \t in %s", source, buf2);
1400 ecore_file_download_full(source, buf2, _tile_downloaded, NULL, gi, &(gi->job), wd->ua);
1402 DBG("Can't start to download %s", buf);
1407 if (source) free(source);
1411 obj_rotate_zoom(obj, gi->img);
1412 evas_object_show(gi->img);
1419 grid_clearall(Evas_Object *obj)
1421 ELM_CHECK_WIDTYPE(obj, widtype);
1422 Widget_Data *wd = elm_widget_data_get(obj);
1426 EINA_LIST_FREE(wd->grids, g)
1434 _smooth_update(Evas_Object *obj)
1436 ELM_CHECK_WIDTYPE(obj, widtype);
1437 Widget_Data *wd = elm_widget_data_get(obj);
1442 EINA_LIST_FOREACH(wd->grids, l, g)
1444 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1445 Eina_Matrixsparse_Cell *cell;
1447 EINA_ITERATOR_FOREACH(it, cell)
1449 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1450 evas_object_image_smooth_scale_set(gi->img, (!wd->nosmooth));
1452 eina_iterator_free(it);
1457 _scr_timeout(void *data)
1459 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1460 Widget_Data *wd = elm_widget_data_get(data);
1462 if (!wd) return ECORE_CALLBACK_CANCEL;
1464 if (!wd->nosmooth) _smooth_update(data);
1465 wd->scr_timer = NULL;
1466 return ECORE_CALLBACK_CANCEL;
1470 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1472 ELM_CHECK_WIDTYPE(data, widtype);
1473 Widget_Data *wd = elm_widget_data_get(data);
1479 if (wd->nosmooth == 1) _smooth_update(data);
1481 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1482 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
1486 zoom_do(Evas_Object *obj)
1488 ELM_CHECK_WIDTYPE(obj, widtype);
1489 Widget_Data *wd = elm_widget_data_get(obj);
1490 Evas_Coord xx, yy, ow, oh;
1493 wd->size.w = wd->size.nw;
1494 wd->size.h = wd->size.nh;
1496 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
1498 if (wd->center_on.enabled)
1500 elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy);
1506 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
1507 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
1512 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
1514 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
1516 wd->show.show = EINA_TRUE;
1522 if (wd->calc_job) ecore_job_del(wd->calc_job);
1523 wd->calc_job = ecore_job_add(_calc_job, wd);
1527 _zoom_timeout(void *data)
1529 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1530 Widget_Data *wd = elm_widget_data_get(data);
1532 if (!wd) return ECORE_CALLBACK_CANCEL;
1533 wd->zoom_timer = NULL;
1534 wd->pinch.level = 1.0;
1536 evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
1537 return ECORE_CALLBACK_CANCEL;
1541 _zoom_anim(void *data)
1543 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1544 Evas_Object *obj = data;
1545 Widget_Data *wd = elm_widget_data_get(obj);
1547 if (!wd) return ECORE_CALLBACK_CANCEL;
1548 if (wd->zoom_method == ZOOM_METHOD_IN) wd->t += 0.1 ;
1549 else if (wd->zoom_method == ZOOM_METHOD_OUT) wd->t -= 0.05;
1552 wd->zoom_animator = NULL;
1554 evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
1555 return ECORE_CALLBACK_CANCEL;
1560 wd->zoom_animator = NULL;
1561 wd->pinch.level = 2.0;
1562 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1563 wd->zoom_timer = ecore_timer_add(0.35, _zoom_timeout, obj);
1564 return ECORE_CALLBACK_CANCEL;
1566 else if (wd->t <= 0.5)
1568 wd->zoom_animator = NULL;
1569 wd->pinch.level = 0.5;
1570 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1571 wd->zoom_timer = ecore_timer_add(1.35, _zoom_timeout, obj);
1572 return ECORE_CALLBACK_CANCEL;
1574 else if (wd->t != 1.0)
1576 Evas_Coord x, y, w, h;
1577 float half_w, half_h;
1578 evas_object_geometry_get(data, &x, &y, &w, &h);
1579 half_w = (float)w * 0.5;
1580 half_h = (float)h * 0.5;
1581 wd->pinch.cx = x + half_w;
1582 wd->pinch.cy = y + half_h;
1583 wd->pinch.level = wd->t;
1584 if (wd->calc_job) ecore_job_del(wd->calc_job);
1585 wd->calc_job = ecore_job_add(_calc_job, wd);
1587 return ECORE_CALLBACK_RENEW;
1591 _long_press(void *data)
1593 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1594 Widget_Data *wd = elm_widget_data_get(data);
1596 if (!wd) return ECORE_CALLBACK_CANCEL;
1597 wd->long_timer = NULL;
1598 evas_object_smart_callback_call(data, SIG_LONGPRESSED, &wd->ev);
1599 return ECORE_CALLBACK_CANCEL;
1603 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1605 ELM_CHECK_WIDTYPE(data, widtype);
1606 Widget_Data *wd = elm_widget_data_get(data);
1607 Evas_Event_Mouse_Down *ev = event_info;
1611 ev0 = get_event_object(data, 0);
1613 ev0 = create_event_object(data, obj, 0);
1616 ev0->hold_timer = NULL;
1617 ev0->prev.x = ev->output.x;
1618 ev0->prev.y = ev->output.y;
1620 if (ev->button != 1) return;
1621 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1622 else wd->on_hold = EINA_FALSE;
1623 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1624 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, ev);
1626 evas_object_smart_callback_call(data, SIG_PRESS, ev);
1627 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1628 wd->ev.output.x = ev->output.x;
1629 wd->ev.output.y = ev->output.y;
1630 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1634 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1636 Evas_Event_Mouse_Move *move = event_info;
1639 ev0 = get_event_object(data, 0);
1641 ev0->prev.x = move->cur.output.x;
1642 ev0->prev.y = move->cur.output.y;
1646 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1648 ELM_CHECK_WIDTYPE(data, widtype);
1649 Widget_Data *wd = elm_widget_data_get(data);
1652 Evas_Event_Mouse_Up *ev = event_info;
1657 ev0 = get_event_object(data, 0);
1660 mdevice = get_multi_device(data);
1663 if (ev0->hold_timer)
1665 ecore_timer_del(ev0->hold_timer);
1666 ev0->hold_timer = NULL;
1668 elm_smart_scroller_hold_set(wd->scr, 0);
1669 elm_smart_scroller_freeze_set(wd->scr, 0);
1673 ev1 = get_event_object(data, mdevice);
1675 ev1->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev1);
1677 destroy_event_object(data, ev0);
1680 if (ev->button != 1) return;
1681 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1682 else wd->on_hold = EINA_FALSE;
1685 ecore_timer_del(wd->long_timer);
1686 wd->long_timer = NULL;
1688 if (!wd->on_hold) evas_object_smart_callback_call(data, SIG_CLICKED, ev);
1689 wd->on_hold = EINA_FALSE;
1693 _mouse_multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1695 ELM_CHECK_WIDTYPE(data, widtype);
1696 Widget_Data *wd = elm_widget_data_get(data);
1698 Evas_Event_Multi_Down *down = event_info;
1700 elm_smart_scroller_hold_set(wd->scr, 1);
1701 elm_smart_scroller_freeze_set(wd->scr, 1);
1703 ev = create_event_object(data, obj, down->device);
1706 DBG("Failed : create_event_object");
1711 ev->hold_timer = NULL;
1712 ev->start.x = ev->prev.x = down->output.x;
1713 ev->start.y = ev->prev.y = down->output.y;
1714 ev->pinch_start_dis = 0;
1715 wd->pinch.level = 1.0;
1716 wd->pinch.diff = 1.0;
1721 ecore_timer_del(wd->long_timer);
1722 wd->long_timer = NULL;
1728 _mouse_multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1730 ELM_CHECK_WIDTYPE(data, widtype);
1731 Widget_Data *wd = elm_widget_data_get(data);
1732 Evas_Event_Multi_Move *move = event_info;
1734 double t, tt, a, a_diff;
1738 if ((!wd) || (!wd->src)) return;
1739 ev = get_event_object(data, move->device);
1742 ev0 = get_event_object(data, 0);
1745 if (wd->multi_count >= 1)
1747 Evas_Coord x, y, w, h;
1748 float half_w, half_h;
1750 evas_object_geometry_get(data, &x, &y, &w, &h);
1751 half_w = (float)w * 0.5;
1752 half_h = (float)h * 0.5;
1753 dis_new = get_distance(ev0->prev.x, ev0->prev.y, ev->prev.x, ev->prev.y);
1755 if (!ev->pinch_start_dis) ev->pinch_start_dis = dis_new;
1758 ev->pinch_dis = dis_new;
1759 tt = wd->pinch.diff;
1760 wd->pinch.diff = (double)(ev->pinch_dis - ev->pinch_start_dis);
1761 t = (wd->pinch.diff * 0.01) + 1.0;
1762 if (((wd->zoom + (int)t - 1) < wd->src->zoom_min) ||
1763 ((wd->zoom + (int)t - 1) > wd->src->zoom_max) ||
1764 (t > PINCH_ZOOM_MAX) || (t < PINCH_ZOOM_MIN))
1766 wd->pinch.diff = tt;
1771 wd->pinch.level = (wd->pinch.diff * 0.01) + 1.0;
1772 wd->pinch.cx = x + half_w;
1773 wd->pinch.cy = y + half_h;
1776 a = (double)(ev->prev.y - ev0->prev.y) / (double)(ev->prev.x - ev0->prev.x);
1777 if (!wd->rotate.a) wd->rotate.a = a;
1780 a_diff = wd->rotate.a - a;
1781 if (a_diff > 0) wd->rotate.d -= 1.0;
1782 else if (a_diff < 0) wd->rotate.d += 1.0;
1784 wd->rotate.cx = x + half_w;
1785 wd->rotate.cy = y + half_h;
1788 if (wd->calc_job) ecore_job_del(wd->calc_job);
1789 wd->calc_job = ecore_job_add(_calc_job, wd);
1793 ev->prev.x = move->cur.output.x;
1794 ev->prev.y = move->cur.output.y;
1798 _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1800 ELM_CHECK_WIDTYPE(data, widtype);
1801 Widget_Data *wd = elm_widget_data_get(data);
1802 Evas_Event_Multi_Up *up = event_info;
1809 if (wd->calc_job) ecore_job_del(wd->calc_job);
1810 if (wd->zoom_animator)
1812 ecore_animator_del(wd->zoom_animator);
1813 wd->zoom_animator = NULL;
1816 wd->paused = EINA_TRUE;
1817 if (wd->pinch.diff >= 0.0) zoom = (int)ceil((wd->pinch.diff * 0.01) - 1.0);
1818 else if (wd->pinch.diff < 0.0) zoom = (int)floor(-1.0 / ((wd->pinch.diff * 0.005) + 1.0));
1819 elm_map_zoom_set(data, wd->zoom + zoom);
1820 wd->pinch.level = 1.0;
1824 ev = get_event_object(data, up->device);
1827 DBG("Cannot get multi device");
1831 ev0 = get_event_object(data, 0);
1833 ev0->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev0);
1838 ecore_timer_del(ev->hold_timer);
1839 ev->hold_timer = NULL;
1842 destroy_event_object(data, ev);
1846 _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1848 ELM_CHECK_WIDTYPE(data, widtype);
1849 Widget_Data *wd = elm_widget_data_get(data);
1850 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
1851 Evas_Coord x, y, w, h;
1852 float half_w, half_h;
1855 evas_object_geometry_get(data, &x, &y, &w, &h);
1856 half_w = (float)w * 0.5;
1857 half_h = (float)h * 0.5;
1859 if (!wd->wheel_zoom) wd->wheel_zoom = 1.0;
1862 wd->zoom_method = ZOOM_METHOD_OUT;
1863 wd->wheel_zoom -= 0.05;
1864 if (wd->wheel_zoom <= PINCH_ZOOM_MIN) wd->wheel_zoom = PINCH_ZOOM_MIN;
1868 wd->zoom_method = ZOOM_METHOD_IN;
1869 wd->wheel_zoom += 0.2;
1870 if (wd->wheel_zoom >= PINCH_ZOOM_MAX) wd->wheel_zoom = PINCH_ZOOM_MAX;
1875 wd->pinch.level = wd->wheel_zoom;
1876 wd->pinch.cx = x + half_w;
1877 wd->pinch.cy = y + half_h;
1878 if (wd->calc_job) ecore_job_del(wd->calc_job);
1879 wd->calc_job = ecore_job_add(_calc_job, wd);
1882 if (wd->wheel_timer) ecore_timer_del(wd->wheel_timer);
1883 wd->wheel_timer = ecore_timer_add(0.35, _wheel_timer_cb, data);
1887 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
1890 _hold_timer_cb(void *data)
1894 ev0->hold_timer = NULL;
1895 return ECORE_CALLBACK_CANCEL;
1899 _wheel_timer_cb(void *data)
1901 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1902 Widget_Data *wd = elm_widget_data_get(data);
1907 wd->wheel_timer = NULL;
1908 return ECORE_CALLBACK_CANCEL;
1910 if (wd->zoom_method == ZOOM_METHOD_IN) zoom = (int)ceil(wd->wheel_zoom - 1.0);
1911 else if (wd->zoom_method == ZOOM_METHOD_OUT) zoom = (int)floor((-1.0 / wd->wheel_zoom) + 1.0);
1914 wd->wheel_timer = NULL;
1915 return ECORE_CALLBACK_CANCEL;
1917 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
1918 elm_map_zoom_set(data, wd->zoom + zoom);
1919 wd->wheel_zoom = 0.0;
1920 wd->wheel_timer = NULL;
1921 return ECORE_CALLBACK_CANCEL;
1925 _rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1927 ELM_CHECK_WIDTYPE(data, widtype);
1928 Widget_Data *wd = elm_widget_data_get(data);
1931 evas_object_geometry_get(wd->rect, &x, &y, &w, &h);
1932 evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h);
1933 evas_object_resize(wd->rect, w, h);
1934 evas_object_move(wd->rect, x, y);
1938 _del_hook(Evas_Object *obj)
1940 ELM_CHECK_WIDTYPE(obj, widtype);
1941 Widget_Data *wd = elm_widget_data_get(obj);
1942 Elm_Map_Group_Class *group_clas;
1943 Elm_Map_Marker_Class *marker_clas;
1949 Ecore_Event_Handler *h;
1954 EINA_LIST_FREE(wd->groups_clas, group_clas)
1956 if (group_clas->style)
1957 eina_stringshare_del(group_clas->style);
1961 EINA_LIST_FREE(wd->markers_clas, marker_clas)
1963 if (marker_clas->style)
1964 eina_stringshare_del(marker_clas->style);
1968 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
1970 destroy_event_object(obj, ev);
1973 EINA_LIST_FOREACH(wd->route, l, r)
1975 EINA_LIST_FREE(r->path, p)
1980 EINA_LIST_FREE(r->waypoint, w)
1982 if (w->point) eina_stringshare_del(w->point);
1986 EINA_LIST_FREE(r->nodes, n)
1988 if (n->pos.address) eina_stringshare_del(n->pos.address);
1992 EINA_LIST_FREE(r->handlers, h)
1994 ecore_event_handler_del(h);
1997 if (r->con_url) ecore_con_url_free(r->con_url);
1998 if (r->info.nodes) eina_stringshare_del(r->info.nodes);
1999 if (r->info.waypoints) eina_stringshare_del(r->info.waypoints);
2002 EINA_LIST_FREE(wd->names, na)
2004 if (na->address) free(na->address);
2005 if (na->handler) ecore_event_handler_del(na->handler);
2008 ecore_file_remove(na->ud.fname);
2010 na->ud.fname = NULL;
2014 if (wd->map) evas_map_free(wd->map);
2015 if (wd->source_names) free(wd->source_names);
2016 if (wd->calc_job) ecore_job_del(wd->calc_job);
2017 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
2018 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
2019 if (wd->long_timer) ecore_timer_del(wd->long_timer);
2020 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
2021 if (wd->ua) eina_hash_free(wd->ua);
2027 _del_pre_hook(Evas_Object *obj)
2029 ELM_CHECK_WIDTYPE(obj, widtype);
2030 Widget_Data *wd = elm_widget_data_get(obj);
2031 Marker_Group *group;
2032 Elm_Map_Marker *marker;
2034 Eina_Bool free_marker = EINA_TRUE;
2039 for (i = 0; i < ZOOM_MAX + 1; i++)
2041 if (!wd->markers[i]) continue;
2042 Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
2043 Eina_Matrixsparse_Cell *cell;
2045 EINA_ITERATOR_FOREACH(it, cell)
2047 l = eina_matrixsparse_cell_data_get(cell);
2048 EINA_LIST_FREE(l, group)
2050 EINA_LIST_FREE(group->markers, marker)
2052 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2053 _bubble_sc_hits_changed_cb, group);
2054 if (free_marker) free(marker);
2058 free_marker = EINA_FALSE;
2060 eina_iterator_free(it);
2061 eina_matrixsparse_free(wd->markers[i]);
2064 evas_object_del(wd->sep_maps_markers);
2065 evas_object_del(wd->pan_smart);
2066 wd->pan_smart = NULL;
2070 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
2072 ELM_CHECK_WIDTYPE(obj, widtype);
2073 Widget_Data *wd = elm_widget_data_get(obj);
2076 if (elm_widget_focus_get(obj))
2078 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
2079 evas_object_focus_set(wd->obj, EINA_TRUE);
2083 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
2084 evas_object_focus_set(wd->obj, EINA_FALSE);
2089 _theme_hook(Evas_Object *obj)
2091 ELM_CHECK_WIDTYPE(obj, widtype);
2092 Widget_Data *wd = elm_widget_data_get(obj);
2095 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
2096 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
2101 _sizing_eval(Evas_Object *obj)
2103 ELM_CHECK_WIDTYPE(obj, widtype);
2104 Widget_Data *wd = elm_widget_data_get(obj);
2105 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
2108 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
2109 evas_object_size_hint_min_set(obj, minw, minh);
2110 evas_object_size_hint_max_set(obj, maxw, maxh);
2114 _calc_job(void *data)
2116 Widget_Data *wd = data;
2117 Evas_Coord minw, minh;
2124 wd->resized = EINA_FALSE;
2125 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
2127 double tz = wd->zoom;
2129 elm_map_zoom_set(wd->obj, tz);
2132 if ((minw != wd->minw) || (minh != wd->minh))
2136 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
2137 _sizing_eval(wd->obj);
2139 wd->calc_job = NULL;
2140 evas_object_smart_changed(wd->pan_smart);
2144 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2146 Pan *sd = evas_object_smart_data_get(obj);
2148 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2151 evas_object_smart_changed(obj);
2155 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2157 Pan *sd = evas_object_smart_data_get(obj);
2159 if (x) *x = sd->wd->pan_x;
2160 if (y) *y = sd->wd->pan_y;
2164 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2166 Pan *sd = evas_object_smart_data_get(obj);
2169 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2170 ow = sd->wd->minw - ow;
2172 oh = sd->wd->minh - oh;
2179 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
2186 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2188 Pan *sd = evas_object_smart_data_get(obj);
2190 if (w) *w = sd->wd->minw;
2191 if (h) *h = sd->wd->minh;
2195 _pan_add(Evas_Object *obj)
2198 Evas_Object_Smart_Clipped_Data *cd;
2200 cd = evas_object_smart_data_get(obj);
2202 sd = calloc(1, sizeof(Pan));
2204 sd->__clipped_data = *cd;
2206 evas_object_smart_data_set(obj, sd);
2210 _pan_del(Evas_Object *obj)
2212 Pan *sd = evas_object_smart_data_get(obj);
2218 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2220 Pan *sd = evas_object_smart_data_get(obj);
2223 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2224 if ((ow == w) && (oh == h)) return;
2225 sd->wd->resized = EINA_TRUE;
2226 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2227 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2231 _pan_calculate(Evas_Object *obj)
2233 Pan *sd = evas_object_smart_data_get(obj);
2234 Evas_Coord ox, oy, ow, oh;
2238 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2239 rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2240 EINA_LIST_FOREACH(sd->wd->grids, l, g)
2242 if ((sd->wd->pinch.level == 1.0) || (sd->wd->pinch.level == 0.5)) grid_load(sd->wd->obj, g);
2243 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2244 marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2245 if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2250 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2252 Pan *sd = evas_object_smart_data_get(obj);
2254 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2255 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2259 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2261 ELM_CHECK_WIDTYPE(obj, widtype);
2262 Widget_Data *wd = elm_widget_data_get(obj);
2265 elm_smart_scroller_hold_set(wd->scr, 1);
2269 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2271 ELM_CHECK_WIDTYPE(obj, widtype);
2272 Widget_Data *wd = elm_widget_data_get(obj);
2275 elm_smart_scroller_hold_set(wd->scr, 0);
2279 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2281 ELM_CHECK_WIDTYPE(obj, widtype);
2282 Widget_Data *wd = elm_widget_data_get(obj);
2285 elm_smart_scroller_freeze_set(wd->scr, 1);
2289 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2291 ELM_CHECK_WIDTYPE(obj, widtype);
2292 Widget_Data *wd = elm_widget_data_get(obj);
2295 elm_smart_scroller_freeze_set(wd->scr, 0);
2299 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2301 evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
2305 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2307 evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
2311 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2313 Widget_Data *wd = elm_widget_data_get(data);
2314 wd->center_on.enabled = EINA_FALSE;
2315 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2319 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2321 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2325 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2327 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
2332 _group_object_create(Marker_Group *group)
2334 const char *style = "radio";
2335 Evas_Object *icon = NULL;
2337 if (group->obj) return;
2338 if ((!group->clas->priv.objs_notused) || (eina_list_count(group->markers) == 1))
2340 //set icon and style
2341 if (eina_list_count(group->markers) == 1)
2343 Elm_Map_Marker *m = eina_list_data_get(group->markers);
2345 style = m->clas->style;
2347 if (m->clas->func.icon_get)
2348 icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
2350 group->delete_object = EINA_TRUE;
2354 if (group->clas->style)
2355 style = group->clas->style;
2357 if (group->clas->func.icon_get)
2358 icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
2360 group->delete_object = EINA_FALSE;
2363 group->obj = elm_layout_add(group->wd->obj);
2364 elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
2366 if (icon) elm_layout_content_set(group->obj, "elm.icon", icon);
2368 evas_object_smart_member_add(group->obj, group->wd->pan_smart);
2369 elm_widget_sub_object_add(group->wd->obj, group->obj);
2370 evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
2372 if (!group->delete_object)
2373 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2377 group->delete_object = EINA_FALSE;
2379 group->obj = eina_list_data_get(group->clas->priv.objs_notused);
2380 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2381 group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
2382 evas_object_show(group->obj);
2385 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
2386 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
2388 group->update_nbelems = EINA_TRUE;
2389 group->update_resize = EINA_TRUE;
2390 group->update_raise = EINA_TRUE;
2392 if (group->open) _group_bubble_create(group);
2396 _group_object_free(Marker_Group *group)
2398 if (!group->obj) return;
2399 if (!group->delete_object)
2401 group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
2402 group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
2403 evas_object_hide(group->obj);
2405 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
2406 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
2409 evas_object_del(group->obj);
2412 _group_bubble_free(group);
2416 _group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2418 Marker_Group *group = data;
2420 if (!evas_object_above_get(group->rect)) return;
2421 evas_object_raise(group->bubble);
2422 evas_object_raise(group->sc);
2423 evas_object_raise(group->rect);
2427 _group_bubble_create(Marker_Group *group)
2429 if (group->bubble) return;
2431 group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
2432 group->bubble = edje_object_add(evas_object_evas_get(group->obj));
2433 _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
2434 elm_widget_style_get(group->wd->obj));
2435 evas_object_smart_member_add(group->bubble,
2437 elm_widget_sub_object_add(group->wd->obj, group->bubble);
2439 _group_bubble_content_free(group);
2440 if (!_group_bubble_content_update(group))
2442 //no content, we can delete the bubble
2443 _group_bubble_free(group);
2447 group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
2448 evas_object_color_set(group->rect, 0, 0, 0, 0);
2449 evas_object_repeat_events_set(group->rect, EINA_TRUE);
2450 evas_object_smart_member_add(group->rect, group->wd->obj);
2451 elm_widget_sub_object_add(group->wd->obj, group->rect);
2453 evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
2455 _group_bubble_place(group);
2458 static void _bubble_sc_hits_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2460 _group_bubble_place(data);
2464 _group_bubble_content_update(Marker_Group *group)
2467 Elm_Map_Marker *marker;
2470 if (!group->bubble) return 1;
2474 group->sc = elm_scroller_add(group->bubble);
2475 elm_widget_style_set(group->sc, "map_bubble");
2476 elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
2477 elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
2478 elm_scroller_bounce_set(group->sc, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
2479 edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
2480 evas_object_show(group->sc);
2481 evas_object_smart_member_add(group->sc,
2483 elm_widget_sub_object_add(group->wd->obj, group->sc);
2485 group->bx = elm_box_add(group->bubble);
2486 evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2487 evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
2488 elm_box_horizontal_set(group->bx, EINA_TRUE);
2489 evas_object_show(group->bx);
2491 elm_scroller_content_set(group->sc, group->bx);
2493 evas_object_event_callback_add(group->sc, EVAS_CALLBACK_RESIZE,
2494 _bubble_sc_hits_changed_cb, group);
2497 EINA_LIST_FOREACH(group->markers, l, marker)
2499 if (i >= group->wd->markers_max_num) break;
2500 if ((!marker->content) && (marker->clas->func.get))
2501 marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
2502 else if (marker->content)
2503 elm_box_unpack(group->bx, marker->content);
2504 if (marker->content)
2506 elm_box_pack_end(group->bx, marker->content);
2514 _group_bubble_content_free(Marker_Group *group)
2517 Elm_Map_Marker *marker;
2519 if (!group->sc) return;
2520 EINA_LIST_FOREACH(group->markers, l, marker)
2522 if ((marker->content) && (marker->clas->func.del))
2523 marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
2524 else if (marker->content)
2525 evas_object_del(marker->content);
2526 marker->content = NULL;
2528 evas_object_del(group->sc);
2533 _group_bubble_free(Marker_Group *group)
2535 if (!group->bubble) return;
2536 group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
2537 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2538 _bubble_sc_hits_changed_cb, group);
2539 evas_object_del(group->bubble);
2540 evas_object_del(group->rect);
2541 group->bubble = NULL;
2542 _group_bubble_content_free(group);
2546 _group_bubble_place(Marker_Group *group)
2549 Evas_Coord xx, yy, ww, hh;
2552 if ((!group->bubble) || (!group->obj)) return;
2554 evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
2555 edje_object_size_min_calc(group->bubble, NULL, &hh);
2557 s = edje_object_data_get(group->bubble, "size_w");
2558 if (s) ww = atoi(s);
2560 xx = x + w / 2 - ww / 2;
2563 evas_object_move(group->bubble, xx, yy);
2564 evas_object_resize(group->bubble, ww, hh);
2565 obj_rotate_zoom(group->wd, group->bubble);
2566 evas_object_show(group->bubble);
2568 evas_object_move(group->rect, xx, yy);
2569 evas_object_resize(group->rect, ww, hh);
2570 obj_rotate_zoom(group->wd, group->rect);
2571 evas_object_show(group->rect);
2575 _group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2577 Marker_Group *group = data;
2578 Elm_Map_Marker *marker = eina_list_data_get(group->markers);
2579 if (!marker) return;
2580 group->bringin = EINA_TRUE;
2581 elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
2585 _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2587 Marker_Group *group = data;
2591 group->bringin = EINA_FALSE;
2597 group->open = EINA_FALSE;
2598 _group_bubble_free(group);
2601 group->open = EINA_TRUE;
2602 _group_bubble_create(group);
2606 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
2608 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2609 Widget_Data *wd = elm_widget_data_get(obj);
2613 Evas_Coord step_x = 0;
2614 Evas_Coord step_y = 0;
2617 Evas_Coord page_x = 0;
2618 Evas_Coord page_y = 0;
2620 if (!wd) return EINA_FALSE;
2621 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
2622 Evas_Event_Key_Down *ev = event_info;
2623 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
2625 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
2626 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
2627 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
2628 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
2630 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
2634 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
2638 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
2642 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
2646 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
2649 y -= -(page_y * v_h) / 100;
2653 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
2656 y += -(page_y * v_h) / 100;
2660 else if (!strcmp(ev->keyname, "KP_Add"))
2662 zoom = elm_map_zoom_get(obj) + 1;
2663 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2664 elm_map_zoom_set(obj, zoom);
2667 else if (!strcmp(ev->keyname, "KP_Subtract"))
2669 zoom = elm_map_zoom_get(obj) - 1;
2670 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2671 elm_map_zoom_set(obj, zoom);
2674 else return EINA_FALSE;
2676 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2677 elm_smart_scroller_child_pos_set(wd->scr, x, y);
2683 cb_dump_name_attrs(void *data, const char *key, const char *value)
2685 Name_Dump *dump = (Name_Dump*)data;
2686 if (!dump) return EINA_FALSE;
2688 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
2689 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
2696 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2698 Route_Dump *dump = data;
2699 if (!dump) return EINA_FALSE;
2703 case EINA_SIMPLE_XML_OPEN:
2704 case EINA_SIMPLE_XML_OPEN_EMPTY:
2708 attrs = eina_simple_xml_tag_attributes_find(value, length);
2711 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
2712 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
2713 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
2714 else dump->id = ROUTE_XML_NONE;
2718 case EINA_SIMPLE_XML_DATA:
2720 char *buf = malloc(length);
2721 if (!buf) return EINA_FALSE;
2722 snprintf(buf, length, "%s", value);
2723 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
2724 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2725 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2737 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2739 Name_Dump *dump = data;
2740 if (!dump) return EINA_FALSE;
2744 case EINA_SIMPLE_XML_OPEN:
2745 case EINA_SIMPLE_XML_OPEN_EMPTY:
2748 attrs = eina_simple_xml_tag_attributes_find(value, length);
2751 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME;
2752 else dump->id = NAME_XML_NONE;
2754 eina_simple_xml_attributes_parse
2755 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
2759 case EINA_SIMPLE_XML_DATA:
2761 char *buf = malloc(length + 1);
2762 if (!buf) return EINA_FALSE;
2763 snprintf(buf, length + 1, "%s", value);
2764 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2776 _parse_kml(void *data)
2778 Elm_Map_Route *r = (Elm_Map_Route*)data;
2779 if (!r && !r->ud.fname) return;
2783 unsigned int ele, idx;
2787 Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL};
2789 f = fopen(r->ud.fname, "rb");
2794 fseek(f, 0, SEEK_END);
2800 fseek(f, 0, SEEK_SET);
2804 if (fread(buf, 1, sz, f))
2806 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump);
2813 if (dump.distance) r->info.distance = dump.distance;
2814 if (dump.description)
2816 eina_stringshare_replace(&r->info.waypoints, dump.description);
2817 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2818 r->info.waypoint_count = ele;
2819 for (idx = 0 ; idx < ele ; idx++)
2821 Route_Waypoint *wp = ELM_NEW(Route_Waypoint);
2825 wp->point = eina_stringshare_add(str[idx]);
2826 DBG("%s", str[idx]);
2827 r->waypoint = eina_list_append(r->waypoint, wp);
2836 else WRN("description is not found !");
2838 if (dump.coordinates)
2840 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2841 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2842 r->info.node_count = ele;
2843 for (idx = 0 ; idx < ele ; idx++)
2845 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2846 Route_Node *n = ELM_NEW(Route_Node);
2853 DBG("%lf:%lf", lon, lat);
2854 n->pos.address = NULL;
2855 r->nodes = eina_list_append(r->nodes, n);
2857 path = evas_object_polygon_add(evas_object_evas_get(r->wd->obj));
2858 evas_object_smart_member_add(path, r->wd->pan_smart);
2859 r->path = eina_list_append(r->path, path);
2872 _parse_name(void *data)
2874 Elm_Map_Name *n = (Elm_Map_Name*)data;
2875 if (!n && !n->ud.fname) return;
2879 Name_Dump dump = {0, NULL, 0.0, 0.0};
2881 f = fopen(n->ud.fname, "rb");
2886 fseek(f, 0, SEEK_END);
2892 fseek(f, 0, SEEK_SET);
2896 if (fread(buf, 1, sz, f))
2898 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
2907 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
2908 n->address = strdup(dump.address);
2916 _route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
2918 Ecore_Con_Event_Url_Complete *ev = event;
2919 Elm_Map_Route *r = (Elm_Map_Route*)data;
2920 Widget_Data *wd = r->wd;
2922 if ((!r) || (!ev)) return EINA_TRUE;
2923 Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url);
2924 ecore_con_url_data_set(r->con_url, NULL);
2925 if (r!=rr) return EINA_TRUE;
2927 if (r->ud.fd) fclose(r->ud.fd);
2932 Evas_Coord ox, oy, ow, oh;
2933 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
2934 route_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
2936 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2937 "elm,state,busy,stop", "elm");
2938 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
2943 _name_complete_cb(void *data, int ev_type __UNUSED__, void *event)
2945 Ecore_Con_Event_Url_Complete *ev = event;
2946 Elm_Map_Name *n = (Elm_Map_Name*)data;
2947 Widget_Data *wd = n->wd;
2949 if ((!n) || (!ev)) return EINA_TRUE;
2950 Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url);
2951 ecore_con_url_data_set(n->con_url, NULL);
2952 if (n!=nn) return EINA_TRUE;
2954 if (n->ud.fd) fclose(n->ud.fd);
2957 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2958 "elm,state,busy,stop", "elm");
2959 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
2963 static Elm_Map_Name *
2964 _utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat)
2966 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2967 Widget_Data *wd = elm_widget_data_get(obj);
2972 if ((!wd) || (!wd->src)) return NULL;
2973 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
2974 if (!name) return NULL;
2976 snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE);
2984 name->con_url = ecore_con_url_new(NULL);
2985 name->ud.fname = strdup(buf);
2986 INF("xml file : %s", name->ud.fname);
2988 name->ud.fd = fdopen(fd, "w+");
2989 if ((!name->con_url) || (!name->ud.fd))
2991 ecore_con_url_free(name->con_url);
2997 name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name);
2998 name->method = method;
2999 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
3000 else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL;
3004 source = wd->src->name_url_cb(wd->obj, method, address, lon, lat);
3005 INF("name url = %s", source);
3007 wd->names = eina_list_append(wd->names, name);
3008 ecore_con_url_url_set(name->con_url, source);
3009 ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd));
3010 ecore_con_url_data_set(name->con_url, name);
3012 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3013 "elm,state,busy,start", "elm");
3014 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL);
3015 ecore_con_url_get(name->con_url);
3016 if (source) free(source);
3022 static int idnum = 1;
3025 * Add a new Map object
3027 * @param parent The parent object
3028 * @return The new object or NULL if it cannot be created
3033 elm_map_add(Evas_Object *parent)
3037 Evas_Coord minw, minh;
3039 static Evas_Smart *smart = NULL;
3040 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
3042 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3044 ELM_SET_WIDTYPE(widtype, "map");
3045 elm_widget_type_set(obj, "map");
3046 elm_widget_sub_object_add(parent, obj);
3047 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3048 elm_widget_data_set(obj, wd);
3049 elm_widget_del_hook_set(obj, _del_hook);
3050 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3051 elm_widget_theme_hook_set(obj, _theme_hook);
3052 elm_widget_can_focus_set(obj, EINA_TRUE);
3053 elm_widget_event_hook_set(obj, _event_hook);
3055 wd->scr = elm_smart_scroller_add(e);
3056 elm_smart_scroller_widget_set(wd->scr, obj);
3057 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
3058 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
3059 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
3060 elm_widget_resize_object_set(obj, wd->scr);
3061 elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE);
3063 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3064 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3065 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3066 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3067 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
3069 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
3073 wd->map = evas_map_new(4);
3074 if (!wd->map) return NULL;
3076 wd->markers_max_num = 30;
3077 wd->pinch.level = 1.0;
3079 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3080 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3081 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3082 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3086 static Evas_Smart_Class sc;
3088 evas_object_smart_clipped_smart_set(&_pan_sc);
3090 sc.name = "elm_map_pan";
3091 sc.version = EVAS_SMART_CLASS_VERSION;
3094 sc.resize = _pan_resize;
3095 sc.move = _pan_move;
3096 sc.calculate = _pan_calculate;
3097 smart = evas_smart_class_new(&sc);
3101 wd->pan_smart = evas_object_smart_add(e, smart);
3102 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3106 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3107 _pan_set, _pan_get, _pan_max_get,
3108 _pan_min_get, _pan_child_size_get);
3110 wd->rect = evas_object_rectangle_add(e);
3111 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_RESIZE,
3112 _rect_resize_cb, obj);
3113 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
3115 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_MOVE,
3117 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
3119 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_DOWN,
3120 _mouse_multi_down, obj);
3121 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_MOVE,
3122 _mouse_multi_move, obj);
3123 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP,
3124 _mouse_multi_up, obj);
3125 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL,
3126 _mouse_wheel_cb, obj);
3128 evas_object_smart_member_add(wd->rect, wd->pan_smart);
3129 elm_widget_sub_object_add(obj, wd->rect);
3130 evas_object_show(wd->rect);
3131 evas_object_color_set(wd->rect, 0, 0, 0, 0);
3133 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
3134 wd->id = ((int)getpid() << 16) | idnum;
3138 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3140 evas_object_size_hint_min_set(obj, minw, minh);
3142 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
3143 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
3145 wd->paused = EINA_TRUE;
3146 elm_map_zoom_set(obj, 0);
3147 wd->paused = EINA_FALSE;
3150 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3151 // TODO: and save some bytes, making descriptions per-class and not instance!
3152 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3154 if (!ecore_file_download_protocol_available("http://"))
3156 ERR("Ecore must be built with curl support for the map widget!");
3163 * Set the zoom level of the map
3165 * This sets the zoom level. 0 is the world map and 18 is the maximum zoom.
3167 * @param obj The map object
3168 * @param zoom The zoom level to set
3173 elm_map_zoom_set(Evas_Object *obj, int zoom)
3175 ELM_CHECK_WIDTYPE(obj, widtype);
3176 Widget_Data *wd = elm_widget_data_get(obj);
3178 Grid *g, *g_zoom = NULL;
3179 Evas_Coord rx, ry, rw, rh;
3182 int z = 0, zoom_changed = 0, started = 0;
3184 if ((!wd) || (!wd->src) || (wd->zoom_animator)) return;
3185 if (zoom < 0 ) zoom = 0;
3186 if (zoom > wd->src->zoom_max) zoom = wd->src->zoom_max;
3187 if (zoom < wd->src->zoom_min) zoom = wd->src->zoom_min;
3189 if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT;
3190 else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN;
3191 else wd->zoom_method = ZOOM_METHOD_NONE;
3192 if (wd->zoom != zoom ) zoom_changed = 1;
3194 wd->size.ow = wd->size.w;
3195 wd->size.oh = wd->size.h;
3196 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
3197 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3199 EINA_LIST_FOREACH(wd->route, l, r)
3203 EINA_LIST_FOREACH(r->path, l, p)
3205 evas_object_polygon_points_clear(p);
3210 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3217 while (cumulw <= rw)
3226 while (cumulh <= rh)
3233 if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3235 if (p2w < p2h) z = p2w;
3238 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3240 if (p2w > p2h) z = p2w;
3245 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3246 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3248 g = grid_create(obj);
3251 if (eina_list_count(wd->grids) > 1)
3253 g_zoom = eina_list_last(wd->grids)->data;
3254 wd->grids = eina_list_remove(wd->grids, g_zoom);
3255 grid_clear(obj, g_zoom);
3258 wd->grids = eina_list_prepend(wd->grids, g);
3262 EINA_LIST_FREE(wd->grids, g)
3270 if ((wd->size.w > 0) && (wd->size.h > 0))
3272 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow;
3273 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.oh;
3277 wd->size.spos.x = 0.5;
3278 wd->size.spos.y = 0.5;
3281 if (rw > wd->size.ow) wd->size.spos.x = 0.5;
3282 if (rh > wd->size.oh) wd->size.spos.y = 0.5;
3283 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
3284 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
3289 if (wd->calc_job) ecore_job_del(wd->calc_job);
3290 wd->calc_job = ecore_job_add(_calc_job, wd);
3294 if (!wd->zoom_animator)
3296 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
3298 if (wd->nosmooth == 1) _smooth_update(obj);
3305 if (started) evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
3306 if (!wd->zoom_animator) evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3309 if (zoom_changed) evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
3313 * Get the zoom level of the map
3315 * This returns the current zoom level of the map object. Note that if
3316 * you set the fill mode to other than ELM_MAP_ZOOM_MODE_MANUAL
3317 * (which is the default), the zoom level may be changed at any time by the
3318 * map object itself to account for map size and map viewpoer size
3320 * @param obj The map object
3321 * @return The current zoom level
3326 elm_map_zoom_get(const Evas_Object *obj)
3328 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3329 Widget_Data *wd = elm_widget_data_get(obj);
3338 * This sets the zoom mode to manual or one of several automatic levels.
3339 * Manual (ELM_MAP_ZOOM_MODE_MANUAL) means that zoom is set manually by
3340 * elm_map_zoom_set() and will stay at that level until changed by code
3341 * or until zoom mode is changed. This is the default mode.
3342 * The Automatic modes will allow the map object to automatically
3343 * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT will
3344 * adjust zoom so the map fits inside the scroll frame with no pixels
3345 * outside this area. ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but
3346 * 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.
3348 * @param obj The map object
3349 * @param mode The desired mode
3354 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
3356 ELM_CHECK_WIDTYPE(obj, widtype);
3357 Widget_Data *wd = elm_widget_data_get(obj);
3360 if (wd->mode == mode) return;
3363 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3367 elm_map_zoom_set(wd->obj, tz);
3374 * This gets the current zoom mode of the map object
3376 * @param obj The map object
3377 * @return The current zoom mode
3381 EAPI Elm_Map_Zoom_Mode
3382 elm_map_zoom_mode_get(const Evas_Object *obj)
3384 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
3385 Widget_Data *wd = elm_widget_data_get(obj);
3387 if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
3392 * Centers the map at @p lon @p lat using an animation to scroll.
3394 * @param obj The map object
3395 * @param lon Longitude to center at
3396 * @param lon Latitude to center at
3401 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
3403 ELM_CHECK_WIDTYPE(obj, widtype);
3404 Widget_Data *wd = elm_widget_data_get(obj);
3408 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3409 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3414 if (wd->zoom_animator)
3417 if (!wd->nosmooth) _smooth_update(obj);
3418 ecore_animator_del(wd->zoom_animator);
3419 wd->zoom_animator = NULL;
3421 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3423 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
3425 wd->center_on.enabled = EINA_TRUE;
3426 wd->center_on.lon = lon;
3427 wd->center_on.lat = lat;
3431 * Move the map to the current coordinates.
3433 * This move the map to the current coordinates. The map will be centered on these coordinates.
3435 * @param obj The map object
3436 * @param lat The latitude.
3437 * @param lon The longitude.
3442 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
3444 ELM_CHECK_WIDTYPE(obj, widtype);
3445 Widget_Data *wd = elm_widget_data_get(obj);
3449 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3450 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3455 if (wd->zoom_animator)
3458 ecore_animator_del(wd->zoom_animator);
3459 wd->zoom_animator = NULL;
3461 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3463 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
3465 wd->center_on.enabled = EINA_TRUE;
3466 wd->center_on.lon = lon;
3467 wd->center_on.lat = lat;
3471 * Get the current coordinates of the map.
3473 * This gets the current coordinates of the map object.
3475 * @param obj The map object
3476 * @param lat The latitude.
3477 * @param lon The longitude.
3482 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
3484 ELM_CHECK_WIDTYPE(obj, widtype);
3485 Widget_Data *wd = elm_widget_data_get(obj);
3486 Evas_Coord sx, sy, sw, sh;
3489 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
3490 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
3494 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
3498 * Set the paused state for map
3500 * This sets the paused state to on (1) or off (0) for map. The default
3501 * is off. This will stop zooming using animation change zoom levels and
3502 * change instantly. This will stop any existing animations that are running.
3504 * @param obj The map object
3505 * @param paused The pause state to set
3510 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
3512 ELM_CHECK_WIDTYPE(obj, widtype);
3513 Widget_Data *wd = elm_widget_data_get(obj);
3516 if (wd->paused == !!paused) return;
3517 wd->paused = paused;
3520 if (wd->zoom_animator)
3522 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
3523 wd->zoom_animator = NULL;
3525 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3531 * Set the paused state for the markers
3533 * This sets the paused state to on (1) or off (0) for the markers. The default
3534 * is off. This will stop displaying the markers during change zoom levels. Set
3535 * to on if you have a large number of markers.
3537 * @param obj The map object
3538 * @param paused The pause state to set
3543 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
3545 ELM_CHECK_WIDTYPE(obj, widtype);
3546 Widget_Data *wd = elm_widget_data_get(obj);
3549 if (wd->paused_markers == !!paused) return;
3550 wd->paused_markers = paused;
3554 * Get the paused state for map
3556 * This gets the current paused state for the map object.
3558 * @param obj The map object
3559 * @return The current paused state
3564 elm_map_paused_get(const Evas_Object *obj)
3566 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3567 Widget_Data *wd = elm_widget_data_get(obj);
3569 if (!wd) return EINA_FALSE;
3574 * Get the paused state for the markers
3576 * This gets the current paused state for the markers object.
3578 * @param obj The map object
3579 * @return The current paused state
3584 elm_map_paused_markers_get(const Evas_Object *obj)
3586 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3587 Widget_Data *wd = elm_widget_data_get(obj);
3589 if (!wd) return EINA_FALSE;
3590 return wd->paused_markers;
3594 * Get the information of downloading status
3596 * This gets the current downloading status for the map object.
3598 * @param obj The map object
3599 * @param try_num the number of download trying map
3600 * @param finish_num the number of downloaded map
3606 elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
3608 ELM_CHECK_WIDTYPE(obj, widtype);
3609 Widget_Data *wd = elm_widget_data_get(obj);
3614 *try_num = wd->try_num;
3619 *finish_num = wd->finish_num;
3623 * Convert a pixel coordinate (x,y) into a geographic coordinate (longitude, latitude).
3625 * @param obj The map object
3626 * @param x the coordinate
3627 * @param y the coordinate
3628 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
3629 * @param lon the longitude correspond to x
3630 * @param lat the latitude correspond to y
3635 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
3637 ELM_CHECK_WIDTYPE(obj, widtype);
3638 Widget_Data *wd = elm_widget_data_get(obj);
3641 int zoom = floor(log(size / 256) / log(2));
3642 if ((wd->src) && (wd->src->coord_into_geo))
3644 if (wd->src->coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
3649 *lon = x / (double)size * 360.0 - 180;
3653 double n = ELM_PI - 2.0 * ELM_PI * y / size;
3654 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
3659 * Convert a geographic coordinate (longitude, latitude) into a pixel coordinate (x, y).
3661 * @param obj The map object
3662 * @param lon the longitude
3663 * @param lat the latitude
3664 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
3665 * @param x the coordinate correspond to the longitude
3666 * @param y the coordinate correspond to the latitude
3671 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
3673 ELM_CHECK_WIDTYPE(obj, widtype);
3674 Widget_Data *wd = elm_widget_data_get(obj);
3677 int zoom = floor(log(size / 256) / log(2));
3678 if ((wd->src) && (wd->src->geo_into_coord))
3680 if (wd->src->geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
3684 *x = floor((lon + 180.0) / 360.0 * size);
3686 *y = floor((1.0 - log( tan(lat * ELM_PI / 180.0) + 1.0 / cos(lat * ELM_PI / 180.0)) / ELM_PI) / 2.0 * size);
3690 * Convert a geographic coordinate (longitude, latitude) into a name (address).
3692 * @param obj The map object
3693 * @param lon the longitude
3694 * @param lat the latitude
3696 * @return name the address
3701 elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat)
3703 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3704 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat);
3708 * Convert a name (address) into a geographic coordinate (longitude, latitude).
3710 * @param obj The map object
3711 * @param name the address
3712 * @param lat the latitude correspond to y
3714 * @return name the address
3719 elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address)
3721 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3722 if (!address) return NULL;
3723 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0);
3727 * Convert a pixel coordinate into a roated pixcel coordinate.
3729 * @param obj The map object
3730 * @param x x to rotate.
3731 * @param y y to rotate.
3732 * @param cx rotation's center horizontal position.
3733 * @param cy rotation's center vertical position.
3734 * @param degree amount of degrees from 0.0 to 360.0 to rotate arount Z axis.
3735 * @param xx rotated x.
3736 * @param yy rotated y.
3741 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)
3743 if ((!xx) || (!yy)) return;
3745 double r = (degree * M_PI) / 180.0;
3746 double tx, ty, ttx, tty;
3753 tx = ttx + (ty * cos(r + M_PI_2));
3754 ty = tty + (ty * sin(r + M_PI_2));
3761 * Add a marker on the map
3763 * @param obj The map object
3764 * @param lon the longitude
3765 * @param lat the latitude
3766 * @param clas the class to use
3767 * @param clas_group the class group
3768 * @param data the data passed to the callbacks
3770 * @return The marker object
3774 EAPI Elm_Map_Marker *
3775 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
3777 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3778 Widget_Data *wd = elm_widget_data_get(obj);
3781 Marker_Group *group;
3789 if (!wd) return NULL;
3790 EINA_SAFETY_ON_NULL_RETURN_VAL(clas_group, NULL);
3791 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, NULL);
3793 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
3796 marker->clas = clas;
3797 marker->clas_group = clas_group;
3798 marker->longitude = lon;
3799 marker->latitude = lat;
3800 marker->data = data;
3802 tabi[1] = tabi[4] = tabi[6] = -1;
3803 tabi[2] = tabi[0] = tabi[7] = 0;
3804 tabi[3] = tabi[5] = tabi[8] = 1;
3806 tabj[1] = tabj[2] = tabj[3] = -1;
3807 tabj[4] = tabj[0] = tabj[5] = 0;
3808 tabj[6] = tabj[7] = tabj[8] = 1;
3810 if (!clas_group->priv.set)
3813 if (marker->clas_group && marker->clas_group->style)
3814 style = marker->clas_group->style;
3816 o = edje_object_add(evas_object_evas_get(obj));
3817 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3818 s = edje_object_data_get(o, "size_w");
3819 if (s) clas_group->priv.edje_w = atoi(s);
3820 else clas_group->priv.edje_w = 0;
3821 s = edje_object_data_get(o, "size_h");
3822 if (s) clas_group->priv.edje_h = atoi(s);
3823 else clas_group->priv.edje_h = 0;
3824 s = edje_object_data_get(o, "size_max_w");
3825 if (s) clas_group->priv.edje_max_w = atoi(s);
3826 else clas_group->priv.edje_max_w = 0;
3827 s = edje_object_data_get(o, "size_max_h");
3828 if (s) clas_group->priv.edje_max_h = atoi(s);
3829 else clas_group->priv.edje_max_h = 0;
3832 clas_group->priv.set = EINA_TRUE;
3835 if (!clas->priv.set)
3838 if (marker->clas && marker->clas->style)
3839 style = marker->clas->style;
3841 o = edje_object_add(evas_object_evas_get(obj));
3842 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3843 s = edje_object_data_get(o, "size_w");
3844 if (s) clas->priv.edje_w = atoi(s);
3845 else clas->priv.edje_w = 0;
3846 s = edje_object_data_get(o, "size_h");
3847 if (s) clas->priv.edje_h = atoi(s);
3848 else clas->priv.edje_h = 0;
3851 clas->priv.set = EINA_TRUE;
3854 for (i = clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
3856 elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
3857 &(marker->x[i]), &(marker->y[i]));
3859 //search in the matrixsparse the region where the marker will be
3860 mpi = marker->x[i] / wd->tsize;
3861 mpj = marker->y[i] / wd->tsize;
3863 if (!wd->markers[i])
3865 int size = pow(2.0, i);
3866 wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
3870 if (i <= clas_group->zoom_grouped)
3872 for (j = 0, group = NULL; j < 9 && !group; j++)
3874 EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
3877 if (group->clas == marker->clas_group
3878 && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
3879 marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
3880 group->x-group->w/4, group->y-group->h/4, group->w, group->h))
3882 group->markers = eina_list_append(group->markers, marker);
3883 group->update_nbelems = EINA_TRUE;
3884 group->update_resize = EINA_TRUE;
3886 group->sum_x += marker->x[i];
3887 group->sum_y += marker->y[i];
3888 group->x = group->sum_x / eina_list_count(group->markers);
3889 group->y = group->sum_y / eina_list_count(group->markers);
3891 group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
3892 * eina_list_count(group->markers);
3893 group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
3894 * eina_list_count(group->markers);
3895 if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
3896 if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
3898 if (group->obj && eina_list_count(group->markers) == 2)
3900 _group_object_free(group);
3901 _group_object_create(group);
3904 _group_bubble_content_update(group);
3913 group = calloc(1, sizeof(Marker_Group));
3915 group->sum_x = marker->x[i];
3916 group->sum_y = marker->y[i];
3917 group->x = marker->x[i];
3918 group->y = marker->y[i];
3919 group->w = clas_group->priv.edje_w;
3920 group->h = clas_group->priv.edje_h;
3921 group->clas = clas_group;
3923 group->markers = eina_list_append(group->markers, marker);
3924 group->update_nbelems = EINA_TRUE;
3925 group->update_resize = EINA_TRUE;
3927 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3931 l = eina_list_append(NULL, group);
3932 eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
3933 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3937 l = eina_matrixsparse_cell_data_get(group->cell);
3938 l = eina_list_append(l, group);
3939 eina_matrixsparse_cell_data_set(group->cell, l);
3942 marker->groups[i] = group;
3947 Evas_Coord ox, oy, ow, oh;
3948 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3949 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3956 * Remove a marker from the map
3958 * @param marker The marker to remove
3963 elm_map_marker_remove(Elm_Map_Marker *marker)
3969 EINA_SAFETY_ON_NULL_RETURN(marker);
3972 for (i = marker->clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
3974 marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
3975 if (!eina_list_count(marker->groups[i]->markers))
3977 groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
3978 groups = eina_list_remove(groups, marker->groups[i]);
3979 eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
3981 _group_object_free(marker->groups[i]);
3982 _group_bubble_free(marker->groups[i]);
3983 free(marker->groups[i]);
3987 marker->groups[i]->sum_x -= marker->x[i];
3988 marker->groups[i]->sum_y -= marker->y[i];
3990 marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
3991 marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
3993 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
3994 + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
3995 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
3996 + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
3997 if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
3998 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
3999 if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
4000 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
4002 if ((marker->groups[i]->obj) && (eina_list_count(marker->groups[i]->markers) == 1))
4004 _group_object_free(marker->groups[i]);
4005 _group_object_create(marker->groups[i]);
4010 if ((marker->content) && (marker->clas->func.del))
4011 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4012 else if (marker->content)
4013 evas_object_del(marker->content);
4019 Evas_Coord ox, oy, ow, oh;
4020 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
4021 marker_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4026 * Get the current coordinates of the marker.
4028 * @param marker marker.
4029 * @param lat The latitude.
4030 * @param lon The longitude.
4035 elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat)
4037 EINA_SAFETY_ON_NULL_RETURN(marker);
4038 if (lon) *lon = marker->longitude;
4039 if (lat) *lat = marker->latitude;
4043 * Move the map to the coordinate of the marker.
4045 * @param marker The marker where the map will be center.
4050 elm_map_marker_bring_in(Elm_Map_Marker *marker)
4052 EINA_SAFETY_ON_NULL_RETURN(marker);
4053 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
4057 * Move the map to the coordinate of the marker.
4059 * @param marker The marker where the map will be center.
4064 elm_map_marker_show(Elm_Map_Marker *marker)
4066 EINA_SAFETY_ON_NULL_RETURN(marker);
4067 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
4071 * Move and zoom the map to display a list of markers.
4073 * The map will be centered on the center point of the markers in the list. Then
4074 * the map will be zoomed in order to fit the markers using the maximum zoom which
4075 * allows display of all the markers.
4077 * @param markers The list of markers (list of Elm_Map_Marker *)
4082 elm_map_markers_list_show(Eina_List *markers)
4087 Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
4088 Evas_Coord rw, rh, xc, yc;
4091 EINA_SAFETY_ON_NULL_RETURN(markers);
4092 EINA_LIST_FOREACH(markers, l, marker)
4096 if ((!m_min_lon) || (marker->longitude < m_min_lon->longitude))
4099 if ((!m_max_lon) || (marker->longitude > m_max_lon->longitude))
4102 if ((!m_min_lat) || (marker->latitude > m_min_lat->latitude))
4105 if ((!m_max_lat) || (marker->latitude < m_max_lat->latitude))
4109 lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
4110 lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
4112 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
4113 for (zoom = wd->src->zoom_max; zoom > wd->src->zoom_min; zoom--)
4115 Evas_Coord size = pow(2.0, zoom)*wd->tsize;
4116 elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
4118 if ((m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2)
4119 && (m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2)
4120 && (m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2)
4121 && (m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2))
4125 elm_map_geo_region_show(wd->obj, lon, lat);
4126 elm_map_zoom_set(wd->obj, zoom);
4130 * Set the maximum numbers of markers display in a group.
4132 * A group can have a long list of markers, consequently the creation of the content
4133 * of the bubble can be very slow. In order to avoid this, a maximum number of items
4134 * is displayed in a bubble. By default this number is 30.
4136 * @param obj The map object.
4137 * @param max The maximum numbers of items displayed in a bubble.
4142 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
4144 ELM_CHECK_WIDTYPE(obj, widtype);
4145 Widget_Data *wd = elm_widget_data_get(obj);
4148 wd->markers_max_num = max;
4152 * Return the evas object getting from the ElmMapMarkerGetFunc callback
4154 * @param marker The marker.
4155 * @return Return the evas object if it exists, else NULL.
4160 elm_map_marker_object_get(const Elm_Map_Marker *marker)
4162 EINA_SAFETY_ON_NULL_RETURN_VAL(marker, NULL);
4163 return marker->content;
4169 * @param marker The marker.
4174 elm_map_marker_update(Elm_Map_Marker *marker)
4176 EINA_SAFETY_ON_NULL_RETURN(marker);
4177 if (marker->content)
4179 if (marker->clas->func.del)
4180 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4182 evas_object_del(marker->content);
4183 marker->content = NULL;
4184 _group_bubble_content_update(marker->groups[marker->wd->zoom]);
4189 * Close all opened bubbles
4191 * @param obj The map object
4196 elm_map_bubbles_close(Evas_Object *obj)
4198 ELM_CHECK_WIDTYPE(obj, widtype);
4199 Widget_Data *wd = elm_widget_data_get(obj);
4200 Marker_Group *group;
4201 Eina_List *l, *l_next;
4204 EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
4205 _group_bubble_free(group);
4209 * Create a group class.
4211 * Each marker must be associated to a group class. Marker with the same group are grouped if they are close.
4212 * The group class defines the style of the marker when a marker is grouped to others markers.
4214 * @param obj The map object
4215 * @return Returns the new group class
4219 EAPI Elm_Map_Group_Class *
4220 elm_map_group_class_new(Evas_Object *obj)
4222 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4223 Widget_Data *wd = elm_widget_data_get(obj);
4225 if (!wd) return NULL;
4226 Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
4227 clas->zoom_grouped = ZOOM_MAX;
4228 wd->groups_clas = eina_list_append(wd->groups_clas, clas);
4233 * Set the style of a group class (radio, radio2 or empty)
4235 * @param clas the group class
4236 * @param style the new style
4241 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
4243 EINA_SAFETY_ON_NULL_RETURN(clas);
4244 eina_stringshare_replace(&clas->style, style);
4248 * Set the icon callback of a group class.
4250 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
4252 * @param clas the group class
4253 * @param icon_get the callback to create the icon
4258 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
4260 EINA_SAFETY_ON_NULL_RETURN(clas);
4261 clas->func.icon_get = icon_get;
4265 * Set the data associated to the group class (radio, radio2 or empty)
4267 * @param clas the group class
4268 * @param data the new user data
4273 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
4275 EINA_SAFETY_ON_NULL_RETURN(clas);
4280 * Set the zoom from where the markers are displayed.
4282 * Markers will not be displayed for a zoom less than @ref zoom
4284 * @param clas the group class
4285 * @param zoom the zoom
4290 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
4292 EINA_SAFETY_ON_NULL_RETURN(clas);
4293 clas->zoom_displayed = zoom;
4297 * Set the zoom from where the markers are no more grouped.
4299 * @param clas the group class
4300 * @param zoom the zoom
4305 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
4307 EINA_SAFETY_ON_NULL_RETURN(clas);
4308 clas->zoom_grouped = zoom;
4312 * Set if the markers associated to the group class @clas are hidden or not.
4313 * If @ref hide is true the markers will be hidden.
4315 * @param clas the group class
4316 * @param hide if true the markers will be hidden, else they will be displayed.
4321 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
4323 ELM_CHECK_WIDTYPE(obj, widtype);
4324 Widget_Data *wd = elm_widget_data_get(obj);
4327 EINA_SAFETY_ON_NULL_RETURN(clas);
4328 if (clas->hide == hide) return;
4332 Evas_Coord ox, oy, ow, oh;
4333 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
4334 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4340 * Create a marker class.
4342 * Each marker must be associated to a class.
4343 * The class defines the style of the marker when a marker is displayed alone (not grouped).
4345 * @param obj The map object
4346 * @return Returns the new class
4350 EAPI Elm_Map_Marker_Class *
4351 elm_map_marker_class_new(Evas_Object *obj)
4353 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4354 Widget_Data *wd = elm_widget_data_get(obj);
4356 if (!wd) return NULL;
4357 Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
4358 wd->markers_clas = eina_list_append(wd->markers_clas, clas);
4363 * Set the style of a class (radio, radio2 or empty)
4365 * @param clas the group class
4366 * @param style the new style
4371 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
4373 EINA_SAFETY_ON_NULL_RETURN(clas);
4374 eina_stringshare_replace(&clas->style, style);
4378 * Set the icon callback of a class.
4380 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
4382 * @param clas the group class
4383 * @param icon_get the callback to create the icon
4388 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
4390 EINA_SAFETY_ON_NULL_RETURN(clas);
4391 clas->func.icon_get = icon_get;
4396 * Set the callback of the content of the bubble.
4398 * When the user click on a marker, a bubble is displayed with a content.
4399 * The callback @ref get musst return this content. It can be NULL.
4401 * @param clas the group class
4402 * @param get the callback to create the content
4407 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
4409 EINA_SAFETY_ON_NULL_RETURN(clas);
4410 clas->func.get = get;
4414 * Set the callback of the content of delete the object created by the callback "get".
4416 * If this callback is defined the user will have to delete (or not) the object inside.
4417 * If the callback is not defined the object will be destroyed with evas_object_del()
4419 * @param clas the group class
4420 * @param del the callback to delete the content
4425 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
4427 EINA_SAFETY_ON_NULL_RETURN(clas);
4428 clas->func.del = del;
4432 * Get the list of the sources.
4434 * @param obj The map object
4435 * @return sources the source list
4441 elm_map_source_names_get(const Evas_Object *obj)
4443 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4444 Widget_Data *wd = elm_widget_data_get(obj);
4446 if (!wd) return NULL;
4447 return wd->source_names;
4451 * Set the source of the map.
4453 * Elm_Map retrieves the image which composed the map from a web service. This web service can
4454 * be set with this method. A different service can return a different maps with different
4455 * information and it can use different zoom value.
4457 * @param obj the map object
4458 * @param source the new source
4463 elm_map_source_name_set(Evas_Object *obj, const char *source_name)
4465 ELM_CHECK_WIDTYPE(obj, widtype);
4466 Widget_Data *wd = elm_widget_data_get(obj);
4473 if ((wd->src) && (!strcmp(wd->src->name, source_name))) return;
4474 if ((wd->src) && (!wd->src->url_cb)) return;
4476 EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid);
4477 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
4479 if (!strcmp(s->name, source_name))
4488 if (wd->src->zoom_max < zoom)
4489 zoom = wd->src->zoom_max;
4490 if (wd->src->zoom_min > zoom)
4491 zoom = wd->src->zoom_min;
4493 elm_map_zoom_set(obj, zoom);
4497 * Get the name of a source.
4499 * @param source the source
4500 * @return Returns the name of the source
4505 elm_map_source_name_get(const Evas_Object *obj)
4507 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4508 Widget_Data *wd = elm_widget_data_get(obj);
4510 if ((!wd) || (!wd->src)) return NULL;
4511 return wd->src->name;
4515 * Set the source of the route.
4517 * @param clas the group class
4518 * @param source the new source
4523 elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
4525 ELM_CHECK_WIDTYPE(obj, widtype);
4526 Widget_Data *wd = elm_widget_data_get(obj);
4529 wd->route_source = source;
4533 * Get the current route source
4535 * @param obj the map object
4536 * @return Returns the source of the route
4540 EAPI Elm_Map_Route_Sources
4541 elm_map_route_source_get(const Evas_Object *obj)
4543 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS;
4544 Widget_Data *wd = elm_widget_data_get(obj);
4546 if (!wd) return ELM_MAP_ROUTE_SOURCE_YOURS;
4547 return wd->route_source;
4551 * Get the maximum zoom of the source.
4553 * @param source the source
4554 * @return Returns the maximum zoom of the source
4559 elm_map_source_zoom_max_get(const Evas_Object *obj)
4561 ELM_CHECK_WIDTYPE(obj, widtype) 18;
4562 Widget_Data *wd = elm_widget_data_get(obj);
4564 if ((!wd) || (!wd->src)) return 18;
4565 return wd->src->zoom_max;
4569 * Get the minimum zoom of the source.
4571 * @param source the source
4572 * @return Returns the minimum zoom of the source
4577 elm_map_source_zoom_min_get(const Evas_Object *obj)
4579 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4580 Widget_Data *wd = elm_widget_data_get(obj);
4582 if ((!wd) || (!wd->src)) return 0;
4583 return wd->src->zoom_min;
4587 * Set the user agent of the widget map.
4589 * @param obj The map object
4590 * @param user_agent the user agent of the widget map
4595 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
4597 ELM_CHECK_WIDTYPE(obj, widtype);
4598 Widget_Data *wd = elm_widget_data_get(obj);
4601 if (!wd->user_agent) wd->user_agent = eina_stringshare_add(user_agent);
4602 else eina_stringshare_replace(&wd->user_agent, user_agent);
4604 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4605 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4609 * Get the user agent of the widget map.
4611 * @param obj The map object
4612 * @return The user agent of the widget map
4617 elm_map_user_agent_get(const Evas_Object *obj)
4619 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4620 Widget_Data *wd = elm_widget_data_get(obj);
4622 if (!wd) return NULL;
4623 return wd->user_agent;
4627 * Add a route on the map
4629 * @param obj The map object
4630 * @param type the type if transport
4631 * @param method the routing method
4632 * @param flon the start longitude
4633 * @param flat the start latitude
4634 * @param tlon the destination longitude
4635 * @param tlat the destination latitude
4637 * @return The Route object
4641 EAPI Elm_Map_Route *
4642 elm_map_route_add(Evas_Object *obj,
4643 Elm_Map_Route_Type type,
4644 Elm_Map_Route_Method method,
4650 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4651 Widget_Data *wd = elm_widget_data_get(obj);
4654 char *type_name = NULL;
4657 if ((!wd) || (!wd->src)) return NULL;
4659 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4660 if (!route) return NULL;
4662 snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE);
4670 route->con_url = ecore_con_url_new(NULL);
4671 route->ud.fname = strdup(buf);
4672 INF("xml file : %s", route->ud.fname);
4674 route->ud.fd = fdopen(fd, "w+");
4675 if ((!route->con_url) || (!route->ud.fd))
4677 ecore_con_url_free(route->con_url);
4683 route->color.r = 255;
4686 route->color.a = 255;
4687 route->handlers = eina_list_append
4688 (route->handlers, (void *)ecore_event_handler_add
4689 (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route));
4691 route->inbound = EINA_FALSE;
4693 route->method = method;
4701 case ELM_MAP_ROUTE_TYPE_MOTOCAR:
4702 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4704 case ELM_MAP_ROUTE_TYPE_BICYCLE:
4705 type_name = strdup(ROUTE_TYPE_BICYCLE);
4707 case ELM_MAP_ROUTE_TYPE_FOOT:
4708 type_name = strdup(ROUTE_TYPE_FOOT);
4714 source = wd->src->route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4715 INF("route url = %s", source);
4717 wd->route = eina_list_append(wd->route, route);
4719 ecore_con_url_url_set(route->con_url, source);
4720 ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd));
4721 ecore_con_url_data_set(route->con_url, route);
4722 ecore_con_url_get(route->con_url);
4723 if (type_name) free(type_name);
4724 if (source) free(source);
4726 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4727 "elm,state,busy,start", "elm");
4728 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL);
4733 * Remove a route from the map
4735 * @param route The route to remove
4741 elm_map_route_remove(Elm_Map_Route *route)
4743 EINA_SAFETY_ON_NULL_RETURN(route);
4748 Ecore_Event_Handler *h;
4750 EINA_LIST_FREE(route->path, p)
4755 EINA_LIST_FREE(route->waypoint, w)
4757 if (w->point) eina_stringshare_del(w->point);
4761 EINA_LIST_FREE(route->nodes, n)
4763 if (n->pos.address) eina_stringshare_del(n->pos.address);
4767 EINA_LIST_FREE(route->handlers, h)
4769 ecore_event_handler_del(h);
4772 if (route->ud.fname)
4774 ecore_file_remove(route->ud.fname);
4775 free(route->ud.fname);
4776 route->ud.fname = NULL;
4781 * Set the option used for the background color
4783 * @param route The route object
4789 * This sets the color used for the route
4794 elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a)
4796 EINA_SAFETY_ON_NULL_RETURN(route);
4804 * Get the option used for the background color
4806 * @param route The route object
4815 elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a)
4817 EINA_SAFETY_ON_NULL_RETURN(route);
4818 if (r) *r = route->color.r;
4819 if (g) *g = route->color.g;
4820 if (b) *b = route->color.b;
4821 if (a) *a = route->color.a;
4825 * Get the information of route distance
4827 * @param route the route object
4828 * @return Returns the distance of route (unit : km)
4833 elm_map_route_distance_get(const Elm_Map_Route *route)
4835 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
4836 return route->info.distance;
4840 * Get the information of route nodes
4842 * @param route the route object
4843 * @return Returns the nodes of route
4849 elm_map_route_node_get(const Elm_Map_Route *route)
4851 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4852 return route->info.nodes;
4856 * Get the information of route waypoint
4858 * @param route the route object
4859 * @return Returns the waypoint of route
4865 elm_map_route_waypoint_get(const Elm_Map_Route *route)
4867 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4868 return route->info.waypoints;
4872 * Get the information of address
4874 * @param name the name object
4875 * @return Returns the address of name
4880 elm_map_name_address_get(const Elm_Map_Name *name)
4882 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
4883 return name->address;
4887 * Get the current coordinates of the name.
4889 * This gets the current coordinates of the name object.
4891 * @param obj The name object
4892 * @param lat The latitude
4893 * @param lon The longitude
4898 elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
4900 EINA_SAFETY_ON_NULL_RETURN(name);
4901 if (lon) *lon = name->lon;
4902 if (lat) *lat = name->lat;
4906 * Remove a name from the map
4908 * @param name The name to remove
4913 elm_map_name_remove(Elm_Map_Name *name)
4915 EINA_SAFETY_ON_NULL_RETURN(name);
4918 free(name->address);
4919 name->address = NULL;
4923 ecore_event_handler_del(name->handler);
4924 name->handler = NULL;
4928 ecore_file_remove(name->ud.fname);
4929 free(name->ud.fname);
4930 name->ud.fname = NULL;
4935 * Set the rotate degree of the map
4937 * @param obj The map object
4938 * @param angle amount of degrees from 0.0 to 360.0 to rotate arount Z axis
4939 * @param cx rotation's center horizontal position
4940 * @param cy rotation's center vertical position
4945 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
4947 ELM_CHECK_WIDTYPE(obj, widtype);
4948 Widget_Data *wd = elm_widget_data_get(obj);
4951 wd->rotate.d = degree;
4954 wd->calc_job = ecore_job_add(_calc_job, wd);
4958 * Get the rotate degree of the map
4960 * @param obj The map object
4961 * @return amount of degrees from 0.0 to 360.0 to rotate arount Z axis
4962 * @param cx rotation's center horizontal position
4963 * @param cy rotation's center vertical position
4968 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
4970 ELM_CHECK_WIDTYPE(obj, widtype);
4971 Widget_Data *wd = elm_widget_data_get(obj);
4974 if (degree) *degree = wd->rotate.d;
4975 if (cx) *cx = wd->rotate.cx;
4976 if (cy) *cy = wd->rotate.cy;
4980 * Set the wheel control state of the map
4982 * @param obj The map object
4983 * @param disabled status of wheel control
4988 elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
4990 ELM_CHECK_WIDTYPE(obj, widtype);
4991 Widget_Data *wd = elm_widget_data_get(obj);
4994 if ((!wd->wheel_disabled) && (disabled))
4995 evas_object_event_callback_del_full(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
4996 else if ((wd->wheel_disabled) && (!disabled))
4997 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
4998 wd->wheel_disabled = !!disabled;
5002 * Get the wheel control state of the map
5004 * @param obj The map object
5005 * @return Returns the status of wheel control
5010 elm_map_wheel_disabled_get(const Evas_Object *obj)
5012 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5013 Widget_Data *wd = elm_widget_data_get(obj);
5015 if (!wd) return EINA_FALSE;
5016 return wd->wheel_disabled;
5020 _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5023 snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
5029 _osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5032 snprintf(buf, sizeof(buf),
5033 "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
5039 _cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5042 snprintf(buf, sizeof(buf),
5043 "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
5049 _maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5052 snprintf(buf, sizeof(buf),
5053 "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
5058 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5061 snprintf(buf, sizeof(buf),
5062 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
5063 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
5068 // TODO: fix monav api
5070 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5073 snprintf(buf, sizeof(buf),
5074 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
5075 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
5081 // TODO: fix ors api
5083 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5086 snprintf(buf, sizeof(buf),
5087 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
5088 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
5095 _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
5097 ELM_CHECK_WIDTYPE(obj, widtype) strdup("");
5098 Widget_Data *wd = elm_widget_data_get(obj);
5100 unsigned int ele, idx;
5101 char search_url[PATH_MAX];
5104 if (!wd) return strdup("");
5105 if (method == ELM_MAP_NAME_METHOD_SEARCH)
5107 search_url[0] = '\0';
5108 str = eina_str_split_full(name, " ", 0, &ele);
5109 for (idx = 0 ; idx < ele ; idx++)
5111 eina_strlcat(search_url, str[idx], sizeof(search_url));
5112 if (!(idx == (ele-1))) eina_strlcat(search_url, "+", sizeof(search_url));
5114 snprintf(buf, sizeof(buf), "%s/search?q=%s&format=xml&polygon=0&addressdetails=0", NAME_NOMINATIM_URL, search_url);
5116 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);
5117 else strcpy(buf, "");