2 #include "Elementary.h"
9 * This is a widget specifically for displaying the map. It uses basically
10 * OpenStreetMap provider. but it can be added custom providers.
12 * Signals that you can add callbacks for are:
14 * "clicked" - This is called when a user has clicked the map without dragging
17 * "press" - This is called when a user has pressed down on the map.
19 * "longpressed" - This is called when a user has pressed down on the map for
20 * a long time without dragging around.
22 * "clicked,double" - This is called when a user has double-clicked the map.
24 * "load,detail" - Map detailed data load begins.
26 * "loaded,detail" - This is called when all parts of the map are loaded.
28 * "zoom,start" - Zoom animation started.
30 * "zoom,stop" - Zoom animation stopped.
32 * "zoom,change" - Zoom changed when using an auto zoom mode.
34 * "scroll" - the content has been scrolled (moved)
36 * "scroll,anim,start" - scrolling animation has started
38 * "scroll,anim,stop" - scrolling animation has stopped
40 * "scroll,drag,start" - dragging the contents around has started
42 * "scroll,drag,stop" - dragging the contents around has stopped
44 * "downloaded" - This is called when map images are downloaded
46 * "route,load" - This is called when route request begins
48 * "route,loaded" - This is called when route request ends
50 * "name,load" - This is called when name request begins
52 * "name,loaded- This is called when name request ends
58 typedef struct _Widget_Data Widget_Data;
59 typedef struct _Pan Pan;
60 typedef struct _Grid Grid;
61 typedef struct _Grid_Item Grid_Item;
62 typedef struct _Marker_Group Marker_Group;
63 typedef struct _Event Event;
64 typedef struct _Path_Node Path_Node;
65 typedef struct _Path_Waypoint Path_Waypoint;
66 typedef struct _Url_Data Url_Data;
67 typedef struct _Route_Dump Route_Dump;
68 typedef struct _Name_Dump Name_Dump;
69 typedef struct _Track_Dump Track_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
98 #define GPX_NAME "name>"
99 #define GPX_COORDINATES "trkpt "
100 #define GPX_LON "lon"
101 #define GPX_LAT "lat"
102 #define GPX_ELE "ele>"
103 #define GPX_TIME "time>"
106 // Currently the size of a tile must be 256*256
107 // and the size of the map must be pow(2.0, z)*tile_size
108 typedef struct _Map_Sources_Tab
113 ElmMapModuleUrlFunc url_cb;
114 Elm_Map_Route_Sources route_source;
115 ElmMapModuleRouteUrlFunc route_url_cb;
116 ElmMapModuleNameUrlFunc name_url_cb;
117 ElmMapModuleGeoIntoCoordFunc geo_into_coord;
118 ElmMapModuleCoordIntoGeoFunc coord_into_geo;
121 //Zemm min is supposed to be 0
122 static char *_mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
123 static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
124 static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
125 static char *_maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
127 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
129 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
130 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
132 static char *_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat);
134 static Map_Sources_Tab default_map_sources_tab[] =
136 {"Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
137 {"Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
138 {"CycleMap", 0, 17, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
139 {"Maplint", 12, 16, _maplint_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
144 Ecore_Con_Url *con_url;
150 struct _Elm_Map_Marker_Class
155 struct _Elm_Map_Marker_Class_Func {
156 ElmMapMarkerGetFunc get;
157 ElmMapMarkerDelFunc del; //if NULL the object will be destroyed with evas_object_del()
158 ElmMapMarkerIconGetFunc icon_get;
161 struct { //this part is private, do not modify these values
163 Evas_Coord edje_w, edje_h;
167 struct _Elm_Map_Marker
170 Elm_Map_Marker_Class *clas;
171 Elm_Map_Group_Class *clas_group;
172 double longitude, latitude;
177 Marker_Group **groups;
178 Evas_Object *content;
181 struct _Elm_Map_Group_Class
185 int zoom_displayed; // display the group if the zoom is >= to zoom_display
186 int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
190 ElmMapGroupIconGetFunc icon_get;
193 struct { //this part is private, do not modify these values
195 Evas_Coord edje_w, edje_h;
196 Evas_Coord edje_max_w, edje_max_h;
198 Eina_List *objs_used;
199 Eina_List *objs_notused;
206 Eina_Matrixsparse_Cell *cell;
207 Elm_Map_Group_Class *clas;
210 long long sum_x, sum_y;
214 Evas_Object *obj, *bubble, *sc, *bx, *rect;
216 Eina_Bool bringin : 1;
217 Eina_Bool update_nbelems : 1;
218 Eina_Bool update_resize : 1;
219 Eina_Bool update_raise : 1;
220 Eina_Bool delete_object : 1;
223 struct _Elm_Map_Route
229 Ecore_Con_Url *con_url;
234 double flon, flat, tlon, tlat;
236 Eina_List *nodes, *path;
243 const char *waypoints;
244 double distance; /* unit : km */
257 Eina_Bool inbound : 1;
271 struct _Path_Waypoint
282 Ecore_Con_Url *con_url;
287 Ecore_Event_Handler *handler;
300 Eina_Bool download : 1;
302 Ecore_File_Download_Job *job;
309 int tsize; // size of tile (tsize x tsize pixels)
310 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
311 int iw, ih; // size of image in pixels
312 int w, h; // size of grid image in pixels (represented by grid)
313 int gw, gh; // size of grid in tiles
314 Eina_Matrixsparse *grid;
321 Evas_Object *pan_smart;
323 Evas_Object *sep_maps_markers; //map objects are below this object and marker objects are on top
325 Evas_Coord pan_x, pan_y, minw, minh;
330 Elm_Map_Zoom_Mode mode;
333 Ecore_Timer *scr_timer;
334 Ecore_Timer *long_timer;
335 Ecore_Animator *zoom_animator;
346 Evas_Coord x, y ,w ,h;
352 Eina_Bool resized : 1;
353 Eina_Bool on_hold : 1;
354 Eina_Bool paused : 1;
355 Eina_Bool paused_markers : 1;
362 Ecore_Job *markers_place_job;
363 Eina_Matrixsparse **markers;
364 Eina_List *cells_displayed; // list of Eina_Matrixsparse_Cell
365 Evas_Coord markers_max_num;
366 int marker_max_w, marker_max_h;
368 Eina_List *opened_bubbles; //opened bubbles, list of Map_Group *
370 Eina_List *groups_clas; // list of Elm_Map_Group_Class*
371 Eina_List *markers_clas; // list of Elm_Map_Markers_Class*
373 Elm_Map_Route_Sources route_source;
374 Eina_List *s_event_list;
379 const char *user_agent;
382 Evas_Event_Mouse_Down ev;
403 Ecore_Timer *wheel_timer;
404 Eina_Bool wheel_disabled : 1;
407 Eina_List *map_sources_tab;
408 const char **source_names;
410 Ecore_Timer *zoom_timer;
411 Map_Sources_Tab *src;
412 const char *gpx_file;
413 int zoom_min, zoom_max;
418 Evas_Object_Smart_Clipped_Data __clipped_data;
434 Evas_Coord x, y, w, h;
437 Ecore_Timer *hold_timer;
452 enum _Route_Xml_Attribute
456 ROUTE_XML_DESCRIPTION,
457 ROUTE_XML_COORDINATES,
459 } Route_Xml_Attibute;
469 enum _Name_Xml_Attribute
486 enum _Track_Xml_Attribute
489 TRACK_XML_COORDINATES,
491 } Track_Xml_Attibute;
494 static const char *widtype = NULL;
496 static const char SIG_CHANGED[] = "changed";
497 static const char SIG_CLICKED[] = "clicked";
498 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
499 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
500 static const char SIG_LOAD_DETAIL[] = "load,detail";
501 static const char SIG_LONGPRESSED[] = "longpressed";
502 static const char SIG_PRESS[] = "press";
503 static const char SIG_SCROLL[] = "scroll";
504 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
505 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
506 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
507 static const char SIG_ZOOM_START[] = "zoom,start";
508 static const char SIG_ZOOM_STOP[] = "zoom,stop";
509 static const char SIG_DOWNLOADED[] = "downloaded";
510 static const char SIG_ROUTE_LOAD[] = "route,load";
511 static const char SIG_ROUTE_LOADED[] = "route,loaded";
512 static const char SIG_NAME_LOAD[] = "name,load";
513 static const char SIG_NAME_LOADED[] = "name,loaded";
514 static const Evas_Smart_Cb_Description _signals[] = {
517 {SIG_CLICKED_DOUBLE, ""},
518 {SIG_LOADED_DETAIL, ""},
519 {SIG_LOAD_DETAIL, ""},
520 {SIG_LONGPRESSED, ""},
523 {SIG_SCROLL_DRAG_START, ""},
524 {SIG_SCROLL_DRAG_STOP, ""},
525 {SIG_ZOOM_CHANGE, ""},
526 {SIG_ZOOM_START, ""},
528 {SIG_DOWNLOADED, ""},
529 {SIG_ROUTE_LOAD, ""},
530 {SIG_ROUTE_LOADED, ""},
532 {SIG_NAME_LOADED, ""},
536 static void _pan_calculate(Evas_Object *obj);
538 static Eina_Bool _hold_timer_cb(void *data);
539 static Eina_Bool _wheel_timer_cb(void *data);
540 static void _rect_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
541 static void _del_hook(Evas_Object *obj);
542 static void _theme_hook(Evas_Object *obj);
543 static void _on_focus_hook(void *data, Evas_Object *obj);
544 static void _sizing_eval(Evas_Object *obj);
545 static void _calc_job(void *data);
546 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
547 Evas_Callback_Type type, void *event_info);
548 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);
549 static void grid_clear(Evas_Object *obj, Grid *g);
550 static Grid *grid_create(Evas_Object *obj);
551 static void grid_load(Evas_Object *obj, Grid *g);
554 static void _group_object_create(Marker_Group *group);
555 static void _group_object_free(Marker_Group *group);
556 static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
557 static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
558 static void _group_bubble_create(Marker_Group *group);
559 static void _group_bubble_free(Marker_Group *group);
560 static void _group_bubble_place(Marker_Group *group);
562 static int _group_bubble_content_update(Marker_Group *group);
563 static void _group_bubble_content_free(Marker_Group *group);
564 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);
565 static void _bubble_sc_hits_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
567 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
568 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
569 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
571 static void _mouse_multi_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
572 static void _mouse_multi_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
573 static void _mouse_multi_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
575 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);
576 static void track_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
579 get_multi_device(Evas_Object *obj)
581 Widget_Data *wd = elm_widget_data_get(obj);
585 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
587 if (ev->device) return ev->device;
593 create_event_object(void *data, Evas_Object *obj, int device)
595 Widget_Data *wd = elm_widget_data_get(data);
596 Event *ev = calloc(1, sizeof(Event));
598 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, NULL);
602 evas_object_geometry_get(obj, &ev->x, &ev->y, &ev->w, &ev->h);
603 wd->s_event_list = eina_list_append(wd->s_event_list, ev);
608 get_event_object(void *data, int device)
610 Widget_Data *wd = elm_widget_data_get(data);
614 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
616 if (ev->device == device) break;
623 destroy_event_object(void *data, Event *ev)
625 Widget_Data *wd = elm_widget_data_get(data);
626 EINA_SAFETY_ON_NULL_RETURN(ev);
628 wd->s_event_list = eina_list_remove(wd->s_event_list, ev);
631 ecore_timer_del(ev->hold_timer);
632 ev->hold_timer = NULL;
638 module_list_cb(Eina_Module *m, void *data)
640 ELM_CHECK_WIDTYPE(data, widtype) EINA_FALSE;
641 Widget_Data *wd = elm_widget_data_get(data);
643 ElmMapModuleSourceFunc source;
644 ElmMapModuleZoomMinFunc zoom_min;
645 ElmMapModuleZoomMaxFunc zoom_max;
646 ElmMapModuleUrlFunc url;
647 ElmMapModuleRouteSourceFunc route_source;
648 ElmMapModuleRouteUrlFunc route_url;
649 ElmMapModuleNameUrlFunc name_url;
650 ElmMapModuleGeoIntoCoordFunc geo_into_coord;
651 ElmMapModuleCoordIntoGeoFunc coord_into_geo;
654 if (!wd) return EINA_FALSE;
656 file = eina_module_file_get(m);
657 if (!eina_module_load(m))
659 ERR("could not load module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
663 source = eina_module_symbol_get(m, "map_module_source_get");
664 zoom_min = eina_module_symbol_get(m, "map_module_zoom_min_get");
665 zoom_max = eina_module_symbol_get(m, "map_module_zoom_max_get");
666 url = eina_module_symbol_get(m, "map_module_url_get");
667 route_source = eina_module_symbol_get(m, "map_module_route_source_get");
668 route_url = eina_module_symbol_get(m, "map_module_route_url_get");
669 name_url = eina_module_symbol_get(m, "map_module_name_url_get");
670 geo_into_coord = eina_module_symbol_get(m, "map_module_geo_into_coord");
671 coord_into_geo = eina_module_symbol_get(m, "map_module_coord_into_geo");
672 if ((!source) || (!zoom_min) || (!zoom_max) || (!url) || (!route_source) || (!route_url) || (!name_url) || (!geo_into_coord) || (!coord_into_geo))
674 ERR("could not find map_module_source_get() in module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
675 eina_module_unload(m);
678 s = calloc(1, sizeof(Map_Sources_Tab));
679 EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE);
681 s->zoom_min = zoom_min();
682 s->zoom_max = zoom_max();
684 s->route_source = route_source();
685 s->route_url_cb = route_url;
686 s->name_url_cb = name_url;
687 s->geo_into_coord = geo_into_coord;
688 s->coord_into_geo = coord_into_geo;
689 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
695 module_init(void *data)
697 ELM_CHECK_WIDTYPE(data, widtype);
698 Widget_Data *wd = elm_widget_data_get(data);
701 wd->modules = eina_module_list_get(wd->modules, MODULES_PATH, 1, &module_list_cb, data);
705 source_init(void *data)
707 ELM_CHECK_WIDTYPE(data, widtype);
708 Widget_Data *wd = elm_widget_data_get(data);
714 for (idx = 0; idx < 4; idx++)
716 s = calloc(1, sizeof(Map_Sources_Tab));
717 EINA_SAFETY_ON_NULL_RETURN(s);
718 s->name = default_map_sources_tab[idx].name;
719 s->zoom_min = default_map_sources_tab[idx].zoom_min;
720 s->zoom_max = default_map_sources_tab[idx].zoom_max;
721 s->url_cb = default_map_sources_tab[idx].url_cb;
722 s->route_source = default_map_sources_tab[idx].route_source;
723 s->route_url_cb = default_map_sources_tab[idx].route_url_cb;
724 s->name_url_cb = default_map_sources_tab[idx].name_url_cb;
725 s->geo_into_coord = default_map_sources_tab[idx].geo_into_coord;
726 s->coord_into_geo = default_map_sources_tab[idx].coord_into_geo;
727 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
728 if (!idx) wd->src = s;
732 int n = eina_list_count(wd->map_sources_tab);
733 wd->source_names = malloc(sizeof(char *) * (n + 1));
734 if (!wd->source_names)
736 ERR("init source names failed.");
740 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
742 wd->source_names[idx] = strdup(s->name);
743 INF("source : %s", wd->source_names[idx]);
746 wd->source_names[idx] = NULL;
750 zoom_min_get(void *data)
752 ELM_CHECK_WIDTYPE(data, widtype);
753 Widget_Data *wd = elm_widget_data_get(data);
759 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
762 if (tz < wd->zoom_min) wd->zoom_min = tz;
767 zoom_max_get(void *data)
769 ELM_CHECK_WIDTYPE(data, widtype);
770 Widget_Data *wd = elm_widget_data_get(data);
776 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
779 if (tz > wd->zoom_max) wd->zoom_max = tz;
784 obj_rotate_zoom(void *data, Evas_Object *obj)
786 ELM_CHECK_WIDTYPE(data, widtype);
787 Widget_Data *wd = elm_widget_data_get(data);
788 if ((!wd->pinch.cx) && (!wd->pinch.cy))
790 wd->pinch.cx = wd->rotate.cx;
791 wd->pinch.cy = wd->rotate.cy;
794 evas_map_util_points_populate_from_object_full(wd->map, obj, 0);
795 evas_map_util_zoom(wd->map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy);
796 evas_map_util_rotate(wd->map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
797 evas_object_map_enable_set(obj, EINA_TRUE);
798 evas_object_map_set(obj, wd->map);
803 track_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)
805 track_place(Evas_Object *obj __UNUSED__, Grid *g __UNUSED__, Evas_Coord px __UNUSED__, Evas_Coord py __UNUSED__, Evas_Coord ox __UNUSED__, Evas_Coord oy __UNUSED__, Evas_Coord ow __UNUSED__, Evas_Coord oh __UNUSED__)
809 ELM_CHECK_WIDTYPE(obj, widtype);
810 Widget_Data *wd = elm_widget_data_get(obj);
813 int xmin, xmax, ymin, ymax;
816 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
818 EINA_LIST_FOREACH(wd->track, l, route)
820 elm_map_utils_convert_geo_into_coord(wd->obj, elm_route_lon_min_get(route), elm_route_lat_max_get(route), size, &xmin, &ymin);
821 elm_map_utils_convert_geo_into_coord(wd->obj, elm_route_lon_max_get(route), elm_route_lat_min_get(route), size, &xmax, &ymax);
823 if( !(xmin < px && xmax < px) && !(xmin > px+ow && xmax > px+ow))
825 if( !(ymin < py && ymax < py) && !(ymin > py+oh && ymax > py+oh))
828 evas_object_move(route, xmin - px + ox, ymin - py + oy);
829 evas_object_resize(route, xmax - xmin, ymax - ymin);
831 evas_object_raise(route);
832 obj_rotate_zoom(obj, route);
833 evas_object_show(route);
838 //the route is not display
839 evas_object_hide(route);
844 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)
846 ELM_CHECK_WIDTYPE(obj, widtype);
847 Widget_Data *wd = elm_widget_data_get(obj);
848 Eina_List *lr, *lp, *ln;
857 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
859 EINA_LIST_FOREACH(wd->route, lr, r)
861 EINA_LIST_FOREACH(r->path, lp, p)
863 evas_object_polygon_points_clear(p);
866 evas_object_geometry_get(wd->rect, &rx, &ry, NULL, NULL);
867 nodes = eina_list_count(r->nodes);
869 EINA_LIST_FOREACH(r->nodes, ln, n)
871 if ((!wd->zoom) || ((n->idx) &&
872 ((n->idx % (int)ceil((double)nodes/(double)size*100.0))))) continue;
875 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
876 if ((x >= px - ow) && (x <= (px + ow*2)) &&
877 (y >= py - oh) && (y <= (py + oh*2)))
882 p = eina_list_nth(r->path, n->idx);
883 a = (double)(y - r->y) / (double)(x - r->x);
884 if ((abs(a) >= 1) || (r->x == x))
886 evas_object_polygon_point_add(p, r->x - 3, r->y);
887 evas_object_polygon_point_add(p, r->x + 3, r->y);
888 evas_object_polygon_point_add(p, x + 3, y);
889 evas_object_polygon_point_add(p, x - 3, y);
893 evas_object_polygon_point_add(p, r->x, r->y - 3);
894 evas_object_polygon_point_add(p, r->x, r->y + 3);
895 evas_object_polygon_point_add(p, x, y + 3);
896 evas_object_polygon_point_add(p, x, y - 3);
899 evas_object_color_set(p, r->color.r, r->color.g, r->color.b, r->color.a);
900 evas_object_raise(p);
901 obj_rotate_zoom(obj, p);
906 else r->inbound = EINA_FALSE;
910 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
911 if ((x >= px - ow) && (x <= (px + ow*2)) &&
912 (y >= py - oh) && (y <= (py + oh*2)))
916 r->inbound = EINA_TRUE;
918 else r->inbound = EINA_FALSE;
921 r->inbound = EINA_FALSE;
926 rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
928 ELM_CHECK_WIDTYPE(obj, widtype);
929 Widget_Data *wd = elm_widget_data_get(obj);
930 Evas_Coord ax, ay, gw, gh, hh, ww;
933 evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh);
940 if ((ww == gw) && (hh == gh)) return;
942 if (ow > gw) ax = (ow - gw) / 2;
943 if (oh > gh) ay = (oh - gh) / 2;
944 evas_object_move(wd->rect,
947 evas_object_resize(wd->rect, gw, gh);
951 wd->show.show = EINA_FALSE;
952 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
957 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)
959 ELM_CHECK_WIDTYPE(obj, widtype);
960 Widget_Data *wd = elm_widget_data_get(obj);
961 Evas_Coord ax, ay, gw, gh, tx, ty;
962 Eina_List *l, *markers;
963 Eina_Matrixsparse_Cell *cell;
968 int g_xx, g_yy, g_hh, g_ww;
971 if (g != eina_list_data_get(wd->grids)) return;
977 if (ow > gw) ax = (ow - gw) / 2;
978 if (oh > gh) ay = (oh - gh) / 2;
980 if (wd->zoom != wd->marker_zoom)
982 EINA_LIST_FREE(wd->cells_displayed, cell)
984 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
986 if (group->obj) _group_object_free(group);
990 wd->marker_zoom = wd->zoom;
992 if ((wd->paused_markers)
993 && ((wd->size.nw != wd->size.w) || (wd->size.nh != wd->size.h)) )
996 g_xx = wd->pan_x / wd->tsize;
997 if (g_xx < 0) g_xx = 0;
998 g_yy = wd->pan_y / wd->tsize;
999 if (g_yy < 0) g_yy = 0;
1000 g_ww = (ow / wd->tsize) + 1;
1001 if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
1002 g_hh = (oh / wd->tsize) + 1;
1003 if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
1005 //hide groups no more displayed
1006 EINA_LIST_FREE(wd->cells_displayed, cell)
1008 eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x);
1009 if ((y < g_yy) || (y > g_yy + g_hh) || (x < g_xx) || (x > g_xx + g_ww))
1011 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
1013 if (group->obj) _group_object_free(group);
1018 if (!wd->marker_zoom)
1024 for (y = g_yy; y <= g_yy + g_hh; y++)
1026 for (x = g_xx; x <= g_xx + g_ww; x++)
1028 if (!wd->markers[wd->zoom]) continue;
1029 eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell);
1030 if (!cell) continue;
1031 wd->cells_displayed = eina_list_append(wd->cells_displayed, cell);
1032 markers = eina_matrixsparse_cell_data_get(cell);
1033 EINA_LIST_FOREACH(markers, l, group)
1035 if (!group->markers) continue;
1036 if (group->clas->zoom_displayed > wd->zoom) continue;
1043 if (eina_list_count(group->markers) == 1)
1045 Elm_Map_Marker *m = eina_list_data_get(group->markers);
1046 ww = m->clas->priv.edje_w;
1047 hh = m->clas->priv.edje_h;
1050 if (ww <= 0) ww = 1;
1051 if (hh <= 0) hh = 1;
1053 if ((gw != g->w) && (g->w > 0))
1056 xx = ((long long )gw * xx) / g->w;
1057 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1059 if ((gh != g->h) && (g->h > 0))
1062 yy = ((long long)gh * yy) / g->h;
1063 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1066 if ((!group->clas->hide)
1067 && (xx-px+ax+ox >= ox) && (xx-px+ax+ox<= ox+ow)
1068 && (yy-py+ay+oy >= oy) && (yy-py+ay+oy<= oy+oh))
1070 if (!group->obj) _group_object_create(group);
1072 if (group->update_nbelems)
1074 group->update_nbelems = EINA_FALSE;
1075 if (eina_list_count(group->markers) > 1)
1077 snprintf(buf, sizeof(buf), "%d", eina_list_count(group->markers));
1078 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
1081 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", "");
1083 evas_object_move(group->obj,
1084 xx - px + ax + ox - ww/2,
1085 yy - py + ay + oy - hh/2);
1086 if ((!wd->paused_markers) || (group->update_resize))
1088 group->update_resize = EINA_FALSE;
1089 evas_object_resize(group->obj, ww, hh);
1090 obj_rotate_zoom(obj, group->obj);
1092 if (group->update_raise)
1094 group->update_raise = EINA_FALSE;
1095 evas_object_raise(group->obj);
1096 obj_rotate_zoom(obj, group->obj);
1097 evas_object_show(group->obj);
1099 if (group->bubble) _group_bubble_place(group);
1101 else if (group->obj)
1103 _group_object_free(group);
1111 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)
1113 ELM_CHECK_WIDTYPE(obj, widtype);
1114 Widget_Data *wd = elm_widget_data_get(obj);
1115 Evas_Coord ax, ay, gw, gh, tx, ty;
1123 if (ow > gw) ax = (ow - gw) / 2;
1124 if (oh > gh) ay = (oh - gh) / 2;
1126 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1127 Eina_Matrixsparse_Cell *cell;
1129 EINA_ITERATOR_FOREACH(it, cell)
1131 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1137 if ((gw != g->w) && (g->w > 0))
1140 xx = ((long long )gw * xx) / g->w;
1141 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1143 if ((gh != g->h) && (g->h > 0))
1146 yy = ((long long)gh * yy) / g->h;
1147 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1149 evas_object_move(gi->img,
1153 evas_object_resize(gi->img, ww, hh);
1155 obj_rotate_zoom(obj, gi->img);
1156 /*evas_object_move(gi->txt,
1160 evas_object_resize(gi->txt, ww, hh);
1163 eina_iterator_free(it);
1167 grid_clear(Evas_Object *obj, Grid *g)
1169 ELM_CHECK_WIDTYPE(obj, widtype);
1170 Widget_Data *wd = elm_widget_data_get(obj);
1174 if (!g->grid) return;
1176 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1177 Eina_Matrixsparse_Cell *cell;
1179 snprintf(buf, sizeof(buf), DEST_DIR_ZOOM_PATH, wd->id, g->zoom);
1180 ecore_file_recursive_rm(buf);
1182 EINA_ITERATOR_FOREACH(it, cell)
1184 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1185 evas_object_del(gi->img);
1186 //evas_object_del(gi->txt);
1190 gi->want = EINA_FALSE;
1192 if (!wd->preload_num)
1194 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1195 "elm,state,busy,stop", "elm");
1196 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
1202 DBG("DOWNLOAD abort %s", gi->file);
1203 ecore_file_download_abort(gi->job);
1204 ecore_file_remove(gi->file);
1209 eina_stringshare_del(gi->file);
1213 eina_matrixsparse_free(g->grid);
1214 eina_iterator_free(it);
1221 _tile_update(Grid_Item *gi)
1223 gi->want = EINA_FALSE;
1224 gi->download = EINA_FALSE;
1225 evas_object_image_file_set(gi->img, gi->file, NULL);
1226 if (evas_object_image_load_error_get(gi->img) != EVAS_LOAD_ERROR_NONE)
1227 ecore_file_remove(gi->file);
1229 obj_rotate_zoom(gi->wd->obj, gi->img);
1230 evas_object_show(gi->img);
1232 //evas_object_text_text_set(gi->txt, gi->file);
1233 //evas_object_show(gi->txt);
1235 gi->have = EINA_TRUE;
1236 gi->wd->preload_num--;
1237 if (!gi->wd->preload_num)
1239 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
1240 "elm,state,busy,stop", "elm");
1241 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
1247 _tile_downloaded(void *data, const char *file __UNUSED__, int status)
1249 Grid_Item *gi = data;
1251 gi->download = EINA_FALSE;
1254 DBG("DOWNLOAD done %s", gi->file);
1255 if ((gi->want) && (!status)) _tile_update(gi);
1259 DBG("Download failed %s (%d) ", gi->file, status);
1260 ecore_file_remove(gi->file);
1263 gi->wd->finish_num++;
1265 evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL);
1269 grid_create(Evas_Object *obj)
1271 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1272 Widget_Data *wd = elm_widget_data_get(obj);
1275 if ((!wd) || (!wd->src)) return NULL;
1276 g = calloc(1, sizeof(Grid));
1279 g->tsize = wd->tsize;
1282 if (g->zoom > wd->src->zoom_max) return NULL;
1283 if (g->zoom < wd->src->zoom_min) return NULL;
1285 int size = pow(2.0, wd->zoom);
1289 g->w = g->tsize * g->gw;
1290 g->h = g->tsize * g->gh;
1292 g->grid = eina_matrixsparse_new(g->gh, g->gw, NULL, NULL);
1298 grid_load(Evas_Object *obj, Grid *g)
1300 ELM_CHECK_WIDTYPE(obj, widtype);
1301 Widget_Data *wd = elm_widget_data_get(obj);
1304 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
1306 Eina_Matrixsparse_Cell *cell;
1309 if ((!wd) || (!wd->src)) return;
1310 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
1311 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
1316 if ((gw <= 0) || (gh <= 0)) return;
1319 if ((gw != g->w) && (g->w > 0))
1320 size = ((long long)gw * size) / g->w;
1321 if (size < (g->tsize / 2)) return; // else we will load to much tiles
1323 it = eina_matrixsparse_iterator_new(g->grid);
1325 EINA_ITERATOR_FOREACH(it, cell)
1327 gi = eina_matrixsparse_cell_data_get(cell);
1334 if ((gw != g->w) && (g->w > 0))
1337 xx = ((long long )gw * xx) / g->w;
1338 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1340 if ((gh != g->h) && (g->h > 0))
1343 yy = ((long long)gh * yy) / g->h;
1344 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1347 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
1348 yy - wd->pan_y + oy,
1350 cvx, cvy, cvw, cvh))
1354 evas_object_hide(gi->img);
1355 //evas_object_hide(gi->txt);
1356 evas_object_image_file_set(gi->img, NULL, NULL);
1357 gi->want = EINA_FALSE;
1358 gi->have = EINA_FALSE;
1362 DBG("DOWNLOAD abort %s", gi->file);
1363 ecore_file_download_abort(gi->job);
1364 ecore_file_remove(gi->file);
1368 gi->download = EINA_FALSE;
1370 if (!wd->preload_num)
1372 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1373 "elm,state,busy,stop", "elm");
1374 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL,
1381 evas_object_hide(gi->img);
1382 //evas_object_hide(gi->txt);
1383 evas_object_image_preload(gi->img, 1);
1384 evas_object_image_file_set(gi->img, NULL, NULL);
1385 gi->have = EINA_FALSE;
1386 gi->want = EINA_FALSE;
1390 eina_iterator_free(it);
1392 xx = wd->pan_x / size - 1;
1395 yy = wd->pan_y / size - 1;
1399 if (xx + ww >= g->gw) ww = g->gw - xx - 1;
1402 if (yy + hh >= g->gh) hh = g->gh - yy - 1;
1404 for (y = yy; y <= yy + hh; y++)
1406 for (x = xx; x <= xx + ww; x++)
1408 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
1410 if ((!gi) && (g != eina_list_data_get(wd->grids)))
1415 gi = calloc(1, sizeof(Grid_Item));
1416 gi->src.x = x * g->tsize;
1417 gi->src.y = y * g->tsize;
1418 gi->src.w = g->tsize;
1419 gi->src.h = g->tsize;
1421 gi->out.x = gi->src.x;
1422 gi->out.y = gi->src.y;
1423 gi->out.w = gi->src.w;
1424 gi->out.h = gi->src.h;
1428 gi->img = evas_object_image_add(evas_object_evas_get(obj));
1429 evas_object_image_scale_hint_set
1430 (gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1431 evas_object_image_filled_set(gi->img, 1);
1433 evas_object_smart_member_add(gi->img, wd->pan_smart);
1434 elm_widget_sub_object_add(obj, gi->img);
1435 evas_object_pass_events_set(gi->img, EINA_TRUE);
1436 evas_object_stack_below(gi->img, wd->sep_maps_markers);
1438 /* gi->txt = evas_object_text_add(evas_object_evas_get(obj));
1439 evas_object_text_font_set(gi->txt, "Vera", 12);
1440 evas_object_color_set(gi->txt, 100, 100, 100, 255);
1441 evas_object_smart_member_add(gi->txt,
1443 elm_widget_sub_object_add(obj, gi->txt);
1444 evas_object_pass_events_set(gi->txt, EINA_TRUE);
1446 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
1449 if ((!gi->have) && (!gi->download))
1451 char buf[PATH_MAX], buf2[PATH_MAX];
1454 gi->want = EINA_TRUE;
1456 snprintf(buf, sizeof(buf), DEST_DIR_PATH, wd->id, g->zoom, x);
1457 if (!ecore_file_exists(buf))
1458 ecore_file_mkpath(buf);
1460 snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y);
1462 source = wd->src->url_cb(obj, x, y, g->zoom);
1463 if ((!source) || (strlen(source)==0)) continue;
1465 eina_stringshare_replace(&gi->file, buf2);
1467 if ((ecore_file_exists(buf2)) || (g == eina_list_data_get(wd->grids)))
1469 gi->download = EINA_TRUE;
1471 if (wd->preload_num == 1)
1473 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1474 "elm,state,busy,start", "elm");
1475 evas_object_smart_callback_call(obj,
1480 if (ecore_file_exists(buf2))
1484 DBG("DOWNLOAD %s \t in %s", source, buf2);
1485 ecore_file_download_full(source, buf2, _tile_downloaded, NULL, gi, &(gi->job), wd->ua);
1487 DBG("Can't start to download %s", buf);
1492 if (source) free(source);
1496 obj_rotate_zoom(obj, gi->img);
1497 evas_object_show(gi->img);
1504 grid_clearall(Evas_Object *obj)
1506 ELM_CHECK_WIDTYPE(obj, widtype);
1507 Widget_Data *wd = elm_widget_data_get(obj);
1511 EINA_LIST_FREE(wd->grids, g)
1519 _smooth_update(Evas_Object *obj)
1521 ELM_CHECK_WIDTYPE(obj, widtype);
1522 Widget_Data *wd = elm_widget_data_get(obj);
1527 EINA_LIST_FOREACH(wd->grids, l, g)
1529 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1530 Eina_Matrixsparse_Cell *cell;
1532 EINA_ITERATOR_FOREACH(it, cell)
1534 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1535 evas_object_image_smooth_scale_set(gi->img, (!wd->nosmooth));
1537 eina_iterator_free(it);
1542 _scr_timeout(void *data)
1544 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1545 Widget_Data *wd = elm_widget_data_get(data);
1547 if (!wd) return ECORE_CALLBACK_CANCEL;
1549 if (!wd->nosmooth) _smooth_update(data);
1550 wd->scr_timer = NULL;
1551 return ECORE_CALLBACK_CANCEL;
1555 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1557 ELM_CHECK_WIDTYPE(data, widtype);
1558 Widget_Data *wd = elm_widget_data_get(data);
1564 if (wd->nosmooth == 1) _smooth_update(data);
1566 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1567 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
1571 zoom_do(Evas_Object *obj)
1573 ELM_CHECK_WIDTYPE(obj, widtype);
1574 Widget_Data *wd = elm_widget_data_get(obj);
1575 Evas_Coord xx, yy, ow, oh;
1578 wd->size.w = wd->size.nw;
1579 wd->size.h = wd->size.nh;
1581 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
1583 if (wd->center_on.enabled)
1585 elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy);
1591 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
1592 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
1597 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
1599 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
1601 wd->show.show = EINA_TRUE;
1607 if (wd->calc_job) ecore_job_del(wd->calc_job);
1608 wd->calc_job = ecore_job_add(_calc_job, wd);
1612 _zoom_timeout(void *data)
1614 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1615 Widget_Data *wd = elm_widget_data_get(data);
1617 if (!wd) return ECORE_CALLBACK_CANCEL;
1618 wd->zoom_timer = NULL;
1619 wd->pinch.level = 1.0;
1621 evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
1622 return ECORE_CALLBACK_CANCEL;
1626 _zoom_anim(void *data)
1628 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1629 Evas_Object *obj = data;
1630 Widget_Data *wd = elm_widget_data_get(obj);
1632 if (!wd) return ECORE_CALLBACK_CANCEL;
1633 if (wd->zoom_method == ZOOM_METHOD_IN) wd->t += 0.1 ;
1634 else if (wd->zoom_method == ZOOM_METHOD_OUT) wd->t -= 0.05;
1637 wd->zoom_animator = NULL;
1639 evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
1640 return ECORE_CALLBACK_CANCEL;
1645 wd->zoom_animator = NULL;
1646 wd->pinch.level = 2.0;
1647 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1648 wd->zoom_timer = ecore_timer_add(0.35, _zoom_timeout, obj);
1649 return ECORE_CALLBACK_CANCEL;
1651 else if (wd->t <= 0.5)
1653 wd->zoom_animator = NULL;
1654 wd->pinch.level = 0.5;
1655 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1656 wd->zoom_timer = ecore_timer_add(1.35, _zoom_timeout, obj);
1657 return ECORE_CALLBACK_CANCEL;
1659 else if (wd->t != 1.0)
1661 Evas_Coord x, y, w, h;
1662 float half_w, half_h;
1663 evas_object_geometry_get(data, &x, &y, &w, &h);
1664 half_w = (float)w * 0.5;
1665 half_h = (float)h * 0.5;
1666 wd->pinch.cx = x + half_w;
1667 wd->pinch.cy = y + half_h;
1668 wd->pinch.level = wd->t;
1669 if (wd->calc_job) ecore_job_del(wd->calc_job);
1670 wd->calc_job = ecore_job_add(_calc_job, wd);
1672 return ECORE_CALLBACK_RENEW;
1676 _long_press(void *data)
1678 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1679 Widget_Data *wd = elm_widget_data_get(data);
1681 if (!wd) return ECORE_CALLBACK_CANCEL;
1682 wd->long_timer = NULL;
1683 evas_object_smart_callback_call(data, SIG_LONGPRESSED, &wd->ev);
1684 return ECORE_CALLBACK_CANCEL;
1688 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1690 ELM_CHECK_WIDTYPE(data, widtype);
1691 Widget_Data *wd = elm_widget_data_get(data);
1692 Evas_Event_Mouse_Down *ev = event_info;
1696 ev0 = get_event_object(data, 0);
1698 ev0 = create_event_object(data, obj, 0);
1701 ev0->hold_timer = NULL;
1702 ev0->prev.x = ev->canvas.x;
1703 ev0->prev.y = ev->canvas.y;
1705 if (ev->button != 1) return;
1706 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1707 else wd->on_hold = EINA_FALSE;
1708 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1709 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, ev);
1711 evas_object_smart_callback_call(data, SIG_PRESS, ev);
1712 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1713 wd->ev.canvas.x = ev->output.x;
1714 wd->ev.canvas.y = ev->output.y;
1715 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1719 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1721 Evas_Event_Mouse_Move *move = event_info;
1724 ev0 = get_event_object(data, 0);
1726 ev0->prev.x = move->cur.canvas.x;
1727 ev0->prev.y = move->cur.canvas.y;
1731 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1733 ELM_CHECK_WIDTYPE(data, widtype);
1734 Widget_Data *wd = elm_widget_data_get(data);
1737 Evas_Event_Mouse_Up *ev = event_info;
1742 ev0 = get_event_object(data, 0);
1745 mdevice = get_multi_device(data);
1748 if (ev0->hold_timer)
1750 ecore_timer_del(ev0->hold_timer);
1751 ev0->hold_timer = NULL;
1753 elm_smart_scroller_hold_set(wd->scr, 0);
1754 elm_smart_scroller_freeze_set(wd->scr, 0);
1758 ev1 = get_event_object(data, mdevice);
1760 ev1->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev1);
1762 destroy_event_object(data, ev0);
1765 if (ev->button != 1) return;
1766 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1767 else wd->on_hold = EINA_FALSE;
1770 ecore_timer_del(wd->long_timer);
1771 wd->long_timer = NULL;
1773 if (!wd->on_hold) evas_object_smart_callback_call(data, SIG_CLICKED, ev);
1774 wd->on_hold = EINA_FALSE;
1778 _mouse_multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1780 ELM_CHECK_WIDTYPE(data, widtype);
1781 Widget_Data *wd = elm_widget_data_get(data);
1783 Evas_Event_Multi_Down *down = event_info;
1785 elm_smart_scroller_hold_set(wd->scr, 1);
1786 elm_smart_scroller_freeze_set(wd->scr, 1);
1788 ev = create_event_object(data, obj, down->device);
1791 DBG("Failed : create_event_object");
1796 ev->hold_timer = NULL;
1797 ev->start.x = ev->prev.x = down->canvas.x;
1798 ev->start.y = ev->prev.y = down->canvas.y;
1799 ev->pinch_start_dis = 0;
1800 wd->pinch.level = 1.0;
1801 wd->pinch.diff = 1.0;
1806 ecore_timer_del(wd->long_timer);
1807 wd->long_timer = NULL;
1813 _mouse_multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1815 ELM_CHECK_WIDTYPE(data, widtype);
1816 Widget_Data *wd = elm_widget_data_get(data);
1817 Evas_Event_Multi_Move *move = event_info;
1818 int dis_new, dx, dy;
1819 double t, tt, a, a_diff;
1823 if ((!wd) || (!wd->src)) return;
1824 ev = get_event_object(data, move->device);
1827 ev0 = get_event_object(data, 0);
1830 if (wd->multi_count >= 1)
1832 Evas_Coord x, y, w, h;
1833 float half_w, half_h;
1835 evas_object_geometry_get(data, &x, &y, &w, &h);
1836 half_w = (float)w * 0.5;
1837 half_h = (float)h * 0.5;
1838 dx = ev0->prev.x - ev->prev.x;
1839 dy = ev0->prev.y - ev->prev.y;
1840 dis_new = sqrt((dx * dx) + (dy * dy));
1842 if (!ev->pinch_start_dis) ev->pinch_start_dis = dis_new;
1845 ev->pinch_dis = dis_new;
1846 tt = wd->pinch.diff;
1847 wd->pinch.diff = (double)(ev->pinch_dis - ev->pinch_start_dis);
1848 t = (wd->pinch.diff * 0.01) + 1.0;
1849 if ((t > 1.1) || (wd->rotate.doing))
1851 if (((wd->zoom + (int)t - 1) < wd->src->zoom_min) ||
1852 ((wd->zoom + (int)t - 1) > wd->src->zoom_max) ||
1853 (t > PINCH_ZOOM_MAX) || (t < PINCH_ZOOM_MIN))
1855 wd->pinch.diff = tt;
1860 wd->pinch.level = (wd->pinch.diff * 0.01) + 1.0;
1861 wd->pinch.cx = x + half_w;
1862 wd->pinch.cy = y + half_h;
1863 wd->pinch.doing = EINA_TRUE;
1864 if (!wd->rotate.doing) goto do_zoom_only;
1869 if (wd->pinch.doing) goto do_nothing;
1872 a = (double)(ev->prev.y - ev0->prev.y) / (double)(ev->prev.x - ev0->prev.x);
1873 if (!wd->rotate.a) wd->rotate.a = a;
1876 a_diff = wd->rotate.a - a;
1877 if (a_diff > 0) wd->rotate.d -= 1.0;
1878 else if (a_diff < 0) wd->rotate.d += 1.0;
1880 wd->rotate.cx = x + half_w;
1881 wd->rotate.cy = y + half_h;
1882 wd->rotate.doing = EINA_TRUE;
1885 if (wd->calc_job) ecore_job_del(wd->calc_job);
1886 wd->calc_job = ecore_job_add(_calc_job, wd);
1890 ev->prev.x = move->cur.canvas.x;
1891 ev->prev.y = move->cur.canvas.y;
1895 _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1897 ELM_CHECK_WIDTYPE(data, widtype);
1898 Widget_Data *wd = elm_widget_data_get(data);
1899 Evas_Event_Multi_Up *up = event_info;
1906 if (wd->calc_job) ecore_job_del(wd->calc_job);
1907 if (wd->zoom_animator)
1909 ecore_animator_del(wd->zoom_animator);
1910 wd->zoom_animator = NULL;
1913 wd->paused = EINA_TRUE;
1914 if (wd->pinch.diff >= 0.0) zoom = (int)ceil((wd->pinch.diff * 0.01) - 1.0);
1915 else if (wd->pinch.diff < 0.0) zoom = (int)floor(-1.0 / ((wd->pinch.diff * 0.005) + 1.0));
1916 elm_map_zoom_set(data, wd->zoom + zoom);
1917 wd->pinch.level = 1.0;
1918 wd->pinch.doing = EINA_FALSE;
1921 wd->rotate.doing = EINA_FALSE;
1923 ev = get_event_object(data, up->device);
1926 DBG("Cannot get multi device");
1930 ev0 = get_event_object(data, 0);
1932 ev0->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev0);
1937 ecore_timer_del(ev->hold_timer);
1938 ev->hold_timer = NULL;
1941 destroy_event_object(data, ev);
1945 _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1947 ELM_CHECK_WIDTYPE(data, widtype);
1948 Widget_Data *wd = elm_widget_data_get(data);
1949 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
1950 Evas_Coord x, y, w, h;
1951 float half_w, half_h;
1954 evas_object_geometry_get(data, &x, &y, &w, &h);
1955 half_w = (float)w * 0.5;
1956 half_h = (float)h * 0.5;
1958 if (!wd->wheel_zoom) wd->wheel_zoom = 1.0;
1961 wd->zoom_method = ZOOM_METHOD_OUT;
1962 wd->wheel_zoom -= 0.05;
1963 if (wd->wheel_zoom <= PINCH_ZOOM_MIN) wd->wheel_zoom = PINCH_ZOOM_MIN;
1967 wd->zoom_method = ZOOM_METHOD_IN;
1968 wd->wheel_zoom += 0.2;
1969 if (wd->wheel_zoom >= PINCH_ZOOM_MAX) wd->wheel_zoom = PINCH_ZOOM_MAX;
1974 wd->pinch.level = wd->wheel_zoom;
1975 wd->pinch.cx = x + half_w;
1976 wd->pinch.cy = y + half_h;
1977 if (wd->calc_job) ecore_job_del(wd->calc_job);
1978 wd->calc_job = ecore_job_add(_calc_job, wd);
1981 if (wd->wheel_timer) ecore_timer_del(wd->wheel_timer);
1982 wd->wheel_timer = ecore_timer_add(0.35, _wheel_timer_cb, data);
1986 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
1989 _hold_timer_cb(void *data)
1993 ev0->hold_timer = NULL;
1994 return ECORE_CALLBACK_CANCEL;
1998 _wheel_timer_cb(void *data)
2000 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
2001 Widget_Data *wd = elm_widget_data_get(data);
2006 wd->wheel_timer = NULL;
2007 return ECORE_CALLBACK_CANCEL;
2009 if (wd->zoom_method == ZOOM_METHOD_IN) zoom = (int)ceil(wd->wheel_zoom - 1.0);
2010 else if (wd->zoom_method == ZOOM_METHOD_OUT) zoom = (int)floor((-1.0 / wd->wheel_zoom) + 1.0);
2013 wd->wheel_timer = NULL;
2014 return ECORE_CALLBACK_CANCEL;
2016 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
2017 elm_map_zoom_set(data, wd->zoom + zoom);
2018 wd->wheel_zoom = 0.0;
2019 wd->wheel_timer = NULL;
2020 return ECORE_CALLBACK_CANCEL;
2024 _rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2026 ELM_CHECK_WIDTYPE(data, widtype);
2027 Widget_Data *wd = elm_widget_data_get(data);
2030 evas_object_geometry_get(wd->rect, &x, &y, &w, &h);
2031 evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h);
2032 evas_object_resize(wd->rect, w, h);
2033 evas_object_move(wd->rect, x, y);
2037 _del_hook(Evas_Object *obj)
2039 ELM_CHECK_WIDTYPE(obj, widtype);
2040 Widget_Data *wd = elm_widget_data_get(obj);
2041 Elm_Map_Group_Class *group_clas;
2042 Elm_Map_Marker_Class *marker_clas;
2048 Ecore_Event_Handler *h;
2054 EINA_LIST_FREE(wd->groups_clas, group_clas)
2056 if (group_clas->style)
2057 eina_stringshare_del(group_clas->style);
2061 EINA_LIST_FREE(wd->markers_clas, marker_clas)
2063 if (marker_clas->style)
2064 eina_stringshare_del(marker_clas->style);
2068 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
2070 destroy_event_object(obj, ev);
2073 EINA_LIST_FOREACH(wd->route, l, r)
2075 EINA_LIST_FREE(r->path, p)
2080 EINA_LIST_FREE(r->waypoint, w)
2082 if (w->point) eina_stringshare_del(w->point);
2086 EINA_LIST_FREE(r->nodes, n)
2088 if (n->pos.address) eina_stringshare_del(n->pos.address);
2092 EINA_LIST_FREE(r->handlers, h)
2094 ecore_event_handler_del(h);
2097 if (r->con_url) ecore_con_url_free(r->con_url);
2098 if (r->info.nodes) eina_stringshare_del(r->info.nodes);
2099 if (r->info.waypoints) eina_stringshare_del(r->info.waypoints);
2102 EINA_LIST_FREE(wd->names, na)
2104 if (na->address) free(na->address);
2105 if (na->handler) ecore_event_handler_del(na->handler);
2108 ecore_file_remove(na->ud.fname);
2110 na->ud.fname = NULL;
2114 EINA_LIST_FREE(wd->track, route)
2116 evas_object_del(route);
2119 if (wd->map) evas_map_free(wd->map);
2120 if (wd->source_names) free(wd->source_names);
2121 if (wd->calc_job) ecore_job_del(wd->calc_job);
2122 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
2123 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
2124 if (wd->long_timer) ecore_timer_del(wd->long_timer);
2125 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
2126 if (wd->ua) eina_hash_free(wd->ua);
2127 if (wd->markers) free(wd->markers);
2133 _del_pre_hook(Evas_Object *obj)
2135 ELM_CHECK_WIDTYPE(obj, widtype);
2136 Widget_Data *wd = elm_widget_data_get(obj);
2137 Marker_Group *group;
2138 Elm_Map_Marker *marker;
2140 Eina_Bool free_marker = EINA_TRUE;
2145 for (i = 0; i <= wd->zoom_max; i++)
2147 if (!wd->markers[i]) continue;
2148 Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
2149 Eina_Matrixsparse_Cell *cell;
2151 EINA_ITERATOR_FOREACH(it, cell)
2153 l = eina_matrixsparse_cell_data_get(cell);
2154 EINA_LIST_FREE(l, group)
2156 EINA_LIST_FREE(group->markers, marker)
2158 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2159 _bubble_sc_hits_changed_cb, group);
2160 if (free_marker) free(marker);
2164 free_marker = EINA_FALSE;
2166 eina_iterator_free(it);
2167 eina_matrixsparse_free(wd->markers[i]);
2170 evas_object_del(wd->sep_maps_markers);
2171 evas_object_del(wd->pan_smart);
2172 wd->pan_smart = NULL;
2176 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
2178 ELM_CHECK_WIDTYPE(obj, widtype);
2179 Widget_Data *wd = elm_widget_data_get(obj);
2182 if (elm_widget_focus_get(obj))
2184 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
2185 evas_object_focus_set(wd->obj, EINA_TRUE);
2189 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
2190 evas_object_focus_set(wd->obj, EINA_FALSE);
2195 _theme_hook(Evas_Object *obj)
2197 ELM_CHECK_WIDTYPE(obj, widtype);
2198 Widget_Data *wd = elm_widget_data_get(obj);
2201 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
2202 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
2207 _sizing_eval(Evas_Object *obj)
2209 ELM_CHECK_WIDTYPE(obj, widtype);
2210 Widget_Data *wd = elm_widget_data_get(obj);
2211 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
2214 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
2215 evas_object_size_hint_min_set(obj, minw, minh);
2216 evas_object_size_hint_max_set(obj, maxw, maxh);
2220 _calc_job(void *data)
2222 Widget_Data *wd = data;
2223 Evas_Coord minw, minh;
2230 wd->resized = EINA_FALSE;
2231 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
2233 double tz = wd->zoom;
2235 elm_map_zoom_set(wd->obj, tz);
2238 if ((minw != wd->minw) || (minh != wd->minh))
2242 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
2243 _sizing_eval(wd->obj);
2245 wd->calc_job = NULL;
2246 evas_object_smart_changed(wd->pan_smart);
2250 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2252 Pan *sd = evas_object_smart_data_get(obj);
2254 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2257 evas_object_smart_changed(obj);
2261 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2263 Pan *sd = evas_object_smart_data_get(obj);
2265 if (x) *x = sd->wd->pan_x;
2266 if (y) *y = sd->wd->pan_y;
2270 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2272 Pan *sd = evas_object_smart_data_get(obj);
2275 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2276 ow = sd->wd->minw - ow;
2278 oh = sd->wd->minh - oh;
2285 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
2292 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2294 Pan *sd = evas_object_smart_data_get(obj);
2296 if (w) *w = sd->wd->minw;
2297 if (h) *h = sd->wd->minh;
2301 _pan_add(Evas_Object *obj)
2304 Evas_Object_Smart_Clipped_Data *cd;
2306 cd = evas_object_smart_data_get(obj);
2308 sd = calloc(1, sizeof(Pan));
2310 sd->__clipped_data = *cd;
2312 evas_object_smart_data_set(obj, sd);
2316 _pan_del(Evas_Object *obj)
2318 Pan *sd = evas_object_smart_data_get(obj);
2324 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2326 Pan *sd = evas_object_smart_data_get(obj);
2329 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2330 if ((ow == w) && (oh == h)) return;
2331 sd->wd->resized = EINA_TRUE;
2332 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2333 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2337 _pan_calculate(Evas_Object *obj)
2339 Pan *sd = evas_object_smart_data_get(obj);
2340 Evas_Coord ox, oy, ow, oh;
2344 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2345 rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2346 EINA_LIST_FOREACH(sd->wd->grids, l, g)
2348 if ((sd->wd->pinch.level == 1.0) || (sd->wd->pinch.level == 0.5)) grid_load(sd->wd->obj, g);
2349 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2350 marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2351 if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2352 if (!sd->wd->zoom_animator) track_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2357 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2359 Pan *sd = evas_object_smart_data_get(obj);
2361 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2362 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2366 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2368 ELM_CHECK_WIDTYPE(obj, widtype);
2369 Widget_Data *wd = elm_widget_data_get(obj);
2372 elm_smart_scroller_hold_set(wd->scr, 1);
2376 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2378 ELM_CHECK_WIDTYPE(obj, widtype);
2379 Widget_Data *wd = elm_widget_data_get(obj);
2382 elm_smart_scroller_hold_set(wd->scr, 0);
2386 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2388 ELM_CHECK_WIDTYPE(obj, widtype);
2389 Widget_Data *wd = elm_widget_data_get(obj);
2392 elm_smart_scroller_freeze_set(wd->scr, 1);
2396 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2398 ELM_CHECK_WIDTYPE(obj, widtype);
2399 Widget_Data *wd = elm_widget_data_get(obj);
2402 elm_smart_scroller_freeze_set(wd->scr, 0);
2406 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2408 evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
2412 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2414 evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
2418 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2420 Widget_Data *wd = elm_widget_data_get(data);
2421 wd->center_on.enabled = EINA_FALSE;
2422 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2426 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2428 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2432 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2434 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
2439 _group_object_create(Marker_Group *group)
2441 const char *style = "radio";
2442 Evas_Object *icon = NULL;
2444 if (group->obj) return;
2445 if ((!group->clas->priv.objs_notused) || (eina_list_count(group->markers) == 1))
2447 //set icon and style
2448 if (eina_list_count(group->markers) == 1)
2450 Elm_Map_Marker *m = eina_list_data_get(group->markers);
2452 style = m->clas->style;
2454 if (m->clas->func.icon_get)
2455 icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
2457 group->delete_object = EINA_TRUE;
2461 if (group->clas->style)
2462 style = group->clas->style;
2464 if (group->clas->func.icon_get)
2465 icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
2467 group->delete_object = EINA_FALSE;
2470 group->obj = elm_layout_add(group->wd->obj);
2471 elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
2473 if (icon) elm_layout_content_set(group->obj, "elm.icon", icon);
2475 evas_object_smart_member_add(group->obj, group->wd->pan_smart);
2476 elm_widget_sub_object_add(group->wd->obj, group->obj);
2477 evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
2479 if (!group->delete_object)
2480 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2484 group->delete_object = EINA_FALSE;
2486 group->obj = eina_list_data_get(group->clas->priv.objs_notused);
2487 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2488 group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
2489 evas_object_show(group->obj);
2492 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
2493 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
2495 group->update_nbelems = EINA_TRUE;
2496 group->update_resize = EINA_TRUE;
2497 group->update_raise = EINA_TRUE;
2499 if (group->open) _group_bubble_create(group);
2503 _group_object_free(Marker_Group *group)
2505 if (!group->obj) return;
2506 if (!group->delete_object)
2508 group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
2509 group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
2510 evas_object_hide(group->obj);
2512 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
2513 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
2516 evas_object_del(group->obj);
2519 _group_bubble_free(group);
2523 _group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2525 Marker_Group *group = data;
2527 if (!evas_object_above_get(group->rect)) return;
2528 evas_object_raise(group->bubble);
2529 evas_object_raise(group->sc);
2530 evas_object_raise(group->rect);
2534 _group_bubble_create(Marker_Group *group)
2536 if (group->bubble) return;
2538 group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
2539 group->bubble = edje_object_add(evas_object_evas_get(group->obj));
2540 _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
2541 elm_widget_style_get(group->wd->obj));
2542 evas_object_smart_member_add(group->bubble,
2544 elm_widget_sub_object_add(group->wd->obj, group->bubble);
2546 _group_bubble_content_free(group);
2547 if (!_group_bubble_content_update(group))
2549 //no content, we can delete the bubble
2550 _group_bubble_free(group);
2554 group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
2555 evas_object_color_set(group->rect, 0, 0, 0, 0);
2556 evas_object_repeat_events_set(group->rect, EINA_TRUE);
2557 evas_object_smart_member_add(group->rect, group->wd->obj);
2558 elm_widget_sub_object_add(group->wd->obj, group->rect);
2560 evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
2562 _group_bubble_place(group);
2565 static void _bubble_sc_hits_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2567 _group_bubble_place(data);
2571 _group_bubble_content_update(Marker_Group *group)
2574 Elm_Map_Marker *marker;
2577 if (!group->bubble) return 1;
2581 group->sc = elm_scroller_add(group->bubble);
2582 elm_widget_style_set(group->sc, "map_bubble");
2583 elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
2584 elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
2585 elm_scroller_bounce_set(group->sc, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
2586 edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
2587 evas_object_show(group->sc);
2588 evas_object_smart_member_add(group->sc,
2590 elm_widget_sub_object_add(group->wd->obj, group->sc);
2592 group->bx = elm_box_add(group->bubble);
2593 evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2594 evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
2595 elm_box_horizontal_set(group->bx, EINA_TRUE);
2596 evas_object_show(group->bx);
2598 elm_scroller_content_set(group->sc, group->bx);
2600 evas_object_event_callback_add(group->sc, EVAS_CALLBACK_RESIZE,
2601 _bubble_sc_hits_changed_cb, group);
2604 EINA_LIST_FOREACH(group->markers, l, marker)
2606 if (i >= group->wd->markers_max_num) break;
2607 if ((!marker->content) && (marker->clas->func.get))
2608 marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
2609 else if (marker->content)
2610 elm_box_unpack(group->bx, marker->content);
2611 if (marker->content)
2613 elm_box_pack_end(group->bx, marker->content);
2621 _group_bubble_content_free(Marker_Group *group)
2624 Elm_Map_Marker *marker;
2626 if (!group->sc) return;
2627 EINA_LIST_FOREACH(group->markers, l, marker)
2629 if ((marker->content) && (marker->clas->func.del))
2630 marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
2631 else if (marker->content)
2632 evas_object_del(marker->content);
2633 marker->content = NULL;
2635 evas_object_del(group->sc);
2640 _group_bubble_free(Marker_Group *group)
2642 if (!group->bubble) return;
2643 group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
2644 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2645 _bubble_sc_hits_changed_cb, group);
2646 evas_object_del(group->bubble);
2647 evas_object_del(group->rect);
2648 group->bubble = NULL;
2649 _group_bubble_content_free(group);
2653 _group_bubble_place(Marker_Group *group)
2656 Evas_Coord xx, yy, ww, hh;
2659 if ((!group->bubble) || (!group->obj)) return;
2661 evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
2662 edje_object_size_min_calc(group->bubble, NULL, &hh);
2664 s = edje_object_data_get(group->bubble, "size_w");
2665 if (s) ww = atoi(s);
2667 xx = x + w / 2 - ww / 2;
2670 evas_object_move(group->bubble, xx, yy);
2671 evas_object_resize(group->bubble, ww, hh);
2672 obj_rotate_zoom(group->wd, group->bubble);
2673 evas_object_show(group->bubble);
2675 evas_object_move(group->rect, xx, yy);
2676 evas_object_resize(group->rect, ww, hh);
2677 obj_rotate_zoom(group->wd, group->rect);
2678 evas_object_show(group->rect);
2682 _group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2684 Marker_Group *group = data;
2685 Elm_Map_Marker *marker = eina_list_data_get(group->markers);
2686 if (!marker) return;
2687 group->bringin = EINA_TRUE;
2688 elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
2692 _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2694 Marker_Group *group = data;
2698 group->bringin = EINA_FALSE;
2704 group->open = EINA_FALSE;
2705 _group_bubble_free(group);
2708 group->open = EINA_TRUE;
2709 _group_bubble_create(group);
2713 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
2715 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2716 Widget_Data *wd = elm_widget_data_get(obj);
2720 Evas_Coord step_x = 0;
2721 Evas_Coord step_y = 0;
2724 Evas_Coord page_x = 0;
2725 Evas_Coord page_y = 0;
2727 if (!wd) return EINA_FALSE;
2728 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
2729 Evas_Event_Key_Down *ev = event_info;
2730 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
2732 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
2733 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
2734 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
2735 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
2737 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
2741 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
2745 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
2749 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
2753 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
2756 y -= -(page_y * v_h) / 100;
2760 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
2763 y += -(page_y * v_h) / 100;
2767 else if (!strcmp(ev->keyname, "KP_Add"))
2769 zoom = elm_map_zoom_get(obj) + 1;
2770 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2771 elm_map_zoom_set(obj, zoom);
2774 else if (!strcmp(ev->keyname, "KP_Subtract"))
2776 zoom = elm_map_zoom_get(obj) - 1;
2777 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2778 elm_map_zoom_set(obj, zoom);
2781 else return EINA_FALSE;
2783 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2784 elm_smart_scroller_child_pos_set(wd->scr, x, y);
2790 cb_dump_name_attrs(void *data, const char *key, const char *value)
2792 Name_Dump *dump = (Name_Dump*)data;
2793 if (!dump) return EINA_FALSE;
2795 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
2796 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
2803 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2805 Route_Dump *dump = data;
2806 if (!dump) return EINA_FALSE;
2810 case EINA_SIMPLE_XML_OPEN:
2811 case EINA_SIMPLE_XML_OPEN_EMPTY:
2815 attrs = eina_simple_xml_tag_attributes_find(value, length);
2818 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
2819 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
2820 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
2821 else dump->id = ROUTE_XML_NONE;
2825 case EINA_SIMPLE_XML_DATA:
2827 char *buf = malloc(length);
2828 if (!buf) return EINA_FALSE;
2829 snprintf(buf, length, "%s", value);
2830 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
2831 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2832 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2844 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2846 Name_Dump *dump = data;
2847 if (!dump) return EINA_FALSE;
2851 case EINA_SIMPLE_XML_OPEN:
2852 case EINA_SIMPLE_XML_OPEN_EMPTY:
2855 attrs = eina_simple_xml_tag_attributes_find(value, length);
2858 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME;
2859 else dump->id = NAME_XML_NONE;
2861 eina_simple_xml_attributes_parse
2862 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
2866 case EINA_SIMPLE_XML_DATA:
2868 char *buf = malloc(length + 1);
2869 if (!buf) return EINA_FALSE;
2870 snprintf(buf, length + 1, "%s", value);
2871 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2883 _parse_kml(void *data)
2885 Elm_Map_Route *r = (Elm_Map_Route*)data;
2886 if (!r && !r->ud.fname) return;
2890 unsigned int ele, idx;
2894 Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL};
2896 f = fopen(r->ud.fname, "rb");
2901 fseek(f, 0, SEEK_END);
2907 fseek(f, 0, SEEK_SET);
2911 if (fread(buf, 1, sz, f))
2913 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump);
2920 if (dump.distance) r->info.distance = dump.distance;
2921 if (dump.description)
2923 eina_stringshare_replace(&r->info.waypoints, dump.description);
2924 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2925 r->info.waypoint_count = ele;
2926 for (idx = 0 ; idx < ele ; idx++)
2928 Path_Waypoint *wp = ELM_NEW(Path_Waypoint);
2932 wp->point = eina_stringshare_add(str[idx]);
2933 DBG("%s", str[idx]);
2934 r->waypoint = eina_list_append(r->waypoint, wp);
2943 else WRN("description is not found !");
2945 if (dump.coordinates)
2947 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2948 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2949 r->info.node_count = ele;
2950 for (idx = 0 ; idx < ele ; idx++)
2952 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2953 Path_Node *n = ELM_NEW(Path_Node);
2960 DBG("%lf:%lf", lon, lat);
2961 n->pos.address = NULL;
2962 r->nodes = eina_list_append(r->nodes, n);
2964 path = evas_object_polygon_add(evas_object_evas_get(r->wd->obj));
2965 evas_object_smart_member_add(path, r->wd->pan_smart);
2966 r->path = eina_list_append(r->path, path);
2979 _parse_name(void *data)
2981 Elm_Map_Name *n = (Elm_Map_Name*)data;
2982 if (!n && !n->ud.fname) return;
2986 Name_Dump dump = {0, NULL, 0.0, 0.0};
2988 f = fopen(n->ud.fname, "rb");
2993 fseek(f, 0, SEEK_END);
2999 fseek(f, 0, SEEK_SET);
3003 if (fread(buf, 1, sz, f))
3005 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
3014 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
3015 n->address = strdup(dump.address);
3023 _route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
3025 Ecore_Con_Event_Url_Complete *ev = event;
3026 Elm_Map_Route *r = (Elm_Map_Route*)data;
3027 Widget_Data *wd = r->wd;
3029 if ((!r) || (!ev)) return EINA_TRUE;
3030 Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url);
3031 ecore_con_url_data_set(r->con_url, NULL);
3032 if (r!=rr) return EINA_TRUE;
3034 if (r->ud.fd) fclose(r->ud.fd);
3039 Evas_Coord ox, oy, ow, oh;
3040 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3041 route_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3043 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3044 "elm,state,busy,stop", "elm");
3045 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
3050 _name_complete_cb(void *data, int ev_type __UNUSED__, void *event)
3052 Ecore_Con_Event_Url_Complete *ev = event;
3053 Elm_Map_Name *n = (Elm_Map_Name*)data;
3054 Widget_Data *wd = n->wd;
3056 if ((!n) || (!ev)) return EINA_TRUE;
3057 Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url);
3058 ecore_con_url_data_set(n->con_url, NULL);
3059 if (n!=nn) return EINA_TRUE;
3061 if (n->ud.fd) fclose(n->ud.fd);
3064 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3065 "elm,state,busy,stop", "elm");
3066 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
3070 static Elm_Map_Name *
3071 _utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat)
3073 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3074 Widget_Data *wd = elm_widget_data_get(obj);
3079 if ((!wd) || (!wd->src)) return NULL;
3080 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
3081 if (!name) return NULL;
3083 snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE);
3091 name->con_url = ecore_con_url_new(NULL);
3092 name->ud.fname = strdup(buf);
3093 INF("xml file : %s", name->ud.fname);
3095 name->ud.fd = fdopen(fd, "w+");
3096 if ((!name->con_url) || (!name->ud.fd))
3098 ecore_con_url_free(name->con_url);
3104 name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name);
3105 name->method = method;
3106 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
3107 else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL;
3111 source = wd->src->name_url_cb(wd->obj, method, address, lon, lat);
3112 INF("name url = %s", source);
3114 wd->names = eina_list_append(wd->names, name);
3115 ecore_con_url_url_set(name->con_url, source);
3116 ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd));
3117 ecore_con_url_data_set(name->con_url, name);
3119 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3120 "elm,state,busy,start", "elm");
3121 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL);
3122 ecore_con_url_get(name->con_url);
3123 if (source) free(source);
3129 static int idnum = 1;
3132 * Add a new Map object
3134 * @param parent The parent object
3135 * @return The new object or NULL if it cannot be created
3140 elm_map_add(Evas_Object *parent)
3144 Evas_Coord minw, minh;
3146 static Evas_Smart *smart = NULL;
3147 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
3149 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3151 ELM_SET_WIDTYPE(widtype, "map");
3152 elm_widget_type_set(obj, "map");
3153 elm_widget_sub_object_add(parent, obj);
3154 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3155 elm_widget_data_set(obj, wd);
3156 elm_widget_del_hook_set(obj, _del_hook);
3157 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3158 elm_widget_theme_hook_set(obj, _theme_hook);
3159 elm_widget_can_focus_set(obj, EINA_TRUE);
3160 elm_widget_event_hook_set(obj, _event_hook);
3162 wd->scr = elm_smart_scroller_add(e);
3163 elm_smart_scroller_widget_set(wd->scr, obj);
3164 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
3165 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
3166 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
3167 elm_widget_resize_object_set(obj, wd->scr);
3168 elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE);
3170 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3171 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3172 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3173 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3174 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
3176 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
3180 wd->map = evas_map_new(4);
3181 if (!wd->map) return NULL;
3183 wd->zoom_min = 0xFF;
3184 wd->zoom_max = 0X00;
3185 wd->markers_max_num = 30;
3186 wd->pinch.level = 1.0;
3189 wd->markers = calloc(wd->zoom_max + 1, sizeof(void*));
3191 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3192 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3193 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3194 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3198 static Evas_Smart_Class sc;
3200 evas_object_smart_clipped_smart_set(&_pan_sc);
3202 sc.name = "elm_map_pan";
3203 sc.version = EVAS_SMART_CLASS_VERSION;
3206 sc.resize = _pan_resize;
3207 sc.move = _pan_move;
3208 sc.calculate = _pan_calculate;
3209 smart = evas_smart_class_new(&sc);
3213 wd->pan_smart = evas_object_smart_add(e, smart);
3214 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3218 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3219 _pan_set, _pan_get, _pan_max_get,
3220 _pan_min_get, _pan_child_size_get);
3222 wd->rect = evas_object_rectangle_add(e);
3223 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_RESIZE,
3224 _rect_resize_cb, obj);
3225 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
3227 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_MOVE,
3229 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
3231 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_DOWN,
3232 _mouse_multi_down, obj);
3233 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_MOVE,
3234 _mouse_multi_move, obj);
3235 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP,
3236 _mouse_multi_up, obj);
3237 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL,
3238 _mouse_wheel_cb, obj);
3240 evas_object_smart_member_add(wd->rect, wd->pan_smart);
3241 elm_widget_sub_object_add(obj, wd->rect);
3242 evas_object_show(wd->rect);
3243 evas_object_color_set(wd->rect, 0, 0, 0, 0);
3245 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
3246 wd->id = ((int)getpid() << 16) | idnum;
3250 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3252 evas_object_size_hint_min_set(obj, minw, minh);
3254 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
3255 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
3257 wd->paused = EINA_TRUE;
3258 elm_map_zoom_set(obj, 0);
3259 wd->paused = EINA_FALSE;
3262 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3263 // TODO: and save some bytes, making descriptions per-class and not instance!
3264 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3266 if (!ecore_file_download_protocol_available("http://"))
3268 ERR("Ecore must be built with curl support for the map widget!");
3275 * Set the zoom level of the map
3277 * This sets the zoom level. 0 is the world map and 18 is the maximum zoom.
3279 * @param obj The map object
3280 * @param zoom The zoom level to set
3285 elm_map_zoom_set(Evas_Object *obj, int zoom)
3287 ELM_CHECK_WIDTYPE(obj, widtype);
3288 Widget_Data *wd = elm_widget_data_get(obj);
3290 Grid *g, *g_zoom = NULL;
3291 Evas_Coord rx, ry, rw, rh;
3295 int z = 0, zoom_changed = 0, started = 0;
3297 if ((!wd) || (!wd->src) || (wd->zoom_animator)) return;
3298 if (zoom < 0 ) zoom = 0;
3299 if (zoom > wd->src->zoom_max) zoom = wd->src->zoom_max;
3300 if (zoom < wd->src->zoom_min) zoom = wd->src->zoom_min;
3302 if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT;
3303 else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN;
3304 else wd->zoom_method = ZOOM_METHOD_NONE;
3305 if (wd->zoom != zoom ) zoom_changed = 1;
3307 wd->size.ow = wd->size.w;
3308 wd->size.oh = wd->size.h;
3309 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
3310 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3312 EINA_LIST_FOREACH(wd->route, l, r)
3316 EINA_LIST_FOREACH(r->path, l, p)
3318 evas_object_polygon_points_clear(p);
3323 EINA_LIST_FOREACH(wd->track, l, route)
3325 evas_object_hide(route);
3328 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3335 while (cumulw <= rw)
3344 while (cumulh <= rh)
3351 if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3353 if (p2w < p2h) z = p2w;
3356 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3358 if (p2w > p2h) z = p2w;
3363 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3364 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3366 g = grid_create(obj);
3369 if (eina_list_count(wd->grids) > 1)
3371 g_zoom = eina_list_last(wd->grids)->data;
3372 wd->grids = eina_list_remove(wd->grids, g_zoom);
3373 grid_clear(obj, g_zoom);
3376 wd->grids = eina_list_prepend(wd->grids, g);
3380 EINA_LIST_FREE(wd->grids, g)
3388 if ((wd->size.w > 0) && (wd->size.h > 0))
3390 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow;
3391 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.oh;
3395 wd->size.spos.x = 0.5;
3396 wd->size.spos.y = 0.5;
3399 if (rw > wd->size.ow) wd->size.spos.x = 0.5;
3400 if (rh > wd->size.oh) wd->size.spos.y = 0.5;
3401 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
3402 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
3407 if (wd->calc_job) ecore_job_del(wd->calc_job);
3408 wd->calc_job = ecore_job_add(_calc_job, wd);
3412 if (!wd->zoom_animator)
3414 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
3416 if (wd->nosmooth == 1) _smooth_update(obj);
3423 if (started) evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
3424 if (!wd->zoom_animator) evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3427 if (zoom_changed) evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
3431 * Get the zoom level of the map
3433 * This returns the current zoom level of the map object. Note that if
3434 * you set the fill mode to other than ELM_MAP_ZOOM_MODE_MANUAL
3435 * (which is the default), the zoom level may be changed at any time by the
3436 * map object itself to account for map size and map viewpoer size
3438 * @param obj The map object
3439 * @return The current zoom level
3444 elm_map_zoom_get(const Evas_Object *obj)
3446 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3447 Widget_Data *wd = elm_widget_data_get(obj);
3456 * This sets the zoom mode to manual or one of several automatic levels.
3457 * Manual (ELM_MAP_ZOOM_MODE_MANUAL) means that zoom is set manually by
3458 * elm_map_zoom_set() and will stay at that level until changed by code
3459 * or until zoom mode is changed. This is the default mode.
3460 * The Automatic modes will allow the map object to automatically
3461 * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT will
3462 * adjust zoom so the map fits inside the scroll frame with no pixels
3463 * outside this area. ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but
3464 * 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.
3466 * @param obj The map object
3467 * @param mode The desired mode
3472 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
3474 ELM_CHECK_WIDTYPE(obj, widtype);
3475 Widget_Data *wd = elm_widget_data_get(obj);
3478 if (wd->mode == mode) return;
3481 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3485 elm_map_zoom_set(wd->obj, tz);
3492 * This gets the current zoom mode of the map object
3494 * @param obj The map object
3495 * @return The current zoom mode
3499 EAPI Elm_Map_Zoom_Mode
3500 elm_map_zoom_mode_get(const Evas_Object *obj)
3502 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
3503 Widget_Data *wd = elm_widget_data_get(obj);
3505 if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
3510 * Centers the map at @p lon @p lat using an animation to scroll.
3512 * @param obj The map object
3513 * @param lon Longitude to center at
3514 * @param lon Latitude to center at
3519 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
3521 ELM_CHECK_WIDTYPE(obj, widtype);
3522 Widget_Data *wd = elm_widget_data_get(obj);
3526 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3527 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3532 if (wd->zoom_animator)
3535 if (!wd->nosmooth) _smooth_update(obj);
3536 ecore_animator_del(wd->zoom_animator);
3537 wd->zoom_animator = NULL;
3539 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3541 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
3543 wd->center_on.enabled = EINA_TRUE;
3544 wd->center_on.lon = lon;
3545 wd->center_on.lat = lat;
3549 * Move the map to the current coordinates.
3551 * This move the map to the current coordinates. The map will be centered on these coordinates.
3553 * @param obj The map object
3554 * @param lat The latitude.
3555 * @param lon The longitude.
3560 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
3562 ELM_CHECK_WIDTYPE(obj, widtype);
3563 Widget_Data *wd = elm_widget_data_get(obj);
3567 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3568 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3573 if (wd->zoom_animator)
3576 ecore_animator_del(wd->zoom_animator);
3577 wd->zoom_animator = NULL;
3579 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3581 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
3583 wd->center_on.enabled = EINA_TRUE;
3584 wd->center_on.lon = lon;
3585 wd->center_on.lat = lat;
3589 * Get the current coordinates of the map.
3591 * This gets the current coordinates of the map object.
3593 * @param obj The map object
3594 * @param lat The latitude.
3595 * @param lon The longitude.
3600 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
3602 ELM_CHECK_WIDTYPE(obj, widtype);
3603 Widget_Data *wd = elm_widget_data_get(obj);
3604 Evas_Coord sx, sy, sw, sh;
3607 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
3608 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
3612 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
3616 * Set the paused state for map
3618 * This sets the paused state to on (1) or off (0) for map. The default
3619 * is off. This will stop zooming using animation change zoom levels and
3620 * change instantly. This will stop any existing animations that are running.
3622 * @param obj The map object
3623 * @param paused The pause state to set
3628 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
3630 ELM_CHECK_WIDTYPE(obj, widtype);
3631 Widget_Data *wd = elm_widget_data_get(obj);
3634 if (wd->paused == !!paused) return;
3635 wd->paused = paused;
3638 if (wd->zoom_animator)
3640 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
3641 wd->zoom_animator = NULL;
3643 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3649 * Set the paused state for the markers
3651 * This sets the paused state to on (1) or off (0) for the markers. The default
3652 * is off. This will stop displaying the markers during change zoom levels. Set
3653 * to on if you have a large number of markers.
3655 * @param obj The map object
3656 * @param paused The pause state to set
3661 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
3663 ELM_CHECK_WIDTYPE(obj, widtype);
3664 Widget_Data *wd = elm_widget_data_get(obj);
3667 if (wd->paused_markers == !!paused) return;
3668 wd->paused_markers = paused;
3672 * Get the paused state for map
3674 * This gets the current paused state for the map object.
3676 * @param obj The map object
3677 * @return The current paused state
3682 elm_map_paused_get(const Evas_Object *obj)
3684 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3685 Widget_Data *wd = elm_widget_data_get(obj);
3687 if (!wd) return EINA_FALSE;
3692 * Get the paused state for the markers
3694 * This gets the current paused state for the markers object.
3696 * @param obj The map object
3697 * @return The current paused state
3702 elm_map_paused_markers_get(const Evas_Object *obj)
3704 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3705 Widget_Data *wd = elm_widget_data_get(obj);
3707 if (!wd) return EINA_FALSE;
3708 return wd->paused_markers;
3712 * Get the information of downloading status
3714 * This gets the current downloading status for the map object.
3716 * @param obj The map object
3717 * @param try_num the number of download trying map
3718 * @param finish_num the number of downloaded map
3724 elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
3726 ELM_CHECK_WIDTYPE(obj, widtype);
3727 Widget_Data *wd = elm_widget_data_get(obj);
3732 *try_num = wd->try_num;
3737 *finish_num = wd->finish_num;
3741 * Convert a pixel coordinate (x,y) into a geographic coordinate (longitude, latitude).
3743 * @param obj The map object
3744 * @param x the coordinate
3745 * @param y the coordinate
3746 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
3747 * @param lon the longitude correspond to x
3748 * @param lat the latitude correspond to y
3753 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
3755 ELM_CHECK_WIDTYPE(obj, widtype);
3756 Widget_Data *wd = elm_widget_data_get(obj);
3759 int zoom = floor(log(size / 256) / log(2));
3760 if ((wd->src) && (wd->src->coord_into_geo))
3762 if (wd->src->coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
3767 *lon = x / (double)size * 360.0 - 180;
3771 double n = ELM_PI - 2.0 * ELM_PI * y / size;
3772 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
3777 * Convert a geographic coordinate (longitude, latitude) into a pixel coordinate (x, y).
3779 * @param obj The map object
3780 * @param lon the longitude
3781 * @param lat the latitude
3782 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
3783 * @param x the coordinate correspond to the longitude
3784 * @param y the coordinate correspond to the latitude
3789 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
3791 ELM_CHECK_WIDTYPE(obj, widtype);
3792 Widget_Data *wd = elm_widget_data_get(obj);
3795 int zoom = floor(log(size / 256) / log(2));
3796 if ((wd->src) && (wd->src->geo_into_coord))
3798 if (wd->src->geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
3802 *x = floor((lon + 180.0) / 360.0 * size);
3804 *y = floor((1.0 - log( tan(lat * ELM_PI / 180.0) + 1.0 / cos(lat * ELM_PI / 180.0)) / ELM_PI) / 2.0 * size);
3808 * Convert a geographic coordinate (longitude, latitude) into a name (address).
3810 * @param obj The map object
3811 * @param lon the longitude
3812 * @param lat the latitude
3814 * @return name the address
3819 elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat)
3821 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3822 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat);
3826 * Convert a name (address) into a geographic coordinate (longitude, latitude).
3828 * @param obj The map object
3829 * @param name the address
3830 * @param lat the latitude correspond to y
3832 * @return name the address
3837 elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address)
3839 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3840 if (!address) return NULL;
3841 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0);
3845 * Convert a pixel coordinate into a roated pixcel coordinate.
3847 * @param obj The map object
3848 * @param x x to rotate.
3849 * @param y y to rotate.
3850 * @param cx rotation's center horizontal position.
3851 * @param cy rotation's center vertical position.
3852 * @param degree amount of degrees from 0.0 to 360.0 to rotate arount Z axis.
3853 * @param xx rotated x.
3854 * @param yy rotated y.
3859 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)
3861 if ((!xx) || (!yy)) return;
3863 double r = (degree * M_PI) / 180.0;
3864 double tx, ty, ttx, tty;
3871 tx = ttx + (ty * cos(r + M_PI_2));
3872 ty = tty + (ty * sin(r + M_PI_2));
3879 * Add a marker on the map
3881 * @param obj The map object
3882 * @param lon the longitude
3883 * @param lat the latitude
3884 * @param clas the class to use
3885 * @param clas_group the class group
3886 * @param data the data passed to the callbacks
3888 * @return The marker object
3892 EAPI Elm_Map_Marker *
3893 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
3895 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3896 Widget_Data *wd = elm_widget_data_get(obj);
3899 Marker_Group *group;
3907 if (!wd) return NULL;
3908 EINA_SAFETY_ON_NULL_RETURN_VAL(clas_group, NULL);
3909 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, NULL);
3911 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
3914 marker->clas = clas;
3915 marker->clas_group = clas_group;
3916 marker->longitude = lon;
3917 marker->latitude = lat;
3918 marker->data = data;
3919 marker->x = calloc(wd->zoom_max + 1, sizeof(Evas_Coord));
3920 marker->y = calloc(wd->zoom_max + 1, sizeof(Evas_Coord));
3921 marker->groups = calloc(wd->zoom_max + 1, sizeof(Marker_Group*));
3923 tabi[1] = tabi[4] = tabi[6] = -1;
3924 tabi[2] = tabi[0] = tabi[7] = 0;
3925 tabi[3] = tabi[5] = tabi[8] = 1;
3927 tabj[1] = tabj[2] = tabj[3] = -1;
3928 tabj[4] = tabj[0] = tabj[5] = 0;
3929 tabj[6] = tabj[7] = tabj[8] = 1;
3931 if (!clas_group->priv.set)
3934 if (marker->clas_group && marker->clas_group->style)
3935 style = marker->clas_group->style;
3937 o = edje_object_add(evas_object_evas_get(obj));
3938 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3939 s = edje_object_data_get(o, "size_w");
3940 if (s) clas_group->priv.edje_w = atoi(s);
3941 else clas_group->priv.edje_w = 0;
3942 s = edje_object_data_get(o, "size_h");
3943 if (s) clas_group->priv.edje_h = atoi(s);
3944 else clas_group->priv.edje_h = 0;
3945 s = edje_object_data_get(o, "size_max_w");
3946 if (s) clas_group->priv.edje_max_w = atoi(s);
3947 else clas_group->priv.edje_max_w = 0;
3948 s = edje_object_data_get(o, "size_max_h");
3949 if (s) clas_group->priv.edje_max_h = atoi(s);
3950 else clas_group->priv.edje_max_h = 0;
3953 clas_group->priv.set = EINA_TRUE;
3956 if (!clas->priv.set)
3959 if (marker->clas && marker->clas->style)
3960 style = marker->clas->style;
3962 o = edje_object_add(evas_object_evas_get(obj));
3963 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3964 s = edje_object_data_get(o, "size_w");
3965 if (s) clas->priv.edje_w = atoi(s);
3966 else clas->priv.edje_w = 0;
3967 s = edje_object_data_get(o, "size_h");
3968 if (s) clas->priv.edje_h = atoi(s);
3969 else clas->priv.edje_h = 0;
3972 clas->priv.set = EINA_TRUE;
3975 for (i = clas_group->zoom_displayed; i <= wd->zoom_max; i++)
3977 elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
3978 &(marker->x[i]), &(marker->y[i]));
3980 //search in the matrixsparse the region where the marker will be
3981 mpi = marker->x[i] / wd->tsize;
3982 mpj = marker->y[i] / wd->tsize;
3984 if (!wd->markers[i])
3986 int size = pow(2.0, i);
3987 wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
3991 if (i <= clas_group->zoom_grouped)
3993 for (j = 0, group = NULL; j < 9 && !group; j++)
3995 EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
3998 if (group->clas == marker->clas_group
3999 && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
4000 marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
4001 group->x-group->w/4, group->y-group->h/4, group->w, group->h))
4003 group->markers = eina_list_append(group->markers, marker);
4004 group->update_nbelems = EINA_TRUE;
4005 group->update_resize = EINA_TRUE;
4007 group->sum_x += marker->x[i];
4008 group->sum_y += marker->y[i];
4009 group->x = group->sum_x / eina_list_count(group->markers);
4010 group->y = group->sum_y / eina_list_count(group->markers);
4012 group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
4013 * eina_list_count(group->markers);
4014 group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
4015 * eina_list_count(group->markers);
4016 if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
4017 if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
4019 if (group->obj && eina_list_count(group->markers) == 2)
4021 _group_object_free(group);
4022 _group_object_create(group);
4025 _group_bubble_content_update(group);
4034 group = calloc(1, sizeof(Marker_Group));
4036 group->sum_x = marker->x[i];
4037 group->sum_y = marker->y[i];
4038 group->x = marker->x[i];
4039 group->y = marker->y[i];
4040 group->w = clas_group->priv.edje_w;
4041 group->h = clas_group->priv.edje_h;
4042 group->clas = clas_group;
4044 group->markers = eina_list_append(group->markers, marker);
4045 group->update_nbelems = EINA_TRUE;
4046 group->update_resize = EINA_TRUE;
4048 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
4052 l = eina_list_append(NULL, group);
4053 eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
4054 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
4058 l = eina_matrixsparse_cell_data_get(group->cell);
4059 l = eina_list_append(l, group);
4060 eina_matrixsparse_cell_data_set(group->cell, l);
4063 marker->groups[i] = group;
4068 Evas_Coord ox, oy, ow, oh;
4069 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
4070 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4077 * Remove a marker from the map
4079 * @param marker The marker to remove
4084 elm_map_marker_remove(Elm_Map_Marker *marker)
4090 EINA_SAFETY_ON_NULL_RETURN(marker);
4093 for (i = marker->clas_group->zoom_displayed; i <= wd->zoom_max; i++)
4095 marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
4096 if (!eina_list_count(marker->groups[i]->markers))
4098 groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
4099 groups = eina_list_remove(groups, marker->groups[i]);
4100 eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
4102 _group_object_free(marker->groups[i]);
4103 _group_bubble_free(marker->groups[i]);
4104 free(marker->groups[i]);
4108 marker->groups[i]->sum_x -= marker->x[i];
4109 marker->groups[i]->sum_y -= marker->y[i];
4111 marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
4112 marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
4114 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
4115 + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
4116 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
4117 + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
4118 if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
4119 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
4120 if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
4121 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
4123 if ((marker->groups[i]->obj) && (eina_list_count(marker->groups[i]->markers) == 1))
4125 _group_object_free(marker->groups[i]);
4126 _group_object_create(marker->groups[i]);
4131 if ((marker->content) && (marker->clas->func.del))
4132 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4133 else if (marker->content)
4134 evas_object_del(marker->content);
4136 if (marker->x) free(marker->x);
4137 if (marker->y) free(marker->y);
4138 if (marker->groups) free(marker->groups);
4144 Evas_Coord ox, oy, ow, oh;
4145 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
4146 marker_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4151 * Get the current coordinates of the marker.
4153 * @param marker marker.
4154 * @param lat The latitude.
4155 * @param lon The longitude.
4160 elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat)
4162 EINA_SAFETY_ON_NULL_RETURN(marker);
4163 if (lon) *lon = marker->longitude;
4164 if (lat) *lat = marker->latitude;
4168 * Move the map to the coordinate of the marker.
4170 * @param marker The marker where the map will be center.
4175 elm_map_marker_bring_in(Elm_Map_Marker *marker)
4177 EINA_SAFETY_ON_NULL_RETURN(marker);
4178 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
4182 * Move the map to the coordinate of the marker.
4184 * @param marker The marker where the map will be center.
4189 elm_map_marker_show(Elm_Map_Marker *marker)
4191 EINA_SAFETY_ON_NULL_RETURN(marker);
4192 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
4196 * Move and zoom the map to display a list of markers.
4198 * The map will be centered on the center point of the markers in the list. Then
4199 * the map will be zoomed in order to fit the markers using the maximum zoom which
4200 * allows display of all the markers.
4202 * @param markers The list of markers (list of Elm_Map_Marker *)
4207 elm_map_markers_list_show(Eina_List *markers)
4212 Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
4213 Evas_Coord rw, rh, xc, yc;
4216 EINA_SAFETY_ON_NULL_RETURN(markers);
4217 EINA_LIST_FOREACH(markers, l, marker)
4221 if ((!m_min_lon) || (marker->longitude < m_min_lon->longitude))
4224 if ((!m_max_lon) || (marker->longitude > m_max_lon->longitude))
4227 if ((!m_min_lat) || (marker->latitude > m_min_lat->latitude))
4230 if ((!m_max_lat) || (marker->latitude < m_max_lat->latitude))
4234 lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
4235 lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
4237 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
4238 for (zoom = wd->src->zoom_max; zoom > wd->src->zoom_min; zoom--)
4240 Evas_Coord size = pow(2.0, zoom)*wd->tsize;
4241 elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
4243 if ((m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2)
4244 && (m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2)
4245 && (m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2)
4246 && (m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2))
4250 elm_map_geo_region_show(wd->obj, lon, lat);
4251 elm_map_zoom_set(wd->obj, zoom);
4255 * Set the maximum numbers of markers display in a group.
4257 * A group can have a long list of markers, consequently the creation of the content
4258 * of the bubble can be very slow. In order to avoid this, a maximum number of items
4259 * is displayed in a bubble. By default this number is 30.
4261 * @param obj The map object.
4262 * @param max The maximum numbers of items displayed in a bubble.
4267 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
4269 ELM_CHECK_WIDTYPE(obj, widtype);
4270 Widget_Data *wd = elm_widget_data_get(obj);
4273 wd->markers_max_num = max;
4277 * Return the evas object getting from the ElmMapMarkerGetFunc callback
4279 * @param marker The marker.
4280 * @return Return the evas object if it exists, else NULL.
4285 elm_map_marker_object_get(const Elm_Map_Marker *marker)
4287 EINA_SAFETY_ON_NULL_RETURN_VAL(marker, NULL);
4288 return marker->content;
4294 * @param marker The marker.
4299 elm_map_marker_update(Elm_Map_Marker *marker)
4301 EINA_SAFETY_ON_NULL_RETURN(marker);
4302 if (marker->content)
4304 if (marker->clas->func.del)
4305 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4307 evas_object_del(marker->content);
4308 marker->content = NULL;
4309 _group_bubble_content_update(marker->groups[marker->wd->zoom]);
4314 * Close all opened bubbles
4316 * @param obj The map object
4321 elm_map_bubbles_close(Evas_Object *obj)
4323 ELM_CHECK_WIDTYPE(obj, widtype);
4324 Widget_Data *wd = elm_widget_data_get(obj);
4325 Marker_Group *group;
4326 Eina_List *l, *l_next;
4329 EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
4330 _group_bubble_free(group);
4334 * Create a group class.
4336 * Each marker must be associated to a group class. Marker with the same group are grouped if they are close.
4337 * The group class defines the style of the marker when a marker is grouped to others markers.
4339 * @param obj The map object
4340 * @return Returns the new group class
4344 EAPI Elm_Map_Group_Class *
4345 elm_map_group_class_new(Evas_Object *obj)
4347 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4348 Widget_Data *wd = elm_widget_data_get(obj);
4350 if (!wd) return NULL;
4351 Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
4352 clas->zoom_grouped = wd->zoom_max;
4353 wd->groups_clas = eina_list_append(wd->groups_clas, clas);
4358 * Set the style of a group class (radio, radio2 or empty)
4360 * @param clas the group class
4361 * @param style the new style
4366 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
4368 EINA_SAFETY_ON_NULL_RETURN(clas);
4369 eina_stringshare_replace(&clas->style, style);
4373 * Set the icon callback of a group class.
4375 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
4377 * @param clas the group class
4378 * @param icon_get the callback to create the icon
4383 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
4385 EINA_SAFETY_ON_NULL_RETURN(clas);
4386 clas->func.icon_get = icon_get;
4390 * Set the data associated to the group class (radio, radio2 or empty)
4392 * @param clas the group class
4393 * @param data the new user data
4398 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
4400 EINA_SAFETY_ON_NULL_RETURN(clas);
4405 * Set the zoom from where the markers are displayed.
4407 * Markers will not be displayed for a zoom less than @ref zoom
4409 * @param clas the group class
4410 * @param zoom the zoom
4415 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
4417 EINA_SAFETY_ON_NULL_RETURN(clas);
4418 clas->zoom_displayed = zoom;
4422 * Set the zoom from where the markers are no more grouped.
4424 * @param clas the group class
4425 * @param zoom the zoom
4430 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
4432 EINA_SAFETY_ON_NULL_RETURN(clas);
4433 clas->zoom_grouped = zoom;
4437 * Set if the markers associated to the group class @clas are hidden or not.
4438 * If @ref hide is true the markers will be hidden.
4440 * @param clas the group class
4441 * @param hide if true the markers will be hidden, else they will be displayed.
4446 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
4448 ELM_CHECK_WIDTYPE(obj, widtype);
4449 Widget_Data *wd = elm_widget_data_get(obj);
4452 EINA_SAFETY_ON_NULL_RETURN(clas);
4453 if (clas->hide == hide) return;
4457 Evas_Coord ox, oy, ow, oh;
4458 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
4459 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4465 * Create a marker class.
4467 * Each marker must be associated to a class.
4468 * The class defines the style of the marker when a marker is displayed alone (not grouped).
4470 * @param obj The map object
4471 * @return Returns the new class
4475 EAPI Elm_Map_Marker_Class *
4476 elm_map_marker_class_new(Evas_Object *obj)
4478 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4479 Widget_Data *wd = elm_widget_data_get(obj);
4481 if (!wd) return NULL;
4482 Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
4483 wd->markers_clas = eina_list_append(wd->markers_clas, clas);
4488 * Set the style of a class (radio, radio2 or empty)
4490 * @param clas the group class
4491 * @param style the new style
4496 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
4498 EINA_SAFETY_ON_NULL_RETURN(clas);
4499 eina_stringshare_replace(&clas->style, style);
4503 * Set the icon callback of a class.
4505 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
4507 * @param clas the group class
4508 * @param icon_get the callback to create the icon
4513 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
4515 EINA_SAFETY_ON_NULL_RETURN(clas);
4516 clas->func.icon_get = icon_get;
4521 * Set the callback of the content of the bubble.
4523 * When the user click on a marker, a bubble is displayed with a content.
4524 * The callback @ref get musst return this content. It can be NULL.
4526 * @param clas the group class
4527 * @param get the callback to create the content
4532 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
4534 EINA_SAFETY_ON_NULL_RETURN(clas);
4535 clas->func.get = get;
4539 * Set the callback of the content of delete the object created by the callback "get".
4541 * If this callback is defined the user will have to delete (or not) the object inside.
4542 * If the callback is not defined the object will be destroyed with evas_object_del()
4544 * @param clas the group class
4545 * @param del the callback to delete the content
4550 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
4552 EINA_SAFETY_ON_NULL_RETURN(clas);
4553 clas->func.del = del;
4557 * Get the list of the sources.
4559 * @param obj The map object
4560 * @return sources the source list
4566 elm_map_source_names_get(const Evas_Object *obj)
4568 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4569 Widget_Data *wd = elm_widget_data_get(obj);
4571 if (!wd) return NULL;
4572 return wd->source_names;
4576 * Set the source of the map.
4578 * Elm_Map retrieves the image which composed the map from a web service. This web service can
4579 * be set with this method. A different service can return a different maps with different
4580 * information and it can use different zoom value.
4582 * @param obj the map object
4583 * @param source the new source
4588 elm_map_source_name_set(Evas_Object *obj, const char *source_name)
4590 ELM_CHECK_WIDTYPE(obj, widtype);
4591 Widget_Data *wd = elm_widget_data_get(obj);
4598 if ((wd->src) && (!strcmp(wd->src->name, source_name))) return;
4599 if ((wd->src) && (!wd->src->url_cb)) return;
4601 EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid);
4602 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
4604 if (!strcmp(s->name, source_name))
4613 if (wd->src->zoom_max < zoom)
4614 zoom = wd->src->zoom_max;
4615 if (wd->src->zoom_min > zoom)
4616 zoom = wd->src->zoom_min;
4618 elm_map_zoom_set(obj, zoom);
4622 * Get the name of a source.
4624 * @param source the source
4625 * @return Returns the name of the source
4630 elm_map_source_name_get(const Evas_Object *obj)
4632 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4633 Widget_Data *wd = elm_widget_data_get(obj);
4635 if ((!wd) || (!wd->src)) return NULL;
4636 return wd->src->name;
4640 * Set the source of the route.
4642 * @param clas the group class
4643 * @param source the new source
4648 elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
4650 ELM_CHECK_WIDTYPE(obj, widtype);
4651 Widget_Data *wd = elm_widget_data_get(obj);
4654 wd->route_source = source;
4658 * Get the current route source
4660 * @param obj the map object
4661 * @return Returns the source of the route
4665 EAPI Elm_Map_Route_Sources
4666 elm_map_route_source_get(const Evas_Object *obj)
4668 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS;
4669 Widget_Data *wd = elm_widget_data_get(obj);
4671 if (!wd) return ELM_MAP_ROUTE_SOURCE_YOURS;
4672 return wd->route_source;
4676 * Set the maximum zoom of the source.
4678 * @param source the source
4683 elm_map_source_zoom_max_set(Evas_Object *obj, int zoom)
4685 ELM_CHECK_WIDTYPE(obj, widtype);
4686 Widget_Data *wd = elm_widget_data_get(obj);
4688 if ((!wd) || (!wd->src)) return;
4689 if ((zoom > wd->zoom_max) || (zoom < wd->zoom_min)) return;
4690 wd->src->zoom_max = zoom;
4694 * Get the maximum zoom of the source.
4696 * @param source the source
4697 * @return Returns the maximum zoom of the source
4702 elm_map_source_zoom_max_get(const Evas_Object *obj)
4704 ELM_CHECK_WIDTYPE(obj, widtype) 18;
4705 Widget_Data *wd = elm_widget_data_get(obj);
4707 if ((!wd) || (!wd->src)) return 18;
4708 return wd->src->zoom_max;
4712 * Set the minimum zoom of the source.
4714 * @param source the source
4719 elm_map_source_zoom_min_set(Evas_Object *obj, int zoom)
4721 ELM_CHECK_WIDTYPE(obj, widtype);
4722 Widget_Data *wd = elm_widget_data_get(obj);
4724 if ((!wd) || (!wd->src)) return;
4725 if ((zoom > wd->zoom_max) || (zoom < wd->zoom_min)) return;
4726 wd->src->zoom_min = zoom;
4731 * Get the minimum zoom of the source.
4733 * @param source the source
4734 * @return Returns the minimum zoom of the source
4739 elm_map_source_zoom_min_get(const Evas_Object *obj)
4741 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4742 Widget_Data *wd = elm_widget_data_get(obj);
4744 if ((!wd) || (!wd->src)) return 0;
4745 return wd->src->zoom_min;
4749 * Set the user agent of the widget map.
4751 * @param obj The map object
4752 * @param user_agent the user agent of the widget map
4757 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
4759 ELM_CHECK_WIDTYPE(obj, widtype);
4760 Widget_Data *wd = elm_widget_data_get(obj);
4763 if (!wd->user_agent) wd->user_agent = eina_stringshare_add(user_agent);
4764 else eina_stringshare_replace(&wd->user_agent, user_agent);
4766 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4767 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4771 * Get the user agent of the widget map.
4773 * @param obj The map object
4774 * @return The user agent of the widget map
4779 elm_map_user_agent_get(const Evas_Object *obj)
4781 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4782 Widget_Data *wd = elm_widget_data_get(obj);
4784 if (!wd) return NULL;
4785 return wd->user_agent;
4789 * Add a route on the map
4791 * @param obj The map object
4792 * @param type the type if transport
4793 * @param method the routing method
4794 * @param flon the start longitude
4795 * @param flat the start latitude
4796 * @param tlon the destination longitude
4797 * @param tlat the destination latitude
4799 * @return The Route object
4803 EAPI Elm_Map_Route *
4804 elm_map_route_add(Evas_Object *obj,
4805 Elm_Map_Route_Type type,
4806 Elm_Map_Route_Method method,
4812 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4813 Widget_Data *wd = elm_widget_data_get(obj);
4816 char *type_name = NULL;
4819 if ((!wd) || (!wd->src)) return NULL;
4821 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4822 if (!route) return NULL;
4824 snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE);
4832 route->con_url = ecore_con_url_new(NULL);
4833 route->ud.fname = strdup(buf);
4834 INF("xml file : %s", route->ud.fname);
4836 route->ud.fd = fdopen(fd, "w+");
4837 if ((!route->con_url) || (!route->ud.fd))
4839 ecore_con_url_free(route->con_url);
4845 route->color.r = 255;
4848 route->color.a = 255;
4849 route->handlers = eina_list_append
4850 (route->handlers, (void *)ecore_event_handler_add
4851 (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route));
4853 route->inbound = EINA_FALSE;
4855 route->method = method;
4863 case ELM_MAP_ROUTE_TYPE_MOTOCAR:
4864 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4866 case ELM_MAP_ROUTE_TYPE_BICYCLE:
4867 type_name = strdup(ROUTE_TYPE_BICYCLE);
4869 case ELM_MAP_ROUTE_TYPE_FOOT:
4870 type_name = strdup(ROUTE_TYPE_FOOT);
4876 source = wd->src->route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4877 INF("route url = %s", source);
4879 wd->route = eina_list_append(wd->route, route);
4881 ecore_con_url_url_set(route->con_url, source);
4882 ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd));
4883 ecore_con_url_data_set(route->con_url, route);
4884 ecore_con_url_get(route->con_url);
4885 if (type_name) free(type_name);
4886 if (source) free(source);
4888 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4889 "elm,state,busy,start", "elm");
4890 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL);
4896 * Remove a route from the map
4898 * @param route The route to remove
4904 elm_map_route_remove(Elm_Map_Route *route)
4906 EINA_SAFETY_ON_NULL_RETURN(route);
4911 Ecore_Event_Handler *h;
4913 EINA_LIST_FREE(route->path, p)
4918 EINA_LIST_FREE(route->waypoint, w)
4920 if (w->point) eina_stringshare_del(w->point);
4924 EINA_LIST_FREE(route->nodes, n)
4926 if (n->pos.address) eina_stringshare_del(n->pos.address);
4930 EINA_LIST_FREE(route->handlers, h)
4932 ecore_event_handler_del(h);
4935 if (route->ud.fname)
4937 ecore_file_remove(route->ud.fname);
4938 free(route->ud.fname);
4939 route->ud.fname = NULL;
4944 * Set the option used for the background color
4946 * @param route The route object
4952 * This sets the color used for the route
4957 elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a)
4959 EINA_SAFETY_ON_NULL_RETURN(route);
4967 * Get the option used for the background color
4969 * @param route The route object
4978 elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a)
4980 EINA_SAFETY_ON_NULL_RETURN(route);
4981 if (r) *r = route->color.r;
4982 if (g) *g = route->color.g;
4983 if (b) *b = route->color.b;
4984 if (a) *a = route->color.a;
4988 * Get the information of route distance
4990 * @param route the route object
4991 * @return Returns the distance of route (unit : km)
4996 elm_map_route_distance_get(const Elm_Map_Route *route)
4998 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
4999 return route->info.distance;
5003 * Get the information of route nodes
5005 * @param route the route object
5006 * @return Returns the nodes of route
5012 elm_map_route_node_get(const Elm_Map_Route *route)
5014 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
5015 return route->info.nodes;
5019 * Get the information of route waypoint
5021 * @param route the route object
5022 * @return Returns the waypoint of route
5028 elm_map_route_waypoint_get(const Elm_Map_Route *route)
5030 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
5031 return route->info.waypoints;
5035 * Get the information of address
5037 * @param name the name object
5038 * @return Returns the address of name
5043 elm_map_name_address_get(const Elm_Map_Name *name)
5045 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
5046 return name->address;
5050 * Get the current coordinates of the name.
5052 * This gets the current coordinates of the name object.
5054 * @param obj The name object
5055 * @param lat The latitude
5056 * @param lon The longitude
5061 elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
5063 EINA_SAFETY_ON_NULL_RETURN(name);
5064 if (lon) *lon = name->lon;
5065 if (lat) *lat = name->lat;
5069 * Remove a name from the map
5071 * @param name The name to remove
5076 elm_map_name_remove(Elm_Map_Name *name)
5078 EINA_SAFETY_ON_NULL_RETURN(name);
5081 free(name->address);
5082 name->address = NULL;
5086 ecore_event_handler_del(name->handler);
5087 name->handler = NULL;
5091 ecore_file_remove(name->ud.fname);
5092 free(name->ud.fname);
5093 name->ud.fname = NULL;
5098 * Set the rotate degree of the map
5100 * @param obj The map object
5101 * @param angle amount of degrees from 0.0 to 360.0 to rotate arount Z axis
5102 * @param cx rotation's center horizontal position
5103 * @param cy rotation's center vertical position
5108 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
5110 ELM_CHECK_WIDTYPE(obj, widtype);
5111 Widget_Data *wd = elm_widget_data_get(obj);
5114 wd->rotate.d = degree;
5117 wd->calc_job = ecore_job_add(_calc_job, wd);
5121 * Get the rotate degree of the map
5123 * @param obj The map object
5124 * @return amount of degrees from 0.0 to 360.0 to rotate arount Z axis
5125 * @param cx rotation's center horizontal position
5126 * @param cy rotation's center vertical position
5131 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
5133 ELM_CHECK_WIDTYPE(obj, widtype);
5134 Widget_Data *wd = elm_widget_data_get(obj);
5137 if (degree) *degree = wd->rotate.d;
5138 if (cx) *cx = wd->rotate.cx;
5139 if (cy) *cy = wd->rotate.cy;
5143 * Set the wheel control state of the map
5145 * @param obj The map object
5146 * @param disabled status of wheel control
5151 elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
5153 ELM_CHECK_WIDTYPE(obj, widtype);
5154 Widget_Data *wd = elm_widget_data_get(obj);
5157 if ((!wd->wheel_disabled) && (disabled))
5158 evas_object_event_callback_del_full(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
5159 else if ((wd->wheel_disabled) && (!disabled))
5160 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
5161 wd->wheel_disabled = !!disabled;
5165 * Get the wheel control state of the map
5167 * @param obj The map object
5168 * @return Returns the status of wheel control
5173 elm_map_wheel_disabled_get(const Evas_Object *obj)
5175 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5176 Widget_Data *wd = elm_widget_data_get(obj);
5178 if (!wd) return EINA_FALSE;
5179 return wd->wheel_disabled;
5184 * Add a track on the map
5186 * @param obj The map object
5187 * @param emap the emap object
5189 * @return The Route object. This is a elm object of type Elm_Route
5194 elm_map_track_add(Evas_Object *obj, EMap_Route *emap)
5196 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5197 Widget_Data *wd = elm_widget_data_get(obj);
5199 if (!wd) return EINA_FALSE;
5201 Evas_Object *route = elm_route_add(obj);
5202 elm_route_emap_set(route, emap);
5203 wd->track = eina_list_append(wd->track, route);
5211 * Remove a track from the map
5213 * @param track The track to remove
5219 elm_map_track_remove(Evas_Object *obj, Evas_Object *route)
5221 ELM_CHECK_WIDTYPE(obj, widtype) ;
5222 Widget_Data *wd = elm_widget_data_get(obj);
5226 wd->track = eina_list_remove(wd->track, route);
5227 evas_object_del(route);
5231 _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5234 snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
5240 _osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5243 snprintf(buf, sizeof(buf),
5244 "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
5250 _cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5253 snprintf(buf, sizeof(buf),
5254 "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
5260 _maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5263 snprintf(buf, sizeof(buf),
5264 "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
5269 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5272 snprintf(buf, sizeof(buf),
5273 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
5274 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
5279 // TODO: fix monav api
5281 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5284 snprintf(buf, sizeof(buf),
5285 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
5286 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
5292 // TODO: fix ors api
5294 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5297 snprintf(buf, sizeof(buf),
5298 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
5299 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
5306 _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
5308 ELM_CHECK_WIDTYPE(obj, widtype) strdup("");
5309 Widget_Data *wd = elm_widget_data_get(obj);
5311 unsigned int ele, idx;
5312 char search_url[PATH_MAX];
5315 if (!wd) return strdup("");
5316 if (method == ELM_MAP_NAME_METHOD_SEARCH)
5318 search_url[0] = '\0';
5319 str = eina_str_split_full(name, " ", 0, &ele);
5320 for (idx = 0 ; idx < ele ; idx++)
5322 eina_strlcat(search_url, str[idx], sizeof(search_url));
5323 if (!(idx == (ele-1))) eina_strlcat(search_url, "+", sizeof(search_url));
5325 snprintf(buf, sizeof(buf), "%s/search?q=%s&format=xml&polygon=0&addressdetails=0", NAME_NOMINATIM_URL, search_url);
5327 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);
5328 else strcpy(buf, "");