2 # include "elementary_config.h"
5 #include "Elementary.h"
7 #include "els_scroller.h"
9 #ifdef HAVE_ELEMENTARY_ECORE_CON
11 typedef struct _Widget_Data Widget_Data;
12 typedef struct _Pan Pan;
13 typedef struct _Grid Grid;
14 typedef struct _Grid_Item Grid_Item;
15 typedef struct _Overlay_Default Overlay_Default;
16 typedef struct _Overlay_Group Overlay_Group;
17 typedef struct _Overlay_Class Overlay_Class;
18 typedef struct _Overlay_Bubble Overlay_Bubble;
19 typedef struct _Marker_Group Marker_Group;
20 typedef struct _Marker_Bubble Marker_Bubble;
21 typedef struct _Path_Node Path_Node;
22 typedef struct _Path_Waypoint Path_Waypoint;
23 typedef struct _Url_Data Url_Data;
24 typedef struct _Route_Dump Route_Dump;
25 typedef struct _Name_Dump Name_Dump;
26 typedef struct _Delayed_Data Delayed_Data;
27 typedef struct _Map_Sources_Tab Map_Sources_Tab;
29 #define ROUND(z) (((z) < 0) ? (int)ceil((z) - 0.005) : (int)floor((z) + 0.005))
30 #define EVAS_MAP_POINT 4
31 #define DEFAULT_TILE_SIZE 256
32 #define MAX_CONCURRENT_DOWNLOAD 10
34 #define MARER_MAX_NUMBER 30
36 #define CACHE_ROOT_PATH "/tmp/elm_map"
37 #define CACHE_PATH CACHE_ROOT_PATH"/%d/%d/%d"
38 #define CACHE_FILE_PATH "%s/%d.png"
39 #define DEST_ROUTE_XML_FILE "/tmp/elm_map-route-XXXXXX"
40 #define DEST_NAME_XML_FILE "/tmp/elm_map-name-XXXXXX"
42 #define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php"
43 #define ROUTE_TYPE_MOTORCAR "motocar"
44 #define ROUTE_TYPE_BICYCLE "bicycle"
45 #define ROUTE_TYPE_FOOT "foot"
46 #define YOURS_DISTANCE "distance"
47 #define YOURS_DESCRIPTION "description"
48 #define YOURS_COORDINATES "coordinates"
50 #define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org"
51 #define NOMINATIM_RESULT "result"
52 #define NOMINATIM_PLACE "place"
53 #define NOMINATIM_ATTR_LON "lon"
54 #define NOMINATIM_ATTR_LAT "lat"
56 #define OVERLAY_CLASS_ZOOM_MAX 255
57 #define OVERLAY_GROUPING_SCALE 2
59 enum _Route_Xml_Attribute
63 ROUTE_XML_DESCRIPTION,
64 ROUTE_XML_COORDINATES,
68 enum _Name_Xml_Attribute
77 enum _Track_Xml_Attribute
80 TRACK_XML_COORDINATES,
86 void (*func)(void *data);
88 Elm_Map_Zoom_Mode mode;
96 // Currently the size of a tile must be 256*256
97 // and the size of the map must be pow(2.0, z)*tile_size
98 struct _Map_Sources_Tab
103 Elm_Map_Module_Url_Func url_cb;
104 Elm_Map_Route_Sources route_source;
105 Elm_Map_Module_Route_Url_Func route_url_cb;
106 Elm_Map_Module_Name_Url_Func name_url_cb;
107 Elm_Map_Module_Geo_Into_Coord_Func geo_into_coord;
108 Elm_Map_Module_Coord_Into_Geo_Func coord_into_geo;
113 Ecore_Con_Url *con_url;
119 struct _Overlay_Default
123 // Display priority is obj > icon > clas_obj > clas_icon > layout
127 // if obj or icon exists, do not inherit from class
128 Evas_Object *clas_obj; // Duplicated from class icon
129 Evas_Object *clas_obj_ref; // Checking fro class icon is changed
130 Evas_Object *clas_icon; // Duplicated from class icon
131 Evas_Object *clas_icon_ref; // Checking for class icon is changed
139 struct _Overlay_Group
141 Overlay_Default *ovl;
142 Evas_Object *clas_icon;
143 Elm_Map_Overlay *clas;
147 struct _Overlay_Class
149 Elm_Map_Overlay *clas;
157 struct _Overlay_Bubble
161 Evas_Object *obj, *sc, *bx;
163 Evas_Coord x, y, w, h;
166 struct _Elm_Map_Overlay
170 Eina_Bool paused : 1;
174 void *data; // user set data
176 Elm_Map_Overlay_Type type;
177 void *ovl; // Overlay Data for each type
179 // These are not used if overlay type is class
180 Eina_Bool grp_in : 1;
181 Eina_Bool grp_boss : 1;
184 Elm_Map_Overlay_Get_Cb cb;
188 struct _Elm_Map_Marker_Class
191 struct _Elm_Map_Marker_Class_Func
193 Elm_Map_Marker_Get_Func get;
194 Elm_Map_Marker_Del_Func del; //if NULL the object will be destroyed with evas_object_del()
195 Elm_Map_Marker_Icon_Get_Func icon_get;
199 struct _Elm_Map_Group_Class
204 int zoom_displayed; // display the group if the zoom is >= to zoom_display
205 int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
210 Elm_Map_Group_Icon_Get_Func icon_get;
216 struct _Marker_Bubble
220 Evas_Object *obj, *sc, *bx;
223 struct _Elm_Map_Marker
226 Elm_Map_Marker_Class *clas;
227 Elm_Map_Group_Class *group_clas;
228 double longitude, latitude;
233 Eina_Bool grouped : 1;
234 Eina_Bool leader : 1; // if marker is group leader
237 Marker_Bubble *bubble;
238 Evas_Object *content;
245 Elm_Map_Group_Class *clas;
252 Marker_Bubble *bubble;
255 struct _Elm_Map_Route
261 Ecore_Con_Url *con_url;
266 double flon, flat, tlon, tlat;
268 Eina_List *nodes, *path;
276 const char *waypoints;
277 double distance; /* unit : km */
291 Eina_Bool inbound : 1;
306 struct _Path_Waypoint
317 Ecore_Con_Url *con_url;
322 Ecore_Event_Handler *handler;
350 int x, y; // Tile coordinate
351 Eina_Bool file_have : 1;
353 Ecore_File_Download_Job *job;
359 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
360 int tw, th; // size of grid in tiles
361 Eina_Matrixsparse *grid;
366 Evas_Object_Smart_Clipped_Data __clipped_data;
375 Evas_Object *pan_smart;
376 Evas_Object *sep_maps_markers; // Tiles are below this and overlays are on top
379 Map_Sources_Tab *src;
381 const char **src_names;
382 int zoom_min, zoom_max;
390 double prev_lon, prev_lat;
394 int w, h; // Current pixel width, heigth of a grid
395 int tile; // Current pixel size of a grid item
397 Elm_Map_Zoom_Mode mode;
404 Ecore_Timer *zoom_timer;
405 Ecore_Animator *zoom_animator;
410 Eina_List *download_list;
411 Ecore_Idler *download_idler;
413 const char *user_agent;
415 Evas_Coord pan_x, pan_y;
416 Eina_List *delayed_jobs;
418 Ecore_Timer *scr_timer;
419 Ecore_Timer *long_timer;
420 Evas_Event_Mouse_Down ev;
421 Eina_Bool on_hold : 1;
422 Eina_Bool paused : 1;
431 Eina_Bool wheel_disabled : 1;
433 unsigned int markers_max_num;
434 Eina_Bool paused_markers : 1;
435 Eina_List *group_classes;
436 Eina_List *marker_classes;
439 Elm_Map_Route_Sources route_source;
447 static char *_mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
448 static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
449 static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
450 static char *_mapquest_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
451 static char *_mapquest_aerial_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
452 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
453 static char *_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat);
455 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
456 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
459 static Map_Sources_Tab default_map_sources_tab[] =
461 {"Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
462 {"Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
463 {"CycleMap", 0, 16, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
464 {"MapQuest", 0, 18, _mapquest_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
465 {"MapQuest Open Aerial", 0, 11, _mapquest_aerial_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
468 static const char *widtype = NULL;
469 static Evas_Smart_Class parent_sc = EVAS_SMART_CLASS_INIT_NULL;
470 static Evas_Smart_Class sc;
471 static Evas_Smart *smart;
472 static int idnum = 1;
474 static const char SIG_CHANGED[] = "changed";
475 static const char SIG_CLICKED[] = "clicked";
476 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
477 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
478 static const char SIG_LOAD_DETAIL[] = "load,detail";
479 static const char SIG_LONGPRESSED[] = "longpressed";
480 static const char SIG_PRESS[] = "press";
481 static const char SIG_SCROLL[] = "scroll";
482 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
483 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
484 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
485 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
486 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
487 static const char SIG_ZOOM_START[] = "zoom,start";
488 static const char SIG_ZOOM_STOP[] = "zoom,stop";
489 static const char SIG_DOWNLOADED[] = "downloaded";
490 static const char SIG_ROUTE_LOAD[] = "route,load";
491 static const char SIG_ROUTE_LOADED[] = "route,loaded";
492 static const char SIG_NAME_LOAD[] = "name,load";
493 static const char SIG_NAME_LOADED[] = "name,loaded";
494 static const char SIG_OVERLAY_CLICKED[] = "overlay,clicked";
495 static const Evas_Smart_Cb_Description _signals[] = {
498 {SIG_CLICKED_DOUBLE, ""},
499 {SIG_LOADED_DETAIL, ""},
500 {SIG_LOAD_DETAIL, ""},
501 {SIG_LONGPRESSED, ""},
504 {SIG_SCROLL_DRAG_START, ""},
505 {SIG_SCROLL_DRAG_STOP, ""},
506 {SIG_SCROLL_ANIM_START, ""},
507 {SIG_SCROLL_ANIM_STOP, ""},
508 {SIG_ZOOM_CHANGE, ""},
509 {SIG_ZOOM_START, ""},
511 {SIG_DOWNLOADED, ""},
512 {SIG_ROUTE_LOAD, ""},
513 {SIG_ROUTE_LOADED, ""},
515 {SIG_NAME_LOADED, ""},
516 {SIG_OVERLAY_CLICKED, ""},
521 module_list_cb(Eina_Module *m, void *data)
523 EINA_SAFETY_ON_NULL_RETURN_VAL(data,EINA_FALSE);
524 Widget_Data *wd = data;
527 Elm_Map_Module_Source_Func source;
528 Elm_Map_Module_Zoom_Min_Func zoom_min;
529 Elm_Map_Module_Zoom_Max_Func zoom_max;
530 Elm_Map_Module_Url_Func url;
531 Elm_Map_Module_Route_Source_Func route_source;
532 Elm_Map_Module_Route_Url_Func route_url;
533 Elm_Map_Module_Name_Url_Func name_url;
534 Elm_Map_Module_Geo_Into_Coord_Func geo_into_coord;
535 Elm_Map_Module_Coord_Into_Geo_Func coord_into_geo;
538 file = eina_module_file_get(m);
539 if (!eina_module_load(m))
541 ERR("could not load module \"%s\": %s", file,
542 eina_error_msg_get(eina_error_get()));
546 source = eina_module_symbol_get(m, "map_module_source_get");
547 zoom_min = eina_module_symbol_get(m, "map_module_zoom_min_get");
548 zoom_max = eina_module_symbol_get(m, "map_module_zoom_max_get");
549 url = eina_module_symbol_get(m, "map_module_url_get");
550 route_source = eina_module_symbol_get(m, "map_module_route_source_get");
551 route_url = eina_module_symbol_get(m, "map_module_route_url_get");
552 name_url = eina_module_symbol_get(m, "map_module_name_url_get");
553 geo_into_coord = eina_module_symbol_get(m, "map_module_geo_into_coord");
554 coord_into_geo = eina_module_symbol_get(m, "map_module_coord_into_geo");
555 if ((!source) || (!zoom_min) || (!zoom_max) || (!url) || (!route_source) ||
556 (!route_url) || (!name_url) || (!geo_into_coord) || (!coord_into_geo))
558 WRN("could not find map_module_source_get() in module \"%s\": %s",
559 file, eina_error_msg_get(eina_error_get()));
560 eina_module_unload(m);
563 s = ELM_NEW(Map_Sources_Tab);
565 s->zoom_min = zoom_min();
566 s->zoom_max = zoom_max();
568 s->route_source = route_source();
569 s->route_url_cb = route_url;
570 s->name_url_cb = name_url;
571 s->geo_into_coord = geo_into_coord;
572 s->coord_into_geo = coord_into_geo;
573 wd->srcs = eina_list_append(wd->srcs, s);
575 eina_module_unload(m);
580 source_init(Widget_Data *wd)
582 EINA_SAFETY_ON_NULL_RETURN(wd);
586 Eina_Array *modules = NULL;
589 for (idx = 0; idx < (sizeof(default_map_sources_tab) / sizeof(Map_Sources_Tab)); idx++)
591 s = ELM_NEW(Map_Sources_Tab);
592 s->name = default_map_sources_tab[idx].name;
593 s->zoom_min = default_map_sources_tab[idx].zoom_min;
594 s->zoom_max = default_map_sources_tab[idx].zoom_max;
595 s->url_cb = default_map_sources_tab[idx].url_cb;
596 s->route_source = default_map_sources_tab[idx].route_source;
597 s->route_url_cb = default_map_sources_tab[idx].route_url_cb;
598 s->name_url_cb = default_map_sources_tab[idx].name_url_cb;
599 s->geo_into_coord = default_map_sources_tab[idx].geo_into_coord;
600 s->coord_into_geo = default_map_sources_tab[idx].coord_into_geo;
601 wd->srcs = eina_list_append(wd->srcs, s);
605 wd->zoom_min = s->zoom_min;
606 wd->zoom_max = s->zoom_max;
609 modules = eina_module_list_get(modules, MODULES_PATH, 1, &module_list_cb, wd);
610 eina_array_free(modules);
612 wd->src_names = calloc((eina_list_count(wd->srcs) + 1), sizeof(char *));
614 EINA_LIST_FOREACH(wd->srcs, l, s)
616 eina_stringshare_replace(&wd->src_names[idx], s->name);
617 INF("source : %s", wd->src_names[idx]);
623 _edj_marker_size_get(Widget_Data *wd, Evas_Coord *w, Evas_Coord *h)
625 EINA_SAFETY_ON_NULL_RETURN(wd);
626 EINA_SAFETY_ON_NULL_RETURN(w);
627 EINA_SAFETY_ON_NULL_RETURN(h);
632 edj = edje_object_add(evas_object_evas_get(wd->obj));
633 _elm_theme_object_set(wd->obj, edj, "map/marker", "radio",
634 elm_widget_style_get(wd->obj));
635 s = edje_object_data_get(edj, "size_w");
638 s = edje_object_data_get(edj, "size_h");
641 evas_object_del(edj);
645 _coord_rotate(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)
647 EINA_SAFETY_ON_NULL_RETURN(xx);
648 EINA_SAFETY_ON_NULL_RETURN(yy);
650 double r = (degree * M_PI) / 180.0;
651 double tx, ty, ttx, tty;
658 tx = ttx + (ty * cos(r + M_PI_2));
659 ty = tty + (ty * sin(r + M_PI_2));
666 _viewport_size_get(Widget_Data *wd, Evas_Coord *vw, Evas_Coord *vh)
668 EINA_SAFETY_ON_NULL_RETURN(wd);
670 Evas_Coord x, y, w, h;
671 evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h);
672 if (vw) *vw = (x * 2) + w;
673 if (vh) *vh = (y * 2) + h;
677 _pan_geometry_get(Widget_Data *wd, Evas_Coord *px, Evas_Coord *py)
679 EINA_SAFETY_ON_NULL_RETURN(wd);
681 Evas_Coord x, y, vx, vy, vw, vh;
682 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
683 evas_object_geometry_get(wd->pan_smart, &vx, &vy, &vw, &vh);
686 if (vw > wd->size.w) x += (((vw - wd->size.w) / 2) + vx);
688 if (vh > wd->size.h) y += (((vh - wd->size.h) / 2) + vy);
695 _obj_rotate(Widget_Data *wd, Evas_Object *obj)
697 Evas_Coord w, h, ow, oh;
698 evas_map_util_points_populate_from_object(wd->map, obj);
700 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
701 evas_object_image_size_get(obj, &w, &h);
702 if ((w > ow) || (h > oh))
704 evas_map_point_image_uv_set(wd->map, 0, 0, 0);
705 evas_map_point_image_uv_set(wd->map, 1, w, 0);
706 evas_map_point_image_uv_set(wd->map, 2, w, h);
707 evas_map_point_image_uv_set(wd->map, 3, 0, h);
709 evas_map_util_rotate(wd->map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
711 evas_object_map_set(obj, wd->map);
712 evas_object_map_enable_set(obj, EINA_TRUE);
716 _obj_place(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
718 EINA_SAFETY_ON_NULL_RETURN(obj);
720 evas_object_move(obj, x, y);
721 evas_object_resize(obj, w, h);
722 evas_object_show(obj);
726 _region_show(void *data)
728 EINA_SAFETY_ON_NULL_RETURN(data);
729 Delayed_Data *dd = data;
732 elm_map_utils_convert_geo_into_coord(dd->wd->obj, dd->lon, dd->lat,
733 dd->wd->size.w, &x, &y);
734 _viewport_size_get(dd->wd, &w, &h);
737 elm_smart_scroller_child_region_show(dd->wd->scr, x, y, w, h);
738 evas_object_smart_changed(dd->wd->pan_smart);
742 _bubble_update(Marker_Bubble *bubble, Eina_List *contents)
744 EINA_SAFETY_ON_NULL_RETURN(bubble);
745 EINA_SAFETY_ON_NULL_RETURN(contents);
750 elm_box_clear(bubble->bx);
751 EINA_LIST_FOREACH(contents, l, c) elm_box_pack_end(bubble->bx, c);
755 _bubble_place(Marker_Bubble *bubble)
757 EINA_SAFETY_ON_NULL_RETURN(bubble);
759 Evas_Coord x, y, w, h;
760 Evas_Coord xx, yy, ww, hh;
763 if ((!bubble->obj) || (!bubble->pobj)) return;
764 evas_object_geometry_get(bubble->pobj, &x, &y, &w, NULL);
766 s = edje_object_data_get(bubble->obj, "size_w");
770 edje_object_size_min_calc(bubble->obj, NULL, &hh);
771 s = edje_object_data_get(bubble->obj, "size_h");
776 xx = x + (w / 2) - (ww / 2);
779 _obj_place(bubble->obj, xx, yy, ww, hh);
780 evas_object_raise(bubble->obj);
784 _bubble_sc_hints_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
786 Marker_Bubble *bubble = data;
787 EINA_SAFETY_ON_NULL_RETURN(bubble);
792 _bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
794 Marker_Bubble *bubble = data;
795 EINA_SAFETY_ON_NULL_RETURN(bubble);
796 _bubble_place(bubble);
800 _bubble_hide_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
802 Marker_Bubble *bubble = data;
803 EINA_SAFETY_ON_NULL_RETURN(bubble);
804 evas_object_hide(bubble->obj);
808 _bubble_show_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
810 Marker_Bubble *bubble = data;
811 EINA_SAFETY_ON_NULL_RETURN(bubble);
812 _bubble_place(bubble);
816 _bubble_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
818 Marker_Bubble *bubble = data;
819 EINA_SAFETY_ON_NULL_RETURN(bubble);
820 _bubble_place(bubble);
824 _bubble_free(Marker_Bubble* bubble)
826 EINA_SAFETY_ON_NULL_RETURN(bubble);
828 evas_object_del(bubble->bx);
829 evas_object_del(bubble->sc);
830 evas_object_del(bubble->obj);
834 static Marker_Bubble*
835 _bubble_create(Evas_Object *pobj, Widget_Data *wd)
837 EINA_SAFETY_ON_NULL_RETURN_VAL(pobj, NULL);
838 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
840 Marker_Bubble *bubble = ELM_NEW(Marker_Bubble);
841 EINA_SAFETY_ON_NULL_RETURN_VAL(bubble, NULL);
845 evas_object_event_callback_add(pobj, EVAS_CALLBACK_HIDE, _bubble_hide_cb,
847 evas_object_event_callback_add(pobj, EVAS_CALLBACK_SHOW, _bubble_show_cb,
849 evas_object_event_callback_add(pobj, EVAS_CALLBACK_MOVE, _bubble_move_cb,
852 bubble->obj = edje_object_add(evas_object_evas_get(pobj));
853 _elm_theme_object_set(wd->obj, bubble->obj , "map", "marker_bubble",
854 elm_widget_style_get(wd->obj));
855 evas_object_event_callback_add(bubble->obj, EVAS_CALLBACK_MOUSE_UP,
856 _bubble_mouse_up_cb, bubble);
858 bubble->sc = elm_scroller_add(bubble->obj);
859 elm_widget_style_set(bubble->sc, "map_bubble");
860 elm_scroller_content_min_limit(bubble->sc, EINA_FALSE, EINA_TRUE);
861 elm_scroller_policy_set(bubble->sc, ELM_SCROLLER_POLICY_AUTO,
862 ELM_SCROLLER_POLICY_OFF);
863 elm_scroller_bounce_set(bubble->sc, _elm_config->thumbscroll_bounce_enable,
865 edje_object_part_swallow(bubble->obj, "elm.swallow.content", bubble->sc);
866 evas_object_event_callback_add(bubble->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
867 _bubble_sc_hints_changed_cb, bubble);
869 bubble->bx = elm_box_add(bubble->sc);
870 evas_object_size_hint_align_set(bubble->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
871 evas_object_size_hint_weight_set(bubble->bx, EVAS_HINT_EXPAND,
873 elm_box_horizontal_set(bubble->bx, EINA_TRUE);
874 elm_object_content_set(bubble->sc, bubble->bx);
880 _marker_group_update(Marker_Group* group, Elm_Map_Group_Class *clas, Eina_List *markers)
882 EINA_SAFETY_ON_NULL_RETURN(group);
883 EINA_SAFETY_ON_NULL_RETURN(clas);
884 EINA_SAFETY_ON_NULL_RETURN(markers);
885 Widget_Data *wd = clas->wd;
886 EINA_SAFETY_ON_NULL_RETURN(wd);
890 Elm_Map_Marker *marker;
892 int sum_x = 0, sum_y = 0;
894 EINA_LIST_FOREACH(markers, l, marker)
901 group->x = sum_x / cnt;
902 group->y = sum_y / cnt;
903 _edj_marker_size_get(wd, &group->w, &group->h);
907 group->markers = markers;
909 if (clas->style) elm_layout_theme_set(group->obj, "map/marker", clas->style,
910 elm_widget_style_get(wd->obj));
911 else elm_layout_theme_set(group->obj, "map/marker", "radio",
912 elm_widget_style_get(wd->obj));
915 if (clas->func.icon_get)
917 Evas_Object *icon = NULL;
919 icon = elm_object_part_content_get(group->obj, "elm.icon");
920 if (icon) evas_object_del(icon);
922 icon = clas->func.icon_get(wd->obj, clas->data);
923 elm_object_part_content_set(group->obj, "elm.icon", icon);
925 snprintf(buf, sizeof(buf), "%d", cnt);
926 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
931 Elm_Map_Marker *marker;
932 Eina_List *contents = NULL;
934 EINA_LIST_FOREACH(group->markers, l, marker)
936 Evas_Object *c = marker->clas->func.get(marker->wd->obj,
937 marker, marker->data);
938 if (c) contents = eina_list_append(contents, c);
940 _bubble_update(group->bubble, contents);
945 _marker_group_bubble_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
947 EINA_SAFETY_ON_NULL_RETURN(data);
948 Marker_Group *group = data;
950 Elm_Map_Marker *marker;
951 Eina_List *contents = NULL;
953 if (!group->bubble) group->bubble = _bubble_create(group->obj, group->wd);
955 EINA_LIST_FOREACH(group->markers, l, marker)
957 if (group->wd->markers_max_num <= eina_list_count(contents)) break;
958 Evas_Object *c = marker->clas->func.get(marker->wd->obj,
959 marker, marker->data);
960 if (c) contents = eina_list_append(contents, c);
962 _bubble_update(group->bubble, contents);
963 _bubble_place(group->bubble);
967 _marker_group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
969 EINA_SAFETY_ON_NULL_RETURN(data);
972 Marker_Group *group = data;
973 elm_map_utils_convert_coord_into_geo(group->wd->obj, group->x, group->y,
974 group->wd->size.w, &lon, &lat);
975 elm_map_geo_region_bring_in(group->wd->obj, lon, lat);
979 _marker_group_free(Marker_Group* group)
981 EINA_SAFETY_ON_NULL_RETURN(group);
983 if (group->bubble) _bubble_free(group->bubble);
985 eina_list_free(group->markers);
986 evas_object_del(group->obj);
992 _marker_group_create(Widget_Data *wd)
994 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
996 Marker_Group *group = ELM_NEW(Marker_Group);
999 group->obj = elm_layout_add(wd->obj);
1000 evas_object_smart_member_add(group->obj, wd->pan_smart);
1001 evas_object_stack_above(group->obj, wd->sep_maps_markers);
1002 elm_layout_theme_set(group->obj, "map/marker", "radio",
1003 elm_widget_style_get(wd->obj));
1004 edje_object_signal_callback_add(elm_layout_edje_get(group->obj),
1005 "open", "elm", _marker_group_bubble_open_cb,
1007 edje_object_signal_callback_add(elm_layout_edje_get(group->obj),
1008 "bringin", "elm", _marker_group_bringin_cb,
1014 _marker_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
1016 Elm_Map_Marker *marker = data;
1017 EINA_SAFETY_ON_NULL_RETURN(marker);
1018 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
1022 _marker_bubble_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
1024 EINA_SAFETY_ON_NULL_RETURN(data);
1025 Elm_Map_Marker *marker = data;
1027 if (!marker->bubble) marker->bubble = _bubble_create(marker->obj, marker->wd);
1028 evas_object_smart_changed(marker->wd->pan_smart);
1032 _marker_update(Elm_Map_Marker *marker)
1034 EINA_SAFETY_ON_NULL_RETURN(marker);
1035 Elm_Map_Marker_Class *clas = marker->clas;
1036 EINA_SAFETY_ON_NULL_RETURN(clas);
1038 if (clas->style) elm_layout_theme_set(marker->obj, "map/marker", clas->style,
1039 elm_widget_style_get(marker->wd->obj));
1040 else elm_layout_theme_set(marker->obj, "map/marker", "radio",
1041 elm_widget_style_get(marker->wd->obj));
1043 if (clas->func.icon_get)
1045 Evas_Object *icon = NULL;
1047 icon = elm_object_part_content_get(marker->obj, "elm.icon");
1048 if (icon) evas_object_del(icon);
1050 icon = clas->func.icon_get(marker->wd->obj, marker, marker->data);
1051 elm_object_part_content_set(marker->obj, "elm.icon", icon);
1054 elm_map_utils_convert_geo_into_coord(marker->wd->obj, marker->longitude,
1055 marker->latitude, marker->wd->size.w,
1056 &(marker->x), &(marker->y));
1060 if (marker->content) evas_object_del(marker->content);
1061 if (marker->clas->func.get)
1062 marker->content = marker->clas->func.get(marker->wd->obj, marker,
1064 if (marker->content)
1066 Eina_List *contents = NULL;
1067 contents = eina_list_append(contents, marker->content);
1068 _bubble_update(marker->bubble, contents);
1076 _marker_place(Widget_Data *wd)
1078 EINA_SAFETY_ON_NULL_RETURN(wd);
1082 Elm_Map_Marker *marker;
1083 Elm_Map_Group_Class *group_clas;
1088 if (wd->paused_markers || (!eina_list_count(wd->markers))) return;
1090 _pan_geometry_get(wd, &px, &py);
1092 _edj_marker_size_get(wd, &gw, &gh);
1096 EINA_LIST_FOREACH(wd->markers, l, marker)
1098 _marker_update(marker);
1099 marker->grouped = EINA_FALSE;
1100 marker->leader = EINA_FALSE;
1103 EINA_LIST_FOREACH(wd->group_classes, l, group_clas)
1106 EINA_LIST_FOREACH(group_clas->markers, ll, marker)
1110 Eina_List *markers = NULL;
1112 if (marker->grouped) continue;
1113 if (group_clas->zoom_grouped < wd->zoom)
1115 marker->grouped = EINA_FALSE;
1119 EINA_LIST_FOREACH(group_clas->markers, lll, mm)
1121 if (marker == mm || mm->grouped) continue;
1122 if (ELM_RECTS_INTERSECT(mm->x, mm->y, mm->w, mm->h,
1123 marker->x, marker->y, gw, gh))
1125 // mm is group follower.
1126 mm->leader = EINA_FALSE;
1127 mm->grouped = EINA_TRUE;
1128 markers = eina_list_append(markers, mm);
1131 if (eina_list_count(markers) >= 1)
1133 // marker is group leader.
1134 marker->leader = EINA_TRUE;
1135 marker->grouped = EINA_TRUE;
1136 markers = eina_list_append(markers, marker);
1138 if (!marker->group) marker->group = _marker_group_create(wd);
1139 _marker_group_update(marker->group, group_clas, markers);
1144 EINA_LIST_FOREACH(wd->markers, l, marker)
1147 if (marker->grouped ||
1148 (marker->group_clas &&
1149 (marker->group_clas->hide ||
1150 marker->group_clas->zoom_displayed > wd->zoom)))
1151 evas_object_hide(marker->obj);
1155 _coord_rotate(marker->x + px, marker->y + py, wd->rotate.cx,
1156 wd->rotate.cy, wd->rotate.d, &x, &y);
1157 _obj_place(marker->obj, x - (marker->w / 2), y - (marker->h / 2),
1158 marker->w, marker->h);
1162 EINA_LIST_FOREACH(wd->markers, l, marker)
1164 Marker_Group *group = marker->group;
1165 if (!group) continue;
1167 if (!marker->leader || (group->clas->hide) ||
1168 (group->clas->zoom_displayed > wd->zoom))
1169 evas_object_hide(group->obj);
1173 _coord_rotate(group->x + px, group->y + py, wd->rotate.cx,
1174 wd->rotate.cy, wd->rotate.d, &x, &y);
1175 _obj_place(group->obj, x - (group->w / 2), y - (group->h / 2),
1176 group->w, group->h);
1182 _grid_item_coord_get(Grid_Item *gi, int *x, int *y, int *w, int *h)
1184 EINA_SAFETY_ON_NULL_RETURN(gi);
1186 if (x) *x = gi->x * gi->wd->size.tile;
1187 if (y) *y = gi->y * gi->wd->size.tile;
1188 if (w) *w = gi->wd->size.tile;
1189 if (h) *h = gi->wd->size.tile;
1193 _grid_item_intersect(Grid_Item *gi)
1195 EINA_SAFETY_ON_NULL_RETURN_VAL(gi, EINA_FALSE);
1199 Evas_Coord x, y, w, h;
1201 _pan_geometry_get(gi->wd, &px, &py);
1202 _viewport_size_get(gi->wd, &vw, &vh);
1203 _grid_item_coord_get(gi, &x, &y, &w, &h);
1204 return ELM_RECTS_INTERSECT(x + px, y + py, w, h, 0, 0, vw, vh);
1208 _grid_item_update(Grid_Item *gi)
1210 evas_object_image_file_set(gi->img, gi->file, NULL);
1211 if (!gi->wd->zoom_timer && !gi->wd->scr_timer)
1212 evas_object_image_smooth_scale_set(gi->img, EINA_TRUE);
1213 else evas_object_image_smooth_scale_set(gi->img, EINA_FALSE);
1215 Evas_Load_Error err = evas_object_image_load_error_get(gi->img);
1216 if (err != EVAS_LOAD_ERROR_NONE)
1218 ERR("Image loading error (%s): %s", gi->file, evas_load_error_str(err));
1219 ecore_file_remove(gi->file);
1220 gi->file_have = EINA_FALSE;
1225 Evas_Coord x, y, w, h;
1227 _pan_geometry_get(gi->wd, &px, &py);
1228 _grid_item_coord_get(gi, &x, &y, &w, &h);
1230 _obj_place(gi->img, x + px, y + py, w, h);
1231 _obj_rotate(gi->wd, gi->img);
1232 gi->file_have = EINA_TRUE;
1237 _grid_item_load(Grid_Item *gi)
1239 EINA_SAFETY_ON_NULL_RETURN(gi);
1240 if (gi->file_have) _grid_item_update(gi);
1243 gi->wd->download_list = eina_list_remove(gi->wd->download_list, gi);
1244 gi->wd->download_list = eina_list_append(gi->wd->download_list, gi);
1249 _grid_item_unload(Grid_Item *gi)
1251 EINA_SAFETY_ON_NULL_RETURN(gi);
1254 evas_object_hide(gi->img);
1255 evas_object_image_file_set(gi->img, NULL, NULL);
1259 ecore_file_download_abort(gi->job);
1260 ecore_file_remove(gi->file);
1264 else gi->wd->download_list = eina_list_remove(gi->wd->download_list, gi);
1269 _grid_item_create(Grid *g, Evas_Coord x, Evas_Coord y)
1271 EINA_SAFETY_ON_NULL_RETURN_VAL(g, NULL);
1273 char buf2[PATH_MAX];
1277 gi = ELM_NEW(Grid_Item);
1283 gi->file_have = EINA_FALSE;
1286 gi->img = evas_object_image_add(evas_object_evas_get(g->wd->obj));
1287 evas_object_image_smooth_scale_set(gi->img, EINA_FALSE);
1288 evas_object_image_scale_hint_set(gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1289 evas_object_image_filled_set(gi->img, 1);
1290 evas_object_smart_member_add(gi->img, g->wd->pan_smart);
1291 evas_object_pass_events_set(gi->img, EINA_TRUE);
1292 evas_object_stack_below(gi->img, g->wd->sep_maps_markers);
1294 snprintf(buf, sizeof(buf), CACHE_PATH, g->wd->id, g->zoom, x);
1295 snprintf(buf2, sizeof(buf2), CACHE_FILE_PATH, buf, y);
1296 if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
1298 eina_stringshare_replace(&gi->file, buf2);
1299 source = g->wd->src->url_cb(g->wd->obj, x, y, g->zoom);
1300 if ((!source) || (!strlen(source)))
1302 eina_stringshare_replace(&gi->source, NULL);
1303 ERR("Getting source url failed: %s", gi->file);
1305 else eina_stringshare_replace(&gi->source, source);
1306 if (source) free(source);
1307 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
1312 _grid_item_free(Grid_Item *gi)
1314 EINA_SAFETY_ON_NULL_RETURN(gi);
1316 _grid_item_unload(gi);
1317 if (gi->g && gi->g->grid) eina_matrixsparse_data_idx_set(gi->g->grid,
1318 gi->y, gi->x, NULL);
1319 if (gi->source) eina_stringshare_del(gi->source);
1320 if (gi->file) eina_stringshare_del(gi->file);
1321 if (gi->img) evas_object_del(gi->img);
1322 if (gi->file_have) ecore_file_remove(gi->file);
1327 _downloaded_cb(void *data, const char *file __UNUSED__, int status)
1329 Grid_Item *gi = data;
1333 DBG("Download success from %s to %s", gi->source, gi->file);
1334 _grid_item_update(gi);
1335 gi->wd->finish_num++;
1339 WRN("Download failed from %s to %s (%d) ", gi->source, gi->file, status);
1340 ecore_file_remove(gi->file);
1341 gi->file_have = EINA_FALSE;
1345 gi->wd->download_num--;
1346 evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL);
1348 if (!gi->wd->download_num)
1350 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
1351 "elm,state,busy,stop", "elm");
1352 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
1357 _download_job(void *data)
1359 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
1360 Widget_Data *wd = data;
1365 if (!eina_list_count(wd->download_list))
1367 wd->download_idler = NULL;
1368 return ECORE_CALLBACK_CANCEL;
1371 EINA_LIST_REVERSE_FOREACH_SAFE(wd->download_list, l, ll, gi)
1373 if (gi->g->zoom != wd->zoom || !_grid_item_intersect(gi))
1375 wd->download_list = eina_list_remove(wd->download_list, gi);
1378 if (wd->download_num >= MAX_CONCURRENT_DOWNLOAD)
1379 return ECORE_CALLBACK_RENEW;
1381 Eina_Bool ret = ecore_file_download_full(gi->source, gi->file,
1382 _downloaded_cb, NULL,
1383 gi, &(gi->job), wd->ua);
1384 if ((!ret) || (!gi->job))
1385 ERR("Can't start to download from %s to %s", gi->source, gi->file);
1388 wd->download_list = eina_list_remove(wd->download_list, gi);
1392 if (wd->download_num == 1)
1393 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1394 "elm,state,busy,start", "elm");
1397 return ECORE_CALLBACK_RENEW;
1401 _grid_viewport_get(Grid *g, int *x, int *y, int *w, int *h)
1403 EINA_SAFETY_ON_NULL_RETURN(g);
1405 Evas_Coord px, py, vw, vh;
1407 _pan_geometry_get(g->wd, &px, &py);
1408 _viewport_size_get(g->wd, &vw, &vh);
1412 xx = (-px / g->wd->size.tile) - 1;
1415 yy = (-py / g->wd->size.tile) - 1;
1418 ww = (vw / g->wd->size.tile) + 3;
1419 if (xx + ww >= g->tw) ww = g->tw - xx;
1421 hh = (vh / g->wd->size.tile) + 3;
1422 if (yy + hh >= g->th) hh = g->th - yy;
1431 _grid_unload(Grid *g)
1433 EINA_SAFETY_ON_NULL_RETURN(g);
1435 Eina_Matrixsparse_Cell *cell;
1438 it = eina_matrixsparse_iterator_new(g->grid);
1439 EINA_ITERATOR_FOREACH(it, cell)
1441 gi = eina_matrixsparse_cell_data_get(cell);
1442 _grid_item_unload(gi);
1444 eina_iterator_free(it);
1450 EINA_SAFETY_ON_NULL_RETURN(g);
1451 int x, y, xx, yy, ww, hh;
1453 Eina_Matrixsparse_Cell *cell;
1456 it = eina_matrixsparse_iterator_new(g->grid);
1457 EINA_ITERATOR_FOREACH(it, cell)
1459 gi = eina_matrixsparse_cell_data_get(cell);
1460 if (!_grid_item_intersect(gi)) _grid_item_unload(gi);
1462 eina_iterator_free(it);
1464 _grid_viewport_get(g, &xx, &yy, &ww, &hh);
1465 for (y = yy; y < yy + hh; y++)
1467 for (x = xx; x < xx + ww; x++)
1469 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
1470 if (!gi) gi = _grid_item_create(g, x, y);
1471 _grid_item_load(gi);
1477 _grid_place(Widget_Data *wd)
1479 EINA_SAFETY_ON_NULL_RETURN(wd);
1483 EINA_LIST_FOREACH(wd->grids, l, g)
1485 if (wd->zoom == g->zoom) _grid_load(g);
1486 else _grid_unload(g);
1488 if (!wd->download_idler) wd->download_idler = ecore_idler_add(_download_job, wd);
1492 _grid_all_create(Widget_Data *wd)
1494 EINA_SAFETY_ON_NULL_RETURN(wd);
1495 EINA_SAFETY_ON_NULL_RETURN(wd->src);
1498 for (zoom = wd->src->zoom_min; zoom <= wd->src->zoom_max; zoom++)
1505 tnum = pow(2.0, g->zoom);
1508 g->grid = eina_matrixsparse_new(g->th, g->tw, NULL, NULL);
1509 wd->grids = eina_list_append(wd->grids, g);
1514 _grid_all_clear(Widget_Data *wd)
1516 EINA_SAFETY_ON_NULL_RETURN(wd);
1519 EINA_LIST_FREE(wd->grids, g)
1522 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1523 Eina_Matrixsparse_Cell *cell;
1524 EINA_ITERATOR_FOREACH(it, cell)
1526 gi = eina_matrixsparse_cell_data_get(cell);
1527 if (gi) _grid_item_free(gi);
1529 eina_iterator_free(it);
1531 eina_matrixsparse_free(g->grid);
1534 if (!ecore_file_recursive_rm(CACHE_ROOT_PATH))
1535 ERR("Deletion of %s failed", CACHE_ROOT_PATH);
1539 _track_place(Widget_Data *wd)
1542 EINA_SAFETY_ON_NULL_RETURN(wd);
1546 int xmin, xmax, ymin, ymax;
1547 Evas_Coord px, py, ow, oh;
1550 _viewport_size_get(wd, &ow, &oh);
1552 Evas_Coord size = wd->size.w;
1554 EINA_LIST_FOREACH(wd->track, l, route)
1556 double lon_min, lon_max;
1557 double lat_min, lat_max;
1558 elm_route_longitude_min_max_get(route, &lon_min, &lon_max);
1559 elm_route_latitude_min_max_get(route, &lat_min, &lat_max);
1560 elm_map_utils_convert_geo_into_coord(wd->obj, lon_min, lat_max, size, &xmin, &ymin);
1561 elm_map_utils_convert_geo_into_coord(wd->obj, lon_max, lat_min, size, &xmax, &ymax);
1563 if( !(xmin < px && xmax < px) && !(xmin > px+ow && xmax > px+ow))
1565 if( !(ymin < py && ymax < py) && !(ymin > py+oh && ymax > py+oh))
1568 evas_object_move(route, xmin - px, ymin - py);
1569 evas_object_resize(route, xmax - xmin, ymax - ymin);
1571 evas_object_raise(route);
1572 _obj_rotate(wd, route);
1573 evas_object_show(route);
1578 //the route is not display
1579 evas_object_hide(route);
1586 _route_place(Widget_Data *wd)
1588 EINA_SAFETY_ON_NULL_RETURN(wd);
1589 Eina_List *lr, *lp, *ln;
1601 _viewport_size_get(wd, &ow, &oh);
1603 Evas_Coord size = wd->size.w;
1605 EINA_LIST_FOREACH(wd->route, lr, r)
1607 EINA_LIST_FOREACH(r->path, lp, p)
1609 evas_object_polygon_points_clear(p);
1612 nodes = eina_list_count(r->nodes);
1614 EINA_LIST_FOREACH(r->nodes, ln, n)
1616 if ((!wd->zoom) || ((n->idx) &&
1617 ((n->idx % (int)ceil((double)nodes/(double)size*100.0))))) continue;
1620 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
1621 if ((x >= px - ow) && (x <= (px + ow*2)) &&
1622 (y >= py - oh) && (y <= (py + oh*2)))
1627 p = eina_list_nth(r->path, n->idx);
1628 a = (double)(y - r->y) / (double)(x - r->x);
1629 if ((abs(a) >= 1) || (r->x == x))
1631 evas_object_polygon_point_add(p, r->x - 3, r->y);
1632 evas_object_polygon_point_add(p, r->x + 3, r->y);
1633 evas_object_polygon_point_add(p, x + 3, y);
1634 evas_object_polygon_point_add(p, x - 3, y);
1638 evas_object_polygon_point_add(p, r->x, r->y - 3);
1639 evas_object_polygon_point_add(p, r->x, r->y + 3);
1640 evas_object_polygon_point_add(p, x, y + 3);
1641 evas_object_polygon_point_add(p, x, y - 3);
1644 evas_object_color_set(p, r->color.r, r->color.g, r->color.b, r->color.a);
1645 evas_object_raise(p);
1647 evas_object_show(p);
1651 else r->inbound = EINA_FALSE;
1655 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
1656 if ((x >= px - ow) && (x <= (px + ow*2)) &&
1657 (y >= py - oh) && (y <= (py + oh*2)))
1661 r->inbound = EINA_TRUE;
1663 else r->inbound = EINA_FALSE;
1666 r->inbound = EINA_FALSE;
1671 _delayed_do(Widget_Data *wd)
1674 dd = eina_list_nth(wd->delayed_jobs, 0);
1675 if (dd && !dd->wd->zoom_animator)
1678 wd->delayed_jobs = eina_list_remove(wd->delayed_jobs, dd);
1684 _smooth_update(Widget_Data *wd)
1686 EINA_SAFETY_ON_NULL_RETURN(wd);
1690 EINA_LIST_FOREACH(wd->grids, l, g)
1692 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1693 Eina_Matrixsparse_Cell *cell;
1695 EINA_ITERATOR_FOREACH(it, cell)
1697 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1698 if (_grid_item_intersect(gi))
1699 evas_object_image_smooth_scale_set(gi->img, EINA_TRUE);
1701 eina_iterator_free(it);
1706 _zoom_timeout(void *data)
1708 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
1709 Widget_Data *wd = data;
1711 wd->zoom_timer = NULL;
1712 evas_object_smart_callback_call(wd->obj, SIG_ZOOM_STOP, NULL);
1713 return ECORE_CALLBACK_CANCEL;
1717 zoom_do(Widget_Data *wd, double zoom)
1719 EINA_SAFETY_ON_NULL_RETURN(wd);
1720 if (zoom > wd->zoom_max) zoom = wd->zoom_max;
1721 else if (zoom < wd->zoom_min) zoom = wd->zoom_min;
1723 Evas_Coord px, py, vw, vh;
1726 wd->zoom = ROUND(zoom);
1727 wd->zoom_detail = zoom;
1730 wd->size.tile = pow(2.0, (zoom - wd->zoom)) * wd->tsize;
1731 wd->size.w = pow(2.0, wd->zoom) * wd->size.tile;
1732 wd->size.h = wd->size.w;;
1734 // Fix to zooming with (viewport center px, py) as the center to prevent
1735 // from zooming with (0,0) as the cetner. (scroller default behavior)
1736 _pan_geometry_get(wd, &px, &py);
1737 _viewport_size_get(wd, &vw, &vh);
1738 if ((vw > 0) && (vh > 0) && (ow > 0) && (oh > 0))
1742 if (vw > ow) sx = 0.5;
1743 else sx = (double)(-px + (vw / 2)) / ow;
1744 if (vh > oh) sy = 0.5;
1745 else sy = (double)(-py + (vh / 2)) / oh;
1747 if (sx > 1.0) sx = 1.0;
1748 if (sy > 1.0) sy = 1.0;
1750 xx = (sx * wd->size.w) - (vw / 2);
1751 yy = (sy * wd->size.h) - (vh / 2);
1753 else if (xx > (wd->size.w - vw)) xx = wd->size.w - vw;
1755 else if (yy > (wd->size.h - vh)) yy = wd->size.h - vh;
1756 elm_smart_scroller_child_region_show(wd->scr, xx, yy, vw, vh);
1759 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1760 else evas_object_smart_callback_call(wd->obj, SIG_ZOOM_START, NULL);
1761 wd->zoom_timer = ecore_timer_add(0.25, _zoom_timeout, wd);
1762 evas_object_smart_callback_call(wd->obj, SIG_ZOOM_CHANGE, NULL);
1764 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
1765 evas_object_smart_changed(wd->pan_smart);
1769 _zoom_anim(void *data)
1771 Widget_Data *wd = data;
1772 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, ECORE_CALLBACK_CANCEL);
1774 if (wd->ani.cnt <= 0)
1776 wd->zoom_animator = NULL;
1777 evas_object_smart_changed(wd->pan_smart);
1778 return ECORE_CALLBACK_CANCEL;
1782 wd->ani.zoom += wd->ani.diff;
1784 zoom_do(wd, wd->ani.zoom);
1785 return ECORE_CALLBACK_RENEW;
1790 zoom_with_animation(Widget_Data *wd, double zoom, int cnt)
1792 EINA_SAFETY_ON_NULL_RETURN(wd);
1793 if (cnt == 0) return;
1796 wd->ani.zoom = wd->zoom;
1797 wd->ani.diff = (double)(zoom - wd->zoom) / cnt;
1798 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
1799 wd->zoom_animator = ecore_animator_add(_zoom_anim, wd);
1803 _sizing_eval(Widget_Data *wd)
1805 EINA_SAFETY_ON_NULL_RETURN(wd);
1807 Evas_Coord maxw = -1, maxh = -1;
1809 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
1810 evas_object_size_hint_max_set(wd->obj, maxw, maxh);
1814 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1820 _scr_timeout(void *data)
1822 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
1823 Widget_Data *wd = data;
1825 wd->scr_timer = NULL;
1826 evas_object_smart_callback_call(wd->obj, SIG_SCROLL_DRAG_STOP, NULL);
1827 return ECORE_CALLBACK_CANCEL;
1831 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1833 EINA_SAFETY_ON_NULL_RETURN(data);
1834 Widget_Data *wd = data;
1836 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1837 else evas_object_smart_callback_call(wd->obj, SIG_SCROLL_DRAG_START, NULL);
1838 wd->scr_timer = ecore_timer_add(0.25, _scr_timeout, wd);
1839 evas_object_smart_callback_call(wd->obj, SIG_SCROLL, NULL);
1843 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1845 EINA_SAFETY_ON_NULL_RETURN(data);
1846 Widget_Data *wd = data;
1847 evas_object_smart_callback_call(wd->obj, SIG_SCROLL_ANIM_START, NULL);
1851 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1853 EINA_SAFETY_ON_NULL_RETURN(data);
1854 Widget_Data *wd = data;
1855 evas_object_smart_callback_call(wd->obj, SIG_SCROLL_ANIM_STOP, NULL);
1859 _long_press(void *data)
1861 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
1862 Widget_Data *wd = data;
1864 wd->long_timer = NULL;
1865 evas_object_smart_callback_call(wd->obj, SIG_LONGPRESSED, &wd->ev);
1866 return ECORE_CALLBACK_CANCEL;
1870 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1872 EINA_SAFETY_ON_NULL_RETURN(data);
1873 Widget_Data *wd = data;
1874 Evas_Event_Mouse_Down *ev = event_info;
1876 if (ev->button != 1) return;
1878 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1879 else wd->on_hold = EINA_FALSE;
1881 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1882 evas_object_smart_callback_call(wd->obj, SIG_CLICKED_DOUBLE, ev);
1883 else evas_object_smart_callback_call(wd->obj, SIG_PRESS, ev);
1885 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1887 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, wd);
1891 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1893 EINA_SAFETY_ON_NULL_RETURN(data);
1894 Widget_Data *wd = data;
1896 Evas_Event_Mouse_Up *ev = event_info;
1897 EINA_SAFETY_ON_NULL_RETURN(ev);
1899 if (ev->button != 1) return;
1900 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1901 else wd->on_hold = EINA_FALSE;
1904 ecore_timer_del(wd->long_timer);
1905 wd->long_timer = NULL;
1907 if (!wd->on_hold) evas_object_smart_callback_call(wd->obj, SIG_CLICKED, ev);
1908 wd->on_hold = EINA_FALSE;
1912 _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1914 EINA_SAFETY_ON_NULL_RETURN(data);
1915 Widget_Data *wd = data;
1919 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
1920 zoom_do(wd, wd->zoom_detail - ((double)ev->z / 10));
1925 _region_max_min_get(Eina_List *overlays, double *max_longitude, double *min_longitude, double *max_latitude, double *min_latitude)
1927 double max_lon = -180, min_lon = 180;
1928 double max_lat = -90, min_lat = 90;
1929 Elm_Map_Overlay *overlay;
1930 EINA_LIST_FREE(overlays, overlay)
1933 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1935 Overlay_Default *ovl = overlay->ovl;
1939 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
1941 // FIXME: class center coord is alright??
1942 Overlay_Class *ovl = overlay->ovl;
1943 double max_lo, min_lo, max_la, min_la;
1944 _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la,
1946 lon = (max_lo + min_lo) / 2;
1947 lat = (max_la + min_la) / 2;
1949 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
1951 Overlay_Bubble *ovl = overlay->ovl;
1957 WRN("Not supported overlay type: %d", overlay->type);
1960 if (lon> max_lon) max_lon = lon;
1961 if (lon< min_lon) min_lon = lon;
1962 if (lat > max_lat) max_lat = lat;
1963 if (lat < min_lat) min_lat = lat;
1965 if (max_longitude) *max_longitude = max_lon;
1966 if (min_longitude) *min_longitude = min_lon;
1967 if (max_latitude) *max_latitude = max_lat;
1968 if (min_latitude) *min_latitude = min_lat;
1971 static Evas_Object *
1972 _icon_dup(Evas_Object *icon, Evas_Object *parent)
1974 if (!icon || !parent) return NULL;
1975 // Evas_Object do not support object duplication??
1976 const char *file = NULL, *group = NULL;
1977 Eina_Bool scale_up, scale_down;
1979 Evas_Object *dup = elm_icon_add(parent);
1980 elm_icon_file_get(icon, &file, &group);
1981 elm_icon_file_set(dup, file, group);
1982 elm_icon_animated_set(dup, elm_icon_animated_get(icon));
1983 elm_icon_animated_play_set(dup, elm_icon_animated_play_get(icon));
1984 elm_icon_standard_set(dup, elm_icon_standard_get(icon));
1985 elm_icon_order_lookup_set(dup, elm_icon_order_lookup_get(icon));
1986 elm_icon_no_scale_set(dup, elm_icon_no_scale_get(icon));
1987 elm_icon_scale_get(icon, &scale_up, &scale_down);
1988 elm_icon_scale_set(dup, scale_up, scale_down);
1989 elm_icon_fill_outside_set(dup, elm_icon_fill_outside_get(icon));
1990 elm_icon_prescale_set(dup, elm_icon_prescale_get(icon));
1991 elm_icon_aspect_fixed_set(dup, elm_icon_aspect_fixed_get(icon));
1995 static Evas_Object *
1996 _overlay_layout_new(Widget_Data *wd, const char *group)
1998 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1999 EINA_SAFETY_ON_NULL_RETURN_VAL(group, NULL);
2000 Evas_Object *obj = elm_layout_add(wd->obj);
2001 evas_object_smart_member_add(obj, wd->pan_smart);
2002 evas_object_stack_above(obj, wd->sep_maps_markers);
2003 elm_layout_theme_set(obj, "map/marker", group, elm_widget_style_get(wd->obj));
2008 _overlay_layout_update(Widget_Data *wd, Evas_Object *layout, Evas_Object *icon, const char *text, const char *group)
2010 EINA_SAFETY_ON_NULL_RETURN(wd);
2011 EINA_SAFETY_ON_NULL_RETURN(layout);
2013 Evas_Object *prev_icon = elm_object_part_content_get(layout, "elm.icon");
2014 if (icon && (prev_icon != icon))
2016 elm_layout_theme_set(layout, "map/marker", "empty",
2017 elm_widget_style_get(wd->obj));
2018 elm_object_part_content_set(layout, "elm.icon", icon);
2022 if (group) elm_layout_theme_set(layout, "map/marker", group,
2023 elm_widget_style_get(wd->obj));
2024 edje_object_part_text_set(elm_layout_edje_get(layout), "elm.text", text);
2029 _overlay_clicked_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
2031 EINA_SAFETY_ON_NULL_RETURN(data);
2032 Elm_Map_Overlay *overlay = data;
2034 evas_object_smart_callback_call(overlay->wd->obj, SIG_OVERLAY_CLICKED,
2036 if (overlay->cb) overlay->cb(overlay->cb_data, overlay->wd->obj,
2041 _overlay_default_cb_add(Overlay_Default *ovl, Evas_Object_Event_Cb cb, void *data)
2043 EINA_SAFETY_ON_NULL_RETURN(ovl);
2044 EINA_SAFETY_ON_NULL_RETURN(data);
2046 // FIXME: Add icon or object event callback
2047 evas_object_event_callback_add(ovl->layout, EVAS_CALLBACK_MOUSE_DOWN, cb,
2052 _overlay_default_cb_del(Overlay_Default *ovl, Evas_Object_Event_Cb cb)
2054 EINA_SAFETY_ON_NULL_RETURN(ovl);
2055 // FIXME: Add icon or object event callback
2056 evas_object_event_callback_del(ovl->layout, EVAS_CALLBACK_MOUSE_DOWN, cb);
2060 _overlay_default_hide(Overlay_Default *ovl)
2062 EINA_SAFETY_ON_NULL_RETURN(ovl);
2063 if (ovl->obj) evas_object_hide(ovl->obj);
2064 if (ovl->layout) evas_object_hide(ovl->layout);
2068 _overlay_default_show(Widget_Data *wd, Overlay_Default *ovl)
2072 Evas_Coord x, y, w, h;
2077 evas_object_geometry_get(disp, NULL, NULL, &w, &h);
2078 if (w <= 0 || h <= 0) evas_object_size_hint_min_get(disp, &w, &h);
2087 _pan_geometry_get(wd, &px, &py);
2088 _coord_rotate(ovl->x + px, ovl->y + py, wd->rotate.cx, wd->rotate.cy,
2089 wd->rotate.d, &x, &y);
2090 _obj_place(disp, x - (w / 2), y - (h / 2), w, h);
2094 _overlay_default_update(Widget_Data *wd, Overlay_Default *ovl, Evas_Object *obj, Evas_Object *icon, Overlay_Class *ovl_clas, const char *text, const char *group)
2096 EINA_SAFETY_ON_NULL_RETURN(wd);
2097 EINA_SAFETY_ON_NULL_RETURN(ovl);
2099 elm_map_utils_convert_geo_into_coord(wd->obj, ovl->lon, ovl->lat,
2100 wd->size.w, &ovl->x, &ovl->y);
2104 if (ovl->obj == obj) return;
2105 if (ovl->obj) evas_object_del(ovl->obj);
2108 else if (!(ovl->obj) && icon)
2110 if (ovl->icon == icon) return;
2111 if (ovl->icon) evas_object_del(ovl->icon);
2113 _overlay_layout_update(wd, ovl->layout, ovl->icon, NULL, NULL);
2116 else if (!(ovl->obj) && !(ovl->icon) && (ovl_clas) &&
2117 ((ovl_clas->obj) || (ovl_clas->icon)))
2119 // Inherit icon from group overlay's ojbect or icon
2121 // FIXME: It is hard to duplicate evas object :-)
2123 if (ovl_clas->obj && (ovl_clas->obj != ovl->clas_obj_ref))
2125 if (ovl->clas_obj) evas_object_del(ovl->clas_obj);
2126 ovl->clas_obj_ref = ovl_clas->obj;
2127 ovl->clas_obj = _obj_dup(ovl->clas_obj_ref, ovl->layout);
2128 _overlay_layout_update(wd, ovl->layout, ovl->clas_obj, NULL, NULL);
2131 if (ovl_clas->icon && (ovl_clas->icon != ovl->clas_icon_ref))
2133 if (ovl->clas_icon) evas_object_del(ovl->clas_icon);
2134 ovl->clas_icon_ref = ovl_clas->icon;
2135 ovl->clas_icon = _icon_dup(ovl->clas_icon_ref, ovl->layout);
2136 _overlay_layout_update(wd, ovl->layout, ovl->clas_icon, NULL, NULL);
2139 else if (!(ovl->obj) && !(ovl->icon) && !(ovl->clas_icon) && text)
2141 _overlay_layout_update(wd, ovl->layout, NULL, text, group);
2146 _overlay_default_free(Overlay_Default *ovl)
2148 EINA_SAFETY_ON_NULL_RETURN(ovl);
2149 if (ovl->obj) evas_object_del(ovl->obj);
2150 if (ovl->icon) evas_object_del(ovl->icon);
2151 if (ovl->clas_icon) evas_object_del(ovl->clas_icon);
2152 evas_object_event_callback_del(ovl->layout, EVAS_CALLBACK_MOUSE_DOWN,
2153 _overlay_clicked_cb);
2154 if (ovl->layout) evas_object_del(ovl->layout);
2158 static Overlay_Default *
2159 _overlay_default_new(Widget_Data *wd, double lon, double lat, const char *group)
2161 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2162 EINA_SAFETY_ON_NULL_RETURN_VAL(group, NULL);
2164 Overlay_Default *ovl = ELM_NEW(Overlay_Default);
2165 _edj_marker_size_get(wd, &(ovl->w), &(ovl->h));
2166 ovl->layout = _overlay_layout_new(wd, group);
2173 _overlay_group_clicked_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
2175 EINA_SAFETY_ON_NULL_RETURN(data);
2176 Overlay_Group *ovl = data;
2178 evas_object_smart_callback_call(ovl->clas->wd->obj, SIG_OVERLAY_CLICKED,
2180 if (ovl->clas->cb) ovl->clas->cb(ovl->clas->cb_data, ovl->clas->wd->obj,
2185 _overlay_group_cb_add(Overlay_Group *ovl)
2187 EINA_SAFETY_ON_NULL_RETURN(ovl);
2188 _overlay_default_cb_add(ovl->ovl, _overlay_group_clicked_cb, ovl);
2192 _overlay_group_cb_del(Overlay_Group *ovl)
2194 EINA_SAFETY_ON_NULL_RETURN(ovl);
2195 _overlay_default_cb_del(ovl->ovl, _overlay_group_clicked_cb);
2199 _overlay_group_update(Widget_Data *wd, Overlay_Group *grp, Eina_List *members)
2201 EINA_SAFETY_ON_NULL_RETURN(wd);
2202 EINA_SAFETY_ON_NULL_RETURN(grp);
2205 Elm_Map_Overlay *overlay;
2206 Evas_Coord sum_x = 0, sum_y = 0, cnt = 0;
2208 if (grp->members) eina_list_free(grp->members);
2209 grp->members = members;
2211 if (!grp->members || eina_list_count(grp->members) <= 0)
2213 _overlay_default_hide(grp->ovl);
2216 EINA_LIST_FOREACH(grp->members, l, overlay)
2218 Overlay_Default *df = overlay->ovl;
2224 Overlay_Class *ovl_clas = grp->clas->ovl;
2227 snprintf(text, sizeof(text), "%d", cnt);
2228 _overlay_default_update(wd, grp->ovl, NULL, NULL, ovl_clas, text, "radio2");
2230 grp->ovl->x = sum_x / cnt;
2231 grp->ovl->y = sum_y / cnt;
2235 _overlay_group_free(Overlay_Group *grp, Elm_Map_Overlay *club_owner)
2237 EINA_SAFETY_ON_NULL_RETURN(grp);
2239 _overlay_default_cb_del(grp->ovl, _overlay_group_clicked_cb);
2240 _overlay_default_free(grp->ovl);
2241 if (grp->clas) elm_map_overlay_class_remove(grp->clas, club_owner);
2242 if (grp->members) eina_list_free(grp->members);
2246 static Overlay_Group *
2247 _overlay_group_new(Widget_Data *wd)
2249 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2251 Overlay_Group *grp = ELM_NEW(Overlay_Group);
2252 grp->ovl = ELM_NEW(Overlay_Default);
2253 grp->ovl = _overlay_default_new(wd, -1, -1, "radio2");
2260 _overlay_class_update(Widget_Data *wd, Overlay_Class *clas, Evas_Object *obj, Evas_Object *icon)
2262 EINA_SAFETY_ON_NULL_RETURN(wd);
2263 EINA_SAFETY_ON_NULL_RETURN(clas);
2265 if (obj && (clas->obj != obj))
2267 if (clas->obj) evas_object_del(clas->obj);
2270 else if (icon && (clas->icon != icon))
2272 if (clas->icon) evas_object_del(clas->icon);
2278 _overlay_class_free(Overlay_Class *clas)
2280 EINA_SAFETY_ON_NULL_RETURN(clas);
2281 if (clas->icon) evas_object_del(clas->icon);
2282 if (clas->members) eina_list_free(clas->members);
2286 static Overlay_Class *
2287 _overlay_class_new(Widget_Data *wd, Elm_Map_Overlay *clas)
2289 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2290 Overlay_Class *ovl = ELM_NEW(Overlay_Class);
2293 ovl->zoom_max = OVERLAY_CLASS_ZOOM_MAX;
2298 _overlay_bubble_cb_add(Overlay_Bubble *ovl, Elm_Map_Overlay *overlay)
2300 EINA_SAFETY_ON_NULL_RETURN(ovl);
2301 EINA_SAFETY_ON_NULL_RETURN(overlay);
2302 evas_object_event_callback_add(ovl->obj, EVAS_CALLBACK_MOUSE_DOWN,
2303 _overlay_clicked_cb, overlay);
2307 _overlay_bubble_cb_del(Overlay_Bubble *ovl)
2309 EINA_SAFETY_ON_NULL_RETURN(ovl);
2310 evas_object_event_callback_del(ovl->obj, EVAS_CALLBACK_MOUSE_DOWN,
2311 _overlay_clicked_cb);
2315 _overlay_bubble_hide(Overlay_Bubble *bubble)
2317 EINA_SAFETY_ON_NULL_RETURN(bubble);
2318 if (bubble->obj) evas_object_hide(bubble->obj);
2322 _overlay_bubble_update(Overlay_Bubble *bubble)
2324 EINA_SAFETY_ON_NULL_RETURN(bubble);
2325 if ((!bubble->pobj) && (bubble->lon >= 0) && (bubble->lat >= 0))
2327 elm_map_utils_convert_geo_into_coord(bubble->wd->obj, bubble->lon,
2328 bubble->lat, bubble->wd->size.w,
2329 &bubble->x, &bubble->y);
2334 _overlay_bubble_show(Overlay_Bubble *bubble)
2336 EINA_SAFETY_ON_NULL_RETURN(bubble);
2339 if ((bubble->x < 0) || (bubble->y < 0)) return;
2341 _pan_geometry_get(bubble->wd, &px, &py);
2342 _coord_rotate(bubble->x + px, bubble->y + py, bubble->wd->rotate.cx,
2343 bubble->wd->rotate.cy, bubble->wd->rotate.d, &x, &y);
2344 x = x - (bubble->w / 2);
2345 y = y - (bubble->h / 2);
2346 _obj_place(bubble->obj, x, y, bubble->w, bubble->h);
2347 //evas_object_raise(bubble->obj);
2351 _overlay_bubble_chase(Overlay_Bubble *bubble)
2353 EINA_SAFETY_ON_NULL_RETURN(bubble);
2354 EINA_SAFETY_ON_NULL_RETURN(bubble->pobj);
2357 evas_object_geometry_get(bubble->pobj, &x, &y, &w, NULL);
2358 x = x + (w / 2) - (bubble->w / 2);
2360 _obj_place(bubble->obj, x, y, bubble->w, bubble->h);
2361 evas_object_raise(bubble->obj);
2365 _overlay_bubble_hide_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2367 EINA_SAFETY_ON_NULL_RETURN(data);
2368 _overlay_bubble_hide(data);
2372 _overlay_bubble_chase_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2374 EINA_SAFETY_ON_NULL_RETURN(data);
2375 _overlay_bubble_chase(data);
2379 _overlay_bubble_free(Overlay_Bubble* bubble)
2381 EINA_SAFETY_ON_NULL_RETURN(bubble);
2383 evas_object_del(bubble->bx);
2384 evas_object_del(bubble->sc);
2385 evas_object_del(bubble->obj);
2388 evas_object_event_callback_del_full(bubble->pobj, EVAS_CALLBACK_HIDE,
2389 _overlay_bubble_hide_cb, bubble);
2390 evas_object_event_callback_del_full(bubble->pobj, EVAS_CALLBACK_SHOW,
2391 _overlay_bubble_chase_cb, bubble);
2392 evas_object_event_callback_del_full(bubble->pobj, EVAS_CALLBACK_MOVE,
2393 _overlay_bubble_chase_cb, bubble);
2398 static Overlay_Bubble*
2399 _overlay_bubble_new(Widget_Data *wd)
2401 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2405 Overlay_Bubble *bubble = ELM_NEW(Overlay_Bubble);
2408 bubble->obj = edje_object_add(evas_object_evas_get(wd->obj));
2409 _elm_theme_object_set(wd->obj, bubble->obj , "map", "marker_bubble",
2410 elm_widget_style_get(wd->obj));
2411 evas_object_event_callback_add(bubble->obj, EVAS_CALLBACK_MOUSE_UP,
2412 _overlay_bubble_chase_cb, bubble);
2414 bubble->sc = elm_scroller_add(bubble->obj);
2415 elm_widget_style_set(bubble->sc, "map_bubble");
2416 elm_scroller_content_min_limit(bubble->sc, EINA_FALSE, EINA_TRUE);
2417 elm_scroller_policy_set(bubble->sc, ELM_SCROLLER_POLICY_AUTO,
2418 ELM_SCROLLER_POLICY_OFF);
2419 elm_scroller_bounce_set(bubble->sc, _elm_config->thumbscroll_bounce_enable,
2421 edje_object_part_swallow(bubble->obj, "elm.swallow.content", bubble->sc);
2423 bubble->bx = elm_box_add(bubble->sc);
2424 evas_object_size_hint_align_set(bubble->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2425 evas_object_size_hint_weight_set(bubble->bx, EVAS_HINT_EXPAND,
2427 elm_box_horizontal_set(bubble->bx, EINA_TRUE);
2428 elm_object_content_set(bubble->sc, bubble->bx);
2430 s = edje_object_data_get(bubble->obj, "size_w");
2431 if (s) bubble->w = atoi(s);
2434 edje_object_size_min_calc(bubble->obj, NULL, &(bubble->h));
2435 s = edje_object_data_get(bubble->obj, "size_h");
2438 if (bubble->h < h) bubble->h = h;
2448 _overlay_grouping(Eina_List *members, Elm_Map_Overlay *overlay)
2450 EINA_SAFETY_ON_NULL_RETURN(members);
2451 EINA_SAFETY_ON_NULL_RETURN(overlay);
2452 // Currently support only basic overlay type
2453 EINA_SAFETY_ON_FALSE_RETURN(overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT);
2456 Elm_Map_Overlay *overlay_memb;
2457 Eina_List *club_members = NULL;
2459 // Grouping only supports overlay default
2460 Overlay_Default *ovl = (Overlay_Default *)overlay->ovl;
2461 EINA_LIST_FOREACH(members, l, overlay_memb)
2463 Overlay_Default *ovl_memb = overlay_memb->ovl;
2464 if ((overlay_memb->hide) ||
2465 (overlay_memb->zoom_min > overlay_memb->wd->zoom)) continue;
2466 if (overlay == overlay_memb || overlay_memb->grp_in) continue;
2467 if (ELM_RECTS_INTERSECT(ovl_memb->x, ovl_memb->y, ovl_memb->w,
2468 ovl_memb->h, ovl->x, ovl->y,
2469 ovl->w * OVERLAY_GROUPING_SCALE,
2470 ovl->h * OVERLAY_GROUPING_SCALE))
2473 overlay_memb->grp_boss = EINA_FALSE;
2474 overlay_memb->grp_in = EINA_TRUE;
2475 club_members = eina_list_append(club_members, overlay_memb);
2476 _overlay_group_update(overlay_memb->wd, overlay_memb->grp, NULL);
2477 _overlay_group_cb_del(overlay_memb->grp);
2481 if (eina_list_count(club_members) >= 1)
2484 overlay->grp_boss = EINA_TRUE;
2485 overlay->grp_in = EINA_TRUE;
2486 club_members = eina_list_append(club_members, overlay);
2487 _overlay_group_update(overlay->wd, overlay->grp, club_members);
2488 _overlay_group_cb_del(overlay->grp);
2489 _overlay_group_cb_add(overlay->grp);
2494 _overlay_display(Widget_Data *wd, Elm_Map_Overlay *overlay)
2496 Eina_Bool hide = EINA_FALSE;
2498 if ((overlay->grp_in) || (overlay->hide) || (overlay->zoom_min > wd->zoom))
2500 if ((overlay->grp->clas) && ((overlay->grp->clas->hide) ||
2501 (overlay->grp->clas->zoom_min > wd->zoom)))
2504 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2506 if (hide) _overlay_default_hide(overlay->ovl);
2507 else _overlay_default_show(wd, overlay->ovl);
2509 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2511 if (hide) _overlay_bubble_hide(overlay->ovl);
2512 else _overlay_bubble_show(overlay->ovl);
2517 _overlay_place(Widget_Data *wd)
2519 EINA_SAFETY_ON_NULL_RETURN(wd);
2522 Elm_Map_Overlay *overlay, *grp;
2524 if (eina_list_count(wd->overlays) == 0) return;
2526 // Reset overlays coord & grp except class type
2527 EINA_LIST_FOREACH(wd->overlays, l, overlay)
2530 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2531 if (overlay->paused) continue;
2532 if ((overlay->grp) && (overlay->grp->clas) &&
2533 (overlay->grp->clas->paused)) continue;
2534 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2536 Overlay_Class *ovl_grp = NULL;
2537 if (overlay->grp->clas) ovl_grp = overlay->grp->clas->ovl;
2538 _overlay_default_update(wd, overlay->ovl, NULL, NULL, ovl_grp, NULL,
2541 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2542 _overlay_bubble_update(overlay->ovl);
2544 overlay->grp_in = EINA_FALSE;
2545 overlay->grp_boss = EINA_FALSE;
2546 _overlay_group_update(wd, overlay->grp, NULL);
2549 // Classify into group idol or follwer
2550 EINA_LIST_FOREACH(wd->overlays, l, grp)
2552 Elm_Map_Overlay *idol;
2555 if (grp->type != ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2556 if ((grp->hide) || (grp->zoom_min > wd->zoom)) continue;
2559 if (ovl->zoom_max < wd->zoom) continue;
2560 EINA_LIST_FOREACH(ovl->members, ll, idol)
2562 if (!idol->grp_in) _overlay_grouping(ovl->members, idol);
2567 EINA_LIST_FOREACH(wd->overlays, l, overlay)
2568 if (overlay->type != ELM_MAP_OVERLAY_TYPE_CLASS)
2569 _overlay_display(wd, overlay);
2571 // Place group overlays
2572 EINA_LIST_FOREACH(wd->overlays, l, overlay)
2574 if (overlay->grp_boss) _overlay_default_show(wd, overlay->grp->ovl);
2578 static Evas_Object *
2579 _overlay_obj_get(Elm_Map_Overlay *overlay)
2581 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
2582 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2584 Overlay_Default *ovl = overlay->ovl;
2589 ERR("Not supported overlay type: %d", overlay->type);
2595 _overlays_show(void *data)
2597 EINA_SAFETY_ON_NULL_RETURN(data);
2598 Delayed_Data *dd = data;
2601 double max_lon, min_lon, max_lat, min_lat;
2604 _region_max_min_get(dd->overlays, &max_lon, &min_lon, &max_lat, &min_lat);
2605 dd->lon = (max_lon + min_lon) / 2;
2606 dd->lat = (max_lat + min_lat) / 2;
2608 zoom = dd->wd->src->zoom_min;
2609 _viewport_size_get(dd->wd, &vw, &vh);
2610 while (zoom <= dd->wd->src->zoom_max)
2612 Evas_Coord size, max_x, max_y, min_x, min_y;
2613 size = pow(2.0, zoom) * dd->wd->tsize;
2614 elm_map_utils_convert_geo_into_coord(dd->wd->obj, min_lon, max_lat,
2615 size, &min_x, &max_y);
2616 elm_map_utils_convert_geo_into_coord(dd->wd->obj, max_lon, min_lat,
2617 size, &max_x, &min_y);
2618 if ((max_x - min_x) > vw || (max_y - min_y) > vh) break;
2623 zoom_do(dd->wd, zoom);
2625 evas_object_smart_changed(dd->wd->pan_smart);
2629 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2631 Pan *sd = evas_object_smart_data_get(obj);
2632 EINA_SAFETY_ON_NULL_RETURN(sd);
2633 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2637 evas_object_smart_changed(obj);
2641 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2643 Pan *sd = evas_object_smart_data_get(obj);
2644 EINA_SAFETY_ON_NULL_RETURN(sd);
2645 if (x) *x = sd->wd->pan_x;
2646 if (y) *y = sd->wd->pan_y;
2650 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2652 Pan *sd = evas_object_smart_data_get(obj);
2653 EINA_SAFETY_ON_NULL_RETURN(sd);
2655 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2656 ow = sd->wd->size.w - ow;
2657 oh = sd->wd->size.h - oh;
2665 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
2672 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2674 Pan *sd = evas_object_smart_data_get(obj);
2675 EINA_SAFETY_ON_NULL_RETURN(sd);
2676 if (w) *w = sd->wd->size.w;
2677 if (h) *h = sd->wd->size.h;
2681 _pan_add(Evas_Object *obj)
2684 Evas_Object_Smart_Clipped_Data *cd;
2686 cd = evas_object_smart_data_get(obj);
2687 EINA_SAFETY_ON_NULL_RETURN(cd);
2689 sd->__clipped_data = *cd;
2691 evas_object_smart_data_set(obj, sd);
2695 _pan_resize(Evas_Object *obj, Evas_Coord w __UNUSED__, Evas_Coord h __UNUSED__)
2697 Pan *sd = evas_object_smart_data_get(obj);
2698 EINA_SAFETY_ON_NULL_RETURN(sd);
2700 _sizing_eval(sd->wd);
2701 elm_map_zoom_mode_set(sd->wd->obj, sd->wd->mode);
2702 evas_object_smart_changed(obj);
2706 _pan_calculate(Evas_Object *obj)
2708 Pan *sd = evas_object_smart_data_get(obj);
2709 EINA_SAFETY_ON_NULL_RETURN(sd);
2712 evas_object_geometry_get(sd->wd->pan_smart, NULL, NULL, &w, &h);
2713 if (w <= 0 || h <= 0) return;
2715 _grid_place(sd->wd);
2716 _marker_place(sd->wd);
2717 _overlay_place(sd->wd);
2718 _route_place(sd->wd);
2719 _track_place(sd->wd);
2720 _delayed_do(sd->wd);
2724 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2726 EINA_SAFETY_ON_NULL_RETURN(obj);
2727 evas_object_smart_changed(obj);
2731 _hold_on(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2733 EINA_SAFETY_ON_NULL_RETURN(data);
2734 Widget_Data *wd = data;
2735 elm_smart_scroller_hold_set(wd->scr, 1);
2739 _hold_off(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2741 EINA_SAFETY_ON_NULL_RETURN(data);
2742 Widget_Data *wd = data;
2743 elm_smart_scroller_hold_set(wd->scr, 0);
2747 _freeze_on(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2749 EINA_SAFETY_ON_NULL_RETURN(data);
2750 Widget_Data *wd = data;
2751 elm_smart_scroller_freeze_set(wd->scr, 1);
2755 _freeze_off(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2757 EINA_SAFETY_ON_NULL_RETURN(data);
2758 Widget_Data *wd = data;
2759 elm_smart_scroller_freeze_set(wd->scr, 0);
2763 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
2765 ELM_CHECK_WIDTYPE(obj, widtype);
2766 Widget_Data *wd = elm_widget_data_get(obj);
2767 EINA_SAFETY_ON_NULL_RETURN(wd);
2769 if (elm_widget_focus_get(obj))
2771 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
2772 evas_object_focus_set(wd->obj, EINA_TRUE);
2776 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
2777 evas_object_focus_set(wd->obj, EINA_FALSE);
2782 _del_hook(Evas_Object *obj)
2784 ELM_CHECK_WIDTYPE(obj, widtype);
2785 Widget_Data *wd = elm_widget_data_get(obj);
2786 EINA_SAFETY_ON_NULL_RETURN(wd);
2792 Ecore_Event_Handler *h;
2796 Elm_Map_Marker *marker;
2797 Elm_Map_Group_Class *group_clas;
2798 Elm_Map_Marker_Class *clas;
2799 Elm_Map_Overlay *overlay;
2804 EINA_LIST_FOREACH(wd->route, l, r)
2806 EINA_LIST_FREE(r->path, p)
2811 EINA_LIST_FREE(r->waypoint, w)
2813 if (w->point) eina_stringshare_del(w->point);
2817 EINA_LIST_FREE(r->nodes, n)
2819 if (n->pos.address) eina_stringshare_del(n->pos.address);
2823 EINA_LIST_FREE(r->handlers, h)
2825 ecore_event_handler_del(h);
2828 if (r->con_url) ecore_con_url_free(r->con_url);
2829 if (r->info.nodes) eina_stringshare_del(r->info.nodes);
2830 if (r->info.waypoints) eina_stringshare_del(r->info.waypoints);
2833 EINA_LIST_FREE(wd->names, na)
2835 if (na->address) free(na->address);
2836 if (na->handler) ecore_event_handler_del(na->handler);
2839 ecore_file_remove(na->ud.fname);
2841 na->ud.fname = NULL;
2845 EINA_LIST_FREE(wd->track, route)
2847 evas_object_del(route);
2851 EINA_LIST_FOREACH_SAFE(wd->markers, l, ll, marker)
2852 elm_map_marker_remove(marker);
2853 eina_list_free(wd->markers);
2855 EINA_LIST_FREE(wd->group_classes, group_clas)
2857 eina_list_free(group_clas->markers);
2858 if (group_clas->style) eina_stringshare_del(group_clas->style);
2862 EINA_LIST_FREE(wd->marker_classes, clas)
2864 if (clas->style) eina_stringshare_del(clas->style);
2868 EINA_LIST_FREE(wd->overlays, overlay) elm_map_overlay_del(overlay);
2870 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
2871 if (wd->long_timer) ecore_timer_del(wd->long_timer);
2873 if (wd->delayed_jobs) EINA_LIST_FREE(wd->delayed_jobs, dd) free(dd);
2875 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
2876 if (wd->ua) eina_hash_free(wd->ua);
2877 if (wd->download_idler) ecore_idler_del(wd->download_idler);
2878 eina_list_free(wd->download_list);
2880 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
2881 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
2883 _grid_all_clear(wd);
2885 for (idx = 0; wd->src_names[idx]; idx++)
2886 eina_stringshare_del(wd->src_names[idx]);
2888 EINA_LIST_FREE(wd->srcs, s) free(s);
2890 if (wd->map) evas_map_free(wd->map);
2896 _del_pre_hook(Evas_Object *obj)
2898 ELM_CHECK_WIDTYPE(obj, widtype);
2899 Widget_Data *wd = elm_widget_data_get(obj);
2900 EINA_SAFETY_ON_NULL_RETURN(wd);
2904 _theme_hook(Evas_Object *obj)
2906 ELM_CHECK_WIDTYPE(obj, widtype);
2907 Widget_Data *wd = elm_widget_data_get(obj);
2908 EINA_SAFETY_ON_NULL_RETURN(wd);
2910 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
2915 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
2917 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2918 Widget_Data *wd = elm_widget_data_get(obj);
2919 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
2923 Evas_Coord step_x, step_y, page_x, page_y;
2925 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
2926 Evas_Event_Key_Down *ev = event_info;
2927 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
2929 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
2930 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
2931 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
2932 _viewport_size_get(wd, NULL, &vh);
2934 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
2938 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
2942 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
2946 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
2950 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
2953 y -= -(page_y * vh) / 100;
2957 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
2960 y += -(page_y * vh) / 100;
2964 else if (!strcmp(ev->keyname, "KP_Add"))
2966 zoom_with_animation(wd, wd->zoom + 1, 10);
2969 else if (!strcmp(ev->keyname, "KP_Subtract"))
2971 zoom_with_animation(wd, wd->zoom - 1, 10);
2974 else return EINA_FALSE;
2976 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2977 elm_smart_scroller_child_pos_set(wd->scr, x, y);
2983 cb_dump_name_attrs(void *data, const char *key, const char *value)
2985 Name_Dump *dump = (Name_Dump*)data;
2986 if (!dump) return EINA_FALSE;
2988 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
2989 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
2995 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2997 Route_Dump *dump = data;
2998 if (!dump) return EINA_FALSE;
3002 case EINA_SIMPLE_XML_OPEN:
3003 case EINA_SIMPLE_XML_OPEN_EMPTY:
3007 attrs = eina_simple_xml_tag_attributes_find(value, length);
3010 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
3011 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
3012 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
3013 else dump->id = ROUTE_XML_NONE;
3017 case EINA_SIMPLE_XML_DATA:
3019 char *buf = malloc(length);
3020 if (!buf) return EINA_FALSE;
3021 snprintf(buf, length, "%s", value);
3022 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
3023 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
3024 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
3036 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
3038 Name_Dump *dump = data;
3039 if (!dump) return EINA_FALSE;
3043 case EINA_SIMPLE_XML_OPEN:
3044 case EINA_SIMPLE_XML_OPEN_EMPTY:
3047 attrs = eina_simple_xml_tag_attributes_find(value, length);
3050 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME;
3051 else dump->id = NAME_XML_NONE;
3053 eina_simple_xml_attributes_parse
3054 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
3058 case EINA_SIMPLE_XML_DATA:
3060 char *buf = malloc(length + 1);
3061 if (!buf) return EINA_FALSE;
3062 snprintf(buf, length + 1, "%s", value);
3063 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
3075 _parse_kml(void *data)
3077 Elm_Map_Route *r = (Elm_Map_Route*)data;
3078 if (!r || !r->ud.fname) return;
3082 unsigned int ele, idx;
3086 Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL};
3088 f = fopen(r->ud.fname, "rb");
3093 fseek(f, 0, SEEK_END);
3099 fseek(f, 0, SEEK_SET);
3103 if (fread(buf, 1, sz, f))
3105 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump);
3112 if (dump.distance) r->info.distance = dump.distance;
3113 if (dump.description)
3115 eina_stringshare_replace(&r->info.waypoints, dump.description);
3116 str = eina_str_split_full(dump.description, "\n", 0, &ele);
3117 r->info.waypoint_count = ele;
3118 for (idx = 0; idx < ele; idx++)
3120 Path_Waypoint *wp = ELM_NEW(Path_Waypoint);
3124 wp->point = eina_stringshare_add(str[idx]);
3125 DBG("%s", str[idx]);
3126 r->waypoint = eina_list_append(r->waypoint, wp);
3135 else WRN("description is not found !");
3137 if (dump.coordinates)
3139 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
3140 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
3141 r->info.node_count = ele;
3142 for (idx = 0; idx < ele; idx++)
3144 sscanf(str[idx], "%lf,%lf", &lon, &lat);
3145 Path_Node *n = ELM_NEW(Path_Node);
3152 DBG("%lf:%lf", lon, lat);
3153 n->pos.address = NULL;
3154 r->nodes = eina_list_append(r->nodes, n);
3156 path = evas_object_polygon_add(evas_object_evas_get(r->wd->obj));
3157 evas_object_smart_member_add(path, r->wd->pan_smart);
3158 r->path = eina_list_append(r->path, path);
3171 _parse_name(void *data)
3173 Elm_Map_Name *n = (Elm_Map_Name*)data;
3174 if (!n || !n->ud.fname) return;
3178 Name_Dump dump = {0, NULL, 0.0, 0.0};
3180 f = fopen(n->ud.fname, "rb");
3185 fseek(f, 0, SEEK_END);
3191 fseek(f, 0, SEEK_SET);
3195 if (fread(buf, 1, sz, f))
3197 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
3206 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
3207 n->address = strdup(dump.address);
3214 Grid *_get_current_grid(Widget_Data *wd)
3216 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
3218 Grid *g = NULL, *ret = NULL;
3219 EINA_LIST_FOREACH(wd->grids, l, g)
3221 if (wd->zoom == g->zoom)
3231 _route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
3233 Ecore_Con_Event_Url_Complete *ev = event;
3234 Elm_Map_Route *r = (Elm_Map_Route*)data;
3235 Widget_Data *wd = r->wd;
3237 if ((!r) || (!ev)) return EINA_TRUE;
3238 Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url);
3239 ecore_con_url_data_set(r->con_url, NULL);
3240 if (r!=rr) return EINA_TRUE;
3242 if (r->ud.fd) fclose(r->ud.fd);
3247 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3248 "elm,state,busy,stop", "elm");
3249 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
3254 _name_complete_cb(void *data, int ev_type __UNUSED__, void *event)
3256 Ecore_Con_Event_Url_Complete *ev = event;
3257 Elm_Map_Name *n = (Elm_Map_Name*)data;
3258 Widget_Data *wd = n->wd;
3260 if ((!n) || (!ev)) return EINA_TRUE;
3261 Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url);
3262 ecore_con_url_data_set(n->con_url, NULL);
3263 if (n!=nn) return EINA_TRUE;
3265 if (n->ud.fd) fclose(n->ud.fd);
3268 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3269 "elm,state,busy,stop", "elm");
3270 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
3274 static Elm_Map_Name *
3275 _utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat)
3277 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3278 Widget_Data *wd = elm_widget_data_get(obj);
3283 if ((!wd) || (!wd->src)) return NULL;
3284 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
3286 snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE);
3294 name->con_url = ecore_con_url_new(NULL);
3295 name->ud.fname = strdup(buf);
3296 INF("xml file : %s", name->ud.fname);
3298 name->ud.fd = fdopen(fd, "w+");
3299 if ((!name->con_url) || (!name->ud.fd))
3301 ecore_con_url_free(name->con_url);
3307 name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name);
3308 name->method = method;
3309 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
3310 else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL;
3314 source = wd->src->name_url_cb(wd->obj, method, address, lon, lat);
3315 INF("name url = %s", source);
3317 wd->names = eina_list_append(wd->names, name);
3318 ecore_con_url_url_set(name->con_url, source);
3319 ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd));
3320 ecore_con_url_data_set(name->con_url, name);
3322 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3323 "elm,state,busy,start", "elm");
3324 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL);
3325 ecore_con_url_get(name->con_url);
3326 if (source) free(source);
3332 static Evas_Event_Flags
3333 _pinch_zoom_start_cb(void *data, void *event_info __UNUSED__)
3335 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EVAS_EVENT_FLAG_NONE);
3336 Widget_Data *wd = data;
3338 wd->pinch_zoom = wd->zoom_detail;
3339 return EVAS_EVENT_FLAG_NONE;
3342 static Evas_Event_Flags
3343 _pinch_zoom_cb(void *data, void *event_info)
3345 Widget_Data *wd = data;
3346 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
3350 Elm_Gesture_Zoom_Info *ei = event_info;
3351 zoom_do(wd, wd->pinch_zoom + ei->zoom - 1);
3353 return EVAS_EVENT_FLAG_NONE;
3356 static Evas_Event_Flags
3357 _pinch_rotate_cb(void *data, void *event_info)
3359 Widget_Data *wd = data;
3360 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
3365 Elm_Gesture_Rotate_Info *ei = event_info;
3366 evas_object_geometry_get(wd->obj, &x, &y, &w, &h);
3368 wd->rotate.d = wd->rotate.a + ei->angle - ei->base_angle;
3369 wd->rotate.cx = x + ((double)w * 0.5);
3370 wd->rotate.cy = y + ((double)h * 0.5);
3372 evas_object_smart_changed(wd->pan_smart);
3374 return EVAS_EVENT_FLAG_NONE;
3377 static Evas_Event_Flags
3378 _pinch_rotate_end_cb(void *data, void *event_info __UNUSED__)
3380 Widget_Data *wd = data;
3381 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
3383 wd->rotate.a = wd->rotate.d;
3385 return EVAS_EVENT_FLAG_NONE;
3389 _zoom_mode_set(void *data)
3391 EINA_SAFETY_ON_NULL_RETURN(data);
3392 Delayed_Data *dd = data;
3394 dd->wd->mode = dd->mode;
3395 if (dd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3405 zoom = dd->wd->zoom_detail;
3406 _viewport_size_get(dd->wd, &vw, &vh);
3408 if (dd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3410 if ((w < vw) && (h < vh))
3413 while ((w < vw) && (h < vh))
3416 w = pow(2.0, zoom) * dd->wd->tsize;
3417 h = pow(2.0, zoom) * dd->wd->tsize;
3423 while ((w > vw) || (h > vh))
3426 w = pow(2.0, zoom) * dd->wd->tsize;
3427 h = pow(2.0, zoom) * dd->wd->tsize;
3432 else if (dd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3434 if ((w < vw) || (h < vh))
3437 while ((w < vw) || (h < vh))
3440 w = pow(2.0, zoom) * dd->wd->tsize;
3441 h = pow(2.0, zoom) * dd->wd->tsize;
3447 while ((w > vw) && (h > vh))
3450 w = pow(2.0, zoom) * dd->wd->tsize;
3451 h = pow(2.0, zoom) * dd->wd->tsize;
3455 zoom_with_animation(dd->wd, zoom, 10);
3460 _zoom_set(void *data)
3462 EINA_SAFETY_ON_NULL_RETURN(data);
3463 Delayed_Data *dd = data;
3465 if (dd->wd->paused) zoom_do(dd->wd, dd->zoom);
3466 else zoom_with_animation(dd->wd, dd->zoom, 10);
3467 evas_object_smart_changed(dd->wd->pan_smart);
3471 _region_bring_in(void *data)
3473 EINA_SAFETY_ON_NULL_RETURN(data);
3474 Delayed_Data *dd = data;
3477 elm_map_utils_convert_geo_into_coord(dd->wd->obj, dd->lon, dd->lat,
3478 dd->wd->size.w, &x, &y);
3479 _viewport_size_get(dd->wd, &w, &h);
3482 elm_smart_scroller_region_bring_in(dd->wd->scr, x, y, w, h);
3483 evas_object_smart_changed(dd->wd->pan_smart);
3487 _marker_list_show(void *data)
3489 EINA_SAFETY_ON_NULL_RETURN(data);
3490 Delayed_Data *dd = data;
3492 double max_lon = -180, min_lon = 180;
3493 double max_lat = -90, min_lat = 90;
3495 Elm_Map_Marker *marker;
3497 EINA_LIST_FREE(dd->markers, marker)
3499 if (marker->longitude > max_lon) max_lon = marker->longitude;
3500 if (marker->longitude < min_lon) min_lon = marker->longitude;
3501 if (marker->latitude > max_lat) max_lat = marker->latitude;
3502 if (marker->latitude < min_lat) min_lat = marker->latitude;
3504 dd->lon = (max_lon + min_lon) / 2;
3505 dd->lat = (max_lat + min_lat) / 2;
3507 zoom = dd->wd->src->zoom_min;
3508 _viewport_size_get(dd->wd, &vw, &vh);
3509 while (zoom <= dd->wd->src->zoom_max)
3511 Evas_Coord size, max_x, max_y, min_x, min_y;
3512 size = pow(2.0, zoom) * dd->wd->tsize;
3513 elm_map_utils_convert_geo_into_coord(dd->wd->obj, min_lon, max_lat, size, &min_x, &max_y);
3514 elm_map_utils_convert_geo_into_coord(dd->wd->obj, max_lon, min_lat, size, &max_x, &min_y);
3515 if ((max_x - min_x) > vw || (max_y - min_y) > vh) break;
3520 zoom_do(dd->wd, zoom);
3522 evas_object_smart_changed(dd->wd->pan_smart);
3526 _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3529 // ((x+y+zoom)%3)+'a' is requesting map images from distributed tile servers (eg., a, b, c)
3530 snprintf(buf, sizeof(buf), "http://%c.tile.openstreetmap.org/%d/%d/%d.png",
3531 ((x + y + zoom) % 3) + 'a', zoom, x, y);
3536 _osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3539 snprintf(buf, sizeof(buf),
3540 "http://%c.tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
3541 ((x + y + zoom) % 3) + 'a', zoom, x, y);
3546 _cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3549 snprintf(buf, sizeof(buf),
3550 "http://%c.tile.opencyclemap.org/cycle/%d/%d/%d.png",
3551 (( x + y + zoom) % 3) + 'a', zoom, x, y);
3556 _mapquest_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3559 snprintf(buf, sizeof(buf),
3560 "http://otile%d.mqcdn.com/tiles/1.0.0/osm/%d/%d/%d.png",
3561 ((x + y + zoom) % 4) + 1, zoom, x, y);
3566 _mapquest_aerial_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3569 snprintf(buf, sizeof(buf), "http://oatile%d.mqcdn.com/naip/%d/%d/%d.png",
3570 ((x + y + zoom) % 4) + 1, zoom, x, y);
3574 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
3577 snprintf(buf, sizeof(buf),
3578 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
3579 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
3584 // TODO: fix monav api
3586 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
3589 snprintf(buf, sizeof(buf),
3590 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
3591 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
3597 // TODO: fix ors api
3599 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
3602 snprintf(buf, sizeof(buf),
3603 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
3604 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
3611 _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
3613 ELM_CHECK_WIDTYPE(obj, widtype) strdup("");
3614 Widget_Data *wd = elm_widget_data_get(obj);
3615 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, strdup(""));
3618 unsigned int ele, idx;
3619 char search_url[PATH_MAX];
3622 if (method == ELM_MAP_NAME_METHOD_SEARCH)
3624 search_url[0] = '\0';
3625 str = eina_str_split_full(name, " ", 0, &ele);
3626 for (idx = 0; idx < ele; idx++)
3628 eina_strlcat(search_url, str[idx], sizeof(search_url));
3629 if (!(idx == (ele-1)))
3630 eina_strlcat(search_url, "+", sizeof(search_url));
3632 snprintf(buf, sizeof(buf),
3633 "%s/search?q=%s&format=xml&polygon=0&addressdetails=0",
3634 NAME_NOMINATIM_URL, search_url);
3642 else if (method == ELM_MAP_NAME_METHOD_REVERSE)
3643 snprintf(buf, sizeof(buf),
3644 "%s/reverse?format=xml&lat=%lf&lon=%lf&zoom=%d&addressdetails=0",
3645 NAME_NOMINATIM_URL, lat, lon, (int)wd->zoom);
3646 else strcpy(buf, "");
3654 elm_map_add(Evas_Object *parent)
3656 #ifdef HAVE_ELEMENTARY_ECORE_CON
3660 Evas_Coord minw, minh;
3662 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3663 ELM_SET_WIDTYPE(widtype, "map");
3664 elm_widget_type_set(obj, "map");
3665 elm_widget_sub_object_add(parent, obj);
3666 elm_widget_data_set(obj, wd);
3667 elm_widget_can_focus_set(obj, EINA_TRUE);
3668 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3669 elm_widget_del_hook_set(obj, _del_hook);
3670 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3671 elm_widget_theme_hook_set(obj, _theme_hook);
3672 elm_widget_event_hook_set(obj, _event_hook);
3673 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, wd);
3674 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, wd);
3675 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, wd);
3676 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, wd);
3677 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
3679 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
3681 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
3682 _mouse_wheel_cb,wd);
3685 wd->scr = elm_smart_scroller_add(e);
3686 elm_widget_sub_object_add(obj, wd->scr);
3687 elm_smart_scroller_widget_set(wd->scr, obj);
3688 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
3689 elm_widget_resize_object_set(obj, wd->scr);
3690 elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE);
3691 elm_smart_scroller_bounce_allow_set(wd->scr,
3692 _elm_config->thumbscroll_bounce_enable,
3693 _elm_config->thumbscroll_bounce_enable);
3694 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3695 _changed_size_hints, wd);
3696 evas_object_smart_callback_add(wd->scr, "scroll", _scr, wd);
3697 evas_object_smart_callback_add(wd->scr, "drag", _scr, wd);
3698 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, wd);
3699 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, wd);
3703 evas_object_smart_clipped_smart_set(&parent_sc);
3705 sc.name = "elm_map_pan";
3706 sc.version = EVAS_SMART_CLASS_VERSION;
3708 sc.resize = _pan_resize;
3709 sc.move = _pan_move;
3710 sc.calculate = _pan_calculate;
3711 smart = evas_smart_class_new(&sc);
3716 wd->pan_smart = evas_object_smart_add(e, smart);
3717 pan = evas_object_smart_data_get(wd->pan_smart);
3720 elm_widget_sub_object_add(obj, wd->pan_smart);
3722 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3723 _pan_set, _pan_get, _pan_max_get,
3724 _pan_min_get, _pan_child_size_get);
3725 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3727 evas_object_size_hint_min_set(obj, minw, minh);
3729 wd->ges = elm_gesture_layer_add(obj);
3730 if (!wd->ges) ERR("elm_gesture_layer_add() failed");
3731 elm_gesture_layer_attach(wd->ges, obj);
3732 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_START,
3733 _pinch_zoom_start_cb, wd);
3734 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_MOVE,
3735 _pinch_zoom_cb, wd);
3736 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_MOVE,
3737 _pinch_rotate_cb, wd);
3738 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_END,
3739 _pinch_rotate_end_cb, wd);
3740 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_ABORT,
3741 _pinch_rotate_end_cb, wd);
3743 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
3744 elm_widget_sub_object_add(obj, wd->sep_maps_markers);
3745 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
3747 wd->map = evas_map_new(EVAS_MAP_POINT);
3750 wd->tsize = DEFAULT_TILE_SIZE; // FIXME: It should be hard-coded ? or can get from provider?
3752 wd->id = ((int)getpid() << 16) | idnum;
3754 _grid_all_create(wd);
3758 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
3759 wd->markers_max_num = MARER_MAX_NUMBER;
3761 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3762 // TODO: and save some bytes, making descriptions per-class and not instance!
3763 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3765 if (!ecore_file_download_protocol_available("http://"))
3766 ERR("Ecore must be built with curl support for the map widget!");
3776 elm_map_zoom_set(Evas_Object *obj, int zoom)
3778 #ifdef HAVE_ELEMENTARY_ECORE_CON
3779 ELM_CHECK_WIDTYPE(obj, widtype);
3780 Widget_Data *wd = elm_widget_data_get(obj);
3781 EINA_SAFETY_ON_NULL_RETURN(wd);
3782 EINA_SAFETY_ON_NULL_RETURN(wd->src);
3784 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL) return;
3785 if (zoom < 0) zoom = 0;
3786 if (wd->zoom == zoom) return;
3787 if (zoom > wd->src->zoom_max) zoom = wd->src->zoom_max;
3788 if (zoom < wd->src->zoom_min) zoom = wd->src->zoom_min;
3790 Delayed_Data *data = ELM_NEW(Delayed_Data);
3791 data->func = _zoom_set;
3794 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
3795 evas_object_smart_changed(data->wd->pan_smart);
3803 elm_map_zoom_get(const Evas_Object *obj)
3805 #ifdef HAVE_ELEMENTARY_ECORE_CON
3806 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3807 Widget_Data *wd = elm_widget_data_get(obj);
3809 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, 0);
3818 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
3820 #ifdef HAVE_ELEMENTARY_ECORE_CON
3821 ELM_CHECK_WIDTYPE(obj, widtype);
3822 Widget_Data *wd = elm_widget_data_get(obj);
3823 EINA_SAFETY_ON_NULL_RETURN(wd);
3825 if ((mode == ELM_MAP_ZOOM_MODE_MANUAL) && (wd->mode == !!mode)) return;
3827 Delayed_Data *data = ELM_NEW(Delayed_Data);
3829 data->func = _zoom_mode_set;
3831 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
3832 evas_object_smart_changed(data->wd->pan_smart);
3839 EAPI Elm_Map_Zoom_Mode
3840 elm_map_zoom_mode_get(const Evas_Object *obj)
3842 #ifdef HAVE_ELEMENTARY_ECORE_CON
3843 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
3844 Widget_Data *wd = elm_widget_data_get(obj);
3845 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, ELM_MAP_ZOOM_MODE_MANUAL);
3850 return ELM_MAP_ZOOM_MODE_MANUAL;
3855 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
3857 #ifdef HAVE_ELEMENTARY_ECORE_CON
3858 ELM_CHECK_WIDTYPE(obj, widtype);
3859 Widget_Data *wd = elm_widget_data_get(obj);
3861 Delayed_Data *data = ELM_NEW(Delayed_Data);
3862 data->func = _region_bring_in;
3866 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
3867 evas_object_smart_changed(data->wd->pan_smart);
3876 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
3878 #ifdef HAVE_ELEMENTARY_ECORE_CON
3879 ELM_CHECK_WIDTYPE(obj, widtype);
3880 Widget_Data *wd = elm_widget_data_get(obj);
3882 Delayed_Data *data = ELM_NEW(Delayed_Data);
3883 data->func = _region_show;
3887 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
3888 evas_object_smart_changed(data->wd->pan_smart);
3897 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
3899 #ifdef HAVE_ELEMENTARY_ECORE_CON
3900 ELM_CHECK_WIDTYPE(obj, widtype);
3901 Widget_Data *wd = elm_widget_data_get(obj);
3902 EINA_SAFETY_ON_NULL_RETURN(wd);
3905 Evas_Coord px, py, vw, vh;
3907 _pan_geometry_get(wd, &px, &py);
3908 _viewport_size_get(wd, &vw, &vh);
3909 elm_map_utils_convert_coord_into_geo(obj, vw/2 - px, vh/2 -py, wd->size.w,
3911 if (lon) *lon = tlon;
3912 if (lat) *lat = tlat;
3921 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
3923 #ifdef HAVE_ELEMENTARY_ECORE_CON
3924 ELM_CHECK_WIDTYPE(obj, widtype);
3925 Widget_Data *wd = elm_widget_data_get(obj);
3926 EINA_SAFETY_ON_NULL_RETURN(wd);
3928 if (wd->paused == !!paused) return;
3929 wd->paused = !!paused;
3932 if (wd->zoom_animator)
3934 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
3935 wd->zoom_animator = NULL;
3936 zoom_do(wd, wd->zoom);
3938 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3939 "elm,state,busy,stop", "elm");
3943 if (wd->download_num >= 1)
3944 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3945 "elm,state,busy,start", "elm");
3954 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
3956 #ifdef HAVE_ELEMENTARY_ECORE_CON
3957 ELM_CHECK_WIDTYPE(obj, widtype);
3958 Widget_Data *wd = elm_widget_data_get(obj);
3959 EINA_SAFETY_ON_NULL_RETURN(wd);
3961 if (wd->paused_markers == !!paused) return;
3962 wd->paused_markers = paused;
3970 elm_map_paused_get(const Evas_Object *obj)
3972 #ifdef HAVE_ELEMENTARY_ECORE_CON
3973 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3974 Widget_Data *wd = elm_widget_data_get(obj);
3975 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
3985 elm_map_paused_markers_get(const Evas_Object *obj)
3987 #ifdef HAVE_ELEMENTARY_ECORE_CON
3988 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3989 Widget_Data *wd = elm_widget_data_get(obj);
3990 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
3992 return wd->paused_markers;
4000 elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
4002 #ifdef HAVE_ELEMENTARY_ECORE_CON
4003 ELM_CHECK_WIDTYPE(obj, widtype);
4004 Widget_Data *wd = elm_widget_data_get(obj);
4005 EINA_SAFETY_ON_NULL_RETURN(wd);
4007 if (try_num) *try_num = wd->try_num;
4008 if (finish_num) *finish_num = wd->finish_num;
4017 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
4019 #ifdef HAVE_ELEMENTARY_ECORE_CON
4020 ELM_CHECK_WIDTYPE(obj, widtype);
4021 Widget_Data *wd = elm_widget_data_get(obj);
4022 EINA_SAFETY_ON_NULL_RETURN(wd);
4024 int zoom = floor(log(size / 256) / log(2));
4025 if ((wd->src) && (wd->src->coord_into_geo))
4027 if (wd->src->coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
4030 if (lon) *lon = (x / (double)size * 360.0) - 180;
4033 double n = ELM_PI - (2.0 * ELM_PI * y / size);
4034 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
4047 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
4049 #ifdef HAVE_ELEMENTARY_ECORE_CON
4050 ELM_CHECK_WIDTYPE(obj, widtype);
4051 Widget_Data *wd = elm_widget_data_get(obj);
4052 EINA_SAFETY_ON_NULL_RETURN(wd);
4054 int zoom = floor(log(size / 256) / log(2));
4055 if ((wd->src) && (wd->src->geo_into_coord))
4057 if (wd->src->geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
4060 if (x) *x = floor((lon + 180.0) / 360.0 * size);
4062 *y = floor((1.0 - log(tan(lat * ELM_PI / 180.0) + (1.0 / cos(lat * ELM_PI / 180.0)))
4063 / ELM_PI) / 2.0 * size);
4075 elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat)
4077 #ifdef HAVE_ELEMENTARY_ECORE_CON
4078 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4079 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat);
4089 elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address)
4091 #ifdef HAVE_ELEMENTARY_ECORE_CON
4092 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4093 if (!address) return NULL;
4094 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0);
4102 EINA_DEPRECATED EAPI void
4103 elm_map_utils_rotate_coord(const Evas_Object *obj, 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)
4105 #ifdef HAVE_ELEMENTARY_ECORE_CON
4106 ELM_CHECK_WIDTYPE(obj, widtype);
4107 _coord_rotate(x, y, cx, cy, degree, xx, yy);
4120 elm_map_canvas_to_geo_convert(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, double *lon, double *lat)
4122 #ifdef HAVE_ELEMENTARY_ECORE_CON
4123 ELM_CHECK_WIDTYPE(obj, widtype);
4124 Widget_Data *wd = elm_widget_data_get(obj);
4125 EINA_SAFETY_ON_NULL_RETURN(lon);
4126 EINA_SAFETY_ON_NULL_RETURN(lat);
4127 EINA_SAFETY_ON_NULL_RETURN(wd);
4129 Evas_Coord px, py, vw, vh;
4130 _pan_geometry_get(wd, &px, &py);
4131 _viewport_size_get(wd, &vw, &vh);
4132 _coord_rotate(x - px, y - py, (vw / 2) - px, (vh / 2) - py, -wd->rotate.d,
4134 elm_map_utils_convert_coord_into_geo(obj, x, y, wd->size.w, lon, lat);
4144 EAPI Elm_Map_Marker *
4145 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *group_clas, void *data)
4147 #ifdef HAVE_ELEMENTARY_ECORE_CON
4148 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4149 Widget_Data *wd = elm_widget_data_get(obj);
4151 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4152 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, NULL);
4154 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
4156 marker->clas = clas;
4157 marker->group_clas = group_clas;
4158 marker->longitude = lon;
4159 marker->latitude = lat;
4160 marker->data = data;
4163 _edj_marker_size_get(wd, &marker->w, &marker->h);
4165 marker->obj = elm_layout_add(wd->obj);
4166 evas_object_smart_member_add(marker->obj, wd->pan_smart);
4167 evas_object_stack_above(marker->obj, wd->sep_maps_markers);
4169 edje_object_signal_callback_add(elm_layout_edje_get(marker->obj),
4170 "open", "elm", _marker_bubble_open_cb,
4172 edje_object_signal_callback_add(elm_layout_edje_get(marker->obj),
4173 "bringin", "elm", _marker_bringin_cb,
4176 wd->markers = eina_list_append(wd->markers, marker);
4177 if (marker->group_clas) group_clas->markers = eina_list_append(group_clas->markers,
4179 evas_object_smart_changed(wd->pan_smart);
4193 elm_map_marker_remove(Elm_Map_Marker *marker)
4195 #ifdef HAVE_ELEMENTARY_ECORE_CON
4196 EINA_SAFETY_ON_NULL_RETURN(marker);
4197 Widget_Data *wd = marker->wd;
4198 EINA_SAFETY_ON_NULL_RETURN(wd);
4200 if ((marker->content) && (marker->clas->func.del))
4201 marker->clas->func.del(wd->obj, marker, marker->data, marker->content);
4203 if (marker->bubble) _bubble_free(marker->bubble);
4204 if (marker->group) _marker_group_free(marker->group);
4206 if (marker->group_clas)
4207 marker->group_clas->markers = eina_list_remove(marker->group_clas->markers, marker);
4208 wd->markers = eina_list_remove(wd->markers, marker);
4210 evas_object_del(marker->obj);
4213 evas_object_smart_changed(wd->pan_smart);
4220 elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat)
4222 #ifdef HAVE_ELEMENTARY_ECORE_CON
4223 EINA_SAFETY_ON_NULL_RETURN(marker);
4224 if (lon) *lon = marker->longitude;
4225 if (lat) *lat = marker->latitude;
4234 elm_map_marker_bring_in(Elm_Map_Marker *marker)
4236 #ifdef HAVE_ELEMENTARY_ECORE_CON
4237 EINA_SAFETY_ON_NULL_RETURN(marker);
4238 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
4245 elm_map_marker_show(Elm_Map_Marker *marker)
4247 #ifdef HAVE_ELEMENTARY_ECORE_CON
4248 EINA_SAFETY_ON_NULL_RETURN(marker);
4249 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
4256 elm_map_markers_list_show(Eina_List *markers)
4258 #ifdef HAVE_ELEMENTARY_ECORE_CON
4259 EINA_SAFETY_ON_NULL_RETURN(markers);
4260 EINA_SAFETY_ON_FALSE_RETURN(eina_list_count(markers));
4262 Elm_Map_Marker *marker;
4263 marker = eina_list_data_get(markers);
4265 Delayed_Data *data = ELM_NEW(Delayed_Data);
4266 data->func = _marker_list_show;
4267 data->wd = marker->wd;
4268 data->markers = eina_list_clone(markers);
4269 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
4270 evas_object_smart_changed(data->wd->pan_smart);
4277 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
4279 #ifdef HAVE_ELEMENTARY_ECORE_CON
4280 ELM_CHECK_WIDTYPE(obj, widtype);
4281 Widget_Data *wd = elm_widget_data_get(obj);
4282 EINA_SAFETY_ON_NULL_RETURN(wd);
4284 wd->markers_max_num = max;
4292 elm_map_marker_object_get(const Elm_Map_Marker *marker)
4294 #ifdef HAVE_ELEMENTARY_ECORE_CON
4295 EINA_SAFETY_ON_NULL_RETURN_VAL(marker, NULL);
4296 return marker->content;
4304 elm_map_marker_update(Elm_Map_Marker *marker)
4306 #ifdef HAVE_ELEMENTARY_ECORE_CON
4307 EINA_SAFETY_ON_NULL_RETURN(marker);
4308 Widget_Data *wd = marker->wd;
4309 EINA_SAFETY_ON_NULL_RETURN(wd);
4311 _marker_update(marker);
4318 elm_map_bubbles_close(Evas_Object *obj)
4320 #ifdef HAVE_ELEMENTARY_ECORE_CON
4321 ELM_CHECK_WIDTYPE(obj, widtype);
4322 Widget_Data *wd = elm_widget_data_get(obj);
4323 EINA_SAFETY_ON_NULL_RETURN(wd);
4326 Elm_Map_Marker *marker;
4327 EINA_LIST_FOREACH(wd->markers, l, marker)
4329 if (marker->bubble) _bubble_free(marker->bubble);
4330 marker->bubble = NULL;
4334 if (marker->group->bubble) _bubble_free(marker->group->bubble);
4335 marker->group->bubble = NULL;
4343 EAPI Elm_Map_Group_Class *
4344 elm_map_group_class_new(Evas_Object *obj)
4346 #ifdef HAVE_ELEMENTARY_ECORE_CON
4347 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4348 Widget_Data *wd = elm_widget_data_get(obj);
4349 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4351 Elm_Map_Group_Class *clas = ELM_NEW(Elm_Map_Group_Class);
4353 clas->zoom_displayed = 0;
4354 clas->zoom_grouped = 255;
4355 eina_stringshare_replace(&clas->style, "radio");
4357 wd->group_classes = eina_list_append(wd->group_classes, clas);
4367 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
4369 #ifdef HAVE_ELEMENTARY_ECORE_CON
4370 EINA_SAFETY_ON_NULL_RETURN(clas);
4371 eina_stringshare_replace(&clas->style, style);
4379 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, Elm_Map_Group_Icon_Get_Func icon_get)
4381 #ifdef HAVE_ELEMENTARY_ECORE_CON
4382 EINA_SAFETY_ON_NULL_RETURN(clas);
4383 clas->func.icon_get = icon_get;
4391 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
4393 #ifdef HAVE_ELEMENTARY_ECORE_CON
4394 EINA_SAFETY_ON_NULL_RETURN(clas);
4403 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
4405 #ifdef HAVE_ELEMENTARY_ECORE_CON
4406 EINA_SAFETY_ON_NULL_RETURN(clas);
4407 clas->zoom_displayed = zoom;
4415 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
4417 #ifdef HAVE_ELEMENTARY_ECORE_CON
4418 EINA_SAFETY_ON_NULL_RETURN(clas);
4419 clas->zoom_grouped = zoom;
4427 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
4429 #ifdef HAVE_ELEMENTARY_ECORE_CON
4430 ELM_CHECK_WIDTYPE(obj, widtype);
4431 Widget_Data *wd = elm_widget_data_get(obj);
4432 EINA_SAFETY_ON_NULL_RETURN(wd);
4433 EINA_SAFETY_ON_NULL_RETURN(clas);
4436 evas_object_smart_changed(wd->pan_smart);
4444 EAPI Elm_Map_Marker_Class *
4445 elm_map_marker_class_new(Evas_Object *obj)
4447 #ifdef HAVE_ELEMENTARY_ECORE_CON
4448 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4449 Widget_Data *wd = elm_widget_data_get(obj);
4450 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4452 Elm_Map_Marker_Class *clas = ELM_NEW(Elm_Map_Marker_Class);
4453 eina_stringshare_replace(&clas->style, "radio");
4455 wd->marker_classes = eina_list_append(wd->marker_classes, clas);
4464 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
4466 #ifdef HAVE_ELEMENTARY_ECORE_CON
4467 EINA_SAFETY_ON_NULL_RETURN(clas);
4468 eina_stringshare_replace(&clas->style, style);
4476 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, Elm_Map_Marker_Icon_Get_Func icon_get)
4478 #ifdef HAVE_ELEMENTARY_ECORE_CON
4479 EINA_SAFETY_ON_NULL_RETURN(clas);
4480 clas->func.icon_get = icon_get;
4488 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, Elm_Map_Marker_Get_Func get)
4490 #ifdef HAVE_ELEMENTARY_ECORE_CON
4491 EINA_SAFETY_ON_NULL_RETURN(clas);
4492 clas->func.get = get;
4500 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, Elm_Map_Marker_Del_Func del)
4502 #ifdef HAVE_ELEMENTARY_ECORE_CON
4503 EINA_SAFETY_ON_NULL_RETURN(clas);
4504 clas->func.del = del;
4512 elm_map_source_names_get(const Evas_Object *obj)
4514 #ifdef HAVE_ELEMENTARY_ECORE_CON
4515 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4516 Widget_Data *wd = elm_widget_data_get(obj);
4517 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4519 return wd->src_names;
4527 elm_map_source_name_set(Evas_Object *obj, const char *source_name)
4529 #ifdef HAVE_ELEMENTARY_ECORE_CON
4530 ELM_CHECK_WIDTYPE(obj, widtype);
4531 Widget_Data *wd = elm_widget_data_get(obj);
4532 EINA_SAFETY_ON_NULL_RETURN(wd);
4540 if (!strcmp(wd->src->name, source_name)) return;
4541 if (!wd->src->url_cb) return;
4544 _grid_all_clear(wd);
4545 EINA_LIST_FOREACH(wd->srcs, l, s)
4547 if (!strcmp(s->name, source_name))
4558 if (wd->src->zoom_max < zoom)
4559 zoom = wd->src->zoom_max;
4560 if (wd->src->zoom_min > zoom)
4561 zoom = wd->src->zoom_min;
4562 if (wd->src->zoom_max < wd->zoom_max) wd->zoom_max = wd->src->zoom_max;
4563 if (wd->src->zoom_min > wd->zoom_min) wd->zoom_min = wd->src->zoom_min;
4565 _grid_all_create(wd);
4574 elm_map_source_name_get(const Evas_Object *obj)
4576 #ifdef HAVE_ELEMENTARY_ECORE_CON
4577 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4578 Widget_Data *wd = elm_widget_data_get(obj);
4580 if ((!wd) || (!wd->src)) return NULL;
4581 return wd->src->name;
4589 elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
4591 #ifdef HAVE_ELEMENTARY_ECORE_CON
4592 ELM_CHECK_WIDTYPE(obj, widtype);
4593 Widget_Data *wd = elm_widget_data_get(obj);
4594 EINA_SAFETY_ON_NULL_RETURN(wd);
4596 wd->route_source = source;
4603 EAPI Elm_Map_Route_Sources
4604 elm_map_route_source_get(const Evas_Object *obj)
4606 #ifdef HAVE_ELEMENTARY_ECORE_CON
4607 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS;
4608 Widget_Data *wd = elm_widget_data_get(obj);
4609 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, ELM_MAP_ROUTE_SOURCE_YOURS);
4611 return wd->route_source;
4614 return ELM_MAP_ROUTE_SOURCE_YOURS;
4619 elm_map_source_zoom_max_set(Evas_Object *obj, int zoom)
4621 #ifdef HAVE_ELEMENTARY_ECORE_CON
4622 ELM_CHECK_WIDTYPE(obj, widtype);
4623 Widget_Data *wd = elm_widget_data_get(obj);
4624 EINA_SAFETY_ON_NULL_RETURN(wd);
4625 EINA_SAFETY_ON_NULL_RETURN(wd->src);
4627 if ((zoom > wd->src->zoom_max) || (zoom < wd->src->zoom_min)) return;
4628 wd->zoom_max = zoom;
4636 elm_map_source_zoom_max_get(const Evas_Object *obj)
4638 #ifdef HAVE_ELEMENTARY_ECORE_CON
4639 ELM_CHECK_WIDTYPE(obj, widtype) 18;
4640 Widget_Data *wd = elm_widget_data_get(obj);
4641 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1);
4642 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src, -1);
4644 return wd->zoom_max;
4652 elm_map_source_zoom_min_set(Evas_Object *obj, int zoom)
4654 #ifdef HAVE_ELEMENTARY_ECORE_CON
4655 ELM_CHECK_WIDTYPE(obj, widtype);
4656 Widget_Data *wd = elm_widget_data_get(obj);
4657 EINA_SAFETY_ON_NULL_RETURN(wd);
4658 EINA_SAFETY_ON_NULL_RETURN(wd->src);
4660 if ((zoom > wd->src->zoom_max) || (zoom < wd->src->zoom_min)) return;
4661 wd->zoom_min = zoom;
4669 elm_map_source_zoom_min_get(const Evas_Object *obj)
4671 #ifdef HAVE_ELEMENTARY_ECORE_CON
4672 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4673 Widget_Data *wd = elm_widget_data_get(obj);
4674 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1);
4675 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src, -1);
4677 return wd->zoom_min;
4685 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
4687 #ifdef HAVE_ELEMENTARY_ECORE_CON
4688 ELM_CHECK_WIDTYPE(obj, widtype);
4689 Widget_Data *wd = elm_widget_data_get(obj);
4690 EINA_SAFETY_ON_NULL_RETURN(wd);
4691 EINA_SAFETY_ON_NULL_RETURN(user_agent);
4693 eina_stringshare_replace(&wd->user_agent, user_agent);
4695 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4696 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4704 elm_map_user_agent_get(const Evas_Object *obj)
4706 #ifdef HAVE_ELEMENTARY_ECORE_CON
4707 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4708 Widget_Data *wd = elm_widget_data_get(obj);
4709 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4711 return wd->user_agent;
4718 EAPI Elm_Map_Route *
4719 elm_map_route_add(Evas_Object *obj, Elm_Map_Route_Type type, Elm_Map_Route_Method method, double flon, double flat, double tlon, double tlat)
4721 #ifdef HAVE_ELEMENTARY_ECORE_CON
4722 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4723 Widget_Data *wd = elm_widget_data_get(obj);
4726 char *type_name = NULL;
4729 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4730 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src, NULL);
4732 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4734 snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE);
4742 route->con_url = ecore_con_url_new(NULL);
4743 route->ud.fname = strdup(buf);
4744 INF("xml file : %s", route->ud.fname);
4746 route->ud.fd = fdopen(fd, "w+");
4747 if ((!route->con_url) || (!route->ud.fd))
4749 ecore_con_url_free(route->con_url);
4755 route->color.r = 255;
4758 route->color.a = 255;
4759 route->handlers = eina_list_append
4760 (route->handlers, (void *)ecore_event_handler_add
4761 (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route));
4763 route->inbound = EINA_FALSE;
4765 route->method = method;
4773 case ELM_MAP_ROUTE_TYPE_MOTOCAR:
4774 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4776 case ELM_MAP_ROUTE_TYPE_BICYCLE:
4777 type_name = strdup(ROUTE_TYPE_BICYCLE);
4779 case ELM_MAP_ROUTE_TYPE_FOOT:
4780 type_name = strdup(ROUTE_TYPE_FOOT);
4786 source = wd->src->route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4787 INF("route url = %s", source);
4789 wd->route = eina_list_append(wd->route, route);
4791 ecore_con_url_url_set(route->con_url, source);
4792 ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd));
4793 ecore_con_url_data_set(route->con_url, route);
4794 ecore_con_url_get(route->con_url);
4795 if (type_name) free(type_name);
4796 if (source) free(source);
4798 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4799 "elm,state,busy,start", "elm");
4800 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL);
4815 elm_map_route_remove(Elm_Map_Route *route)
4817 #ifdef HAVE_ELEMENTARY_ECORE_CON
4818 EINA_SAFETY_ON_NULL_RETURN(route);
4823 Ecore_Event_Handler *h;
4825 EINA_LIST_FREE(route->path, p)
4830 EINA_LIST_FREE(route->waypoint, w)
4832 if (w->point) eina_stringshare_del(w->point);
4836 EINA_LIST_FREE(route->nodes, n)
4838 if (n->pos.address) eina_stringshare_del(n->pos.address);
4842 EINA_LIST_FREE(route->handlers, h)
4844 ecore_event_handler_del(h);
4847 if (route->ud.fname)
4849 ecore_file_remove(route->ud.fname);
4850 free(route->ud.fname);
4851 route->ud.fname = NULL;
4859 elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a)
4861 #ifdef HAVE_ELEMENTARY_ECORE_CON
4862 EINA_SAFETY_ON_NULL_RETURN(route);
4877 elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a)
4879 #ifdef HAVE_ELEMENTARY_ECORE_CON
4880 EINA_SAFETY_ON_NULL_RETURN(route);
4881 if (r) *r = route->color.r;
4882 if (g) *g = route->color.g;
4883 if (b) *b = route->color.b;
4884 if (a) *a = route->color.a;
4895 elm_map_route_distance_get(const Elm_Map_Route *route)
4897 #ifdef HAVE_ELEMENTARY_ECORE_CON
4898 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
4899 return route->info.distance;
4907 elm_map_route_node_get(const Elm_Map_Route *route)
4909 #ifdef HAVE_ELEMENTARY_ECORE_CON
4910 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4911 return route->info.nodes;
4919 elm_map_route_waypoint_get(const Elm_Map_Route *route)
4921 #ifdef HAVE_ELEMENTARY_ECORE_CON
4922 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4923 return route->info.waypoints;
4931 elm_map_name_address_get(const Elm_Map_Name *name)
4933 #ifdef HAVE_ELEMENTARY_ECORE_CON
4934 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
4935 return name->address;
4943 elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
4945 #ifdef HAVE_ELEMENTARY_ECORE_CON
4946 EINA_SAFETY_ON_NULL_RETURN(name);
4947 if (lon) *lon = name->lon;
4948 if (lat) *lat = name->lat;
4957 elm_map_name_remove(Elm_Map_Name *name)
4959 #ifdef HAVE_ELEMENTARY_ECORE_CON
4960 EINA_SAFETY_ON_NULL_RETURN(name);
4963 free(name->address);
4964 name->address = NULL;
4968 ecore_event_handler_del(name->handler);
4969 name->handler = NULL;
4973 ecore_file_remove(name->ud.fname);
4974 free(name->ud.fname);
4975 name->ud.fname = NULL;
4983 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
4985 #ifdef HAVE_ELEMENTARY_ECORE_CON
4986 ELM_CHECK_WIDTYPE(obj, widtype);
4987 Widget_Data *wd = elm_widget_data_get(obj);
4988 EINA_SAFETY_ON_NULL_RETURN(wd);
4990 wd->rotate.d = degree;
4994 evas_object_smart_changed(wd->pan_smart);
5004 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
5006 #ifdef HAVE_ELEMENTARY_ECORE_CON
5007 ELM_CHECK_WIDTYPE(obj, widtype);
5008 Widget_Data *wd = elm_widget_data_get(obj);
5009 EINA_SAFETY_ON_NULL_RETURN(wd);
5011 if (degree) *degree = wd->rotate.d;
5012 if (cx) *cx = wd->rotate.cx;
5013 if (cy) *cy = wd->rotate.cy;
5023 elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
5025 #ifdef HAVE_ELEMENTARY_ECORE_CON
5026 ELM_CHECK_WIDTYPE(obj, widtype);
5027 Widget_Data *wd = elm_widget_data_get(obj);
5028 EINA_SAFETY_ON_NULL_RETURN(wd);
5030 if ((!wd->wheel_disabled) && (disabled))
5031 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
5032 else if ((wd->wheel_disabled) && (!disabled))
5033 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
5034 wd->wheel_disabled = !!disabled;
5042 elm_map_wheel_disabled_get(const Evas_Object *obj)
5044 #ifdef HAVE_ELEMENTARY_ECORE_CON
5045 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5046 Widget_Data *wd = elm_widget_data_get(obj);
5047 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
5049 return wd->wheel_disabled;
5058 elm_map_track_add(Evas_Object *obj, EMap_Route *emap)
5060 #ifdef HAVE_ELEMENTARY_ECORE_CON
5061 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5062 Widget_Data *wd = elm_widget_data_get(obj);
5063 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
5065 Evas_Object *route = elm_route_add(obj);
5066 elm_route_emap_set(route, emap);
5067 wd->track = eina_list_append(wd->track, route);
5079 elm_map_track_remove(Evas_Object *obj, Evas_Object *route)
5081 #ifdef HAVE_ELEMENTARY_ECORE_CON
5082 ELM_CHECK_WIDTYPE(obj, widtype) ;
5083 Widget_Data *wd = elm_widget_data_get(obj);
5084 EINA_SAFETY_ON_NULL_RETURN(wd);
5086 wd->track = eina_list_remove(wd->track, route);
5087 evas_object_del(route);
5094 EAPI Elm_Map_Overlay *
5095 elm_map_overlay_add(Evas_Object *obj, double lon, double lat)
5097 #ifdef HAVE_ELEMENTARY_ECORE_CON
5098 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5099 Widget_Data *wd = elm_widget_data_get(obj);
5100 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5102 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5104 overlay->type = ELM_MAP_OVERLAY_TYPE_DEFAULT;
5105 overlay->ovl = _overlay_default_new(wd, lon, lat, "radio");
5106 _overlay_default_cb_add(overlay->ovl, _overlay_clicked_cb, overlay);
5107 overlay->grp = _overlay_group_new(wd);
5108 wd->overlays = eina_list_append(wd->overlays, overlay);
5110 evas_object_smart_changed(wd->pan_smart);
5121 elm_map_overlay_del(Elm_Map_Overlay *overlay)
5123 #ifdef HAVE_ELEMENTARY_ECORE_CON
5124 EINA_SAFETY_ON_NULL_RETURN(overlay);
5125 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5126 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5128 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5130 _overlay_default_cb_del(overlay->ovl, _overlay_clicked_cb);
5131 _overlay_default_free(overlay->ovl);
5133 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
5135 _overlay_bubble_cb_del(overlay->ovl);
5136 _overlay_bubble_free(overlay->ovl);
5138 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5139 _overlay_class_free(overlay->ovl);
5143 _overlay_group_cb_del(overlay->grp);
5144 _overlay_group_free(overlay->grp, overlay);
5147 overlay->wd->overlays = eina_list_remove(overlay->wd->overlays, overlay);
5148 evas_object_smart_changed(overlay->wd->pan_smart);
5156 EAPI Elm_Map_Overlay_Type
5157 elm_map_overlay_type_get(Elm_Map_Overlay *overlay)
5159 #ifdef HAVE_ELEMENTARY_ECORE_CON
5160 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, ELM_MAP_OVERLAY_TYPE_NONE);
5161 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, ELM_MAP_OVERLAY_TYPE_NONE);
5162 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) ELM_MAP_OVERLAY_TYPE_NONE;
5164 return overlay->type;
5167 return OVERLAY_TYPE_NONE;
5172 elm_map_overlay_data_set(Elm_Map_Overlay *overlay, void *data)
5174 #ifdef HAVE_ELEMENTARY_ECORE_CON
5175 EINA_SAFETY_ON_NULL_RETURN(overlay);
5176 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5177 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5179 overlay->data = data;
5187 elm_map_overlay_data_get(const Elm_Map_Overlay *overlay)
5189 #ifdef HAVE_ELEMENTARY_ECORE_CON
5190 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
5191 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
5192 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
5194 return overlay->data;
5202 elm_map_overlay_hide_set(Elm_Map_Overlay *overlay, Eina_Bool hide)
5204 #ifdef HAVE_ELEMENTARY_ECORE_CON
5205 EINA_SAFETY_ON_NULL_RETURN(overlay);
5206 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5207 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5209 if (overlay->hide == !!hide) return;
5210 overlay->hide = hide;
5212 evas_object_smart_changed(overlay->wd->pan_smart);
5220 elm_map_overlay_hide_get(const Elm_Map_Overlay *overlay)
5222 #ifdef HAVE_ELEMENTARY_ECORE_CON
5223 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
5224 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE);
5225 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE;
5227 return overlay->hide;
5235 elm_map_overlay_displayed_zoom_min_set(Elm_Map_Overlay *overlay, int zoom)
5237 #ifdef HAVE_ELEMENTARY_ECORE_CON
5238 EINA_SAFETY_ON_NULL_RETURN(overlay);
5239 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5240 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5242 overlay->zoom_min = zoom;
5243 evas_object_smart_changed(overlay->wd->pan_smart);
5251 elm_map_overlay_displayed_zoom_min_get(const Elm_Map_Overlay *overlay)
5253 #ifdef HAVE_ELEMENTARY_ECORE_CON
5254 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, 0);
5255 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, 0);
5256 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) 0;
5258 return overlay->zoom_min;
5266 elm_map_overlay_paused_set(Elm_Map_Overlay *overlay, Eina_Bool paused)
5268 #ifdef HAVE_ELEMENTARY_ECORE_CON
5269 EINA_SAFETY_ON_NULL_RETURN(overlay);
5270 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5271 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5273 if (overlay->paused == !!paused) return;
5274 overlay->paused = paused;
5276 evas_object_smart_changed(overlay->wd->pan_smart);
5284 elm_map_overlay_paused_get(const Elm_Map_Overlay *overlay)
5286 #ifdef HAVE_ELEMENTARY_ECORE_CON
5287 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
5288 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE);
5289 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE;
5291 return overlay->paused;
5299 elm_map_overlay_show(Elm_Map_Overlay *overlay)
5301 #ifdef HAVE_ELEMENTARY_ECORE_CON
5302 EINA_SAFETY_ON_NULL_RETURN(overlay);
5303 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5304 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5306 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5308 Overlay_Default *ovl = overlay->ovl;
5309 elm_map_geo_region_show(overlay->wd->obj, ovl->lon, ovl->lat);
5311 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
5313 Overlay_Bubble *ovl = overlay->ovl;
5314 elm_map_geo_region_show(overlay->wd->obj, ovl->lon, ovl->lat);
5316 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5318 Overlay_Class *ovl = overlay->ovl;
5319 double lon, lat, max_lo, min_lo, max_la, min_la;
5320 _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la, &min_la);
5321 lon = (max_lo + min_lo) / 2;
5322 lat = (max_la + min_la) / 2;
5323 elm_map_geo_region_show(overlay->wd->obj, lon, lat);
5325 else ERR("Not supported overlay type: %d", overlay->type);
5327 evas_object_smart_changed(overlay->wd->pan_smart);
5334 elm_map_overlays_show(Eina_List *overlays)
5336 #ifdef HAVE_ELEMENTARY_ECORE_CON
5337 EINA_SAFETY_ON_NULL_RETURN(overlays);
5338 EINA_SAFETY_ON_FALSE_RETURN(eina_list_count(overlays));
5340 Elm_Map_Overlay *overlay;
5341 overlay = eina_list_data_get(overlays);
5343 Delayed_Data *data = ELM_NEW(Delayed_Data);
5344 data->func = _overlays_show;
5345 data->wd = overlay->wd;
5346 data->overlays = eina_list_clone(overlays);
5347 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
5348 evas_object_smart_changed(data->wd->pan_smart);
5355 elm_map_overlay_geo_set(Elm_Map_Overlay *overlay, double lon, double lat)
5357 #ifdef HAVE_ELEMENTARY_ECORE_CON
5358 EINA_SAFETY_ON_NULL_RETURN(overlay);
5359 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5360 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5362 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5364 Overlay_Default *ovl = overlay->ovl;
5368 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
5370 Overlay_Bubble *ovl = overlay->ovl;
5374 else ERR("Not supported overlay type: %d", overlay->type);
5376 evas_object_smart_changed(overlay->wd->pan_smart);
5385 elm_map_overlay_geo_get(const Elm_Map_Overlay *overlay, double *lon, double *lat)
5387 #ifdef HAVE_ELEMENTARY_ECORE_CON
5388 EINA_SAFETY_ON_NULL_RETURN(overlay);
5389 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5390 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5392 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5394 const Overlay_Default *ovl = overlay->ovl;
5395 if (lon) *lon = ovl->lon;
5396 if (lat) *lat = ovl->lat;
5398 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
5400 const Overlay_Bubble *ovl = overlay->ovl;
5401 if (lon) *lon = ovl->lon;
5402 if (lat) *lat = ovl->lat;
5404 else ERR("Not supported overlay type: %d", overlay->type);
5413 elm_map_overlay_icon_set(Elm_Map_Overlay *overlay, Evas_Object *icon)
5415 #ifdef HAVE_ELEMENTARY_ECORE_CON
5416 EINA_SAFETY_ON_NULL_RETURN(overlay);
5417 EINA_SAFETY_ON_NULL_RETURN(icon);
5418 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5419 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5421 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5422 _overlay_default_update(overlay->wd, overlay->ovl, NULL, icon,
5424 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5425 _overlay_class_update(overlay->wd, overlay->ovl, NULL, icon);
5426 else ERR("Not supported overlay type: %d", overlay->type);
5428 evas_object_smart_changed(overlay->wd->pan_smart);
5435 EAPI const Evas_Object *
5436 elm_map_overlay_icon_get(const Elm_Map_Overlay *overlay)
5438 #ifdef HAVE_ELEMENTARY_ECORE_CON
5439 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
5440 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
5441 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
5443 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5445 const Overlay_Default *ovl = overlay->ovl;
5446 return elm_object_part_content_get(ovl->layout, "elm.icon");
5448 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5450 const Overlay_Class *ovl = overlay->ovl;
5455 ERR("Not supported overlay type: %d", overlay->type);
5465 elm_map_overlay_content_set(Elm_Map_Overlay *overlay, Evas_Object *obj)
5467 #ifdef HAVE_ELEMENTARY_ECORE_CON
5468 EINA_SAFETY_ON_NULL_RETURN(overlay);
5469 EINA_SAFETY_ON_NULL_RETURN(obj);
5470 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5471 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5473 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5474 _overlay_default_update(overlay->wd, overlay->ovl, obj, NULL, NULL,
5476 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5477 _overlay_class_update(overlay->wd, overlay->ovl, obj, NULL);
5478 else ERR("Not supported overlay type: %d", overlay->type);
5480 evas_object_smart_changed(overlay->wd->pan_smart);
5487 EAPI const Evas_Object *
5488 elm_map_overlay_content_get(const Elm_Map_Overlay *overlay)
5490 #ifdef HAVE_ELEMENTARY_ECORE_CON
5491 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
5492 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
5493 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
5495 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5497 const Overlay_Default *ovl = overlay->ovl;
5498 return elm_object_part_content_get(ovl->layout, "elm.icon");
5500 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5502 const Overlay_Class *ovl = overlay->ovl;
5507 ERR("Not supported overlay type: %d", overlay->type);
5517 elm_map_overlay_get_cb_set(Elm_Map_Overlay *overlay, Elm_Map_Overlay_Get_Cb get_cb, void *data)
5519 #ifdef HAVE_ELEMENTARY_ECORE_CON
5520 EINA_SAFETY_ON_NULL_RETURN(overlay);
5521 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5522 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5524 overlay->cb = get_cb;
5525 overlay->cb_data = data;
5533 EAPI Elm_Map_Overlay *
5534 elm_map_overlay_class_add(Evas_Object *obj)
5536 #ifdef HAVE_ELEMENTARY_ECORE_CON
5537 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5538 Widget_Data *wd = elm_widget_data_get(obj);
5539 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5541 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5543 overlay->type = ELM_MAP_OVERLAY_TYPE_CLASS;
5544 overlay->ovl = _overlay_class_new(wd, overlay);
5545 overlay->grp = NULL;
5546 wd->overlays = eina_list_append(wd->overlays, overlay);
5548 evas_object_smart_changed(wd->pan_smart);
5557 elm_map_overlay_class_append(Elm_Map_Overlay *group, Elm_Map_Overlay *overlay)
5559 #ifdef HAVE_ELEMENTARY_ECORE_CON
5560 EINA_SAFETY_ON_NULL_RETURN(group);
5561 EINA_SAFETY_ON_NULL_RETURN(overlay);
5562 EINA_SAFETY_ON_NULL_RETURN(group->wd);
5563 ELM_CHECK_WIDTYPE(group->wd->obj, widtype);
5564 EINA_SAFETY_ON_FALSE_RETURN(group->type == ELM_MAP_OVERLAY_TYPE_CLASS);
5566 if (overlay->type != ELM_MAP_OVERLAY_TYPE_DEFAULT)
5568 ERR("Currently group supports only default overlays");
5572 Overlay_Class *ovl = group->ovl;
5573 if (eina_list_data_find(ovl->members, overlay))
5575 ERR("Already added overlay into group");
5578 ovl->members = eina_list_append(ovl->members, overlay);
5579 overlay->grp->clas = group;
5581 evas_object_smart_changed(group->wd->pan_smart);
5589 elm_map_overlay_class_remove(Elm_Map_Overlay *group, Elm_Map_Overlay *overlay)
5591 #ifdef HAVE_ELEMENTARY_ECORE_CON
5592 EINA_SAFETY_ON_NULL_RETURN(group);
5593 EINA_SAFETY_ON_NULL_RETURN(overlay);
5594 EINA_SAFETY_ON_NULL_RETURN(group->wd);
5595 ELM_CHECK_WIDTYPE(group->wd->obj, widtype);
5596 EINA_SAFETY_ON_FALSE_RETURN(group->type == ELM_MAP_OVERLAY_TYPE_CLASS);
5598 if (overlay->type != ELM_MAP_OVERLAY_TYPE_DEFAULT)
5600 ERR("Currently group supports only default overlays");
5603 Overlay_Class *ovl = group->ovl;
5604 ovl->members = eina_list_remove(ovl->members, overlay);
5605 overlay->grp->clas = NULL;
5606 _overlay_group_update(group->wd, overlay->grp, NULL);
5608 evas_object_smart_changed(group->wd->pan_smart);
5616 elm_map_overlay_class_zoom_max_set(Elm_Map_Overlay *group, int zoom)
5618 #ifdef HAVE_ELEMENTARY_ECORE_CON
5619 EINA_SAFETY_ON_NULL_RETURN(group);
5620 EINA_SAFETY_ON_NULL_RETURN(group->wd);
5621 ELM_CHECK_WIDTYPE(group->wd->obj, widtype);
5622 EINA_SAFETY_ON_FALSE_RETURN(group->type == ELM_MAP_OVERLAY_TYPE_CLASS);
5624 Overlay_Class *ovl = group->ovl;
5625 if (ovl->zoom_max == !!zoom) return;
5626 ovl->zoom_max = zoom;
5628 evas_object_smart_changed(group->wd->pan_smart);
5636 elm_map_overlay_class_zoom_max_get(const Elm_Map_Overlay *group)
5638 #ifdef HAVE_ELEMENTARY_ECORE_CON
5639 EINA_SAFETY_ON_NULL_RETURN_VAL(group, OVERLAY_CLASS_ZOOM_MAX);
5640 EINA_SAFETY_ON_NULL_RETURN_VAL(group->wd, OVERLAY_CLASS_ZOOM_MAX);
5641 ELM_CHECK_WIDTYPE(group->wd->obj, widtype) OVERLAY_CLASS_ZOOM_MAX;
5642 EINA_SAFETY_ON_FALSE_RETURN_VAL(group->type == ELM_MAP_OVERLAY_TYPE_CLASS, OVERLAY_CLASS_ZOOM_MAX);
5644 const Overlay_Class *ovl = group->ovl;
5645 return ovl->zoom_max;
5648 return OVERLAY_CLASS_ZOOM_MAX;
5652 EAPI Elm_Map_Overlay *
5653 elm_map_overlay_bubble_add(Evas_Object *obj)
5655 #ifdef HAVE_ELEMENTARY_ECORE_CON
5656 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5657 Widget_Data *wd = elm_widget_data_get(obj);
5658 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5660 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5662 overlay->type = ELM_MAP_OVERLAY_TYPE_BUBBLE;
5663 overlay->ovl = _overlay_bubble_new(wd);
5664 _overlay_bubble_cb_add(overlay->ovl, overlay);
5665 overlay->grp = _overlay_group_new(wd);
5666 wd->overlays = eina_list_append(wd->overlays, overlay);
5668 evas_object_smart_changed(wd->pan_smart);
5677 elm_map_overlay_bubble_follow(Elm_Map_Overlay *bubble, Elm_Map_Overlay *parent)
5679 #ifdef HAVE_ELEMENTARY_ECORE_CON
5680 EINA_SAFETY_ON_NULL_RETURN(bubble);
5681 EINA_SAFETY_ON_NULL_RETURN(parent);
5682 ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
5683 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
5685 Overlay_Bubble *ovl = bubble->ovl;
5686 Evas_Object *pobj = _overlay_obj_get(parent);
5691 evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_HIDE,
5692 _overlay_bubble_hide_cb, ovl);
5693 evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_SHOW,
5694 _overlay_bubble_chase_cb, ovl);
5695 evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_MOVE,
5696 _overlay_bubble_chase_cb, ovl);
5700 evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_HIDE,
5701 _overlay_bubble_hide_cb, ovl);
5702 evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_SHOW,
5703 _overlay_bubble_chase_cb, ovl);
5704 evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_MOVE,
5705 _overlay_bubble_chase_cb, ovl);
5707 _overlay_bubble_chase(ovl);
5708 evas_object_smart_changed(bubble->wd->pan_smart);
5716 elm_map_overlay_bubble_content_append(Elm_Map_Overlay *bubble, Evas_Object *content)
5718 #ifdef HAVE_ELEMENTARY_ECORE_CON
5719 EINA_SAFETY_ON_NULL_RETURN(bubble);
5720 EINA_SAFETY_ON_NULL_RETURN(content);
5721 ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
5722 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
5724 Overlay_Bubble *bb = bubble->ovl;
5725 elm_box_pack_end(bb->bx, content);
5727 evas_object_smart_changed(bubble->wd->pan_smart);
5735 elm_map_overlay_bubble_content_clear(Elm_Map_Overlay *bubble)
5737 #ifdef HAVE_ELEMENTARY_ECORE_CON
5738 EINA_SAFETY_ON_NULL_RETURN(bubble);
5739 ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
5740 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
5742 Overlay_Bubble *bb = bubble->ovl;
5743 elm_box_clear(bb->bx);
5745 evas_object_smart_changed(bubble->wd->pan_smart);