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 _Marker_Group Marker_Group;
16 typedef struct _Event Event;
17 typedef struct _Path_Node Path_Node;
18 typedef struct _Path_Waypoint Path_Waypoint;
19 typedef struct _Url_Data Url_Data;
20 typedef struct _Route_Dump Route_Dump;
21 typedef struct _Name_Dump Name_Dump;
22 typedef struct _Track_Dump Track_Dump;
24 #define CACHE_ROOT_PATH "/tmp/elm_map"
25 #define CACHE_PATH CACHE_ROOT_PATH"/%d/%d/%d/"
26 #define CACHE_FILE_PATH "%s%d.png"
27 #define DEST_ROUTE_XML_FILE "/tmp/elm_map-route-XXXXXX"
28 #define DEST_NAME_XML_FILE "/tmp/elm_map-name-XXXXXX"
30 #define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php"
31 #define ROUTE_TYPE_MOTORCAR "motocar"
32 #define ROUTE_TYPE_BICYCLE "bicycle"
33 #define ROUTE_TYPE_FOOT "foot"
34 #define YOURS_DISTANCE "distance"
35 #define YOURS_DESCRIPTION "description"
36 #define YOURS_COORDINATES "coordinates"
38 // TODO: fix monav & ors url
39 #define ROUTE_MONAV_URL "http://"
40 #define ROUTE_ORS_URL "http:///"
42 #define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org"
43 #define NOMINATIM_RESULT "result"
44 #define NOMINATIM_PLACE "place"
45 #define NOMINATIM_ATTR_LON "lon"
46 #define NOMINATIM_ATTR_LAT "lat"
48 #define PINCH_ZOOM_MIN 0.25
49 #define PINCH_ZOOM_MAX 4.0
50 #define MAX_CONCURRENT_DOWNLOAD 10
52 #define GPX_NAME "name>"
53 #define GPX_COORDINATES "trkpt "
56 #define GPX_ELE "ele>"
57 #define GPX_TIME "time>"
60 // Currently the size of a tile must be 256*256
61 // and the size of the map must be pow(2.0, z)*tile_size
62 typedef struct _Map_Sources_Tab
67 ElmMapModuleUrlFunc url_cb;
68 Elm_Map_Route_Sources route_source;
69 ElmMapModuleRouteUrlFunc route_url_cb;
70 ElmMapModuleNameUrlFunc name_url_cb;
71 ElmMapModuleGeoIntoCoordFunc geo_into_coord;
72 ElmMapModuleCoordIntoGeoFunc coord_into_geo;
75 //Zemm min is supposed to be 0
76 static char *_mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
77 static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
78 static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
79 static char *_maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
81 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
83 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
84 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
86 static char *_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat);
88 static Map_Sources_Tab default_map_sources_tab[] =
90 {"Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
91 {"Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
92 {"CycleMap", 0, 17, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
93 {"Maplint", 12, 16, _maplint_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
98 Ecore_Con_Url *con_url;
104 struct _Elm_Map_Marker_Class
109 struct _Elm_Map_Marker_Class_Func {
110 ElmMapMarkerGetFunc get;
111 ElmMapMarkerDelFunc del; //if NULL the object will be destroyed with evas_object_del()
112 ElmMapMarkerIconGetFunc icon_get;
115 struct { //this part is private, do not modify these values
117 Evas_Coord edje_w, edje_h;
121 struct _Elm_Map_Marker
124 Elm_Map_Marker_Class *clas;
125 Elm_Map_Group_Class *clas_group;
126 double longitude, latitude;
131 Marker_Group **groups;
132 Evas_Object *content;
135 struct _Elm_Map_Group_Class
139 int zoom_displayed; // display the group if the zoom is >= to zoom_display
140 int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
144 ElmMapGroupIconGetFunc icon_get;
147 struct { //this part is private, do not modify these values
149 Evas_Coord edje_w, edje_h;
150 Evas_Coord edje_max_w, edje_max_h;
152 Eina_List *objs_used;
153 Eina_List *objs_notused;
160 Eina_Matrixsparse_Cell *cell;
161 Elm_Map_Group_Class *clas;
164 long long sum_x, sum_y;
168 Evas_Object *obj, *bubble, *sc, *bx, *rect;
170 Eina_Bool bringin : 1;
171 Eina_Bool update_nbelems : 1;
172 Eina_Bool update_resize : 1;
173 Eina_Bool update_raise : 1;
174 Eina_Bool delete_object : 1;
177 struct _Elm_Map_Route
183 Ecore_Con_Url *con_url;
188 double flon, flat, tlon, tlat;
190 Eina_List *nodes, *path;
197 const char *waypoints;
198 double distance; /* unit : km */
211 Eina_Bool inbound : 1;
225 struct _Path_Waypoint
236 Ecore_Con_Url *con_url;
241 Ecore_Event_Handler *handler;
257 Ecore_File_Download_Job *job;
264 int tsize; // size of tile (tsize x tsize pixels)
265 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
266 int iw, ih; // size of image in pixels
267 int w, h; // size of grid image in pixels (represented by grid)
268 int gw, gh; // size of grid in tiles
269 Eina_Matrixsparse *grid;
276 Evas_Object *pan_smart;
278 Evas_Object *sep_maps_markers; //map objects are below this object and marker objects are on top
280 Evas_Coord pan_x, pan_y, minw, minh;
285 Elm_Map_Zoom_Mode mode;
288 Ecore_Timer *scr_timer;
289 Ecore_Timer *long_timer;
290 Ecore_Animator *zoom_animator;
301 Evas_Coord x, y ,w ,h;
306 Eina_Bool resized : 1;
307 Eina_Bool on_hold : 1;
308 Eina_Bool paused : 1;
309 Eina_Bool paused_markers : 1;
316 Ecore_Job *markers_place_job;
317 Eina_Matrixsparse **markers;
318 Eina_List *cells_displayed; // list of Eina_Matrixsparse_Cell
319 Evas_Coord markers_max_num;
320 int marker_max_w, marker_max_h;
322 Eina_List *opened_bubbles; //opened bubbles, list of Map_Group *
324 Eina_List *groups_clas; // list of Elm_Map_Group_Class*
325 Eina_List *markers_clas; // list of Elm_Map_Markers_Class*
327 Elm_Map_Route_Sources route_source;
328 Eina_List *s_event_list;
333 const char *user_agent;
336 Evas_Event_Mouse_Down ev;
357 Ecore_Timer *wheel_timer;
358 Eina_Bool wheel_disabled : 1;
361 Eina_List *map_sources_tab;
362 const char **source_names;
364 Ecore_Timer *zoom_timer;
365 Map_Sources_Tab *src;
366 const char *gpx_file;
367 int zoom_min, zoom_max;
368 Eina_List *download_list;
374 Evas_Object_Smart_Clipped_Data __clipped_data;
390 Evas_Coord x, y, w, h;
393 Ecore_Timer *hold_timer;
408 enum _Route_Xml_Attribute
412 ROUTE_XML_DESCRIPTION,
413 ROUTE_XML_COORDINATES,
415 } Route_Xml_Attibute;
425 enum _Name_Xml_Attribute
442 enum _Track_Xml_Attribute
445 TRACK_XML_COORDINATES,
447 } Track_Xml_Attibute;
450 static const char *widtype = NULL;
452 static const char SIG_CHANGED[] = "changed";
453 static const char SIG_CLICKED[] = "clicked";
454 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
455 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
456 static const char SIG_LOAD_DETAIL[] = "load,detail";
457 static const char SIG_LONGPRESSED[] = "longpressed";
458 static const char SIG_PRESS[] = "press";
459 static const char SIG_SCROLL[] = "scroll";
460 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
461 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
462 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
463 static const char SIG_ZOOM_START[] = "zoom,start";
464 static const char SIG_ZOOM_STOP[] = "zoom,stop";
465 static const char SIG_DOWNLOADED[] = "downloaded";
466 static const char SIG_ROUTE_LOAD[] = "route,load";
467 static const char SIG_ROUTE_LOADED[] = "route,loaded";
468 static const char SIG_NAME_LOAD[] = "name,load";
469 static const char SIG_NAME_LOADED[] = "name,loaded";
470 static const Evas_Smart_Cb_Description _signals[] = {
473 {SIG_CLICKED_DOUBLE, ""},
474 {SIG_LOADED_DETAIL, ""},
475 {SIG_LOAD_DETAIL, ""},
476 {SIG_LONGPRESSED, ""},
479 {SIG_SCROLL_DRAG_START, ""},
480 {SIG_SCROLL_DRAG_STOP, ""},
481 {SIG_ZOOM_CHANGE, ""},
482 {SIG_ZOOM_START, ""},
484 {SIG_DOWNLOADED, ""},
485 {SIG_ROUTE_LOAD, ""},
486 {SIG_ROUTE_LOADED, ""},
488 {SIG_NAME_LOADED, ""},
492 static void _pan_calculate(Evas_Object *obj);
494 static Eina_Bool _hold_timer_cb(void *data);
495 static Eina_Bool _wheel_timer_cb(void *data);
496 static void _rect_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
497 static void _del_hook(Evas_Object *obj);
498 static void _theme_hook(Evas_Object *obj);
499 static void _on_focus_hook(void *data, Evas_Object *obj);
500 static void _sizing_eval(Evas_Object *obj);
501 static void _calc_job(void *data);
502 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
503 Evas_Callback_Type type, void *event_info);
504 static void grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
505 static void grid_load(Evas_Object *obj, Grid *g);
507 static void _process_download_list(Evas_Object *obj);
508 static void _add_download_list(Evas_Object *obj, Grid_Item *gi);
510 static void _group_object_create(Marker_Group *group);
511 static void _group_object_free(Marker_Group *group);
512 static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
513 static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
514 static void _group_bubble_create(Marker_Group *group);
515 static void _group_bubble_free(Marker_Group *group);
516 static void _group_bubble_place(Marker_Group *group);
518 static int _group_bubble_content_update(Marker_Group *group);
519 static void _group_bubble_content_free(Marker_Group *group);
520 static void marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
521 static void _bubble_sc_hints_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
523 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
524 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
525 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
527 static void _mouse_multi_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
528 static void _mouse_multi_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
529 static void _mouse_multi_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
531 static void route_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
532 static void track_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
535 get_multi_device(Evas_Object *obj)
537 Widget_Data *wd = elm_widget_data_get(obj);
541 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
543 if (ev->device) return ev->device;
549 create_event_object(void *data, Evas_Object *obj, int device)
551 Widget_Data *wd = elm_widget_data_get(data);
552 Event *ev = calloc(1, sizeof(Event));
554 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, NULL);
558 evas_object_geometry_get(obj, &ev->x, &ev->y, &ev->w, &ev->h);
559 wd->s_event_list = eina_list_append(wd->s_event_list, ev);
564 get_event_object(void *data, int device)
566 Widget_Data *wd = elm_widget_data_get(data);
570 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
572 if (ev->device == device) break;
579 destroy_event_object(void *data, Event *ev)
581 Widget_Data *wd = elm_widget_data_get(data);
582 EINA_SAFETY_ON_NULL_RETURN(ev);
584 wd->s_event_list = eina_list_remove(wd->s_event_list, ev);
587 ecore_timer_del(ev->hold_timer);
588 ev->hold_timer = NULL;
594 module_list_cb(Eina_Module *m, void *data)
596 ELM_CHECK_WIDTYPE(data, widtype) EINA_FALSE;
597 Widget_Data *wd = elm_widget_data_get(data);
599 ElmMapModuleSourceFunc source;
600 ElmMapModuleZoomMinFunc zoom_min;
601 ElmMapModuleZoomMaxFunc zoom_max;
602 ElmMapModuleUrlFunc url;
603 ElmMapModuleRouteSourceFunc route_source;
604 ElmMapModuleRouteUrlFunc route_url;
605 ElmMapModuleNameUrlFunc name_url;
606 ElmMapModuleGeoIntoCoordFunc geo_into_coord;
607 ElmMapModuleCoordIntoGeoFunc coord_into_geo;
610 if (!wd) return EINA_FALSE;
612 file = eina_module_file_get(m);
613 if (!eina_module_load(m))
615 ERR("could not load module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
619 source = eina_module_symbol_get(m, "map_module_source_get");
620 zoom_min = eina_module_symbol_get(m, "map_module_zoom_min_get");
621 zoom_max = eina_module_symbol_get(m, "map_module_zoom_max_get");
622 url = eina_module_symbol_get(m, "map_module_url_get");
623 route_source = eina_module_symbol_get(m, "map_module_route_source_get");
624 route_url = eina_module_symbol_get(m, "map_module_route_url_get");
625 name_url = eina_module_symbol_get(m, "map_module_name_url_get");
626 geo_into_coord = eina_module_symbol_get(m, "map_module_geo_into_coord");
627 coord_into_geo = eina_module_symbol_get(m, "map_module_coord_into_geo");
628 if ((!source) || (!zoom_min) || (!zoom_max) || (!url) || (!route_source) || (!route_url) || (!name_url) || (!geo_into_coord) || (!coord_into_geo))
630 WRN("could not find map_module_source_get() in module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
631 eina_module_unload(m);
634 s = calloc(1, sizeof(Map_Sources_Tab));
635 EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE);
637 s->zoom_min = zoom_min();
638 s->zoom_max = zoom_max();
640 s->route_source = route_source();
641 s->route_url_cb = route_url;
642 s->name_url_cb = name_url;
643 s->geo_into_coord = geo_into_coord;
644 s->coord_into_geo = coord_into_geo;
645 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
651 module_init(void *data)
653 ELM_CHECK_WIDTYPE(data, widtype);
654 Widget_Data *wd = elm_widget_data_get(data);
657 wd->modules = eina_module_list_get(wd->modules, MODULES_PATH, 1, &module_list_cb, data);
661 source_init(void *data)
663 ELM_CHECK_WIDTYPE(data, widtype);
664 Widget_Data *wd = elm_widget_data_get(data);
670 for (idx = 0; idx < 4; idx++)
672 s = calloc(1, sizeof(Map_Sources_Tab));
673 EINA_SAFETY_ON_NULL_RETURN(s);
674 s->name = default_map_sources_tab[idx].name;
675 s->zoom_min = default_map_sources_tab[idx].zoom_min;
676 s->zoom_max = default_map_sources_tab[idx].zoom_max;
677 s->url_cb = default_map_sources_tab[idx].url_cb;
678 s->route_source = default_map_sources_tab[idx].route_source;
679 s->route_url_cb = default_map_sources_tab[idx].route_url_cb;
680 s->name_url_cb = default_map_sources_tab[idx].name_url_cb;
681 s->geo_into_coord = default_map_sources_tab[idx].geo_into_coord;
682 s->coord_into_geo = default_map_sources_tab[idx].coord_into_geo;
683 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
684 if (!idx) wd->src = s;
688 int n = eina_list_count(wd->map_sources_tab);
689 wd->source_names = malloc(sizeof(char *) * (n + 1));
690 if (!wd->source_names)
692 ERR("init source names failed.");
696 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
698 wd->source_names[idx] = strdup(s->name);
699 INF("source : %s", wd->source_names[idx]);
700 if (s->zoom_min < wd->zoom_min) wd->zoom_min = s->zoom_min;
701 if (s->zoom_max > wd->zoom_max) wd->zoom_max = s->zoom_max;
704 wd->source_names[idx] = NULL;
708 obj_rotate_zoom(void *data, Evas_Object *obj)
710 ELM_CHECK_WIDTYPE(data, widtype);
711 Widget_Data *wd = elm_widget_data_get(data);
713 if ((!wd->pinch.cx) && (!wd->pinch.cy))
715 wd->pinch.cx = wd->rotate.cx;
716 wd->pinch.cy = wd->rotate.cy;
719 evas_map_util_points_populate_from_object_full(wd->map, obj, 0);
720 evas_object_image_size_get(obj, &iw, &ih);
721 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
722 if ((ow < iw) || (oh < ih))
724 ow *= (double)iw / ow;
725 oh *= (double)ih / oh;
726 evas_map_point_image_uv_set(wd->map, 1, ow, 0);
727 evas_map_point_image_uv_set(wd->map, 2, ow, oh);
728 evas_map_point_image_uv_set(wd->map, 3, 0, oh);
730 evas_map_util_zoom(wd->map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy);
731 evas_map_util_rotate(wd->map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
732 evas_object_map_enable_set(obj, EINA_TRUE);
733 evas_object_map_set(obj, wd->map);
738 track_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py, Evas_Coord ox __UNUSED__, Evas_Coord oy __UNUSED__, Evas_Coord ow, Evas_Coord oh)
740 track_place(Evas_Object *obj __UNUSED__, Grid *g __UNUSED__, Evas_Coord px __UNUSED__, Evas_Coord py __UNUSED__, Evas_Coord ox __UNUSED__, Evas_Coord oy __UNUSED__, Evas_Coord ow __UNUSED__, Evas_Coord oh __UNUSED__)
744 ELM_CHECK_WIDTYPE(obj, widtype);
745 Widget_Data *wd = elm_widget_data_get(obj);
748 int xmin, xmax, ymin, ymax;
751 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
753 EINA_LIST_FOREACH(wd->track, l, route)
755 elm_map_utils_convert_geo_into_coord(wd->obj, elm_route_lon_min_get(route), elm_route_lat_max_get(route), size, &xmin, &ymin);
756 elm_map_utils_convert_geo_into_coord(wd->obj, elm_route_lon_max_get(route), elm_route_lat_min_get(route), size, &xmax, &ymax);
758 if( !(xmin < px && xmax < px) && !(xmin > px+ow && xmax > px+ow))
760 if( !(ymin < py && ymax < py) && !(ymin > py+oh && ymax > py+oh))
763 evas_object_move(route, xmin - px + ox, ymin - py + oy);
764 evas_object_resize(route, xmax - xmin, ymax - ymin);
766 evas_object_raise(route);
767 obj_rotate_zoom(obj, route);
768 evas_object_show(route);
773 //the route is not display
774 evas_object_hide(route);
779 route_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py, Evas_Coord ox __UNUSED__, Evas_Coord oy __UNUSED__, Evas_Coord ow, Evas_Coord oh)
781 ELM_CHECK_WIDTYPE(obj, widtype);
782 Widget_Data *wd = elm_widget_data_get(obj);
783 Eina_List *lr, *lp, *ln;
792 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
794 EINA_LIST_FOREACH(wd->route, lr, r)
796 EINA_LIST_FOREACH(r->path, lp, p)
798 evas_object_polygon_points_clear(p);
801 evas_object_geometry_get(wd->rect, &rx, &ry, NULL, NULL);
802 nodes = eina_list_count(r->nodes);
804 EINA_LIST_FOREACH(r->nodes, ln, n)
806 if ((!wd->zoom) || ((n->idx) &&
807 ((n->idx % (int)ceil((double)nodes/(double)size*100.0))))) continue;
810 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
811 if ((x >= px - ow) && (x <= (px + ow*2)) &&
812 (y >= py - oh) && (y <= (py + oh*2)))
817 p = eina_list_nth(r->path, n->idx);
818 a = (double)(y - r->y) / (double)(x - r->x);
819 if ((abs(a) >= 1) || (r->x == x))
821 evas_object_polygon_point_add(p, r->x - 3, r->y);
822 evas_object_polygon_point_add(p, r->x + 3, r->y);
823 evas_object_polygon_point_add(p, x + 3, y);
824 evas_object_polygon_point_add(p, x - 3, y);
828 evas_object_polygon_point_add(p, r->x, r->y - 3);
829 evas_object_polygon_point_add(p, r->x, r->y + 3);
830 evas_object_polygon_point_add(p, x, y + 3);
831 evas_object_polygon_point_add(p, x, y - 3);
834 evas_object_color_set(p, r->color.r, r->color.g, r->color.b, r->color.a);
835 evas_object_raise(p);
836 obj_rotate_zoom(obj, p);
841 else r->inbound = EINA_FALSE;
845 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
846 if ((x >= px - ow) && (x <= (px + ow*2)) &&
847 (y >= py - oh) && (y <= (py + oh*2)))
851 r->inbound = EINA_TRUE;
853 else r->inbound = EINA_FALSE;
856 r->inbound = EINA_FALSE;
861 rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
863 ELM_CHECK_WIDTYPE(obj, widtype);
864 Widget_Data *wd = elm_widget_data_get(obj);
865 Evas_Coord ax, ay, gw, gh, hh, ww;
868 evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh);
875 if ((ww == gw) && (hh == gh)) return;
877 if (ow > gw) ax = (ow - gw) / 2;
878 if (oh > gh) ay = (oh - gh) / 2;
879 evas_object_move(wd->rect,
882 evas_object_resize(wd->rect, gw, gh);
886 wd->show.show = EINA_FALSE;
887 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
892 marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
894 ELM_CHECK_WIDTYPE(obj, widtype);
895 Widget_Data *wd = elm_widget_data_get(obj);
896 Evas_Coord ax, ay, gw, gh, tx, ty;
897 Eina_List *l, *markers;
898 Eina_Matrixsparse_Cell *cell;
903 int g_xx, g_yy, g_hh, g_ww;
911 if (ow > gw) ax = (ow - gw) / 2;
912 if (oh > gh) ay = (oh - gh) / 2;
914 if (wd->zoom != wd->marker_zoom)
916 EINA_LIST_FREE(wd->cells_displayed, cell)
918 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
920 if (group->obj) _group_object_free(group);
924 wd->marker_zoom = wd->zoom;
926 if ((wd->paused_markers)
927 && ((wd->size.nw != wd->size.w) || (wd->size.nh != wd->size.h)) )
930 g_xx = wd->pan_x / wd->tsize;
931 if (g_xx < 0) g_xx = 0;
932 g_yy = wd->pan_y / wd->tsize;
933 if (g_yy < 0) g_yy = 0;
934 g_ww = (ow / wd->tsize) + 1;
935 if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
936 g_hh = (oh / wd->tsize) + 1;
937 if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
939 //hide groups no more displayed
940 EINA_LIST_FREE(wd->cells_displayed, cell)
942 eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x);
943 if ((y < g_yy) || (y > g_yy + g_hh) || (x < g_xx) || (x > g_xx + g_ww))
945 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
947 if (group->obj) _group_object_free(group);
952 if (!wd->marker_zoom)
958 for (y = g_yy; y <= g_yy + g_hh; y++)
960 for (x = g_xx; x <= g_xx + g_ww; x++)
962 if (!wd->markers[wd->zoom]) continue;
963 eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell);
965 wd->cells_displayed = eina_list_append(wd->cells_displayed, cell);
966 markers = eina_matrixsparse_cell_data_get(cell);
967 EINA_LIST_FOREACH(markers, l, group)
969 if (!group->markers) continue;
970 if (group->clas->zoom_displayed > wd->zoom) continue;
977 if (eina_list_count(group->markers) == 1)
979 Elm_Map_Marker *m = eina_list_data_get(group->markers);
980 ww = m->clas->priv.edje_w;
981 hh = m->clas->priv.edje_h;
987 if ((gw != g->w) && (g->w > 0))
990 xx = ((long long )gw * xx) / g->w;
991 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
993 if ((gh != g->h) && (g->h > 0))
996 yy = ((long long)gh * yy) / g->h;
997 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1000 if ((!group->clas->hide)
1001 && (xx-px+ax+ox >= ox) && (xx-px+ax+ox<= ox+ow)
1002 && (yy-py+ay+oy >= oy) && (yy-py+ay+oy<= oy+oh))
1004 if (!group->obj) _group_object_create(group);
1006 if (group->update_nbelems)
1008 group->update_nbelems = EINA_FALSE;
1009 if (eina_list_count(group->markers) > 1)
1011 snprintf(buf, sizeof(buf), "%d", eina_list_count(group->markers));
1012 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
1015 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", "");
1017 evas_object_move(group->obj,
1018 xx - px + ax + ox - ww/2,
1019 yy - py + ay + oy - hh/2);
1020 if ((!wd->paused_markers) || (group->update_resize))
1022 group->update_resize = EINA_FALSE;
1023 evas_object_resize(group->obj, ww, hh);
1024 obj_rotate_zoom(obj, group->obj);
1026 if (group->update_raise)
1028 group->update_raise = EINA_FALSE;
1029 evas_object_raise(group->obj);
1030 obj_rotate_zoom(obj, group->obj);
1031 evas_object_show(group->obj);
1033 if (group->bubble) _group_bubble_place(group);
1035 else if (group->obj)
1037 _group_object_free(group);
1045 grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
1047 ELM_CHECK_WIDTYPE(obj, widtype);
1048 Widget_Data *wd = elm_widget_data_get(obj);
1049 Evas_Coord ax, ay, gw, gh, tx, ty;
1057 if (ow > gw) ax = (ow - gw) / 2;
1058 if (oh > gh) ay = (oh - gh) / 2;
1060 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1061 Eina_Matrixsparse_Cell *cell;
1063 EINA_ITERATOR_FOREACH(it, cell)
1065 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1071 if ((gw != g->w) && (g->w > 0))
1074 xx = ((long long )gw * xx) / g->w;
1075 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1077 if ((gh != g->h) && (g->h > 0))
1080 yy = ((long long)gh * yy) / g->h;
1081 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1083 evas_object_move(gi->img,
1087 evas_object_resize(gi->img, ww, hh);
1089 obj_rotate_zoom(obj, gi->img);
1090 /*evas_object_move(gi->txt,
1094 evas_object_resize(gi->txt, ww, hh);
1097 eina_iterator_free(it);
1101 _tile_update(Grid_Item *gi)
1103 evas_object_image_file_set(gi->img, gi->file, NULL);
1104 Evas_Load_Error err = evas_object_image_load_error_get(gi->img);
1105 if (err != EVAS_LOAD_ERROR_NONE)
1107 ERR("Image loading error (%s): %s", gi->file, evas_load_error_str(err));
1108 ecore_file_remove(gi->file);
1109 gi->have = EINA_FALSE;
1113 obj_rotate_zoom(gi->wd->obj, gi->img);
1114 evas_object_show(gi->img);
1115 gi->have = EINA_TRUE;
1116 //evas_object_text_text_set(gi->txt, gi->file);
1117 //evas_object_show(gi->txt);
1122 _tile_downloaded(void *data, const char *file __UNUSED__, int status)
1124 Grid_Item *gi = data;
1130 DBG("Download success from %s to %s", gi->source, gi->file);
1132 gi->wd->finish_num++;
1136 WRN("Download failed from %s to %s (%d) ", gi->source, gi->file, status);
1137 ecore_file_remove(gi->file);
1138 gi->have = EINA_FALSE;
1141 evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL);
1142 gi->wd->download_num--;
1143 if (!gi->wd->download_num)
1145 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr), "elm,state,busy,stop", "elm");
1146 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
1148 _process_download_list(gi->wd->obj);
1152 _process_download_list(Evas_Object *obj)
1154 ELM_CHECK_WIDTYPE(obj, widtype);
1155 Widget_Data *wd = elm_widget_data_get(obj);
1157 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
1160 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
1161 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
1166 EINA_LIST_REVERSE_FOREACH_SAFE(wd->download_list, l, ll, gi)
1173 if ((gw != gi->g->w) && (gi->g->w > 0))
1176 xx = ((long long )gw * xx) / gi->g->w;
1177 ww = (((long long)gw * (tx + ww)) / gi->g->w) - xx;
1179 if ((gh != gi->g->h) && (gi->g->h > 0))
1182 yy = ((long long)gh * yy) / gi->g->h;
1183 hh = (((long long)gh * (ty + hh)) / gi->g->h) - yy;
1185 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
1186 yy - wd->pan_y + oy,
1188 cvx, cvy, cvw, cvh))
1190 wd->download_list = eina_list_remove(wd->download_list, gi);
1193 if (gi->zoom != wd->zoom)
1195 wd->download_list = eina_list_remove(wd->download_list, gi);
1199 if (gi->wd->download_num >= MAX_CONCURRENT_DOWNLOAD) break;
1201 DBG("Download request from %s to %s", gi->source, gi->file);
1202 Eina_Bool ret = ecore_file_download_full(gi->source, gi->file, _tile_downloaded, NULL, gi, &(gi->job), wd->ua);
1203 if (!ret || !gi->job) WRN("Can't start to download from %s to %s", gi->source, gi->file);
1206 gi->wd->download_num++;
1208 wd->download_list = eina_list_remove(wd->download_list, gi);
1209 if (wd->download_num == 1)
1210 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,state,busy,start", "elm");
1216 _add_download_list(Evas_Object *obj, Grid_Item *gi)
1218 ELM_CHECK_WIDTYPE(obj, widtype);
1219 Widget_Data *wd = elm_widget_data_get(obj);
1221 wd->download_list = eina_list_remove(wd->download_list, gi);
1222 wd->download_list = eina_list_append(wd->download_list, gi);
1223 _process_download_list(obj);
1227 grid_create_all(Evas_Object *obj)
1229 ELM_CHECK_WIDTYPE(obj, widtype);
1230 Widget_Data *wd = elm_widget_data_get(obj);
1234 EINA_SAFETY_ON_NULL_RETURN(wd);
1235 EINA_SAFETY_ON_NULL_RETURN(wd->src);
1237 for (zoom = wd->src->zoom_min; zoom <= wd->src->zoom_max; zoom++)
1239 g = calloc(1, sizeof(Grid));
1241 g->tsize = wd->tsize;
1243 int size = pow(2.0, g->zoom);
1246 g->w = g->tsize * g->gw;
1247 g->h = g->tsize * g->gh;
1249 g->grid = eina_matrixsparse_new(g->gh, g->gw, NULL, NULL);
1250 wd->grids = eina_list_append(wd->grids, g);
1255 grid_clear_all(Evas_Object *obj)
1257 ELM_CHECK_WIDTYPE(obj, widtype);
1258 Widget_Data *wd = elm_widget_data_get(obj);
1262 EINA_SAFETY_ON_NULL_RETURN(wd);
1264 EINA_LIST_FREE(wd->grids, g)
1266 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1267 Eina_Matrixsparse_Cell *cell;
1269 EINA_ITERATOR_FOREACH(it, cell)
1271 gi = eina_matrixsparse_cell_data_get(cell);
1272 evas_object_del(gi->img);
1273 //evas_object_del(gi->txt);
1277 DBG("DOWNLOAD abort %s", gi->file);
1278 ecore_file_download_abort(gi->job);
1279 ecore_file_remove(gi->file);
1280 gi->have = EINA_FALSE;
1284 if (gi->file) eina_stringshare_del(gi->file);
1285 if (gi->source) eina_stringshare_del(gi->source);
1288 eina_matrixsparse_free(g->grid);
1289 eina_iterator_free(it);
1293 EINA_LIST_FREE(wd->download_list, gi);
1294 if (!ecore_file_recursive_rm(CACHE_ROOT_PATH)) WRN("Deletion of %s failed", CACHE_ROOT_PATH);
1299 grid_unload(Evas_Object *obj, Grid *g)
1301 ELM_CHECK_WIDTYPE(obj, widtype);
1302 Widget_Data *wd = elm_widget_data_get(obj);
1305 Eina_Matrixsparse_Cell *cell;
1308 EINA_SAFETY_ON_NULL_RETURN(wd);
1310 it = eina_matrixsparse_iterator_new(g->grid);
1311 EINA_ITERATOR_FOREACH(it, cell)
1313 gi = eina_matrixsparse_cell_data_get(cell);
1317 evas_object_hide(gi->img);
1318 //evas_object_hide(gi->txt);
1319 evas_object_image_file_set(gi->img, NULL, NULL);
1323 DBG("DOWNLOAD abort %s", gi->file);
1324 ecore_file_download_abort(gi->job);
1325 ecore_file_remove(gi->file);
1330 eina_iterator_free(it);
1335 grid_load(Evas_Object *obj, Grid *g)
1337 ELM_CHECK_WIDTYPE(obj, widtype);
1338 Widget_Data *wd = elm_widget_data_get(obj);
1341 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
1343 Eina_Matrixsparse_Cell *cell;
1346 EINA_SAFETY_ON_NULL_RETURN(wd);
1347 EINA_SAFETY_ON_NULL_RETURN(wd->src);
1349 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
1350 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
1355 if ((gw <= 0) || (gh <= 0)) return;
1358 if ((gw != g->w) && (g->w > 0))
1359 size = ((long long)gw * size) / g->w;
1360 if (size < (g->tsize / 2)) return; // else we will load to much tiles
1362 it = eina_matrixsparse_iterator_new(g->grid);
1364 EINA_ITERATOR_FOREACH(it, cell)
1366 gi = eina_matrixsparse_cell_data_get(cell);
1373 if ((gw != g->w) && (g->w > 0))
1376 xx = ((long long )gw * xx) / g->w;
1377 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1379 if ((gh != g->h) && (g->h > 0))
1382 yy = ((long long)gh * yy) / g->h;
1383 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1386 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
1387 yy - wd->pan_y + oy,
1389 cvx, cvy, cvw, cvh))
1393 evas_object_hide(gi->img);
1394 //evas_object_hide(gi->txt);
1395 evas_object_image_file_set(gi->img, NULL, NULL);
1399 DBG("Download abort: %s", gi->file);
1400 ecore_file_download_abort(gi->job);
1401 ecore_file_remove(gi->file);
1407 eina_iterator_free(it);
1409 xx = wd->pan_x / size - 1;
1412 yy = wd->pan_y / size - 1;
1416 if (xx + ww >= g->gw) ww = g->gw - xx - 1;
1419 if (yy + hh >= g->gh) hh = g->gh - yy - 1;
1421 for (y = yy; y <= yy + hh; y++)
1423 for (x = xx; x <= xx + ww; x++)
1425 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
1429 char buf[PATH_MAX], buf2[PATH_MAX];
1432 gi = calloc(1, sizeof(Grid_Item));
1438 gi->src.x = x * g->tsize;
1439 gi->src.y = y * g->tsize;
1440 gi->src.w = g->tsize;
1441 gi->src.h = g->tsize;
1443 gi->out.x = gi->src.x;
1444 gi->out.y = gi->src.y;
1445 gi->out.w = gi->src.w;
1446 gi->out.h = gi->src.h;
1448 gi->img = evas_object_image_add(evas_object_evas_get(obj));
1449 evas_object_image_scale_hint_set(gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1450 evas_object_image_filled_set(gi->img, 1);
1452 evas_object_smart_member_add(gi->img, wd->pan_smart);
1453 elm_widget_sub_object_add(obj, gi->img);
1454 evas_object_pass_events_set(gi->img, EINA_TRUE);
1455 evas_object_stack_below(gi->img, wd->sep_maps_markers);
1457 /* gi->txt = evas_object_text_add(evas_object_evas_get(obj));
1458 evas_object_text_font_set(gi->txt, "Vera", 12);
1459 evas_object_color_set(gi->txt, 100, 100, 100, 255);
1460 evas_object_smart_member_add(gi->txt,
1462 elm_widget_sub_object_add(obj, gi->txt);
1463 evas_object_pass_events_set(gi->txt, EINA_TRUE);
1465 snprintf(buf, sizeof(buf), CACHE_PATH, wd->id, g->zoom, x);
1466 snprintf(buf2, sizeof(buf2), CACHE_FILE_PATH, buf, y);
1467 if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
1468 eina_stringshare_replace(&gi->file, buf2);
1470 source = wd->src->url_cb(obj, x, y, g->zoom);
1471 if ((!source) || (strlen(source)==0))
1473 eina_stringshare_replace(&gi->source, NULL);
1474 WRN("Getting source url failed: %s", gi->file);
1476 else eina_stringshare_replace(&gi->source, source);
1477 if (source) free(source);
1479 gi->have = EINA_FALSE;
1482 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
1485 if (gi->have) _tile_update(gi);
1486 else if (!gi->job) _add_download_list(obj, gi);
1487 else DBG("Downloading is in progress: %s from %s", gi->file, gi->source);
1493 _smooth_update(Evas_Object *obj)
1495 ELM_CHECK_WIDTYPE(obj, widtype);
1496 Widget_Data *wd = elm_widget_data_get(obj);
1501 EINA_LIST_FOREACH(wd->grids, l, g)
1503 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1504 Eina_Matrixsparse_Cell *cell;
1506 EINA_ITERATOR_FOREACH(it, cell)
1508 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1509 evas_object_image_smooth_scale_set(gi->img, (!wd->nosmooth));
1511 eina_iterator_free(it);
1516 _scr_timeout(void *data)
1518 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1519 Widget_Data *wd = elm_widget_data_get(data);
1521 if (!wd) return ECORE_CALLBACK_CANCEL;
1523 if (!wd->nosmooth) _smooth_update(data);
1524 wd->scr_timer = NULL;
1525 return ECORE_CALLBACK_CANCEL;
1529 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1531 ELM_CHECK_WIDTYPE(data, widtype);
1532 Widget_Data *wd = elm_widget_data_get(data);
1538 if (wd->nosmooth == 1) _smooth_update(data);
1540 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1541 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
1545 zoom_do(Evas_Object *obj)
1547 ELM_CHECK_WIDTYPE(obj, widtype);
1548 Widget_Data *wd = elm_widget_data_get(obj);
1549 Evas_Coord xx, yy, ow, oh;
1552 wd->size.w = wd->size.nw;
1553 wd->size.h = wd->size.nh;
1555 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
1557 if (wd->center_on.enabled)
1559 elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy);
1565 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
1566 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
1571 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
1573 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
1575 wd->show.show = EINA_TRUE;
1581 if (wd->calc_job) ecore_job_del(wd->calc_job);
1582 wd->calc_job = ecore_job_add(_calc_job, wd);
1586 _zoom_timeout(void *data)
1588 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1589 Widget_Data *wd = elm_widget_data_get(data);
1591 if (!wd) return ECORE_CALLBACK_CANCEL;
1592 wd->zoom_timer = NULL;
1593 wd->pinch.level = 1.0;
1595 evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
1596 return ECORE_CALLBACK_CANCEL;
1600 _zoom_anim(void *data)
1602 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1603 Evas_Object *obj = data;
1604 Widget_Data *wd = elm_widget_data_get(obj);
1606 if (!wd) return ECORE_CALLBACK_CANCEL;
1607 if (wd->zoom_method == ZOOM_METHOD_IN) wd->t += 0.1 ;
1608 else if (wd->zoom_method == ZOOM_METHOD_OUT) wd->t -= 0.05;
1611 wd->zoom_animator = NULL;
1613 evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
1614 return ECORE_CALLBACK_CANCEL;
1619 wd->zoom_animator = NULL;
1620 wd->pinch.level = 2.0;
1621 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1622 wd->zoom_timer = ecore_timer_add(0.35, _zoom_timeout, obj);
1623 return ECORE_CALLBACK_CANCEL;
1625 else if (wd->t <= 0.5)
1627 wd->zoom_animator = NULL;
1628 wd->pinch.level = 0.5;
1629 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1630 wd->zoom_timer = ecore_timer_add(1.35, _zoom_timeout, obj);
1631 return ECORE_CALLBACK_CANCEL;
1633 else if (wd->t != 1.0)
1635 Evas_Coord x, y, w, h;
1636 float half_w, half_h;
1637 evas_object_geometry_get(data, &x, &y, &w, &h);
1638 half_w = (float)w * 0.5;
1639 half_h = (float)h * 0.5;
1640 wd->pinch.cx = x + half_w;
1641 wd->pinch.cy = y + half_h;
1642 wd->pinch.level = wd->t;
1643 if (wd->calc_job) ecore_job_del(wd->calc_job);
1644 wd->calc_job = ecore_job_add(_calc_job, wd);
1646 return ECORE_CALLBACK_RENEW;
1650 _long_press(void *data)
1652 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1653 Widget_Data *wd = elm_widget_data_get(data);
1655 if (!wd) return ECORE_CALLBACK_CANCEL;
1656 wd->long_timer = NULL;
1657 evas_object_smart_callback_call(data, SIG_LONGPRESSED, &wd->ev);
1658 return ECORE_CALLBACK_CANCEL;
1662 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1664 ELM_CHECK_WIDTYPE(data, widtype);
1665 Widget_Data *wd = elm_widget_data_get(data);
1666 Evas_Event_Mouse_Down *ev = event_info;
1670 ev0 = get_event_object(data, 0);
1672 ev0 = create_event_object(data, obj, 0);
1675 ev0->hold_timer = NULL;
1676 ev0->prev.x = ev->canvas.x;
1677 ev0->prev.y = ev->canvas.y;
1679 if (ev->button != 1) return;
1680 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1681 else wd->on_hold = EINA_FALSE;
1682 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1683 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, ev);
1685 evas_object_smart_callback_call(data, SIG_PRESS, ev);
1686 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1687 wd->ev.canvas.x = ev->output.x;
1688 wd->ev.canvas.y = ev->output.y;
1689 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1693 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1695 Evas_Event_Mouse_Move *move = event_info;
1698 ev0 = get_event_object(data, 0);
1700 ev0->prev.x = move->cur.canvas.x;
1701 ev0->prev.y = move->cur.canvas.y;
1705 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1707 ELM_CHECK_WIDTYPE(data, widtype);
1708 Widget_Data *wd = elm_widget_data_get(data);
1711 Evas_Event_Mouse_Up *ev = event_info;
1716 ev0 = get_event_object(data, 0);
1719 mdevice = get_multi_device(data);
1722 if (ev0->hold_timer)
1724 ecore_timer_del(ev0->hold_timer);
1725 ev0->hold_timer = NULL;
1727 elm_smart_scroller_hold_set(wd->scr, 0);
1728 elm_smart_scroller_freeze_set(wd->scr, 0);
1732 ev1 = get_event_object(data, mdevice);
1734 ev1->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev1);
1736 destroy_event_object(data, ev0);
1739 if (ev->button != 1) return;
1740 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1741 else wd->on_hold = EINA_FALSE;
1744 ecore_timer_del(wd->long_timer);
1745 wd->long_timer = NULL;
1747 if (!wd->on_hold) evas_object_smart_callback_call(data, SIG_CLICKED, ev);
1748 wd->on_hold = EINA_FALSE;
1752 _mouse_multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1754 ELM_CHECK_WIDTYPE(data, widtype);
1755 Widget_Data *wd = elm_widget_data_get(data);
1757 Evas_Event_Multi_Down *down = event_info;
1759 elm_smart_scroller_hold_set(wd->scr, 1);
1760 elm_smart_scroller_freeze_set(wd->scr, 1);
1762 ev = create_event_object(data, obj, down->device);
1765 DBG("Failed : create_event_object");
1770 ev->hold_timer = NULL;
1771 ev->start.x = ev->prev.x = down->canvas.x;
1772 ev->start.y = ev->prev.y = down->canvas.y;
1773 ev->pinch_start_dis = 0;
1774 wd->pinch.level = 1.0;
1775 wd->pinch.diff = 1.0;
1780 ecore_timer_del(wd->long_timer);
1781 wd->long_timer = NULL;
1787 _mouse_multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1789 ELM_CHECK_WIDTYPE(data, widtype);
1790 Widget_Data *wd = elm_widget_data_get(data);
1791 Evas_Event_Multi_Move *move = event_info;
1792 int dis_new, dx, dy;
1793 double t, tt, a, a_diff;
1797 if ((!wd) || (!wd->src)) return;
1798 ev = get_event_object(data, move->device);
1801 ev0 = get_event_object(data, 0);
1804 if (wd->multi_count >= 1)
1806 Evas_Coord x, y, w, h;
1807 float half_w, half_h;
1809 evas_object_geometry_get(data, &x, &y, &w, &h);
1810 half_w = (float)w * 0.5;
1811 half_h = (float)h * 0.5;
1812 dx = ev0->prev.x - ev->prev.x;
1813 dy = ev0->prev.y - ev->prev.y;
1814 dis_new = sqrt((dx * dx) + (dy * dy));
1816 if (!ev->pinch_start_dis) ev->pinch_start_dis = dis_new;
1819 ev->pinch_dis = dis_new;
1820 tt = wd->pinch.diff;
1821 wd->pinch.diff = (double)(ev->pinch_dis - ev->pinch_start_dis);
1822 t = (wd->pinch.diff * 0.01) + 1.0;
1823 if ((t > 1.1) || (wd->rotate.doing))
1825 if (((wd->zoom + (int)t - 1) < wd->src->zoom_min) ||
1826 ((wd->zoom + (int)t - 1) > wd->src->zoom_max) ||
1827 (t > PINCH_ZOOM_MAX) || (t < PINCH_ZOOM_MIN))
1829 wd->pinch.diff = tt;
1834 wd->pinch.level = (wd->pinch.diff * 0.01) + 1.0;
1835 wd->pinch.cx = x + half_w;
1836 wd->pinch.cy = y + half_h;
1837 wd->pinch.doing = EINA_TRUE;
1838 if (!wd->rotate.doing) goto do_zoom_only;
1843 if (wd->pinch.doing) goto do_nothing;
1846 a = (double)(ev->prev.y - ev0->prev.y) / (double)(ev->prev.x - ev0->prev.x);
1847 if (!wd->rotate.a) wd->rotate.a = a;
1850 a_diff = wd->rotate.a - a;
1851 if (a_diff > 0) wd->rotate.d -= 1.0;
1852 else if (a_diff < 0) wd->rotate.d += 1.0;
1854 wd->rotate.cx = x + half_w;
1855 wd->rotate.cy = y + half_h;
1856 wd->rotate.doing = EINA_TRUE;
1859 if (wd->calc_job) ecore_job_del(wd->calc_job);
1860 wd->calc_job = ecore_job_add(_calc_job, wd);
1864 ev->prev.x = move->cur.canvas.x;
1865 ev->prev.y = move->cur.canvas.y;
1869 _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1871 ELM_CHECK_WIDTYPE(data, widtype);
1872 Widget_Data *wd = elm_widget_data_get(data);
1873 Evas_Event_Multi_Up *up = event_info;
1880 if (wd->calc_job) ecore_job_del(wd->calc_job);
1881 if (wd->zoom_animator)
1883 ecore_animator_del(wd->zoom_animator);
1884 wd->zoom_animator = NULL;
1887 wd->paused = EINA_TRUE;
1888 if (wd->pinch.diff >= 0.0) zoom = (int)ceil((wd->pinch.diff * 0.01) - 1.0);
1889 else if (wd->pinch.diff < 0.0) zoom = (int)floor(-1.0 / ((wd->pinch.diff * 0.005) + 1.0));
1890 elm_map_zoom_set(data, wd->zoom + zoom);
1891 wd->pinch.level = 1.0;
1892 wd->pinch.doing = EINA_FALSE;
1895 wd->rotate.doing = EINA_FALSE;
1897 ev = get_event_object(data, up->device);
1900 DBG("Cannot get multi device");
1904 ev0 = get_event_object(data, 0);
1906 ev0->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev0);
1911 ecore_timer_del(ev->hold_timer);
1912 ev->hold_timer = NULL;
1915 destroy_event_object(data, ev);
1919 _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1921 ELM_CHECK_WIDTYPE(data, widtype);
1922 Widget_Data *wd = elm_widget_data_get(data);
1923 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
1924 Evas_Coord x, y, w, h;
1925 float half_w, half_h;
1928 evas_object_geometry_get(data, &x, &y, &w, &h);
1929 half_w = (float)w * 0.5;
1930 half_h = (float)h * 0.5;
1934 wd->zoom_method = ZOOM_METHOD_OUT;
1935 wd->wheel_zoom -= 0.1;
1936 if (wd->wheel_zoom <= -2.0) wd->wheel_zoom = -2.0;
1940 wd->zoom_method = ZOOM_METHOD_IN;
1941 wd->wheel_zoom += 0.1;
1942 if (wd->wheel_zoom >= 2.0) wd->wheel_zoom = 2.0;
1947 wd->pinch.level = pow(2.0, wd->wheel_zoom);
1948 wd->pinch.cx = x + half_w;
1949 wd->pinch.cy = y + half_h;
1950 if (wd->calc_job) ecore_job_del(wd->calc_job);
1951 wd->calc_job = ecore_job_add(_calc_job, wd);
1954 if (wd->wheel_timer) ecore_timer_del(wd->wheel_timer);
1955 wd->wheel_timer = ecore_timer_add(0.35, _wheel_timer_cb, data);
1959 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
1962 _hold_timer_cb(void *data)
1966 ev0->hold_timer = NULL;
1967 return ECORE_CALLBACK_CANCEL;
1971 _wheel_timer_cb(void *data)
1973 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1974 Widget_Data *wd = elm_widget_data_get(data);
1977 if (!wd) return ECORE_CALLBACK_CANCEL;
1978 if (wd->zoom_method == ZOOM_METHOD_IN) zoom = (int)ceil(wd->wheel_zoom);
1979 else if (wd->zoom_method == ZOOM_METHOD_OUT) zoom = (int)floor(wd->wheel_zoom);
1982 wd->wheel_timer = NULL;
1983 return ECORE_CALLBACK_CANCEL;
1986 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
1987 wd->pinch.level = 1.0;
1988 elm_map_zoom_set(data, wd->zoom + zoom);
1989 wd->wheel_zoom = 0.0;
1990 wd->wheel_timer = NULL;
1991 wd->zoom_method = ZOOM_METHOD_NONE;
1992 return ECORE_CALLBACK_CANCEL;
1996 _rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1998 ELM_CHECK_WIDTYPE(data, widtype);
1999 Widget_Data *wd = elm_widget_data_get(data);
2002 evas_object_geometry_get(wd->rect, &x, &y, &w, &h);
2003 evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h);
2004 evas_object_resize(wd->rect, w, h);
2005 evas_object_move(wd->rect, x, y);
2009 _del_hook(Evas_Object *obj)
2011 ELM_CHECK_WIDTYPE(obj, widtype);
2012 Widget_Data *wd = elm_widget_data_get(obj);
2013 Elm_Map_Group_Class *group_clas;
2014 Elm_Map_Marker_Class *marker_clas;
2020 Ecore_Event_Handler *h;
2026 EINA_LIST_FREE(wd->groups_clas, group_clas)
2028 if (group_clas->style)
2029 eina_stringshare_del(group_clas->style);
2033 EINA_LIST_FREE(wd->markers_clas, marker_clas)
2035 if (marker_clas->style)
2036 eina_stringshare_del(marker_clas->style);
2040 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
2042 destroy_event_object(obj, ev);
2045 EINA_LIST_FOREACH(wd->route, l, r)
2047 EINA_LIST_FREE(r->path, p)
2052 EINA_LIST_FREE(r->waypoint, w)
2054 if (w->point) eina_stringshare_del(w->point);
2058 EINA_LIST_FREE(r->nodes, n)
2060 if (n->pos.address) eina_stringshare_del(n->pos.address);
2064 EINA_LIST_FREE(r->handlers, h)
2066 ecore_event_handler_del(h);
2069 if (r->con_url) ecore_con_url_free(r->con_url);
2070 if (r->info.nodes) eina_stringshare_del(r->info.nodes);
2071 if (r->info.waypoints) eina_stringshare_del(r->info.waypoints);
2074 EINA_LIST_FREE(wd->names, na)
2076 if (na->address) free(na->address);
2077 if (na->handler) ecore_event_handler_del(na->handler);
2080 ecore_file_remove(na->ud.fname);
2082 na->ud.fname = NULL;
2086 EINA_LIST_FREE(wd->track, route)
2088 evas_object_del(route);
2091 if (wd->map) evas_map_free(wd->map);
2092 if (wd->source_names) free(wd->source_names);
2093 if (wd->calc_job) ecore_job_del(wd->calc_job);
2094 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
2095 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
2096 if (wd->long_timer) ecore_timer_del(wd->long_timer);
2097 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
2098 if (wd->ua) eina_hash_free(wd->ua);
2099 if (wd->markers) free(wd->markers);
2105 _del_pre_hook(Evas_Object *obj)
2107 ELM_CHECK_WIDTYPE(obj, widtype);
2108 Widget_Data *wd = elm_widget_data_get(obj);
2109 Marker_Group *group;
2110 Elm_Map_Marker *marker;
2112 Eina_Bool free_marker = EINA_TRUE;
2116 grid_clear_all(obj);
2117 for (i = 0; i <= wd->zoom_max; i++)
2119 if (!wd->markers[i]) continue;
2120 Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
2121 Eina_Matrixsparse_Cell *cell;
2123 EINA_ITERATOR_FOREACH(it, cell)
2125 l = eina_matrixsparse_cell_data_get(cell);
2126 EINA_LIST_FREE(l, group)
2128 EINA_LIST_FREE(group->markers, marker)
2130 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2131 _bubble_sc_hints_changed_cb, group);
2132 if (free_marker) free(marker);
2136 free_marker = EINA_FALSE;
2138 eina_iterator_free(it);
2139 eina_matrixsparse_free(wd->markers[i]);
2142 evas_object_del(wd->sep_maps_markers);
2143 evas_object_del(wd->pan_smart);
2144 wd->pan_smart = NULL;
2148 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
2150 ELM_CHECK_WIDTYPE(obj, widtype);
2151 Widget_Data *wd = elm_widget_data_get(obj);
2154 if (elm_widget_focus_get(obj))
2156 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
2157 evas_object_focus_set(wd->obj, EINA_TRUE);
2161 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
2162 evas_object_focus_set(wd->obj, EINA_FALSE);
2167 _theme_hook(Evas_Object *obj)
2169 ELM_CHECK_WIDTYPE(obj, widtype);
2170 Widget_Data *wd = elm_widget_data_get(obj);
2173 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
2174 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
2179 _sizing_eval(Evas_Object *obj)
2181 ELM_CHECK_WIDTYPE(obj, widtype);
2182 Widget_Data *wd = elm_widget_data_get(obj);
2183 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
2186 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
2187 evas_object_size_hint_min_set(obj, minw, minh);
2188 evas_object_size_hint_max_set(obj, maxw, maxh);
2192 _calc_job(void *data)
2194 Widget_Data *wd = data;
2195 Evas_Coord minw, minh;
2202 wd->resized = EINA_FALSE;
2203 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
2205 double tz = wd->zoom;
2207 elm_map_zoom_set(wd->obj, tz);
2210 if ((minw != wd->minw) || (minh != wd->minh))
2214 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
2215 _sizing_eval(wd->obj);
2217 wd->calc_job = NULL;
2218 evas_object_smart_changed(wd->pan_smart);
2222 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2224 Pan *sd = evas_object_smart_data_get(obj);
2226 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2229 evas_object_smart_changed(obj);
2233 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2235 Pan *sd = evas_object_smart_data_get(obj);
2237 if (x) *x = sd->wd->pan_x;
2238 if (y) *y = sd->wd->pan_y;
2242 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2244 Pan *sd = evas_object_smart_data_get(obj);
2247 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2248 ow = sd->wd->minw - ow;
2250 oh = sd->wd->minh - oh;
2257 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
2264 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2266 Pan *sd = evas_object_smart_data_get(obj);
2268 if (w) *w = sd->wd->minw;
2269 if (h) *h = sd->wd->minh;
2273 _pan_add(Evas_Object *obj)
2276 Evas_Object_Smart_Clipped_Data *cd;
2278 cd = evas_object_smart_data_get(obj);
2280 sd = calloc(1, sizeof(Pan));
2282 sd->__clipped_data = *cd;
2284 evas_object_smart_data_set(obj, sd);
2288 _pan_del(Evas_Object *obj)
2290 Pan *sd = evas_object_smart_data_get(obj);
2296 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2298 Pan *sd = evas_object_smart_data_get(obj);
2301 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2302 if ((ow == w) && (oh == h)) return;
2303 sd->wd->resized = EINA_TRUE;
2304 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2305 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2309 _pan_calculate(Evas_Object *obj)
2311 Pan *sd = evas_object_smart_data_get(obj);
2312 Evas_Coord ox, oy, ow, oh;
2316 EINA_SAFETY_ON_NULL_RETURN(sd);
2317 EINA_SAFETY_ON_NULL_RETURN(sd->wd);
2319 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2320 rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2321 EINA_LIST_FOREACH(sd->wd->grids, l, g)
2323 if (sd->wd->zoom == g->zoom) grid_load(sd->wd->obj, g);
2324 else if (sd->wd->zoom-1 != g->zoom && sd->wd->zoom+1 != g->zoom) grid_unload(sd->wd->obj, g);
2325 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2326 if (sd->wd->zoom == g->zoom) marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2327 if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2328 if (!sd->wd->zoom_animator) track_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2333 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2335 Pan *sd = evas_object_smart_data_get(obj);
2337 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2338 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2342 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2344 ELM_CHECK_WIDTYPE(obj, widtype);
2345 Widget_Data *wd = elm_widget_data_get(obj);
2348 elm_smart_scroller_hold_set(wd->scr, 1);
2352 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2354 ELM_CHECK_WIDTYPE(obj, widtype);
2355 Widget_Data *wd = elm_widget_data_get(obj);
2358 elm_smart_scroller_hold_set(wd->scr, 0);
2362 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2364 ELM_CHECK_WIDTYPE(obj, widtype);
2365 Widget_Data *wd = elm_widget_data_get(obj);
2368 elm_smart_scroller_freeze_set(wd->scr, 1);
2372 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2374 ELM_CHECK_WIDTYPE(obj, widtype);
2375 Widget_Data *wd = elm_widget_data_get(obj);
2378 elm_smart_scroller_freeze_set(wd->scr, 0);
2382 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2384 evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
2388 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2390 evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
2394 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2396 Widget_Data *wd = elm_widget_data_get(data);
2397 wd->center_on.enabled = EINA_FALSE;
2398 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2402 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2404 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2408 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2410 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
2415 _group_object_create(Marker_Group *group)
2417 const char *style = "radio";
2418 Evas_Object *icon = NULL;
2420 if (group->obj) return;
2421 if ((!group->clas->priv.objs_notused) || (eina_list_count(group->markers) == 1))
2423 //set icon and style
2424 if (eina_list_count(group->markers) == 1)
2426 Elm_Map_Marker *m = eina_list_data_get(group->markers);
2428 style = m->clas->style;
2430 if (m->clas->func.icon_get)
2431 icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
2433 group->delete_object = EINA_TRUE;
2437 if (group->clas->style)
2438 style = group->clas->style;
2440 if (group->clas->func.icon_get)
2441 icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
2443 group->delete_object = EINA_FALSE;
2446 group->obj = elm_layout_add(group->wd->obj);
2447 elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
2449 if (icon) elm_object_part_content_set(group->obj, "elm.icon", icon);
2451 evas_object_smart_member_add(group->obj, group->wd->pan_smart);
2452 elm_widget_sub_object_add(group->wd->obj, group->obj);
2453 evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
2455 if (!group->delete_object)
2456 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2460 group->delete_object = EINA_FALSE;
2462 group->obj = eina_list_data_get(group->clas->priv.objs_notused);
2463 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2464 group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
2465 evas_object_show(group->obj);
2468 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
2469 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
2471 group->update_nbelems = EINA_TRUE;
2472 group->update_resize = EINA_TRUE;
2473 group->update_raise = EINA_TRUE;
2475 if (group->open) _group_bubble_create(group);
2479 _group_object_free(Marker_Group *group)
2481 if (!group->obj) return;
2482 if (!group->delete_object)
2484 group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
2485 group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
2486 evas_object_hide(group->obj);
2488 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
2489 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
2492 evas_object_del(group->obj);
2495 _group_bubble_free(group);
2499 _group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2501 Marker_Group *group = data;
2503 if (!evas_object_above_get(group->rect)) return;
2504 evas_object_raise(group->bubble);
2505 evas_object_raise(group->sc);
2506 evas_object_raise(group->rect);
2510 _group_bubble_create(Marker_Group *group)
2512 if (group->bubble) return;
2514 group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
2515 group->bubble = edje_object_add(evas_object_evas_get(group->obj));
2516 _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
2517 elm_widget_style_get(group->wd->obj));
2518 evas_object_smart_member_add(group->bubble,
2520 elm_widget_sub_object_add(group->wd->obj, group->bubble);
2522 _group_bubble_content_free(group);
2523 if (!_group_bubble_content_update(group))
2525 //no content, we can delete the bubble
2526 _group_bubble_free(group);
2530 group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
2531 evas_object_color_set(group->rect, 0, 0, 0, 0);
2532 evas_object_repeat_events_set(group->rect, EINA_TRUE);
2533 evas_object_smart_member_add(group->rect, group->wd->obj);
2534 elm_widget_sub_object_add(group->wd->obj, group->rect);
2536 evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
2538 _group_bubble_place(group);
2541 static void _bubble_sc_hints_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2543 _group_bubble_place(data);
2547 _group_bubble_content_update(Marker_Group *group)
2550 Elm_Map_Marker *marker;
2553 if (!group->bubble) return 1;
2557 group->sc = elm_scroller_add(group->bubble);
2558 elm_widget_style_set(group->sc, "map_bubble");
2559 elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
2560 elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
2561 elm_scroller_bounce_set(group->sc, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
2562 edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
2563 evas_object_show(group->sc);
2564 evas_object_smart_member_add(group->sc,
2566 elm_widget_sub_object_add(group->wd->obj, group->sc);
2568 group->bx = elm_box_add(group->bubble);
2569 evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2570 evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
2571 elm_box_horizontal_set(group->bx, EINA_TRUE);
2572 evas_object_show(group->bx);
2574 elm_object_content_set(group->sc, group->bx);
2576 evas_object_event_callback_add(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2577 _bubble_sc_hints_changed_cb, group);
2580 EINA_LIST_FOREACH(group->markers, l, marker)
2582 if (i >= group->wd->markers_max_num) break;
2583 if ((!marker->content) && (marker->clas->func.get))
2584 marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
2585 else if (marker->content)
2586 elm_box_unpack(group->bx, marker->content);
2587 if (marker->content)
2589 elm_box_pack_end(group->bx, marker->content);
2597 _group_bubble_content_free(Marker_Group *group)
2600 Elm_Map_Marker *marker;
2602 if (!group->sc) return;
2603 EINA_LIST_FOREACH(group->markers, l, marker)
2605 if ((marker->content) && (marker->clas->func.del))
2606 marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
2607 else if (marker->content)
2608 evas_object_del(marker->content);
2609 marker->content = NULL;
2611 evas_object_del(group->sc);
2616 _group_bubble_free(Marker_Group *group)
2618 if (!group->bubble) return;
2619 group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
2620 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2621 _bubble_sc_hints_changed_cb, group);
2622 evas_object_del(group->bubble);
2623 evas_object_del(group->rect);
2624 group->bubble = NULL;
2625 _group_bubble_content_free(group);
2629 _group_bubble_place(Marker_Group *group)
2632 Evas_Coord xx, yy, ww, hh;
2635 if ((!group->bubble) || (!group->obj)) return;
2637 evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
2638 edje_object_size_min_calc(group->bubble, NULL, &hh);
2640 s = edje_object_data_get(group->bubble, "size_w");
2641 if (s) ww = atoi(s);
2643 xx = x + w / 2 - ww / 2;
2646 evas_object_move(group->bubble, xx, yy);
2647 evas_object_resize(group->bubble, ww, hh);
2648 obj_rotate_zoom(group->wd, group->bubble);
2649 evas_object_show(group->bubble);
2651 evas_object_move(group->rect, xx, yy);
2652 evas_object_resize(group->rect, ww, hh);
2653 obj_rotate_zoom(group->wd, group->rect);
2654 evas_object_show(group->rect);
2658 _group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2660 Marker_Group *group = data;
2661 Elm_Map_Marker *marker = eina_list_data_get(group->markers);
2662 if (!marker) return;
2663 group->bringin = EINA_TRUE;
2664 elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
2668 _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2670 Marker_Group *group = data;
2674 group->bringin = EINA_FALSE;
2680 group->open = EINA_FALSE;
2681 _group_bubble_free(group);
2684 group->open = EINA_TRUE;
2685 _group_bubble_create(group);
2689 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
2691 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2692 Widget_Data *wd = elm_widget_data_get(obj);
2696 Evas_Coord step_x = 0;
2697 Evas_Coord step_y = 0;
2700 Evas_Coord page_x = 0;
2701 Evas_Coord page_y = 0;
2703 if (!wd) return EINA_FALSE;
2704 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
2705 Evas_Event_Key_Down *ev = event_info;
2706 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
2708 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
2709 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
2710 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
2711 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
2713 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
2717 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
2721 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
2725 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
2729 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
2732 y -= -(page_y * v_h) / 100;
2736 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
2739 y += -(page_y * v_h) / 100;
2743 else if (!strcmp(ev->keyname, "KP_Add"))
2745 zoom = elm_map_zoom_get(obj) + 1;
2746 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2747 elm_map_zoom_set(obj, zoom);
2750 else if (!strcmp(ev->keyname, "KP_Subtract"))
2752 zoom = elm_map_zoom_get(obj) - 1;
2753 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2754 elm_map_zoom_set(obj, zoom);
2757 else return EINA_FALSE;
2759 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2760 elm_smart_scroller_child_pos_set(wd->scr, x, y);
2766 cb_dump_name_attrs(void *data, const char *key, const char *value)
2768 Name_Dump *dump = (Name_Dump*)data;
2769 if (!dump) return EINA_FALSE;
2771 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
2772 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
2779 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2781 Route_Dump *dump = data;
2782 if (!dump) return EINA_FALSE;
2786 case EINA_SIMPLE_XML_OPEN:
2787 case EINA_SIMPLE_XML_OPEN_EMPTY:
2791 attrs = eina_simple_xml_tag_attributes_find(value, length);
2794 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
2795 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
2796 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
2797 else dump->id = ROUTE_XML_NONE;
2801 case EINA_SIMPLE_XML_DATA:
2803 char *buf = malloc(length);
2804 if (!buf) return EINA_FALSE;
2805 snprintf(buf, length, "%s", value);
2806 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
2807 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2808 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2820 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2822 Name_Dump *dump = data;
2823 if (!dump) return EINA_FALSE;
2827 case EINA_SIMPLE_XML_OPEN:
2828 case EINA_SIMPLE_XML_OPEN_EMPTY:
2831 attrs = eina_simple_xml_tag_attributes_find(value, length);
2834 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME;
2835 else dump->id = NAME_XML_NONE;
2837 eina_simple_xml_attributes_parse
2838 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
2842 case EINA_SIMPLE_XML_DATA:
2844 char *buf = malloc(length + 1);
2845 if (!buf) return EINA_FALSE;
2846 snprintf(buf, length + 1, "%s", value);
2847 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2859 _parse_kml(void *data)
2861 Elm_Map_Route *r = (Elm_Map_Route*)data;
2862 if (!r || !r->ud.fname) return;
2866 unsigned int ele, idx;
2870 Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL};
2872 f = fopen(r->ud.fname, "rb");
2877 fseek(f, 0, SEEK_END);
2883 fseek(f, 0, SEEK_SET);
2887 if (fread(buf, 1, sz, f))
2889 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump);
2896 if (dump.distance) r->info.distance = dump.distance;
2897 if (dump.description)
2899 eina_stringshare_replace(&r->info.waypoints, dump.description);
2900 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2901 r->info.waypoint_count = ele;
2902 for (idx = 0 ; idx < ele ; idx++)
2904 Path_Waypoint *wp = ELM_NEW(Path_Waypoint);
2908 wp->point = eina_stringshare_add(str[idx]);
2909 DBG("%s", str[idx]);
2910 r->waypoint = eina_list_append(r->waypoint, wp);
2919 else WRN("description is not found !");
2921 if (dump.coordinates)
2923 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2924 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2925 r->info.node_count = ele;
2926 for (idx = 0 ; idx < ele ; idx++)
2928 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2929 Path_Node *n = ELM_NEW(Path_Node);
2936 DBG("%lf:%lf", lon, lat);
2937 n->pos.address = NULL;
2938 r->nodes = eina_list_append(r->nodes, n);
2940 path = evas_object_polygon_add(evas_object_evas_get(r->wd->obj));
2941 evas_object_smart_member_add(path, r->wd->pan_smart);
2942 r->path = eina_list_append(r->path, path);
2955 _parse_name(void *data)
2957 Elm_Map_Name *n = (Elm_Map_Name*)data;
2958 if (!n || !n->ud.fname) return;
2962 Name_Dump dump = {0, NULL, 0.0, 0.0};
2964 f = fopen(n->ud.fname, "rb");
2969 fseek(f, 0, SEEK_END);
2975 fseek(f, 0, SEEK_SET);
2979 if (fread(buf, 1, sz, f))
2981 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
2990 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
2991 n->address = strdup(dump.address);
2999 _route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
3001 Ecore_Con_Event_Url_Complete *ev = event;
3002 Elm_Map_Route *r = (Elm_Map_Route*)data;
3003 Widget_Data *wd = r->wd;
3005 if ((!r) || (!ev)) return EINA_TRUE;
3006 Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url);
3007 ecore_con_url_data_set(r->con_url, NULL);
3008 if (r!=rr) return EINA_TRUE;
3010 if (r->ud.fd) fclose(r->ud.fd);
3017 Evas_Coord ox, oy, ow, oh;
3018 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3019 EINA_LIST_FOREACH(wd->grids, l, g)
3021 if (wd->zoom == g->zoom) break;
3023 route_place(wd->obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3025 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3026 "elm,state,busy,stop", "elm");
3027 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
3032 _name_complete_cb(void *data, int ev_type __UNUSED__, void *event)
3034 Ecore_Con_Event_Url_Complete *ev = event;
3035 Elm_Map_Name *n = (Elm_Map_Name*)data;
3036 Widget_Data *wd = n->wd;
3038 if ((!n) || (!ev)) return EINA_TRUE;
3039 Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url);
3040 ecore_con_url_data_set(n->con_url, NULL);
3041 if (n!=nn) return EINA_TRUE;
3043 if (n->ud.fd) fclose(n->ud.fd);
3046 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3047 "elm,state,busy,stop", "elm");
3048 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
3052 static Elm_Map_Name *
3053 _utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat)
3055 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3056 Widget_Data *wd = elm_widget_data_get(obj);
3061 if ((!wd) || (!wd->src)) return NULL;
3062 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
3063 if (!name) return NULL;
3065 snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE);
3073 name->con_url = ecore_con_url_new(NULL);
3074 name->ud.fname = strdup(buf);
3075 INF("xml file : %s", name->ud.fname);
3077 name->ud.fd = fdopen(fd, "w+");
3078 if ((!name->con_url) || (!name->ud.fd))
3080 ecore_con_url_free(name->con_url);
3086 name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name);
3087 name->method = method;
3088 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
3089 else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL;
3093 source = wd->src->name_url_cb(wd->obj, method, address, lon, lat);
3094 INF("name url = %s", source);
3096 wd->names = eina_list_append(wd->names, name);
3097 ecore_con_url_url_set(name->con_url, source);
3098 ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd));
3099 ecore_con_url_data_set(name->con_url, name);
3101 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3102 "elm,state,busy,start", "elm");
3103 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL);
3104 ecore_con_url_get(name->con_url);
3105 if (source) free(source);
3111 static int idnum = 1;
3116 elm_map_add(Evas_Object *parent)
3118 #ifdef HAVE_ELEMENTARY_ECORE_CON
3121 Evas_Coord minw, minh;
3123 static Evas_Smart *smart = NULL;
3124 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
3126 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3128 ELM_SET_WIDTYPE(widtype, "map");
3129 elm_widget_type_set(obj, "map");
3130 elm_widget_sub_object_add(parent, obj);
3131 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3132 elm_widget_data_set(obj, wd);
3133 elm_widget_del_hook_set(obj, _del_hook);
3134 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3135 elm_widget_theme_hook_set(obj, _theme_hook);
3136 elm_widget_can_focus_set(obj, EINA_TRUE);
3137 elm_widget_event_hook_set(obj, _event_hook);
3139 wd->scr = elm_smart_scroller_add(e);
3140 elm_smart_scroller_widget_set(wd->scr, obj);
3141 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
3142 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
3143 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
3144 elm_widget_resize_object_set(obj, wd->scr);
3145 elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE);
3147 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3148 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3149 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3150 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3151 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
3153 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
3155 wd->zoom_min = 0xFF;
3156 wd->zoom_max = 0X00;
3160 wd->map = evas_map_new(4);
3161 if (!wd->map) return NULL;
3163 wd->markers_max_num = 30;
3164 wd->pinch.level = 1.0;
3165 wd->markers = calloc(wd->zoom_max + 1, sizeof(void*));
3167 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3168 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3169 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3170 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3174 static Evas_Smart_Class sc;
3176 evas_object_smart_clipped_smart_set(&_pan_sc);
3178 sc.name = "elm_map_pan";
3179 sc.version = EVAS_SMART_CLASS_VERSION;
3182 sc.resize = _pan_resize;
3183 sc.move = _pan_move;
3184 sc.calculate = _pan_calculate;
3185 smart = evas_smart_class_new(&sc);
3189 wd->pan_smart = evas_object_smart_add(e, smart);
3190 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3194 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3195 _pan_set, _pan_get, _pan_max_get,
3196 _pan_min_get, _pan_child_size_get);
3198 wd->rect = evas_object_rectangle_add(e);
3199 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_RESIZE,
3200 _rect_resize_cb, obj);
3201 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
3203 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_MOVE,
3205 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
3207 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_DOWN,
3208 _mouse_multi_down, obj);
3209 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_MOVE,
3210 _mouse_multi_move, obj);
3211 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP,
3212 _mouse_multi_up, obj);
3213 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL,
3214 _mouse_wheel_cb, obj);
3216 evas_object_smart_member_add(wd->rect, wd->pan_smart);
3217 elm_widget_sub_object_add(obj, wd->rect);
3218 evas_object_show(wd->rect);
3219 evas_object_color_set(wd->rect, 0, 0, 0, 0);
3221 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
3222 wd->id = ((int)getpid() << 16) | idnum;
3226 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3228 evas_object_size_hint_min_set(obj, minw, minh);
3230 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
3231 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
3233 grid_create_all(obj);
3235 wd->paused = EINA_TRUE;
3236 elm_map_zoom_set(obj, 0);
3237 wd->paused = EINA_FALSE;
3240 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3241 // TODO: and save some bytes, making descriptions per-class and not instance!
3242 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3244 if (!ecore_file_download_protocol_available("http://"))
3246 ERR("Ecore must be built with curl support for the map widget!");
3257 elm_map_zoom_set(Evas_Object *obj, int zoom)
3259 #ifdef HAVE_ELEMENTARY_ECORE_CON
3260 ELM_CHECK_WIDTYPE(obj, widtype);
3261 Widget_Data *wd = elm_widget_data_get(obj);
3263 Evas_Coord rx, ry, rw, rh;
3267 int z = 0, zoom_changed = 0, started = 0;
3269 if ((!wd) || (!wd->src) || (wd->zoom_animator)) return;
3270 if (zoom < 0 ) zoom = 0;
3271 if (zoom > wd->src->zoom_max) zoom = wd->src->zoom_max;
3272 if (zoom < wd->src->zoom_min) zoom = wd->src->zoom_min;
3274 if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT;
3275 else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN;
3276 else wd->zoom_method = ZOOM_METHOD_NONE;
3277 if (wd->zoom != zoom ) zoom_changed = 1;
3279 wd->size.ow = wd->size.w;
3280 wd->size.oh = wd->size.h;
3281 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
3282 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3284 EINA_LIST_FOREACH(wd->route, l, r)
3288 EINA_LIST_FOREACH(r->path, l, p)
3290 evas_object_polygon_points_clear(p);
3295 EINA_LIST_FOREACH(wd->track, l, route)
3297 evas_object_hide(route);
3300 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3307 while (cumulw <= rw)
3316 while (cumulh <= rh)
3323 if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3325 if (p2w < p2h) z = p2w;
3328 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3330 if (p2w > p2h) z = p2w;
3336 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3337 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3340 if ((wd->size.w > 0) && (wd->size.h > 0))
3342 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow;
3343 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.oh;
3347 wd->size.spos.x = 0.5;
3348 wd->size.spos.y = 0.5;
3351 if (rw > wd->size.ow) wd->size.spos.x = 0.5;
3352 if (rh > wd->size.oh) wd->size.spos.y = 0.5;
3353 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
3354 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
3359 if (wd->calc_job) ecore_job_del(wd->calc_job);
3360 wd->calc_job = ecore_job_add(_calc_job, wd);
3364 if (!wd->zoom_animator)
3366 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
3368 if (wd->nosmooth == 1) _smooth_update(obj);
3375 if (started) evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
3376 if (!wd->zoom_animator) evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3379 if (zoom_changed) evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
3387 elm_map_zoom_get(const Evas_Object *obj)
3389 #ifdef HAVE_ELEMENTARY_ECORE_CON
3390 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3391 Widget_Data *wd = elm_widget_data_get(obj);
3402 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
3404 #ifdef HAVE_ELEMENTARY_ECORE_CON
3405 ELM_CHECK_WIDTYPE(obj, widtype);
3406 Widget_Data *wd = elm_widget_data_get(obj);
3409 if (wd->mode == mode) return;
3412 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3416 elm_map_zoom_set(wd->obj, tz);
3424 EAPI Elm_Map_Zoom_Mode
3425 elm_map_zoom_mode_get(const Evas_Object *obj)
3427 #ifdef HAVE_ELEMENTARY_ECORE_CON
3428 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
3429 Widget_Data *wd = elm_widget_data_get(obj);
3431 if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
3435 return ELM_MAP_ZOOM_MODE_MANUAL;
3440 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
3442 #ifdef HAVE_ELEMENTARY_ECORE_CON
3443 ELM_CHECK_WIDTYPE(obj, widtype);
3444 Widget_Data *wd = elm_widget_data_get(obj);
3448 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3449 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3454 if (wd->zoom_animator)
3457 if (!wd->nosmooth) _smooth_update(obj);
3458 ecore_animator_del(wd->zoom_animator);
3459 wd->zoom_animator = NULL;
3461 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3463 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
3465 wd->center_on.enabled = EINA_TRUE;
3466 wd->center_on.lon = lon;
3467 wd->center_on.lat = lat;
3476 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
3478 #ifdef HAVE_ELEMENTARY_ECORE_CON
3479 ELM_CHECK_WIDTYPE(obj, widtype);
3480 Widget_Data *wd = elm_widget_data_get(obj);
3484 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3485 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3490 if (wd->zoom_animator)
3493 ecore_animator_del(wd->zoom_animator);
3494 wd->zoom_animator = NULL;
3496 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3498 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
3500 wd->center_on.enabled = EINA_TRUE;
3501 wd->center_on.lon = lon;
3502 wd->center_on.lat = lat;
3511 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
3513 #ifdef HAVE_ELEMENTARY_ECORE_CON
3514 ELM_CHECK_WIDTYPE(obj, widtype);
3515 Widget_Data *wd = elm_widget_data_get(obj);
3516 Evas_Coord sx, sy, sw, sh;
3519 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
3520 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
3524 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
3533 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
3535 #ifdef HAVE_ELEMENTARY_ECORE_CON
3536 ELM_CHECK_WIDTYPE(obj, widtype);
3537 Widget_Data *wd = elm_widget_data_get(obj);
3540 if (wd->paused == !!paused) return;
3541 wd->paused = paused;
3544 if (wd->zoom_animator)
3546 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
3547 wd->zoom_animator = NULL;
3549 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3559 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
3561 #ifdef HAVE_ELEMENTARY_ECORE_CON
3562 ELM_CHECK_WIDTYPE(obj, widtype);
3563 Widget_Data *wd = elm_widget_data_get(obj);
3566 if (wd->paused_markers == !!paused) return;
3567 wd->paused_markers = paused;
3575 elm_map_paused_get(const Evas_Object *obj)
3577 #ifdef HAVE_ELEMENTARY_ECORE_CON
3578 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3579 Widget_Data *wd = elm_widget_data_get(obj);
3581 if (!wd) return EINA_FALSE;
3590 elm_map_paused_markers_get(const Evas_Object *obj)
3592 #ifdef HAVE_ELEMENTARY_ECORE_CON
3593 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3594 Widget_Data *wd = elm_widget_data_get(obj);
3596 if (!wd) return EINA_FALSE;
3597 return wd->paused_markers;
3605 elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
3607 #ifdef HAVE_ELEMENTARY_ECORE_CON
3608 ELM_CHECK_WIDTYPE(obj, widtype);
3609 Widget_Data *wd = elm_widget_data_get(obj);
3614 *try_num = wd->try_num;
3619 *finish_num = wd->finish_num;
3629 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
3631 #ifdef HAVE_ELEMENTARY_ECORE_CON
3632 ELM_CHECK_WIDTYPE(obj, widtype);
3633 Widget_Data *wd = elm_widget_data_get(obj);
3636 int zoom = floor(log(size / 256) / log(2));
3637 if ((wd->src) && (wd->src->coord_into_geo))
3639 if (wd->src->coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
3644 *lon = x / (double)size * 360.0 - 180;
3648 double n = ELM_PI - 2.0 * ELM_PI * y / size;
3649 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
3662 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
3664 #ifdef HAVE_ELEMENTARY_ECORE_CON
3665 ELM_CHECK_WIDTYPE(obj, widtype);
3666 Widget_Data *wd = elm_widget_data_get(obj);
3669 int zoom = floor(log(size / 256) / log(2));
3670 if ((wd->src) && (wd->src->geo_into_coord))
3672 if (wd->src->geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
3676 *x = floor((lon + 180.0) / 360.0 * size);
3678 *y = floor((1.0 - log( tan(lat * ELM_PI / 180.0) + 1.0 / cos(lat * ELM_PI / 180.0)) / ELM_PI) / 2.0 * size);
3690 elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat)
3692 #ifdef HAVE_ELEMENTARY_ECORE_CON
3693 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3694 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat);
3704 elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address)
3706 #ifdef HAVE_ELEMENTARY_ECORE_CON
3707 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3708 if (!address) return NULL;
3709 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0);
3718 elm_map_utils_rotate_coord(const Evas_Object *obj __UNUSED__, const Evas_Coord x, const Evas_Coord y, const Evas_Coord cx, const Evas_Coord cy, const double degree, Evas_Coord *xx, Evas_Coord *yy)
3720 #ifdef HAVE_ELEMENTARY_ECORE_CON
3721 if ((!xx) || (!yy)) return;
3723 double r = (degree * M_PI) / 180.0;
3724 double tx, ty, ttx, tty;
3731 tx = ttx + (ty * cos(r + M_PI_2));
3732 ty = tty + (ty * sin(r + M_PI_2));
3747 EAPI Elm_Map_Marker *
3748 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
3750 #ifdef HAVE_ELEMENTARY_ECORE_CON
3751 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3752 Widget_Data *wd = elm_widget_data_get(obj);
3755 Marker_Group *group;
3763 if (!wd) return NULL;
3764 EINA_SAFETY_ON_NULL_RETURN_VAL(clas_group, NULL);
3765 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, NULL);
3767 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
3770 marker->clas = clas;
3771 marker->clas_group = clas_group;
3772 marker->longitude = lon;
3773 marker->latitude = lat;
3774 marker->data = data;
3775 marker->x = calloc(wd->zoom_max + 1, sizeof(Evas_Coord));
3776 marker->y = calloc(wd->zoom_max + 1, sizeof(Evas_Coord));
3777 marker->groups = calloc(wd->zoom_max + 1, sizeof(Marker_Group*));
3779 tabi[1] = tabi[4] = tabi[6] = -1;
3780 tabi[2] = tabi[0] = tabi[7] = 0;
3781 tabi[3] = tabi[5] = tabi[8] = 1;
3783 tabj[1] = tabj[2] = tabj[3] = -1;
3784 tabj[4] = tabj[0] = tabj[5] = 0;
3785 tabj[6] = tabj[7] = tabj[8] = 1;
3787 if (!clas_group->priv.set)
3790 if (marker->clas_group && marker->clas_group->style)
3791 style = marker->clas_group->style;
3793 o = edje_object_add(evas_object_evas_get(obj));
3794 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3795 s = edje_object_data_get(o, "size_w");
3796 if (s) clas_group->priv.edje_w = atoi(s);
3797 else clas_group->priv.edje_w = 0;
3798 s = edje_object_data_get(o, "size_h");
3799 if (s) clas_group->priv.edje_h = atoi(s);
3800 else clas_group->priv.edje_h = 0;
3801 s = edje_object_data_get(o, "size_max_w");
3802 if (s) clas_group->priv.edje_max_w = atoi(s);
3803 else clas_group->priv.edje_max_w = 0;
3804 s = edje_object_data_get(o, "size_max_h");
3805 if (s) clas_group->priv.edje_max_h = atoi(s);
3806 else clas_group->priv.edje_max_h = 0;
3809 clas_group->priv.set = EINA_TRUE;
3812 if (!clas->priv.set)
3815 if (marker->clas && marker->clas->style)
3816 style = marker->clas->style;
3818 o = edje_object_add(evas_object_evas_get(obj));
3819 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3820 s = edje_object_data_get(o, "size_w");
3821 if (s) clas->priv.edje_w = atoi(s);
3822 else clas->priv.edje_w = 0;
3823 s = edje_object_data_get(o, "size_h");
3824 if (s) clas->priv.edje_h = atoi(s);
3825 else clas->priv.edje_h = 0;
3828 clas->priv.set = EINA_TRUE;
3831 for (i = clas_group->zoom_displayed; i <= wd->zoom_max; i++)
3833 elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
3834 &(marker->x[i]), &(marker->y[i]));
3836 //search in the matrixsparse the region where the marker will be
3837 mpi = marker->x[i] / wd->tsize;
3838 mpj = marker->y[i] / wd->tsize;
3840 if (!wd->markers[i])
3842 int size = pow(2.0, i);
3843 wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
3847 if (i <= clas_group->zoom_grouped)
3849 for (j = 0, group = NULL; j < 9 && !group; j++)
3851 EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
3854 if (group->clas == marker->clas_group
3855 && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
3856 marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
3857 group->x-group->w/4, group->y-group->h/4, group->w, group->h))
3859 group->markers = eina_list_append(group->markers, marker);
3860 group->update_nbelems = EINA_TRUE;
3861 group->update_resize = EINA_TRUE;
3863 group->sum_x += marker->x[i];
3864 group->sum_y += marker->y[i];
3865 group->x = group->sum_x / eina_list_count(group->markers);
3866 group->y = group->sum_y / eina_list_count(group->markers);
3868 group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
3869 * eina_list_count(group->markers);
3870 group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
3871 * eina_list_count(group->markers);
3872 if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
3873 if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
3875 if (group->obj && eina_list_count(group->markers) == 2)
3877 _group_object_free(group);
3878 _group_object_create(group);
3881 _group_bubble_content_update(group);
3890 group = calloc(1, sizeof(Marker_Group));
3892 group->sum_x = marker->x[i];
3893 group->sum_y = marker->y[i];
3894 group->x = marker->x[i];
3895 group->y = marker->y[i];
3896 group->w = clas_group->priv.edje_w;
3897 group->h = clas_group->priv.edje_h;
3898 group->clas = clas_group;
3900 group->markers = eina_list_append(group->markers, marker);
3901 group->update_nbelems = EINA_TRUE;
3902 group->update_resize = EINA_TRUE;
3904 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3908 l = eina_list_append(NULL, group);
3909 eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
3910 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3914 l = eina_matrixsparse_cell_data_get(group->cell);
3915 l = eina_list_append(l, group);
3916 eina_matrixsparse_cell_data_set(group->cell, l);
3919 marker->groups[i] = group;
3926 Evas_Coord ox, oy, ow, oh;
3927 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3928 EINA_LIST_FOREACH(wd->grids, l, g)
3930 if (wd->zoom == g->zoom) break;
3932 marker_place(obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3948 elm_map_marker_remove(Elm_Map_Marker *marker)
3950 #ifdef HAVE_ELEMENTARY_ECORE_CON
3955 EINA_SAFETY_ON_NULL_RETURN(marker);
3958 for (i = marker->clas_group->zoom_displayed; i <= wd->zoom_max; i++)
3960 marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
3961 if (!eina_list_count(marker->groups[i]->markers))
3963 groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
3964 groups = eina_list_remove(groups, marker->groups[i]);
3965 eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
3967 _group_object_free(marker->groups[i]);
3968 _group_bubble_free(marker->groups[i]);
3969 free(marker->groups[i]);
3973 marker->groups[i]->sum_x -= marker->x[i];
3974 marker->groups[i]->sum_y -= marker->y[i];
3976 marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
3977 marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
3979 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
3980 + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
3981 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
3982 + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
3983 if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
3984 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
3985 if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
3986 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
3988 if ((marker->groups[i]->obj) && (eina_list_count(marker->groups[i]->markers) == 1))
3990 _group_object_free(marker->groups[i]);
3991 _group_object_create(marker->groups[i]);
3996 if ((marker->content) && (marker->clas->func.del))
3997 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
3998 else if (marker->content)
3999 evas_object_del(marker->content);
4001 if (marker->x) free(marker->x);
4002 if (marker->y) free(marker->y);
4003 if (marker->groups) free(marker->groups);
4011 Evas_Coord ox, oy, ow, oh;
4012 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
4013 EINA_LIST_FOREACH(wd->grids, l, g)
4015 if (wd->zoom == g->zoom) break;
4017 marker_place(wd->obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4025 elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat)
4027 #ifdef HAVE_ELEMENTARY_ECORE_CON
4028 EINA_SAFETY_ON_NULL_RETURN(marker);
4029 if (lon) *lon = marker->longitude;
4030 if (lat) *lat = marker->latitude;
4039 elm_map_marker_bring_in(Elm_Map_Marker *marker)
4041 #ifdef HAVE_ELEMENTARY_ECORE_CON
4042 EINA_SAFETY_ON_NULL_RETURN(marker);
4043 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
4050 elm_map_marker_show(Elm_Map_Marker *marker)
4052 #ifdef HAVE_ELEMENTARY_ECORE_CON
4053 EINA_SAFETY_ON_NULL_RETURN(marker);
4054 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
4061 elm_map_markers_list_show(Eina_List *markers)
4063 #ifdef HAVE_ELEMENTARY_ECORE_CON
4067 Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
4068 Evas_Coord rw, rh, xc, yc;
4071 EINA_SAFETY_ON_NULL_RETURN(markers);
4072 EINA_LIST_FOREACH(markers, l, marker)
4076 if ((!m_min_lon) || (marker->longitude < m_min_lon->longitude))
4079 if ((!m_max_lon) || (marker->longitude > m_max_lon->longitude))
4082 if ((!m_min_lat) || (marker->latitude > m_min_lat->latitude))
4085 if ((!m_max_lat) || (marker->latitude < m_max_lat->latitude))
4089 lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
4090 lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
4092 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
4093 for (zoom = wd->src->zoom_max; zoom > wd->src->zoom_min; zoom--)
4095 Evas_Coord size = pow(2.0, zoom)*wd->tsize;
4096 elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
4098 if ((m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2)
4099 && (m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2)
4100 && (m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2)
4101 && (m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2))
4105 elm_map_geo_region_show(wd->obj, lon, lat);
4106 elm_map_zoom_set(wd->obj, zoom);
4113 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
4115 #ifdef HAVE_ELEMENTARY_ECORE_CON
4116 ELM_CHECK_WIDTYPE(obj, widtype);
4117 Widget_Data *wd = elm_widget_data_get(obj);
4120 wd->markers_max_num = max;
4128 elm_map_marker_object_get(const Elm_Map_Marker *marker)
4130 #ifdef HAVE_ELEMENTARY_ECORE_CON
4131 EINA_SAFETY_ON_NULL_RETURN_VAL(marker, NULL);
4132 return marker->content;
4140 elm_map_marker_update(Elm_Map_Marker *marker)
4142 #ifdef HAVE_ELEMENTARY_ECORE_CON
4143 EINA_SAFETY_ON_NULL_RETURN(marker);
4144 if (marker->content)
4146 if (marker->clas->func.del)
4147 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4149 evas_object_del(marker->content);
4150 marker->content = NULL;
4151 _group_bubble_content_update(marker->groups[marker->wd->zoom]);
4159 elm_map_bubbles_close(Evas_Object *obj)
4161 #ifdef HAVE_ELEMENTARY_ECORE_CON
4162 ELM_CHECK_WIDTYPE(obj, widtype);
4163 Widget_Data *wd = elm_widget_data_get(obj);
4164 Marker_Group *group;
4165 Eina_List *l, *l_next;
4168 EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
4169 _group_bubble_free(group);
4175 EAPI Elm_Map_Group_Class *
4176 elm_map_group_class_new(Evas_Object *obj)
4178 #ifdef HAVE_ELEMENTARY_ECORE_CON
4179 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4180 Widget_Data *wd = elm_widget_data_get(obj);
4182 if (!wd) return NULL;
4183 Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
4184 clas->zoom_grouped = wd->zoom_max;
4185 wd->groups_clas = eina_list_append(wd->groups_clas, clas);
4194 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
4196 #ifdef HAVE_ELEMENTARY_ECORE_CON
4197 EINA_SAFETY_ON_NULL_RETURN(clas);
4198 eina_stringshare_replace(&clas->style, style);
4206 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
4208 #ifdef HAVE_ELEMENTARY_ECORE_CON
4209 EINA_SAFETY_ON_NULL_RETURN(clas);
4210 clas->func.icon_get = icon_get;
4218 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
4220 #ifdef HAVE_ELEMENTARY_ECORE_CON
4221 EINA_SAFETY_ON_NULL_RETURN(clas);
4230 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
4232 #ifdef HAVE_ELEMENTARY_ECORE_CON
4233 EINA_SAFETY_ON_NULL_RETURN(clas);
4234 clas->zoom_displayed = zoom;
4242 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
4244 #ifdef HAVE_ELEMENTARY_ECORE_CON
4245 EINA_SAFETY_ON_NULL_RETURN(clas);
4246 clas->zoom_grouped = zoom;
4254 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
4256 #ifdef HAVE_ELEMENTARY_ECORE_CON
4257 ELM_CHECK_WIDTYPE(obj, widtype);
4258 Widget_Data *wd = elm_widget_data_get(obj);
4261 EINA_SAFETY_ON_NULL_RETURN(clas);
4262 if (clas->hide == hide) return;
4268 Evas_Coord ox, oy, ow, oh;
4269 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
4270 EINA_LIST_FOREACH(wd->grids, l, g)
4272 if (wd->zoom == g->zoom) break;
4274 marker_place(obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4283 EAPI Elm_Map_Marker_Class *
4284 elm_map_marker_class_new(Evas_Object *obj)
4286 #ifdef HAVE_ELEMENTARY_ECORE_CON
4287 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4288 Widget_Data *wd = elm_widget_data_get(obj);
4290 if (!wd) return NULL;
4291 Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
4292 wd->markers_clas = eina_list_append(wd->markers_clas, clas);
4301 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
4303 #ifdef HAVE_ELEMENTARY_ECORE_CON
4304 EINA_SAFETY_ON_NULL_RETURN(clas);
4305 eina_stringshare_replace(&clas->style, style);
4313 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
4315 #ifdef HAVE_ELEMENTARY_ECORE_CON
4316 EINA_SAFETY_ON_NULL_RETURN(clas);
4317 clas->func.icon_get = icon_get;
4325 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
4327 #ifdef HAVE_ELEMENTARY_ECORE_CON
4328 EINA_SAFETY_ON_NULL_RETURN(clas);
4329 clas->func.get = get;
4337 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
4339 #ifdef HAVE_ELEMENTARY_ECORE_CON
4340 EINA_SAFETY_ON_NULL_RETURN(clas);
4341 clas->func.del = del;
4349 elm_map_source_names_get(const Evas_Object *obj)
4351 #ifdef HAVE_ELEMENTARY_ECORE_CON
4352 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4353 Widget_Data *wd = elm_widget_data_get(obj);
4355 if (!wd) return NULL;
4356 return wd->source_names;
4364 elm_map_source_name_set(Evas_Object *obj, const char *source_name)
4366 #ifdef HAVE_ELEMENTARY_ECORE_CON
4367 ELM_CHECK_WIDTYPE(obj, widtype);
4368 Widget_Data *wd = elm_widget_data_get(obj);
4376 if (!strcmp(wd->src->name, source_name)) return;
4377 if (!wd->src->url_cb) return;
4380 grid_clear_all(obj);
4381 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
4383 if (!strcmp(s->name, source_name))
4394 if (wd->src->zoom_max < zoom)
4395 zoom = wd->src->zoom_max;
4396 if (wd->src->zoom_min > zoom)
4397 zoom = wd->src->zoom_min;
4399 grid_create_all(obj);
4400 elm_map_zoom_set(obj, zoom);
4408 elm_map_source_name_get(const Evas_Object *obj)
4410 #ifdef HAVE_ELEMENTARY_ECORE_CON
4411 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4412 Widget_Data *wd = elm_widget_data_get(obj);
4414 if ((!wd) || (!wd->src)) return NULL;
4415 return wd->src->name;
4423 elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
4425 #ifdef HAVE_ELEMENTARY_ECORE_CON
4426 ELM_CHECK_WIDTYPE(obj, widtype);
4427 Widget_Data *wd = elm_widget_data_get(obj);
4430 wd->route_source = source;
4437 EAPI Elm_Map_Route_Sources
4438 elm_map_route_source_get(const Evas_Object *obj)
4440 #ifdef HAVE_ELEMENTARY_ECORE_CON
4441 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS;
4442 Widget_Data *wd = elm_widget_data_get(obj);
4444 if (!wd) return ELM_MAP_ROUTE_SOURCE_YOURS;
4445 return wd->route_source;
4448 return ELM_MAP_ROUTE_SOURCE_YOURS;
4453 elm_map_source_zoom_max_set(Evas_Object *obj, int zoom)
4455 #ifdef HAVE_ELEMENTARY_ECORE_CON
4456 ELM_CHECK_WIDTYPE(obj, widtype);
4457 Widget_Data *wd = elm_widget_data_get(obj);
4459 if ((!wd) || (!wd->src)) return;
4460 if ((zoom > wd->zoom_max) || (zoom < wd->zoom_min)) return;
4461 wd->src->zoom_max = zoom;
4469 elm_map_source_zoom_max_get(const Evas_Object *obj)
4471 #ifdef HAVE_ELEMENTARY_ECORE_CON
4472 ELM_CHECK_WIDTYPE(obj, widtype) 18;
4473 Widget_Data *wd = elm_widget_data_get(obj);
4475 if ((!wd) || (!wd->src)) return 18;
4476 return wd->src->zoom_max;
4484 elm_map_source_zoom_min_set(Evas_Object *obj, int zoom)
4486 #ifdef HAVE_ELEMENTARY_ECORE_CON
4487 ELM_CHECK_WIDTYPE(obj, widtype);
4488 Widget_Data *wd = elm_widget_data_get(obj);
4490 if ((!wd) || (!wd->src)) return;
4491 if ((zoom > wd->zoom_max) || (zoom < wd->zoom_min)) return;
4492 wd->src->zoom_min = zoom;
4500 elm_map_source_zoom_min_get(const Evas_Object *obj)
4502 #ifdef HAVE_ELEMENTARY_ECORE_CON
4503 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4504 Widget_Data *wd = elm_widget_data_get(obj);
4506 if ((!wd) || (!wd->src)) return 0;
4507 return wd->src->zoom_min;
4515 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
4517 #ifdef HAVE_ELEMENTARY_ECORE_CON
4518 ELM_CHECK_WIDTYPE(obj, widtype);
4519 Widget_Data *wd = elm_widget_data_get(obj);
4522 if (!wd->user_agent) wd->user_agent = eina_stringshare_add(user_agent);
4523 else eina_stringshare_replace(&wd->user_agent, user_agent);
4525 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4526 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4534 elm_map_user_agent_get(const Evas_Object *obj)
4536 #ifdef HAVE_ELEMENTARY_ECORE_CON
4537 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4538 Widget_Data *wd = elm_widget_data_get(obj);
4540 if (!wd) return NULL;
4541 return wd->user_agent;
4548 EAPI Elm_Map_Route *
4549 elm_map_route_add(Evas_Object *obj,
4550 Elm_Map_Route_Type type,
4551 Elm_Map_Route_Method method,
4557 #ifdef HAVE_ELEMENTARY_ECORE_CON
4558 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4559 Widget_Data *wd = elm_widget_data_get(obj);
4562 char *type_name = NULL;
4565 if ((!wd) || (!wd->src)) return NULL;
4567 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4568 if (!route) return NULL;
4570 snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE);
4578 route->con_url = ecore_con_url_new(NULL);
4579 route->ud.fname = strdup(buf);
4580 INF("xml file : %s", route->ud.fname);
4582 route->ud.fd = fdopen(fd, "w+");
4583 if ((!route->con_url) || (!route->ud.fd))
4585 ecore_con_url_free(route->con_url);
4591 route->color.r = 255;
4594 route->color.a = 255;
4595 route->handlers = eina_list_append
4596 (route->handlers, (void *)ecore_event_handler_add
4597 (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route));
4599 route->inbound = EINA_FALSE;
4601 route->method = method;
4609 case ELM_MAP_ROUTE_TYPE_MOTOCAR:
4610 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4612 case ELM_MAP_ROUTE_TYPE_BICYCLE:
4613 type_name = strdup(ROUTE_TYPE_BICYCLE);
4615 case ELM_MAP_ROUTE_TYPE_FOOT:
4616 type_name = strdup(ROUTE_TYPE_FOOT);
4622 source = wd->src->route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4623 INF("route url = %s", source);
4625 wd->route = eina_list_append(wd->route, route);
4627 ecore_con_url_url_set(route->con_url, source);
4628 ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd));
4629 ecore_con_url_data_set(route->con_url, route);
4630 ecore_con_url_get(route->con_url);
4631 if (type_name) free(type_name);
4632 if (source) free(source);
4634 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4635 "elm,state,busy,start", "elm");
4636 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL);
4651 elm_map_route_remove(Elm_Map_Route *route)
4653 #ifdef HAVE_ELEMENTARY_ECORE_CON
4654 EINA_SAFETY_ON_NULL_RETURN(route);
4659 Ecore_Event_Handler *h;
4661 EINA_LIST_FREE(route->path, p)
4666 EINA_LIST_FREE(route->waypoint, w)
4668 if (w->point) eina_stringshare_del(w->point);
4672 EINA_LIST_FREE(route->nodes, n)
4674 if (n->pos.address) eina_stringshare_del(n->pos.address);
4678 EINA_LIST_FREE(route->handlers, h)
4680 ecore_event_handler_del(h);
4683 if (route->ud.fname)
4685 ecore_file_remove(route->ud.fname);
4686 free(route->ud.fname);
4687 route->ud.fname = NULL;
4695 elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a)
4697 #ifdef HAVE_ELEMENTARY_ECORE_CON
4698 EINA_SAFETY_ON_NULL_RETURN(route);
4713 elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a)
4715 #ifdef HAVE_ELEMENTARY_ECORE_CON
4716 EINA_SAFETY_ON_NULL_RETURN(route);
4717 if (r) *r = route->color.r;
4718 if (g) *g = route->color.g;
4719 if (b) *b = route->color.b;
4720 if (a) *a = route->color.a;
4731 elm_map_route_distance_get(const Elm_Map_Route *route)
4733 #ifdef HAVE_ELEMENTARY_ECORE_CON
4734 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
4735 return route->info.distance;
4743 elm_map_route_node_get(const Elm_Map_Route *route)
4745 #ifdef HAVE_ELEMENTARY_ECORE_CON
4746 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4747 return route->info.nodes;
4755 elm_map_route_waypoint_get(const Elm_Map_Route *route)
4757 #ifdef HAVE_ELEMENTARY_ECORE_CON
4758 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4759 return route->info.waypoints;
4767 elm_map_name_address_get(const Elm_Map_Name *name)
4769 #ifdef HAVE_ELEMENTARY_ECORE_CON
4770 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
4771 return name->address;
4779 elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
4781 #ifdef HAVE_ELEMENTARY_ECORE_CON
4782 EINA_SAFETY_ON_NULL_RETURN(name);
4783 if (lon) *lon = name->lon;
4784 if (lat) *lat = name->lat;
4793 elm_map_name_remove(Elm_Map_Name *name)
4795 #ifdef HAVE_ELEMENTARY_ECORE_CON
4796 EINA_SAFETY_ON_NULL_RETURN(name);
4799 free(name->address);
4800 name->address = NULL;
4804 ecore_event_handler_del(name->handler);
4805 name->handler = NULL;
4809 ecore_file_remove(name->ud.fname);
4810 free(name->ud.fname);
4811 name->ud.fname = NULL;
4819 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
4821 #ifdef HAVE_ELEMENTARY_ECORE_CON
4822 ELM_CHECK_WIDTYPE(obj, widtype);
4823 Widget_Data *wd = elm_widget_data_get(obj);
4826 wd->rotate.d = degree;
4829 wd->calc_job = ecore_job_add(_calc_job, wd);
4839 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
4841 #ifdef HAVE_ELEMENTARY_ECORE_CON
4842 ELM_CHECK_WIDTYPE(obj, widtype);
4843 Widget_Data *wd = elm_widget_data_get(obj);
4846 if (degree) *degree = wd->rotate.d;
4847 if (cx) *cx = wd->rotate.cx;
4848 if (cy) *cy = wd->rotate.cy;
4858 elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
4860 #ifdef HAVE_ELEMENTARY_ECORE_CON
4861 ELM_CHECK_WIDTYPE(obj, widtype);
4862 Widget_Data *wd = elm_widget_data_get(obj);
4865 if ((!wd->wheel_disabled) && (disabled))
4866 evas_object_event_callback_del_full(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
4867 else if ((wd->wheel_disabled) && (!disabled))
4868 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
4869 wd->wheel_disabled = !!disabled;
4877 elm_map_wheel_disabled_get(const Evas_Object *obj)
4879 #ifdef HAVE_ELEMENTARY_ECORE_CON
4880 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4881 Widget_Data *wd = elm_widget_data_get(obj);
4883 if (!wd) return EINA_FALSE;
4884 return wd->wheel_disabled;
4893 elm_map_track_add(Evas_Object *obj, EMap_Route *emap)
4895 #ifdef HAVE_ELEMENTARY_ECORE_CON
4896 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4897 Widget_Data *wd = elm_widget_data_get(obj);
4899 if (!wd) return EINA_FALSE;
4901 Evas_Object *route = elm_route_add(obj);
4902 elm_route_emap_set(route, emap);
4903 wd->track = eina_list_append(wd->track, route);
4915 elm_map_track_remove(Evas_Object *obj, Evas_Object *route)
4917 #ifdef HAVE_ELEMENTARY_ECORE_CON
4918 ELM_CHECK_WIDTYPE(obj, widtype) ;
4919 Widget_Data *wd = elm_widget_data_get(obj);
4923 wd->track = eina_list_remove(wd->track, route);
4924 evas_object_del(route);
4931 #ifdef HAVE_ELEMENTARY_ECORE_CON
4934 _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4937 snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
4943 _osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4946 snprintf(buf, sizeof(buf),
4947 "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
4953 _cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4956 snprintf(buf, sizeof(buf),
4957 "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
4963 _maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4966 snprintf(buf, sizeof(buf),
4967 "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
4972 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4975 snprintf(buf, sizeof(buf),
4976 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
4977 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
4982 // TODO: fix monav api
4984 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4987 snprintf(buf, sizeof(buf),
4988 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
4989 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
4995 // TODO: fix ors api
4997 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5000 snprintf(buf, sizeof(buf),
5001 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
5002 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
5009 _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
5011 ELM_CHECK_WIDTYPE(obj, widtype) strdup("");
5012 Widget_Data *wd = elm_widget_data_get(obj);
5014 unsigned int ele, idx;
5015 char search_url[PATH_MAX];
5018 if (!wd) return strdup("");
5019 if (method == ELM_MAP_NAME_METHOD_SEARCH)
5021 search_url[0] = '\0';
5022 str = eina_str_split_full(name, " ", 0, &ele);
5023 for (idx = 0 ; idx < ele ; idx++)
5025 eina_strlcat(search_url, str[idx], sizeof(search_url));
5026 if (!(idx == (ele-1))) eina_strlcat(search_url, "+", sizeof(search_url));
5028 snprintf(buf, sizeof(buf), "%s/search?q=%s&format=xml&polygon=0&addressdetails=0", NAME_NOMINATIM_URL, search_url);
5036 else if (method == ELM_MAP_NAME_METHOD_REVERSE) snprintf(buf, sizeof(buf), "%s/reverse?format=xml&lat=%lf&lon=%lf&zoom=%d&addressdetails=0", NAME_NOMINATIM_URL, lat, lon, wd->zoom);
5037 else strcpy(buf, "");