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 *_mapquest_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
80 static char *_mapquest_aerial_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
82 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
84 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
85 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
87 static char *_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat);
89 static Map_Sources_Tab default_map_sources_tab[] =
91 {"Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
92 {"Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
93 {"CycleMap", 0, 16, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
94 {"MapQuest", 0, 18, _mapquest_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
95 {"MapQuest Open Aerial", 0, 11, _mapquest_aerial_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
100 Ecore_Con_Url *con_url;
106 struct _Elm_Map_Marker_Class
111 struct _Elm_Map_Marker_Class_Func {
112 ElmMapMarkerGetFunc get;
113 ElmMapMarkerDelFunc del; //if NULL the object will be destroyed with evas_object_del()
114 ElmMapMarkerIconGetFunc icon_get;
117 struct { //this part is private, do not modify these values
119 Evas_Coord edje_w, edje_h;
123 struct _Elm_Map_Marker
126 Elm_Map_Marker_Class *clas;
127 Elm_Map_Group_Class *clas_group;
128 double longitude, latitude;
133 Marker_Group **groups;
134 Evas_Object *content;
137 struct _Elm_Map_Group_Class
141 int zoom_displayed; // display the group if the zoom is >= to zoom_display
142 int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
146 ElmMapGroupIconGetFunc icon_get;
149 struct { //this part is private, do not modify these values
151 Evas_Coord edje_w, edje_h;
152 Evas_Coord edje_max_w, edje_max_h;
154 Eina_List *objs_used;
155 Eina_List *objs_notused;
162 Eina_Matrixsparse_Cell *cell;
163 Elm_Map_Group_Class *clas;
166 long long sum_x, sum_y;
170 Evas_Object *obj, *bubble, *sc, *bx, *rect;
172 Eina_Bool bringin : 1;
173 Eina_Bool update_nbelems : 1;
174 Eina_Bool update_resize : 1;
175 Eina_Bool update_raise : 1;
176 Eina_Bool delete_object : 1;
179 struct _Elm_Map_Route
185 Ecore_Con_Url *con_url;
190 double flon, flat, tlon, tlat;
192 Eina_List *nodes, *path;
199 const char *waypoints;
200 double distance; /* unit : km */
213 Eina_Bool inbound : 1;
227 struct _Path_Waypoint
238 Ecore_Con_Url *con_url;
243 Ecore_Event_Handler *handler;
259 Eina_Bool file_have : 1;
260 Ecore_File_Download_Job *job;
267 int tsize; // size of tile (tsize x tsize pixels)
268 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
269 int iw, ih; // size of image in pixels
270 int w, h; // size of grid image in pixels (represented by grid)
271 int gw, gh; // size of grid in tiles
272 Eina_Matrixsparse *grid;
280 Evas_Object *pan_smart;
282 Evas_Object *sep_maps_markers; //map objects are below this object and marker objects are on top
284 Evas_Coord pan_x, pan_y, minw, minh;
289 Elm_Map_Zoom_Mode mode;
292 Ecore_Timer *scr_timer;
293 Ecore_Timer *long_timer;
294 Ecore_Animator *zoom_animator;
305 Evas_Coord x, y ,w ,h;
310 Eina_Bool resized : 1;
311 Eina_Bool on_hold : 1;
312 Eina_Bool paused : 1;
313 Eina_Bool paused_markers : 1;
320 Ecore_Job *markers_place_job;
321 Eina_Matrixsparse **markers;
322 Eina_List *cells_displayed; // list of Eina_Matrixsparse_Cell
323 Evas_Coord markers_max_num;
324 int marker_max_w, marker_max_h;
326 Eina_List *opened_bubbles; //opened bubbles, list of Map_Group *
328 Eina_List *groups_clas; // list of Elm_Map_Group_Class*
329 Eina_List *markers_clas; // list of Elm_Map_Markers_Class*
331 Elm_Map_Route_Sources route_source;
332 Eina_List *s_event_list;
337 const char *user_agent;
340 Evas_Event_Mouse_Down ev;
355 Eina_Bool wheel_disabled : 1;
356 Eina_Bool scr_started : 1;
359 Eina_List *map_sources_tab;
360 const char **source_names;
362 Ecore_Timer *zoom_timer;
363 Map_Sources_Tab *src;
364 const char *gpx_file;
365 int zoom_min, zoom_max;
366 Eina_List *download_list;
372 Evas_Object_Smart_Clipped_Data __clipped_data;
388 Evas_Coord x, y, w, h;
405 enum _Route_Xml_Attribute
409 ROUTE_XML_DESCRIPTION,
410 ROUTE_XML_COORDINATES,
412 } Route_Xml_Attibute;
422 enum _Name_Xml_Attribute
439 enum _Track_Xml_Attribute
442 TRACK_XML_COORDINATES,
444 } Track_Xml_Attibute;
446 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
447 static const char *widtype = NULL;
448 static int idnum = 1;
450 static const char SIG_CHANGED[] = "changed";
451 static const char SIG_CLICKED[] = "clicked";
452 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
453 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
454 static const char SIG_LOAD_DETAIL[] = "load,detail";
455 static const char SIG_LONGPRESSED[] = "longpressed";
456 static const char SIG_PRESS[] = "press";
457 static const char SIG_SCROLL[] = "scroll";
458 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
459 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
460 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
461 static const char SIG_ZOOM_START[] = "zoom,start";
462 static const char SIG_ZOOM_STOP[] = "zoom,stop";
463 static const char SIG_DOWNLOADED[] = "downloaded";
464 static const char SIG_ROUTE_LOAD[] = "route,load";
465 static const char SIG_ROUTE_LOADED[] = "route,loaded";
466 static const char SIG_NAME_LOAD[] = "name,load";
467 static const char SIG_NAME_LOADED[] = "name,loaded";
468 static const Evas_Smart_Cb_Description _signals[] = {
471 {SIG_CLICKED_DOUBLE, ""},
472 {SIG_LOADED_DETAIL, ""},
473 {SIG_LOAD_DETAIL, ""},
474 {SIG_LONGPRESSED, ""},
477 {SIG_SCROLL_DRAG_START, ""},
478 {SIG_SCROLL_DRAG_STOP, ""},
479 {SIG_ZOOM_CHANGE, ""},
480 {SIG_ZOOM_START, ""},
482 {SIG_DOWNLOADED, ""},
483 {SIG_ROUTE_LOAD, ""},
484 {SIG_ROUTE_LOADED, ""},
486 {SIG_NAME_LOADED, ""},
490 static void _pan_calculate(Evas_Object *obj);
492 static void _rect_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
493 static void _del_hook(Evas_Object *obj);
494 static void _theme_hook(Evas_Object *obj);
495 static void _on_focus_hook(void *data, Evas_Object *obj);
496 static void _sizing_eval(Evas_Object *obj);
497 static void _calc_job(void *data);
498 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
499 Evas_Callback_Type type, void *event_info);
500 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);
501 static void grid_load(Evas_Object *obj, Grid *g);
503 static void _process_download_list(Evas_Object *obj);
504 static void _add_download_list(Evas_Object *obj, Grid_Item *gi);
506 static void _group_object_create(Marker_Group *group);
507 static void _group_object_free(Marker_Group *group);
508 static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
509 static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
510 static void _group_bubble_create(Marker_Group *group);
511 static void _group_bubble_free(Marker_Group *group);
512 static void _group_bubble_place(Marker_Group *group);
514 static int _group_bubble_content_update(Marker_Group *group);
515 static void _group_bubble_content_free(Marker_Group *group);
516 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);
517 static void _bubble_sc_hints_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
519 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
520 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
522 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);
523 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);
526 module_list_cb(Eina_Module *m, void *data)
528 ELM_CHECK_WIDTYPE(data, widtype) EINA_FALSE;
529 Widget_Data *wd = elm_widget_data_get(data);
531 ElmMapModuleSourceFunc source;
532 ElmMapModuleZoomMinFunc zoom_min;
533 ElmMapModuleZoomMaxFunc zoom_max;
534 ElmMapModuleUrlFunc url;
535 ElmMapModuleRouteSourceFunc route_source;
536 ElmMapModuleRouteUrlFunc route_url;
537 ElmMapModuleNameUrlFunc name_url;
538 ElmMapModuleGeoIntoCoordFunc geo_into_coord;
539 ElmMapModuleCoordIntoGeoFunc coord_into_geo;
542 if (!wd) return EINA_FALSE;
544 file = eina_module_file_get(m);
545 if (!eina_module_load(m))
547 ERR("could not load module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
551 source = eina_module_symbol_get(m, "map_module_source_get");
552 zoom_min = eina_module_symbol_get(m, "map_module_zoom_min_get");
553 zoom_max = eina_module_symbol_get(m, "map_module_zoom_max_get");
554 url = eina_module_symbol_get(m, "map_module_url_get");
555 route_source = eina_module_symbol_get(m, "map_module_route_source_get");
556 route_url = eina_module_symbol_get(m, "map_module_route_url_get");
557 name_url = eina_module_symbol_get(m, "map_module_name_url_get");
558 geo_into_coord = eina_module_symbol_get(m, "map_module_geo_into_coord");
559 coord_into_geo = eina_module_symbol_get(m, "map_module_coord_into_geo");
560 if ((!source) || (!zoom_min) || (!zoom_max) || (!url) || (!route_source) || (!route_url) || (!name_url) || (!geo_into_coord) || (!coord_into_geo))
562 WRN("could not find map_module_source_get() in module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
563 eina_module_unload(m);
566 s = calloc(1, sizeof(Map_Sources_Tab));
567 EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE);
569 s->zoom_min = zoom_min();
570 s->zoom_max = zoom_max();
572 s->route_source = route_source();
573 s->route_url_cb = route_url;
574 s->name_url_cb = name_url;
575 s->geo_into_coord = geo_into_coord;
576 s->coord_into_geo = coord_into_geo;
577 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
583 module_init(void *data)
585 ELM_CHECK_WIDTYPE(data, widtype);
586 Widget_Data *wd = elm_widget_data_get(data);
589 wd->modules = eina_module_list_get(wd->modules, MODULES_PATH, 1, &module_list_cb, data);
593 source_init(void *data)
595 ELM_CHECK_WIDTYPE(data, widtype);
596 Widget_Data *wd = elm_widget_data_get(data);
602 for (idx = 0; idx < sizeof(default_map_sources_tab)/sizeof(Map_Sources_Tab); idx++)
604 s = calloc(1, sizeof(Map_Sources_Tab));
605 EINA_SAFETY_ON_NULL_RETURN(s);
606 s->name = default_map_sources_tab[idx].name;
607 s->zoom_min = default_map_sources_tab[idx].zoom_min;
608 s->zoom_max = default_map_sources_tab[idx].zoom_max;
609 s->url_cb = default_map_sources_tab[idx].url_cb;
610 s->route_source = default_map_sources_tab[idx].route_source;
611 s->route_url_cb = default_map_sources_tab[idx].route_url_cb;
612 s->name_url_cb = default_map_sources_tab[idx].name_url_cb;
613 s->geo_into_coord = default_map_sources_tab[idx].geo_into_coord;
614 s->coord_into_geo = default_map_sources_tab[idx].coord_into_geo;
615 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
616 if (!idx) wd->src = s;
620 int n = eina_list_count(wd->map_sources_tab);
621 wd->source_names = malloc(sizeof(char *) * (n + 1));
622 if (!wd->source_names)
624 ERR("init source names failed.");
628 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
630 wd->source_names[idx] = strdup(s->name);
631 INF("source : %s", wd->source_names[idx]);
632 if (s->zoom_min < wd->zoom_min) wd->zoom_min = s->zoom_min;
633 if (s->zoom_max > wd->zoom_max) wd->zoom_max = s->zoom_max;
636 wd->source_names[idx] = NULL;
640 obj_rotate_zoom(void *data, Evas_Object *obj)
642 ELM_CHECK_WIDTYPE(data, widtype);
643 Widget_Data *wd = elm_widget_data_get(data);
645 if ((!wd->pinch.cx) && (!wd->pinch.cy))
647 wd->pinch.cx = wd->rotate.cx;
648 wd->pinch.cy = wd->rotate.cy;
651 evas_map_util_points_populate_from_object_full(wd->map, obj, 0);
652 evas_object_image_size_get(obj, &iw, &ih);
653 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
654 if ((ow < iw) || (oh < ih))
656 ow *= (double)iw / ow;
657 oh *= (double)ih / oh;
658 evas_map_point_image_uv_set(wd->map, 1, ow, 0);
659 evas_map_point_image_uv_set(wd->map, 2, ow, oh);
660 evas_map_point_image_uv_set(wd->map, 3, 0, oh);
662 evas_map_util_zoom(wd->map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy);
663 evas_map_util_rotate(wd->map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
664 evas_object_map_enable_set(obj, EINA_TRUE);
665 evas_object_map_set(obj, wd->map);
670 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)
672 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__)
676 ELM_CHECK_WIDTYPE(obj, widtype);
677 Widget_Data *wd = elm_widget_data_get(obj);
680 int xmin, xmax, ymin, ymax;
683 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
685 EINA_LIST_FOREACH(wd->track, l, route)
687 elm_map_utils_convert_geo_into_coord(wd->obj, elm_route_lon_min_get(route), elm_route_lat_max_get(route), size, &xmin, &ymin);
688 elm_map_utils_convert_geo_into_coord(wd->obj, elm_route_lon_max_get(route), elm_route_lat_min_get(route), size, &xmax, &ymax);
690 if( !(xmin < px && xmax < px) && !(xmin > px+ow && xmax > px+ow))
692 if( !(ymin < py && ymax < py) && !(ymin > py+oh && ymax > py+oh))
695 evas_object_move(route, xmin - px + ox, ymin - py + oy);
696 evas_object_resize(route, xmax - xmin, ymax - ymin);
698 evas_object_raise(route);
699 obj_rotate_zoom(obj, route);
700 evas_object_show(route);
705 //the route is not display
706 evas_object_hide(route);
711 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)
713 ELM_CHECK_WIDTYPE(obj, widtype);
714 Widget_Data *wd = elm_widget_data_get(obj);
715 Eina_List *lr, *lp, *ln;
724 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
726 EINA_LIST_FOREACH(wd->route, lr, r)
728 EINA_LIST_FOREACH(r->path, lp, p)
730 evas_object_polygon_points_clear(p);
733 evas_object_geometry_get(wd->rect, &rx, &ry, NULL, NULL);
734 nodes = eina_list_count(r->nodes);
736 EINA_LIST_FOREACH(r->nodes, ln, n)
738 if ((!wd->zoom) || ((n->idx) &&
739 ((n->idx % (int)ceil((double)nodes/(double)size*100.0))))) continue;
742 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
743 if ((x >= px - ow) && (x <= (px + ow*2)) &&
744 (y >= py - oh) && (y <= (py + oh*2)))
749 p = eina_list_nth(r->path, n->idx);
750 a = (double)(y - r->y) / (double)(x - r->x);
751 if ((abs(a) >= 1) || (r->x == x))
753 evas_object_polygon_point_add(p, r->x - 3, r->y);
754 evas_object_polygon_point_add(p, r->x + 3, r->y);
755 evas_object_polygon_point_add(p, x + 3, y);
756 evas_object_polygon_point_add(p, x - 3, y);
760 evas_object_polygon_point_add(p, r->x, r->y - 3);
761 evas_object_polygon_point_add(p, r->x, r->y + 3);
762 evas_object_polygon_point_add(p, x, y + 3);
763 evas_object_polygon_point_add(p, x, y - 3);
766 evas_object_color_set(p, r->color.r, r->color.g, r->color.b, r->color.a);
767 evas_object_raise(p);
768 obj_rotate_zoom(obj, p);
773 else r->inbound = EINA_FALSE;
777 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
778 if ((x >= px - ow) && (x <= (px + ow*2)) &&
779 (y >= py - oh) && (y <= (py + oh*2)))
783 r->inbound = EINA_TRUE;
785 else r->inbound = EINA_FALSE;
788 r->inbound = EINA_FALSE;
793 rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
795 ELM_CHECK_WIDTYPE(obj, widtype);
796 Widget_Data *wd = elm_widget_data_get(obj);
797 Evas_Coord ax, ay, gw, gh, hh, ww;
800 evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh);
807 if ((ww == gw) && (hh == gh)) return;
809 if (ow > gw) ax = (ow - gw) / 2;
810 if (oh > gh) ay = (oh - gh) / 2;
811 evas_object_move(wd->rect,
814 evas_object_resize(wd->rect, gw, gh);
818 wd->show.show = EINA_FALSE;
819 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
824 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)
826 ELM_CHECK_WIDTYPE(obj, widtype);
827 Widget_Data *wd = elm_widget_data_get(obj);
828 Evas_Coord ax, ay, gw, gh, tx, ty;
829 Eina_List *l, *markers;
830 Eina_Matrixsparse_Cell *cell;
835 int g_xx, g_yy, g_hh, g_ww;
843 if (ow > gw) ax = (ow - gw) / 2;
844 if (oh > gh) ay = (oh - gh) / 2;
846 if (wd->zoom != wd->marker_zoom)
848 EINA_LIST_FREE(wd->cells_displayed, cell)
850 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
852 if (group->obj) _group_object_free(group);
856 wd->marker_zoom = wd->zoom;
858 if ((wd->paused_markers)
859 && ((wd->size.nw != wd->size.w) || (wd->size.nh != wd->size.h)) )
862 g_xx = wd->pan_x / wd->tsize;
863 if (g_xx < 0) g_xx = 0;
864 g_yy = wd->pan_y / wd->tsize;
865 if (g_yy < 0) g_yy = 0;
866 g_ww = (ow / wd->tsize) + 1;
867 if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
868 g_hh = (oh / wd->tsize) + 1;
869 if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
871 //hide groups no more displayed
872 EINA_LIST_FREE(wd->cells_displayed, cell)
874 eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x);
875 if ((y < g_yy) || (y > g_yy + g_hh) || (x < g_xx) || (x > g_xx + g_ww))
877 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
879 if (group->obj) _group_object_free(group);
884 if (!wd->marker_zoom)
890 for (y = g_yy; y <= g_yy + g_hh; y++)
892 for (x = g_xx; x <= g_xx + g_ww; x++)
894 if (!wd->markers[wd->zoom]) continue;
895 eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell);
897 wd->cells_displayed = eina_list_append(wd->cells_displayed, cell);
898 markers = eina_matrixsparse_cell_data_get(cell);
899 EINA_LIST_FOREACH(markers, l, group)
901 if (!group->markers) continue;
902 if (group->clas->zoom_displayed > wd->zoom) continue;
909 if (eina_list_count(group->markers) == 1)
911 Elm_Map_Marker *m = eina_list_data_get(group->markers);
912 ww = m->clas->priv.edje_w;
913 hh = m->clas->priv.edje_h;
919 if ((gw != g->w) && (g->w > 0))
922 xx = ((long long )gw * xx) / g->w;
923 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
925 if ((gh != g->h) && (g->h > 0))
928 yy = ((long long)gh * yy) / g->h;
929 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
932 if ((!group->clas->hide)
933 && (xx-px+ax+ox >= ox) && (xx-px+ax+ox<= ox+ow)
934 && (yy-py+ay+oy >= oy) && (yy-py+ay+oy<= oy+oh))
936 if (!group->obj) _group_object_create(group);
938 if (group->update_nbelems)
940 group->update_nbelems = EINA_FALSE;
941 if (eina_list_count(group->markers) > 1)
943 snprintf(buf, sizeof(buf), "%d", eina_list_count(group->markers));
944 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
947 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", "");
949 evas_object_move(group->obj,
950 xx - px + ax + ox - ww/2,
951 yy - py + ay + oy - hh/2);
952 if ((!wd->paused_markers) || (group->update_resize))
954 group->update_resize = EINA_FALSE;
955 evas_object_resize(group->obj, ww, hh);
956 obj_rotate_zoom(obj, group->obj);
958 if (group->update_raise)
960 group->update_raise = EINA_FALSE;
961 evas_object_raise(group->obj);
962 obj_rotate_zoom(obj, group->obj);
963 evas_object_show(group->obj);
965 if (group->bubble) _group_bubble_place(group);
969 _group_object_free(group);
977 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)
979 ELM_CHECK_WIDTYPE(obj, widtype);
980 Widget_Data *wd = elm_widget_data_get(obj);
981 Evas_Coord ax, ay, gw, gh, tx, ty;
989 if (ow > gw) ax = (ow - gw) / 2;
990 if (oh > gh) ay = (oh - gh) / 2;
992 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
993 Eina_Matrixsparse_Cell *cell;
995 EINA_ITERATOR_FOREACH(it, cell)
997 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1003 if ((gw != g->w) && (g->w > 0))
1006 xx = ((long long )gw * xx) / g->w;
1007 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1009 if ((gh != g->h) && (g->h > 0))
1012 yy = ((long long)gh * yy) / g->h;
1013 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1015 evas_object_move(gi->img,
1019 evas_object_resize(gi->img, ww, hh);
1021 obj_rotate_zoom(obj, gi->img);
1022 /*evas_object_move(gi->txt,
1026 evas_object_resize(gi->txt, ww, hh);
1029 eina_iterator_free(it);
1033 _tile_update(Grid_Item *gi)
1035 evas_object_image_file_set(gi->img, gi->file, NULL);
1036 Evas_Load_Error err = evas_object_image_load_error_get(gi->img);
1037 if (err != EVAS_LOAD_ERROR_NONE)
1039 ERR("Image loading error (%s): %s", gi->file, evas_load_error_str(err));
1040 ecore_file_remove(gi->file);
1041 gi->file_have = EINA_FALSE;
1045 obj_rotate_zoom(gi->wd->obj, gi->img);
1046 evas_object_show(gi->img);
1047 gi->file_have = EINA_TRUE;
1048 //evas_object_text_text_set(gi->txt, gi->file);
1049 //evas_object_show(gi->txt);
1054 _tile_downloaded(void *data, const char *file __UNUSED__, int status)
1056 Grid_Item *gi = data;
1062 DBG("Download success from %s to %s", gi->source, gi->file);
1064 gi->wd->finish_num++;
1068 WRN("Download failed from %s to %s (%d) ", gi->source, gi->file, status);
1069 ecore_file_remove(gi->file);
1070 gi->file_have = EINA_FALSE;
1073 gi->wd->download_num--;
1074 evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL);
1075 if (!gi->wd->download_num)
1077 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr), "elm,state,busy,stop", "elm");
1078 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
1080 _process_download_list(gi->wd->obj);
1084 _process_download_list(Evas_Object *obj)
1086 ELM_CHECK_WIDTYPE(obj, widtype);
1087 Widget_Data *wd = elm_widget_data_get(obj);
1089 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
1092 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
1093 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
1098 EINA_LIST_REVERSE_FOREACH_SAFE(wd->download_list, l, ll, gi)
1105 if ((gw != gi->g->w) && (gi->g->w > 0))
1108 xx = ((long long )gw * xx) / gi->g->w;
1109 ww = (((long long)gw * (tx + ww)) / gi->g->w) - xx;
1111 if ((gh != gi->g->h) && (gi->g->h > 0))
1114 yy = ((long long)gh * yy) / gi->g->h;
1115 hh = (((long long)gh * (ty + hh)) / gi->g->h) - yy;
1117 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
1118 yy - wd->pan_y + oy,
1120 cvx, cvy, cvw, cvh) ||
1121 (gi->zoom != wd->zoom))
1123 wd->download_list = eina_list_remove(wd->download_list, gi);
1127 if (gi->wd->download_num >= MAX_CONCURRENT_DOWNLOAD) break;
1129 Eina_Bool ret = ecore_file_download_full(gi->source, gi->file, _tile_downloaded, NULL, gi, &(gi->job), wd->ua);
1130 if (!ret || !gi->job) ERR("Can't start to download from %s to %s", gi->source, gi->file);
1133 gi->wd->download_num++;
1135 wd->download_list = eina_list_remove(wd->download_list, gi);
1136 if (wd->download_num == 1)
1137 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,state,busy,start", "elm");
1143 _add_download_list(Evas_Object *obj, Grid_Item *gi)
1145 ELM_CHECK_WIDTYPE(obj, widtype);
1146 Widget_Data *wd = elm_widget_data_get(obj);
1148 wd->download_list = eina_list_remove(wd->download_list, gi);
1149 wd->download_list = eina_list_append(wd->download_list, gi);
1150 _process_download_list(obj);
1154 grid_create_all(Evas_Object *obj)
1156 ELM_CHECK_WIDTYPE(obj, widtype);
1157 Widget_Data *wd = elm_widget_data_get(obj);
1161 EINA_SAFETY_ON_NULL_RETURN(wd);
1162 EINA_SAFETY_ON_NULL_RETURN(wd->src);
1164 for (zoom = wd->src->zoom_min; zoom <= wd->src->zoom_max; zoom++)
1166 g = calloc(1, sizeof(Grid));
1167 EINA_SAFETY_ON_NULL_RETURN(g);
1169 g->tsize = wd->tsize;
1171 int size = pow(2.0, g->zoom);
1174 g->w = g->tsize * g->gw;
1175 g->h = g->tsize * g->gh;
1177 g->grid = eina_matrixsparse_new(g->gh, g->gw, NULL, NULL);
1178 wd->grids = eina_list_append(wd->grids, g);
1183 grid_clear_all(Evas_Object *obj)
1185 ELM_CHECK_WIDTYPE(obj, widtype);
1186 Widget_Data *wd = elm_widget_data_get(obj);
1190 EINA_SAFETY_ON_NULL_RETURN(wd);
1192 EINA_LIST_FREE(wd->grids, g)
1194 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1195 Eina_Matrixsparse_Cell *cell;
1197 EINA_ITERATOR_FOREACH(it, cell)
1199 gi = eina_matrixsparse_cell_data_get(cell);
1200 evas_object_del(gi->img);
1201 //evas_object_del(gi->txt);
1205 DBG("DOWNLOAD abort %s", gi->file);
1206 ecore_file_download_abort(gi->job);
1207 ecore_file_remove(gi->file);
1208 gi->file_have = EINA_FALSE;
1212 if (gi->file) eina_stringshare_del(gi->file);
1213 if (gi->source) eina_stringshare_del(gi->source);
1216 eina_matrixsparse_free(g->grid);
1217 eina_iterator_free(it);
1221 EINA_LIST_FREE(wd->download_list, gi);
1222 if (!ecore_file_recursive_rm("/tmp/elm_map/")) WRN("Deletion of /tmp/elm_map/ failed");
1227 grid_unload(Evas_Object *obj, Grid *g)
1229 ELM_CHECK_WIDTYPE(obj, widtype);
1230 Widget_Data *wd = elm_widget_data_get(obj);
1233 Eina_Matrixsparse_Cell *cell;
1236 EINA_SAFETY_ON_NULL_RETURN(wd);
1238 it = eina_matrixsparse_iterator_new(g->grid);
1239 EINA_ITERATOR_FOREACH(it, cell)
1241 gi = eina_matrixsparse_cell_data_get(cell);
1245 evas_object_hide(gi->img);
1246 //evas_object_hide(gi->txt);
1247 evas_object_image_file_set(gi->img, NULL, NULL);
1251 DBG("DOWNLOAD abort %s", gi->file);
1252 ecore_file_download_abort(gi->job);
1253 ecore_file_remove(gi->file);
1258 eina_iterator_free(it);
1263 grid_load(Evas_Object *obj, Grid *g)
1265 ELM_CHECK_WIDTYPE(obj, widtype);
1266 Widget_Data *wd = elm_widget_data_get(obj);
1269 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
1271 Eina_Matrixsparse_Cell *cell;
1274 EINA_SAFETY_ON_NULL_RETURN(wd);
1275 EINA_SAFETY_ON_NULL_RETURN(wd->src);
1277 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
1278 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
1283 if ((gw <= 0) || (gh <= 0)) return;
1286 if ((gw != g->w) && (g->w > 0))
1287 size = ((long long)gw * size) / g->w;
1288 if (size < (g->tsize / 2)) return; // else we will load to much tiles
1290 it = eina_matrixsparse_iterator_new(g->grid);
1292 EINA_ITERATOR_FOREACH(it, cell)
1294 gi = eina_matrixsparse_cell_data_get(cell);
1301 if ((gw != g->w) && (g->w > 0))
1304 xx = ((long long )gw * xx) / g->w;
1305 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1307 if ((gh != g->h) && (g->h > 0))
1310 yy = ((long long)gh * yy) / g->h;
1311 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1314 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
1315 yy - wd->pan_y + oy,
1317 cvx, cvy, cvw, cvh))
1321 evas_object_hide(gi->img);
1322 //evas_object_hide(gi->txt);
1323 evas_object_image_file_set(gi->img, NULL, NULL);
1327 DBG("Download abort %s", gi->file);
1328 ecore_file_download_abort(gi->job);
1329 ecore_file_remove(gi->file);
1335 eina_iterator_free(it);
1337 xx = wd->pan_x / size - 1;
1340 yy = wd->pan_y / size - 1;
1344 if (xx + ww >= g->gw) ww = g->gw - xx - 1;
1347 if (yy + hh >= g->gh) hh = g->gh - yy - 1;
1349 for (y = yy; y <= yy + hh; y++)
1351 for (x = xx; x <= xx + ww; x++)
1353 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
1358 char buf2[PATH_MAX];
1361 gi = calloc(1, sizeof(Grid_Item));
1362 EINA_SAFETY_ON_NULL_RETURN(gi);
1367 gi->file_have = EINA_FALSE;
1370 gi->src.x = x * g->tsize;
1371 gi->src.y = y * g->tsize;
1372 gi->src.w = g->tsize;
1373 gi->src.h = g->tsize;
1375 gi->out.x = gi->src.x;
1376 gi->out.y = gi->src.y;
1377 gi->out.w = gi->src.w;
1378 gi->out.h = gi->src.h;
1380 gi->img = evas_object_image_add(evas_object_evas_get(obj));
1381 evas_object_image_scale_hint_set(gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1382 evas_object_image_filled_set(gi->img, 1);
1384 evas_object_smart_member_add(gi->img, wd->pan_smart);
1385 elm_widget_sub_object_add(obj, gi->img);
1386 evas_object_pass_events_set(gi->img, EINA_TRUE);
1387 evas_object_stack_below(gi->img, wd->sep_maps_markers);
1389 /* gi->txt = evas_object_text_add(evas_object_evas_get(obj));
1390 evas_object_text_font_set(gi->txt, "Vera", 12);
1391 evas_object_color_set(gi->txt, 100, 100, 100, 255);
1392 evas_object_smart_member_add(gi->txt,
1394 elm_widget_sub_object_add(obj, gi->txt);
1395 evas_object_pass_events_set(gi->txt, EINA_TRUE);
1397 snprintf(buf, sizeof(buf), CACHE_PATH, wd->id, g->zoom, x);
1398 snprintf(buf2, sizeof(buf2), CACHE_FILE_PATH, buf, y);
1399 if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
1401 eina_stringshare_replace(&gi->file, buf2);
1402 source = wd->src->url_cb(obj, x, y, g->zoom);
1403 if ((!source) || (strlen(source)==0))
1405 eina_stringshare_replace(&gi->source, NULL);
1406 WRN("Getting source url failed: %s", gi->file);
1408 else eina_stringshare_replace(&gi->source, source);
1409 if (source) free(source);
1411 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
1416 DBG("File exists: %s", gi->file);
1421 DBG("Added to download list: %s", gi->file);
1422 _add_download_list(obj, gi);
1429 _smooth_update(Evas_Object *obj)
1431 ELM_CHECK_WIDTYPE(obj, widtype);
1432 Widget_Data *wd = elm_widget_data_get(obj);
1437 EINA_LIST_FOREACH(wd->grids, l, g)
1439 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1440 Eina_Matrixsparse_Cell *cell;
1442 EINA_ITERATOR_FOREACH(it, cell)
1444 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1445 evas_object_image_smooth_scale_set(gi->img, (!wd->nosmooth));
1447 eina_iterator_free(it);
1452 _scr_timeout(void *data)
1454 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1455 Widget_Data *wd = elm_widget_data_get(data);
1457 if (!wd) return ECORE_CALLBACK_CANCEL;
1459 if (!wd->nosmooth) _smooth_update(data);
1460 wd->scr_timer = NULL;
1461 return ECORE_CALLBACK_CANCEL;
1465 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1467 ELM_CHECK_WIDTYPE(data, widtype);
1468 Widget_Data *wd = elm_widget_data_get(data);
1474 if (wd->nosmooth == 1) _smooth_update(data);
1476 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1477 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
1481 zoom_do(Evas_Object *obj)
1483 ELM_CHECK_WIDTYPE(obj, widtype);
1484 Widget_Data *wd = elm_widget_data_get(obj);
1485 Evas_Coord xx, yy, ow, oh;
1488 wd->size.w = wd->size.nw;
1489 wd->size.h = wd->size.nh;
1491 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
1493 if (wd->center_on.enabled)
1495 elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy);
1501 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
1502 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
1507 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
1509 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
1511 wd->show.show = EINA_TRUE;
1517 if (wd->calc_job) ecore_job_del(wd->calc_job);
1518 wd->calc_job = ecore_job_add(_calc_job, wd);
1522 _zoom_timeout(void *data)
1524 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1525 Widget_Data *wd = elm_widget_data_get(data);
1527 if (!wd) return ECORE_CALLBACK_CANCEL;
1528 wd->zoom_timer = NULL;
1529 wd->pinch.level = 1.0;
1531 evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
1532 return ECORE_CALLBACK_CANCEL;
1536 _zoom_anim(void *data)
1538 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1539 Evas_Object *obj = data;
1540 Widget_Data *wd = elm_widget_data_get(obj);
1542 if (!wd) return ECORE_CALLBACK_CANCEL;
1543 if (wd->zoom_method == ZOOM_METHOD_IN) wd->t += 0.1 ;
1544 else if (wd->zoom_method == ZOOM_METHOD_OUT) wd->t -= 0.05;
1547 wd->zoom_animator = NULL;
1549 evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
1550 return ECORE_CALLBACK_CANCEL;
1555 wd->zoom_animator = NULL;
1556 wd->pinch.level = 2.0;
1557 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1558 wd->zoom_timer = ecore_timer_add(0.35, _zoom_timeout, obj);
1559 return ECORE_CALLBACK_CANCEL;
1561 else if (wd->t <= 0.5)
1563 wd->zoom_animator = NULL;
1564 wd->pinch.level = 0.5;
1565 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1566 wd->zoom_timer = ecore_timer_add(1.35, _zoom_timeout, obj);
1567 return ECORE_CALLBACK_CANCEL;
1569 else if (wd->t != 1.0)
1571 Evas_Coord x, y, w, h;
1572 float half_w, half_h;
1573 evas_object_geometry_get(data, &x, &y, &w, &h);
1574 half_w = (float)w * 0.5;
1575 half_h = (float)h * 0.5;
1576 wd->pinch.cx = x + half_w;
1577 wd->pinch.cy = y + half_h;
1578 wd->pinch.level = wd->t;
1579 if (wd->calc_job) ecore_job_del(wd->calc_job);
1580 wd->calc_job = ecore_job_add(_calc_job, wd);
1582 return ECORE_CALLBACK_RENEW;
1586 _long_press(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->long_timer = NULL;
1593 evas_object_smart_callback_call(data, SIG_LONGPRESSED, &wd->ev);
1594 return ECORE_CALLBACK_CANCEL;
1598 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1600 ELM_CHECK_WIDTYPE(data, widtype);
1601 Widget_Data *wd = elm_widget_data_get(data);
1602 Evas_Event_Mouse_Down *ev = event_info;
1604 if (ev->button != 1) return;
1605 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1606 else wd->on_hold = EINA_FALSE;
1607 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1608 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, ev);
1610 evas_object_smart_callback_call(data, SIG_PRESS, ev);
1611 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1613 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1617 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1619 ELM_CHECK_WIDTYPE(data, widtype);
1620 Widget_Data *wd = elm_widget_data_get(data);
1621 EINA_SAFETY_ON_NULL_RETURN(wd);
1623 Evas_Event_Mouse_Up *ev = event_info;
1624 EINA_SAFETY_ON_NULL_RETURN(ev);
1626 if (ev->button != 1) return;
1627 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1628 else wd->on_hold = EINA_FALSE;
1631 ecore_timer_del(wd->long_timer);
1632 wd->long_timer = NULL;
1634 if (!wd->on_hold) evas_object_smart_callback_call(data, SIG_CLICKED, ev);
1635 wd->on_hold = EINA_FALSE;
1639 _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1641 ELM_CHECK_WIDTYPE(data, widtype);
1642 Widget_Data *wd = elm_widget_data_get(data);
1643 EINA_SAFETY_ON_NULL_RETURN(wd);
1648 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
1649 Evas_Coord x, y, w, h;
1651 evas_object_geometry_get(data, &x, &y, &w, &h);
1653 if (wd->calc_job) ecore_job_del(wd->calc_job);
1654 wd->calc_job = ecore_job_add(_calc_job, wd);
1656 wd->wheel_diff -= ev->z;
1657 wd->pinch.level = wd->pinch.diff * pow(2.0, (double)wd->wheel_diff/10);
1658 wd->pinch.cx = x + ((double)w * 0.5);
1659 wd->pinch.cy = y + ((double)h * 0.5);
1661 if (wd->pinch.level > 1.99 || wd->pinch.level < 1.01)
1664 if (wd->pinch.level > 1.99)
1667 wd->pinch.diff = wd->pinch.level / 2.0;
1668 wd->pinch.level = wd->pinch.level / 2.0;
1670 else if (wd->pinch.level < 1.01)
1673 wd->pinch.diff = wd->pinch.level * 2.0;
1674 wd->pinch.level = wd->pinch.level * 2.0;
1677 Elm_Map_Zoom_Mode temp;
1679 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
1680 wd->paused = EINA_TRUE;
1681 elm_map_zoom_set(data, wd->zoom + zoom_diff);
1682 wd->paused = EINA_FALSE;
1687 if (wd->calc_job) ecore_job_del(wd->calc_job);
1688 wd->calc_job = ecore_job_add(_calc_job, wd);
1694 _rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1696 ELM_CHECK_WIDTYPE(data, widtype);
1697 Widget_Data *wd = elm_widget_data_get(data);
1700 evas_object_geometry_get(wd->rect, &x, &y, &w, &h);
1701 evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h);
1702 evas_object_resize(wd->rect, w, h);
1703 evas_object_move(wd->rect, x, y);
1707 _del_hook(Evas_Object *obj)
1709 ELM_CHECK_WIDTYPE(obj, widtype);
1710 Widget_Data *wd = elm_widget_data_get(obj);
1711 Elm_Map_Group_Class *group_clas;
1712 Elm_Map_Marker_Class *marker_clas;
1717 Ecore_Event_Handler *h;
1723 EINA_LIST_FREE(wd->groups_clas, group_clas)
1725 if (group_clas->style)
1726 eina_stringshare_del(group_clas->style);
1730 EINA_LIST_FREE(wd->markers_clas, marker_clas)
1732 if (marker_clas->style)
1733 eina_stringshare_del(marker_clas->style);
1737 EINA_LIST_FOREACH(wd->route, l, r)
1739 EINA_LIST_FREE(r->path, p)
1744 EINA_LIST_FREE(r->waypoint, w)
1746 if (w->point) eina_stringshare_del(w->point);
1750 EINA_LIST_FREE(r->nodes, n)
1752 if (n->pos.address) eina_stringshare_del(n->pos.address);
1756 EINA_LIST_FREE(r->handlers, h)
1758 ecore_event_handler_del(h);
1761 if (r->con_url) ecore_con_url_free(r->con_url);
1762 if (r->info.nodes) eina_stringshare_del(r->info.nodes);
1763 if (r->info.waypoints) eina_stringshare_del(r->info.waypoints);
1766 EINA_LIST_FREE(wd->names, na)
1768 if (na->address) free(na->address);
1769 if (na->handler) ecore_event_handler_del(na->handler);
1772 ecore_file_remove(na->ud.fname);
1774 na->ud.fname = NULL;
1778 EINA_LIST_FREE(wd->track, route)
1780 evas_object_del(route);
1783 if (wd->map) evas_map_free(wd->map);
1784 if (wd->source_names) free(wd->source_names);
1785 if (wd->calc_job) ecore_job_del(wd->calc_job);
1786 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1787 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
1788 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1789 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
1790 if (wd->ua) eina_hash_free(wd->ua);
1791 if (wd->markers) free(wd->markers);
1797 _del_pre_hook(Evas_Object *obj)
1799 ELM_CHECK_WIDTYPE(obj, widtype);
1800 Widget_Data *wd = elm_widget_data_get(obj);
1801 Marker_Group *group;
1802 Elm_Map_Marker *marker;
1804 Eina_Bool free_marker = EINA_TRUE;
1808 grid_clear_all(obj);
1809 for (i = 0; i <= wd->zoom_max; i++)
1811 if (!wd->markers[i]) continue;
1812 Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
1813 Eina_Matrixsparse_Cell *cell;
1815 EINA_ITERATOR_FOREACH(it, cell)
1817 l = eina_matrixsparse_cell_data_get(cell);
1818 EINA_LIST_FREE(l, group)
1820 EINA_LIST_FREE(group->markers, marker)
1822 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1823 _bubble_sc_hints_changed_cb, group);
1824 if (free_marker) free(marker);
1828 free_marker = EINA_FALSE;
1830 eina_iterator_free(it);
1831 eina_matrixsparse_free(wd->markers[i]);
1834 evas_object_del(wd->sep_maps_markers);
1835 evas_object_del(wd->pan_smart);
1836 wd->pan_smart = NULL;
1840 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
1842 ELM_CHECK_WIDTYPE(obj, widtype);
1843 Widget_Data *wd = elm_widget_data_get(obj);
1846 if (elm_widget_focus_get(obj))
1848 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
1849 evas_object_focus_set(wd->obj, EINA_TRUE);
1853 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
1854 evas_object_focus_set(wd->obj, EINA_FALSE);
1859 _theme_hook(Evas_Object *obj)
1861 ELM_CHECK_WIDTYPE(obj, widtype);
1862 Widget_Data *wd = elm_widget_data_get(obj);
1865 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
1866 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
1871 _sizing_eval(Evas_Object *obj)
1873 ELM_CHECK_WIDTYPE(obj, widtype);
1874 Widget_Data *wd = elm_widget_data_get(obj);
1875 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
1878 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
1879 evas_object_size_hint_min_set(obj, minw, minh);
1880 evas_object_size_hint_max_set(obj, maxw, maxh);
1884 _calc_job(void *data)
1886 Widget_Data *wd = data;
1887 Evas_Coord minw, minh;
1894 wd->resized = EINA_FALSE;
1895 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
1897 double tz = wd->zoom;
1899 elm_map_zoom_set(wd->obj, tz);
1902 if ((minw != wd->minw) || (minh != wd->minh))
1906 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
1907 _sizing_eval(wd->obj);
1909 wd->calc_job = NULL;
1910 evas_object_smart_changed(wd->pan_smart);
1914 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1916 Pan *sd = evas_object_smart_data_get(obj);
1918 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1921 evas_object_smart_changed(obj);
1925 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1927 Pan *sd = evas_object_smart_data_get(obj);
1929 if (x) *x = sd->wd->pan_x;
1930 if (y) *y = sd->wd->pan_y;
1934 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1936 Pan *sd = evas_object_smart_data_get(obj);
1939 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1940 ow = sd->wd->minw - ow;
1942 oh = sd->wd->minh - oh;
1949 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
1956 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
1958 Pan *sd = evas_object_smart_data_get(obj);
1960 if (w) *w = sd->wd->minw;
1961 if (h) *h = sd->wd->minh;
1965 _pan_add(Evas_Object *obj)
1968 Evas_Object_Smart_Clipped_Data *cd;
1970 cd = evas_object_smart_data_get(obj);
1972 sd = calloc(1, sizeof(Pan));
1974 sd->__clipped_data = *cd;
1976 evas_object_smart_data_set(obj, sd);
1980 _pan_del(Evas_Object *obj)
1982 Pan *sd = evas_object_smart_data_get(obj);
1988 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
1990 Pan *sd = evas_object_smart_data_get(obj);
1993 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1994 if ((ow == w) && (oh == h)) return;
1995 sd->wd->resized = EINA_TRUE;
1996 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1997 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2001 _pan_calculate(Evas_Object *obj)
2003 Pan *sd = evas_object_smart_data_get(obj);
2004 Evas_Coord ox, oy, ow, oh;
2008 EINA_SAFETY_ON_NULL_RETURN(sd);
2009 EINA_SAFETY_ON_NULL_RETURN(sd->wd);
2011 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2012 rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2013 EINA_LIST_FOREACH(sd->wd->grids, l, g)
2015 if (sd->wd->zoom == g->zoom) grid_load(sd->wd->obj, g);
2016 else if (sd->wd->zoom-1 != g->zoom && sd->wd->zoom+1 != g->zoom) grid_unload(sd->wd->obj, g); // remain only adjacent grids
2017 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2018 if (sd->wd->zoom == g->zoom) marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2019 if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2020 if (!sd->wd->zoom_animator) track_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2025 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2027 Pan *sd = evas_object_smart_data_get(obj);
2029 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2030 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2034 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2036 ELM_CHECK_WIDTYPE(obj, widtype);
2037 Widget_Data *wd = elm_widget_data_get(obj);
2040 elm_smart_scroller_hold_set(wd->scr, 1);
2044 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2046 ELM_CHECK_WIDTYPE(obj, widtype);
2047 Widget_Data *wd = elm_widget_data_get(obj);
2050 elm_smart_scroller_hold_set(wd->scr, 0);
2054 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2056 ELM_CHECK_WIDTYPE(obj, widtype);
2057 Widget_Data *wd = elm_widget_data_get(obj);
2060 elm_smart_scroller_freeze_set(wd->scr, 1);
2064 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2066 ELM_CHECK_WIDTYPE(obj, widtype);
2067 Widget_Data *wd = elm_widget_data_get(obj);
2070 elm_smart_scroller_freeze_set(wd->scr, 0);
2074 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2076 evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
2080 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2082 evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
2086 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2088 Widget_Data *wd = elm_widget_data_get(data);
2089 EINA_SAFETY_ON_NULL_RETURN(wd);
2090 wd->center_on.enabled = EINA_FALSE;
2092 // FIXME: els_scoller sometimes give start event again & again... it confuses app. (els_scr bug?)
2093 if (!wd->scr_started)
2095 wd->scr_started = EINA_TRUE;
2096 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2101 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2103 Widget_Data *wd = elm_widget_data_get(data);
2104 EINA_SAFETY_ON_NULL_RETURN(wd);
2105 wd->center_on.enabled = EINA_FALSE;
2107 // FIXME: els_scoller sometimes give start event again & again... it confuses app. (els_scr bug?)
2108 if (wd->scr_started)
2110 wd->scr_started = EINA_FALSE;
2111 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2116 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2118 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
2123 _group_object_create(Marker_Group *group)
2125 const char *style = "radio";
2126 Evas_Object *icon = NULL;
2128 if (group->obj) return;
2129 if ((!group->clas->priv.objs_notused) || (eina_list_count(group->markers) == 1))
2131 //set icon and style
2132 if (eina_list_count(group->markers) == 1)
2134 Elm_Map_Marker *m = eina_list_data_get(group->markers);
2136 style = m->clas->style;
2138 if (m->clas->func.icon_get)
2139 icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
2141 group->delete_object = EINA_TRUE;
2145 if (group->clas->style)
2146 style = group->clas->style;
2148 if (group->clas->func.icon_get)
2149 icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
2151 group->delete_object = EINA_FALSE;
2154 group->obj = elm_layout_add(group->wd->obj);
2155 elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
2157 if (icon) elm_object_part_content_set(group->obj, "elm.icon", icon);
2159 evas_object_smart_member_add(group->obj, group->wd->pan_smart);
2160 elm_widget_sub_object_add(group->wd->obj, group->obj);
2161 evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
2163 if (!group->delete_object)
2164 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2168 group->delete_object = EINA_FALSE;
2170 group->obj = eina_list_data_get(group->clas->priv.objs_notused);
2171 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2172 group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
2173 evas_object_show(group->obj);
2176 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
2177 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
2179 group->update_nbelems = EINA_TRUE;
2180 group->update_resize = EINA_TRUE;
2181 group->update_raise = EINA_TRUE;
2183 if (group->open) _group_bubble_create(group);
2187 _group_object_free(Marker_Group *group)
2189 if (!group->obj) return;
2190 if (!group->delete_object)
2192 group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
2193 group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
2194 evas_object_hide(group->obj);
2196 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
2197 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
2200 evas_object_del(group->obj);
2203 _group_bubble_free(group);
2207 _group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2209 Marker_Group *group = data;
2211 if (!evas_object_above_get(group->rect)) return;
2212 evas_object_raise(group->bubble);
2213 evas_object_raise(group->sc);
2214 evas_object_raise(group->rect);
2218 _group_bubble_create(Marker_Group *group)
2220 if (group->bubble) return;
2222 group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
2223 group->bubble = edje_object_add(evas_object_evas_get(group->obj));
2224 _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
2225 elm_widget_style_get(group->wd->obj));
2226 evas_object_smart_member_add(group->bubble,
2228 elm_widget_sub_object_add(group->wd->obj, group->bubble);
2230 _group_bubble_content_free(group);
2231 if (!_group_bubble_content_update(group))
2233 //no content, we can delete the bubble
2234 _group_bubble_free(group);
2238 group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
2239 evas_object_color_set(group->rect, 0, 0, 0, 0);
2240 evas_object_repeat_events_set(group->rect, EINA_TRUE);
2241 evas_object_smart_member_add(group->rect, group->wd->obj);
2242 elm_widget_sub_object_add(group->wd->obj, group->rect);
2244 evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
2246 _group_bubble_place(group);
2249 static void _bubble_sc_hints_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2251 _group_bubble_place(data);
2255 _group_bubble_content_update(Marker_Group *group)
2258 Elm_Map_Marker *marker;
2261 if (!group->bubble) return 1;
2265 group->sc = elm_scroller_add(group->bubble);
2266 elm_widget_style_set(group->sc, "map_bubble");
2267 elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
2268 elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
2269 elm_scroller_bounce_set(group->sc, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
2270 edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
2271 evas_object_show(group->sc);
2272 evas_object_smart_member_add(group->sc,
2274 elm_widget_sub_object_add(group->wd->obj, group->sc);
2276 group->bx = elm_box_add(group->bubble);
2277 evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2278 evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
2279 elm_box_horizontal_set(group->bx, EINA_TRUE);
2280 evas_object_show(group->bx);
2282 elm_object_content_set(group->sc, group->bx);
2284 evas_object_event_callback_add(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2285 _bubble_sc_hints_changed_cb, group);
2288 EINA_LIST_FOREACH(group->markers, l, marker)
2290 if (i >= group->wd->markers_max_num) break;
2291 if ((!marker->content) && (marker->clas->func.get))
2292 marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
2293 else if (marker->content)
2294 elm_box_unpack(group->bx, marker->content);
2295 if (marker->content)
2297 elm_box_pack_end(group->bx, marker->content);
2305 _group_bubble_content_free(Marker_Group *group)
2308 Elm_Map_Marker *marker;
2310 if (!group->sc) return;
2311 EINA_LIST_FOREACH(group->markers, l, marker)
2313 if ((marker->content) && (marker->clas->func.del))
2314 marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
2315 else if (marker->content)
2316 evas_object_del(marker->content);
2317 marker->content = NULL;
2319 evas_object_del(group->sc);
2324 _group_bubble_free(Marker_Group *group)
2326 if (!group->bubble) return;
2327 group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
2328 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2329 _bubble_sc_hints_changed_cb, group);
2330 evas_object_del(group->bubble);
2331 evas_object_del(group->rect);
2332 group->bubble = NULL;
2333 _group_bubble_content_free(group);
2337 _group_bubble_place(Marker_Group *group)
2340 Evas_Coord xx, yy, ww, hh;
2343 if ((!group->bubble) || (!group->obj)) return;
2345 evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
2346 edje_object_size_min_calc(group->bubble, NULL, &hh);
2348 s = edje_object_data_get(group->bubble, "size_w");
2349 if (s) ww = atoi(s);
2351 xx = x + w / 2 - ww / 2;
2354 evas_object_move(group->bubble, xx, yy);
2355 evas_object_resize(group->bubble, ww, hh);
2356 obj_rotate_zoom(group->wd, group->bubble);
2357 evas_object_show(group->bubble);
2359 evas_object_move(group->rect, xx, yy);
2360 evas_object_resize(group->rect, ww, hh);
2361 obj_rotate_zoom(group->wd, group->rect);
2362 evas_object_show(group->rect);
2366 _group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2368 Marker_Group *group = data;
2369 Elm_Map_Marker *marker = eina_list_data_get(group->markers);
2370 if (!marker) return;
2371 group->bringin = EINA_TRUE;
2372 elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
2376 _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2378 Marker_Group *group = data;
2382 group->bringin = EINA_FALSE;
2388 group->open = EINA_FALSE;
2389 _group_bubble_free(group);
2392 group->open = EINA_TRUE;
2393 _group_bubble_create(group);
2397 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
2399 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2400 Widget_Data *wd = elm_widget_data_get(obj);
2404 Evas_Coord step_x = 0;
2405 Evas_Coord step_y = 0;
2408 Evas_Coord page_x = 0;
2409 Evas_Coord page_y = 0;
2411 if (!wd) return EINA_FALSE;
2412 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
2413 Evas_Event_Key_Down *ev = event_info;
2414 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
2416 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
2417 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
2418 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
2419 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
2421 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
2425 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
2429 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
2433 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
2437 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
2440 y -= -(page_y * v_h) / 100;
2444 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
2447 y += -(page_y * v_h) / 100;
2451 else if (!strcmp(ev->keyname, "KP_Add"))
2453 zoom = elm_map_zoom_get(obj) + 1;
2454 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2455 elm_map_zoom_set(obj, zoom);
2458 else if (!strcmp(ev->keyname, "KP_Subtract"))
2460 zoom = elm_map_zoom_get(obj) - 1;
2461 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2462 elm_map_zoom_set(obj, zoom);
2465 else return EINA_FALSE;
2467 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2468 elm_smart_scroller_child_pos_set(wd->scr, x, y);
2474 cb_dump_name_attrs(void *data, const char *key, const char *value)
2476 Name_Dump *dump = (Name_Dump*)data;
2477 if (!dump) return EINA_FALSE;
2479 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
2480 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
2487 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2489 Route_Dump *dump = data;
2490 if (!dump) return EINA_FALSE;
2494 case EINA_SIMPLE_XML_OPEN:
2495 case EINA_SIMPLE_XML_OPEN_EMPTY:
2499 attrs = eina_simple_xml_tag_attributes_find(value, length);
2502 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
2503 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
2504 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
2505 else dump->id = ROUTE_XML_NONE;
2509 case EINA_SIMPLE_XML_DATA:
2511 char *buf = malloc(length);
2512 if (!buf) return EINA_FALSE;
2513 snprintf(buf, length, "%s", value);
2514 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
2515 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2516 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2528 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2530 Name_Dump *dump = data;
2531 if (!dump) return EINA_FALSE;
2535 case EINA_SIMPLE_XML_OPEN:
2536 case EINA_SIMPLE_XML_OPEN_EMPTY:
2539 attrs = eina_simple_xml_tag_attributes_find(value, length);
2542 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME;
2543 else dump->id = NAME_XML_NONE;
2545 eina_simple_xml_attributes_parse
2546 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
2550 case EINA_SIMPLE_XML_DATA:
2552 char *buf = malloc(length + 1);
2553 if (!buf) return EINA_FALSE;
2554 snprintf(buf, length + 1, "%s", value);
2555 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2567 _parse_kml(void *data)
2569 Elm_Map_Route *r = (Elm_Map_Route*)data;
2570 if (!r || !r->ud.fname) return;
2574 unsigned int ele, idx;
2578 Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL};
2580 f = fopen(r->ud.fname, "rb");
2585 fseek(f, 0, SEEK_END);
2591 fseek(f, 0, SEEK_SET);
2595 if (fread(buf, 1, sz, f))
2597 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump);
2604 if (dump.distance) r->info.distance = dump.distance;
2605 if (dump.description)
2607 eina_stringshare_replace(&r->info.waypoints, dump.description);
2608 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2609 r->info.waypoint_count = ele;
2610 for (idx = 0 ; idx < ele ; idx++)
2612 Path_Waypoint *wp = ELM_NEW(Path_Waypoint);
2616 wp->point = eina_stringshare_add(str[idx]);
2617 DBG("%s", str[idx]);
2618 r->waypoint = eina_list_append(r->waypoint, wp);
2627 else WRN("description is not found !");
2629 if (dump.coordinates)
2631 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2632 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2633 r->info.node_count = ele;
2634 for (idx = 0 ; idx < ele ; idx++)
2636 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2637 Path_Node *n = ELM_NEW(Path_Node);
2644 DBG("%lf:%lf", lon, lat);
2645 n->pos.address = NULL;
2646 r->nodes = eina_list_append(r->nodes, n);
2648 path = evas_object_polygon_add(evas_object_evas_get(r->wd->obj));
2649 evas_object_smart_member_add(path, r->wd->pan_smart);
2650 r->path = eina_list_append(r->path, path);
2663 _parse_name(void *data)
2665 Elm_Map_Name *n = (Elm_Map_Name*)data;
2666 if (!n || !n->ud.fname) return;
2670 Name_Dump dump = {0, NULL, 0.0, 0.0};
2672 f = fopen(n->ud.fname, "rb");
2677 fseek(f, 0, SEEK_END);
2683 fseek(f, 0, SEEK_SET);
2687 if (fread(buf, 1, sz, f))
2689 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
2698 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
2699 n->address = strdup(dump.address);
2706 Grid *_get_current_grid(Widget_Data *wd)
2708 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2710 Grid *g = NULL, *ret = NULL;
2711 EINA_LIST_FOREACH(wd->grids, l, g)
2713 if (wd->zoom == g->zoom)
2723 _route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
2725 Ecore_Con_Event_Url_Complete *ev = event;
2726 Elm_Map_Route *r = (Elm_Map_Route*)data;
2727 Widget_Data *wd = r->wd;
2729 if ((!r) || (!ev)) return EINA_TRUE;
2730 Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url);
2731 ecore_con_url_data_set(r->con_url, NULL);
2732 if (r!=rr) return EINA_TRUE;
2734 if (r->ud.fd) fclose(r->ud.fd);
2740 Evas_Coord ox, oy, ow, oh;
2741 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
2742 g = _get_current_grid(wd);
2743 route_place(wd->obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
2745 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2746 "elm,state,busy,stop", "elm");
2747 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
2752 _name_complete_cb(void *data, int ev_type __UNUSED__, void *event)
2754 Ecore_Con_Event_Url_Complete *ev = event;
2755 Elm_Map_Name *n = (Elm_Map_Name*)data;
2756 Widget_Data *wd = n->wd;
2758 if ((!n) || (!ev)) return EINA_TRUE;
2759 Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url);
2760 ecore_con_url_data_set(n->con_url, NULL);
2761 if (n!=nn) return EINA_TRUE;
2763 if (n->ud.fd) fclose(n->ud.fd);
2766 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2767 "elm,state,busy,stop", "elm");
2768 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
2772 static Elm_Map_Name *
2773 _utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat)
2775 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2776 Widget_Data *wd = elm_widget_data_get(obj);
2781 if ((!wd) || (!wd->src)) return NULL;
2782 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
2783 if (!name) return NULL;
2785 snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE);
2793 name->con_url = ecore_con_url_new(NULL);
2794 name->ud.fname = strdup(buf);
2795 INF("xml file : %s", name->ud.fname);
2797 name->ud.fd = fdopen(fd, "w+");
2798 if ((!name->con_url) || (!name->ud.fd))
2800 ecore_con_url_free(name->con_url);
2806 name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name);
2807 name->method = method;
2808 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
2809 else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL;
2813 source = wd->src->name_url_cb(wd->obj, method, address, lon, lat);
2814 INF("name url = %s", source);
2816 wd->names = eina_list_append(wd->names, name);
2817 ecore_con_url_url_set(name->con_url, source);
2818 ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd));
2819 ecore_con_url_data_set(name->con_url, name);
2821 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2822 "elm,state,busy,start", "elm");
2823 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL);
2824 ecore_con_url_get(name->con_url);
2825 if (source) free(source);
2831 static Evas_Event_Flags
2832 zoom_start_cb(void *data, void *event_info __UNUSED__)
2834 Widget_Data *wd = data;
2835 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
2837 // FIXME: scroller can be jumping strangely when resizing & scrolling at the sametime (els_scr bug?)
2838 elm_smart_scroller_hold_set(wd->scr, 1);
2839 elm_smart_scroller_freeze_set(wd->scr, 1);
2840 _scr_drag_start(wd->obj, NULL, NULL);
2842 wd->pinch.diff += 0.001;
2844 return EVAS_EVENT_FLAG_NONE;
2847 static Evas_Event_Flags
2848 zoom_end_cb(void *data, void *event_info __UNUSED__)
2850 Widget_Data *wd = data;
2851 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
2853 // FIXME: scroller can be jumping strangely when resizing & scrolling at the sametime (els_scr bug?)
2854 elm_smart_scroller_hold_set(wd->scr, 0);
2855 elm_smart_scroller_freeze_set(wd->scr, 0);
2856 _scr_drag_stop(wd->obj, NULL, NULL);
2858 wd->pinch.diff = wd->pinch.level;
2860 return EVAS_EVENT_FLAG_NONE;
2863 static Evas_Event_Flags
2864 zoom_cb(void *data, void *event_info)
2866 Widget_Data *wd = data;
2867 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
2873 Elm_Gesture_Zoom_Info *ei = event_info;
2874 evas_object_geometry_get(wd->obj, &x, &y, &w, &h);
2876 wd->pinch.level = wd->pinch.diff * ei->zoom;
2877 wd->pinch.cx = x + ((double)w * 0.5);
2878 wd->pinch.cy = y + ((double)h * 0.5);
2880 if (wd->pinch.level > 1.999 || wd->pinch.level < 1.001)
2882 if (wd->pinch.level > 1.999)
2885 wd->pinch.diff = wd->pinch.level / 2.0;
2886 wd->pinch.level = wd->pinch.level / 2.0;
2888 else if (wd->pinch.level < 1.001)
2891 wd->pinch.diff = wd->pinch.level * 2.0;
2892 wd->pinch.level = wd->pinch.level * 2.0;
2894 Elm_Map_Zoom_Mode temp;
2895 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_MOVE, NULL, wd); // ei->zoom is refreshed
2897 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
2898 wd->paused = EINA_TRUE;
2899 elm_map_zoom_set(wd->obj, wd->zoom + zoom_diff);
2900 wd->paused = EINA_FALSE;
2902 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_MOVE, zoom_cb, wd); // ei->zoom is refreshed
2906 if (wd->calc_job) ecore_job_del(wd->calc_job);
2907 wd->calc_job = ecore_job_add(_calc_job, wd);
2909 evas_object_smart_callback_call(wd->obj, SIG_ZOOM_CHANGE, NULL);
2912 // FIXME: scroller can be jumping strangely when resizing & scrolling at the sametime (els_scr bug?)
2913 _scr_scroll(wd->obj, NULL, NULL);
2915 return EVAS_EVENT_FLAG_NONE;
2918 static Evas_Event_Flags
2919 rotate_cb(void *data, void *event_info)
2921 Widget_Data *wd = data;
2922 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
2927 Elm_Gesture_Rotate_Info *ei = event_info;
2928 evas_object_geometry_get(wd->obj, &x, &y, &w, &h);
2930 wd->rotate.d = wd->rotate.a + (ei->base_angle-ei->angle)*50;
2931 wd->rotate.cx = x + ((double)w * 0.5);
2932 wd->rotate.cy = y + ((double)h * 0.5);
2934 if (wd->calc_job) ecore_job_del(wd->calc_job);
2935 wd->calc_job = ecore_job_add(_calc_job, wd);
2937 return EVAS_EVENT_FLAG_NONE;
2940 static Evas_Event_Flags
2941 rotate_end_cb(void *data, void *event_info __UNUSED__)
2943 Widget_Data *wd = data;
2944 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
2946 wd->rotate.a = wd->rotate.d;
2948 return EVAS_EVENT_FLAG_NONE;
2954 elm_map_add(Evas_Object *parent)
2956 #ifdef HAVE_ELEMENTARY_ECORE_CON
2959 Evas_Coord minw, minh;
2961 static Evas_Smart *smart = NULL;
2962 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
2964 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
2966 ELM_SET_WIDTYPE(widtype, "map");
2967 elm_widget_type_set(obj, "map");
2968 elm_widget_sub_object_add(parent, obj);
2969 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2970 elm_widget_data_set(obj, wd);
2971 elm_widget_del_hook_set(obj, _del_hook);
2972 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2973 elm_widget_theme_hook_set(obj, _theme_hook);
2974 elm_widget_can_focus_set(obj, EINA_TRUE);
2975 elm_widget_event_hook_set(obj, _event_hook);
2977 wd->scr = elm_smart_scroller_add(e);
2978 elm_smart_scroller_widget_set(wd->scr, obj);
2979 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
2980 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
2981 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
2982 elm_widget_resize_object_set(obj, wd->scr);
2983 elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE);
2985 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
2986 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
2987 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
2988 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
2989 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
2991 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
2993 wd->zoom_min = 0xFF;
2994 wd->zoom_max = 0X00;
2998 wd->map = evas_map_new(4);
2999 if (!wd->map) return NULL;
3001 wd->markers_max_num = 30;
3002 wd->pinch.level = 1.0;
3003 wd->pinch.diff = 1.0;
3004 wd->markers = calloc(wd->zoom_max + 1, sizeof(void*));
3006 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3007 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3008 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3009 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3013 static Evas_Smart_Class sc;
3015 evas_object_smart_clipped_smart_set(&_pan_sc);
3017 sc.name = "elm_map_pan";
3018 sc.version = EVAS_SMART_CLASS_VERSION;
3021 sc.resize = _pan_resize;
3022 sc.move = _pan_move;
3023 sc.calculate = _pan_calculate;
3024 smart = evas_smart_class_new(&sc);
3028 wd->pan_smart = evas_object_smart_add(e, smart);
3029 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3033 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3034 _pan_set, _pan_get, _pan_max_get,
3035 _pan_min_get, _pan_child_size_get);
3037 wd->rect = evas_object_rectangle_add(e);
3038 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_RESIZE,
3039 _rect_resize_cb, obj);
3040 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
3042 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
3044 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL,
3045 _mouse_wheel_cb, obj);
3047 evas_object_smart_member_add(wd->rect, wd->pan_smart);
3048 elm_widget_sub_object_add(obj, wd->rect);
3049 evas_object_show(wd->rect);
3050 evas_object_color_set(wd->rect, 0, 0, 0, 0);
3052 wd->ges = elm_gesture_layer_add(obj);
3053 if (!wd->ges) ERR("elm_gesture_layer_add() failed");
3054 elm_gesture_layer_attach(wd->ges, wd->rect);
3055 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_START,
3057 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_MOVE,
3059 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_END,
3061 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_ABORT,
3063 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_MOVE,
3065 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_END,
3067 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_ABORT,
3070 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
3071 wd->id = ((int)getpid() << 16) | idnum;
3075 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3077 evas_object_size_hint_min_set(obj, minw, minh);
3079 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
3080 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
3082 grid_create_all(obj);
3084 wd->paused = EINA_TRUE;
3085 elm_map_zoom_set(obj, 0);
3086 wd->paused = EINA_FALSE;
3089 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3090 // TODO: and save some bytes, making descriptions per-class and not instance!
3091 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3093 if (!ecore_file_download_protocol_available("http://"))
3095 ERR("Ecore must be built with curl support for the map widget!");
3106 elm_map_zoom_set(Evas_Object *obj, int zoom)
3108 #ifdef HAVE_ELEMENTARY_ECORE_CON
3109 ELM_CHECK_WIDTYPE(obj, widtype);
3110 Widget_Data *wd = elm_widget_data_get(obj);
3112 Evas_Coord rx, ry, rw, rh;
3118 EINA_SAFETY_ON_NULL_RETURN(wd);
3119 EINA_SAFETY_ON_NULL_RETURN(wd->src);
3120 if (wd->zoom_animator) return;
3122 if (zoom < 0) zoom = 0;
3123 if (zoom > wd->src->zoom_max) zoom = wd->src->zoom_max;
3124 if (zoom < wd->src->zoom_min) zoom = wd->src->zoom_min;
3126 if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT;
3127 else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN;
3128 else wd->zoom_method = ZOOM_METHOD_NONE;
3131 wd->size.ow = wd->size.w;
3132 wd->size.oh = wd->size.h;
3133 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
3134 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3136 EINA_LIST_FOREACH(wd->route, l, r)
3140 EINA_LIST_FOREACH(r->path, l, p)
3142 evas_object_polygon_points_clear(p);
3147 EINA_LIST_FOREACH(wd->track, l, route)
3149 evas_object_hide(route);
3152 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3159 while (cumulw <= rw)
3168 while (cumulh <= rh)
3175 if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3177 if (p2w < p2h) z = p2w;
3180 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3182 if (p2w > p2h) z = p2w;
3188 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3189 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3192 if ((wd->size.w > 0) && (wd->size.h > 0))
3194 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow;
3195 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.oh;
3199 wd->size.spos.x = 0.5;
3200 wd->size.spos.y = 0.5;
3203 if (rw > wd->size.ow) wd->size.spos.x = 0.5;
3204 if (rh > wd->size.oh) wd->size.spos.y = 0.5;
3205 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
3206 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
3214 if (!wd->zoom_animator)
3216 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
3218 if (wd->nosmooth == 1) _smooth_update(obj);
3219 evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
3223 if (wd->zoom_method != ZOOM_METHOD_NONE) evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
3231 elm_map_zoom_get(const Evas_Object *obj)
3233 #ifdef HAVE_ELEMENTARY_ECORE_CON
3234 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3235 Widget_Data *wd = elm_widget_data_get(obj);
3246 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
3248 #ifdef HAVE_ELEMENTARY_ECORE_CON
3249 ELM_CHECK_WIDTYPE(obj, widtype);
3250 Widget_Data *wd = elm_widget_data_get(obj);
3253 if (wd->mode == mode) return;
3256 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3260 elm_map_zoom_set(wd->obj, tz);
3268 EAPI Elm_Map_Zoom_Mode
3269 elm_map_zoom_mode_get(const Evas_Object *obj)
3271 #ifdef HAVE_ELEMENTARY_ECORE_CON
3272 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
3273 Widget_Data *wd = elm_widget_data_get(obj);
3275 if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
3279 return ELM_MAP_ZOOM_MODE_MANUAL;
3284 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
3286 #ifdef HAVE_ELEMENTARY_ECORE_CON
3287 ELM_CHECK_WIDTYPE(obj, widtype);
3288 Widget_Data *wd = elm_widget_data_get(obj);
3292 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3293 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3298 if (wd->zoom_animator)
3301 if (!wd->nosmooth) _smooth_update(obj);
3302 ecore_animator_del(wd->zoom_animator);
3303 wd->zoom_animator = NULL;
3305 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3307 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
3309 wd->center_on.enabled = EINA_TRUE;
3310 wd->center_on.lon = lon;
3311 wd->center_on.lat = lat;
3320 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
3322 #ifdef HAVE_ELEMENTARY_ECORE_CON
3323 ELM_CHECK_WIDTYPE(obj, widtype);
3324 Widget_Data *wd = elm_widget_data_get(obj);
3328 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3329 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3334 if (wd->zoom_animator)
3337 ecore_animator_del(wd->zoom_animator);
3338 wd->zoom_animator = NULL;
3340 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3342 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
3344 wd->center_on.enabled = EINA_TRUE;
3345 wd->center_on.lon = lon;
3346 wd->center_on.lat = lat;
3355 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
3357 #ifdef HAVE_ELEMENTARY_ECORE_CON
3358 ELM_CHECK_WIDTYPE(obj, widtype);
3359 Widget_Data *wd = elm_widget_data_get(obj);
3360 Evas_Coord sx, sy, sw, sh;
3363 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
3364 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
3365 if (wd->size.w < sw) sw = wd->size.w;
3366 if (wd->size.h < sh) sh = wd->size.h;
3370 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
3379 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
3381 #ifdef HAVE_ELEMENTARY_ECORE_CON
3382 ELM_CHECK_WIDTYPE(obj, widtype);
3383 Widget_Data *wd = elm_widget_data_get(obj);
3386 if (wd->paused == !!paused) return;
3387 wd->paused = !!paused;
3390 if (wd->zoom_animator)
3392 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
3393 wd->zoom_animator = NULL;
3395 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3397 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3398 "elm,state,busy,stop", "elm");
3402 if (wd->download_num >= 1)
3403 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3404 "elm,state,busy,start", "elm");
3413 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
3415 #ifdef HAVE_ELEMENTARY_ECORE_CON
3416 ELM_CHECK_WIDTYPE(obj, widtype);
3417 Widget_Data *wd = elm_widget_data_get(obj);
3420 if (wd->paused_markers == !!paused) return;
3421 wd->paused_markers = paused;
3429 elm_map_paused_get(const Evas_Object *obj)
3431 #ifdef HAVE_ELEMENTARY_ECORE_CON
3432 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3433 Widget_Data *wd = elm_widget_data_get(obj);
3435 if (!wd) return EINA_FALSE;
3444 elm_map_paused_markers_get(const Evas_Object *obj)
3446 #ifdef HAVE_ELEMENTARY_ECORE_CON
3447 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3448 Widget_Data *wd = elm_widget_data_get(obj);
3450 if (!wd) return EINA_FALSE;
3451 return wd->paused_markers;
3459 elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
3461 #ifdef HAVE_ELEMENTARY_ECORE_CON
3462 ELM_CHECK_WIDTYPE(obj, widtype);
3463 Widget_Data *wd = elm_widget_data_get(obj);
3468 *try_num = wd->try_num;
3473 *finish_num = wd->finish_num;
3483 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
3485 #ifdef HAVE_ELEMENTARY_ECORE_CON
3486 ELM_CHECK_WIDTYPE(obj, widtype);
3487 Widget_Data *wd = elm_widget_data_get(obj);
3490 int zoom = floor(log(size / 256) / log(2));
3491 if ((wd->src) && (wd->src->coord_into_geo))
3493 if (wd->src->coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
3498 *lon = x / (double)size * 360.0 - 180;
3502 double n = ELM_PI - 2.0 * ELM_PI * y / size;
3503 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
3516 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
3518 #ifdef HAVE_ELEMENTARY_ECORE_CON
3519 ELM_CHECK_WIDTYPE(obj, widtype);
3520 Widget_Data *wd = elm_widget_data_get(obj);
3523 int zoom = floor(log(size / 256) / log(2));
3524 if ((wd->src) && (wd->src->geo_into_coord))
3526 if (wd->src->geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
3530 *x = floor((lon + 180.0) / 360.0 * size);
3532 *y = floor((1.0 - log( tan(lat * ELM_PI / 180.0) + 1.0 / cos(lat * ELM_PI / 180.0)) / ELM_PI) / 2.0 * size);
3544 elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat)
3546 #ifdef HAVE_ELEMENTARY_ECORE_CON
3547 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3548 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat);
3558 elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address)
3560 #ifdef HAVE_ELEMENTARY_ECORE_CON
3561 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3562 if (!address) return NULL;
3563 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0);
3572 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)
3574 #ifdef HAVE_ELEMENTARY_ECORE_CON
3575 if ((!xx) || (!yy)) return;
3577 double r = (degree * M_PI) / 180.0;
3578 double tx, ty, ttx, tty;
3585 tx = ttx + (ty * cos(r + M_PI_2));
3586 ty = tty + (ty * sin(r + M_PI_2));
3601 EAPI Elm_Map_Marker *
3602 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
3604 #ifdef HAVE_ELEMENTARY_ECORE_CON
3605 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3606 Widget_Data *wd = elm_widget_data_get(obj);
3609 Marker_Group *group;
3617 if (!wd) return NULL;
3618 EINA_SAFETY_ON_NULL_RETURN_VAL(clas_group, NULL);
3619 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, NULL);
3621 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
3624 marker->clas = clas;
3625 marker->clas_group = clas_group;
3626 marker->longitude = lon;
3627 marker->latitude = lat;
3628 marker->data = data;
3629 marker->x = calloc(wd->zoom_max + 1, sizeof(Evas_Coord));
3630 marker->y = calloc(wd->zoom_max + 1, sizeof(Evas_Coord));
3631 marker->groups = calloc(wd->zoom_max + 1, sizeof(Marker_Group*));
3633 tabi[1] = tabi[4] = tabi[6] = -1;
3634 tabi[2] = tabi[0] = tabi[7] = 0;
3635 tabi[3] = tabi[5] = tabi[8] = 1;
3637 tabj[1] = tabj[2] = tabj[3] = -1;
3638 tabj[4] = tabj[0] = tabj[5] = 0;
3639 tabj[6] = tabj[7] = tabj[8] = 1;
3641 if (!clas_group->priv.set)
3644 if (marker->clas_group && marker->clas_group->style)
3645 style = marker->clas_group->style;
3647 o = edje_object_add(evas_object_evas_get(obj));
3648 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3649 s = edje_object_data_get(o, "size_w");
3650 if (s) clas_group->priv.edje_w = atoi(s);
3651 else clas_group->priv.edje_w = 0;
3652 s = edje_object_data_get(o, "size_h");
3653 if (s) clas_group->priv.edje_h = atoi(s);
3654 else clas_group->priv.edje_h = 0;
3655 s = edje_object_data_get(o, "size_max_w");
3656 if (s) clas_group->priv.edje_max_w = atoi(s);
3657 else clas_group->priv.edje_max_w = 0;
3658 s = edje_object_data_get(o, "size_max_h");
3659 if (s) clas_group->priv.edje_max_h = atoi(s);
3660 else clas_group->priv.edje_max_h = 0;
3663 clas_group->priv.set = EINA_TRUE;
3666 if (!clas->priv.set)
3669 if (marker->clas && marker->clas->style)
3670 style = marker->clas->style;
3672 o = edje_object_add(evas_object_evas_get(obj));
3673 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3674 s = edje_object_data_get(o, "size_w");
3675 if (s) clas->priv.edje_w = atoi(s);
3676 else clas->priv.edje_w = 0;
3677 s = edje_object_data_get(o, "size_h");
3678 if (s) clas->priv.edje_h = atoi(s);
3679 else clas->priv.edje_h = 0;
3682 clas->priv.set = EINA_TRUE;
3685 for (i = clas_group->zoom_displayed; i <= wd->zoom_max; i++)
3687 elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
3688 &(marker->x[i]), &(marker->y[i]));
3690 //search in the matrixsparse the region where the marker will be
3691 mpi = marker->x[i] / wd->tsize;
3692 mpj = marker->y[i] / wd->tsize;
3694 if (!wd->markers[i])
3696 int size = pow(2.0, i);
3697 wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
3701 if (i <= clas_group->zoom_grouped)
3703 for (j = 0, group = NULL; j < 9 && !group; j++)
3705 EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
3708 if (group->clas == marker->clas_group
3709 && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
3710 marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
3711 group->x-group->w/4, group->y-group->h/4, group->w, group->h))
3713 group->markers = eina_list_append(group->markers, marker);
3714 group->update_nbelems = EINA_TRUE;
3715 group->update_resize = EINA_TRUE;
3717 group->sum_x += marker->x[i];
3718 group->sum_y += marker->y[i];
3719 group->x = group->sum_x / eina_list_count(group->markers);
3720 group->y = group->sum_y / eina_list_count(group->markers);
3722 group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
3723 * eina_list_count(group->markers);
3724 group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
3725 * eina_list_count(group->markers);
3726 if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
3727 if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
3729 if (group->obj && eina_list_count(group->markers) == 2)
3731 _group_object_free(group);
3732 _group_object_create(group);
3735 _group_bubble_content_update(group);
3744 group = calloc(1, sizeof(Marker_Group));
3746 group->sum_x = marker->x[i];
3747 group->sum_y = marker->y[i];
3748 group->x = marker->x[i];
3749 group->y = marker->y[i];
3750 group->w = clas_group->priv.edje_w;
3751 group->h = clas_group->priv.edje_h;
3752 group->clas = clas_group;
3754 group->markers = eina_list_append(group->markers, marker);
3755 group->update_nbelems = EINA_TRUE;
3756 group->update_resize = EINA_TRUE;
3758 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3762 l = eina_list_append(NULL, group);
3763 eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
3764 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3768 l = eina_matrixsparse_cell_data_get(group->cell);
3769 l = eina_list_append(l, group);
3770 eina_matrixsparse_cell_data_set(group->cell, l);
3773 marker->groups[i] = group;
3779 Evas_Coord ox, oy, ow, oh;
3780 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3781 g = _get_current_grid(wd);
3782 marker_place(obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3798 elm_map_marker_remove(Elm_Map_Marker *marker)
3800 #ifdef HAVE_ELEMENTARY_ECORE_CON
3805 EINA_SAFETY_ON_NULL_RETURN(marker);
3808 for (i = marker->clas_group->zoom_displayed; i <= wd->zoom_max; i++)
3810 marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
3811 if (!eina_list_count(marker->groups[i]->markers))
3813 groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
3814 groups = eina_list_remove(groups, marker->groups[i]);
3815 eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
3817 _group_object_free(marker->groups[i]);
3818 _group_bubble_free(marker->groups[i]);
3819 free(marker->groups[i]);
3823 marker->groups[i]->sum_x -= marker->x[i];
3824 marker->groups[i]->sum_y -= marker->y[i];
3826 marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
3827 marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
3829 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
3830 + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
3831 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
3832 + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
3833 if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
3834 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
3835 if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
3836 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
3838 if ((marker->groups[i]->obj) && (eina_list_count(marker->groups[i]->markers) == 1))
3840 _group_object_free(marker->groups[i]);
3841 _group_object_create(marker->groups[i]);
3846 if ((marker->content) && (marker->clas->func.del))
3847 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
3848 else if (marker->content)
3849 evas_object_del(marker->content);
3851 if (marker->x) free(marker->x);
3852 if (marker->y) free(marker->y);
3853 if (marker->groups) free(marker->groups);
3860 Evas_Coord ox, oy, ow, oh;
3861 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3862 g = _get_current_grid(wd);
3863 marker_place(wd->obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3871 elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat)
3873 #ifdef HAVE_ELEMENTARY_ECORE_CON
3874 EINA_SAFETY_ON_NULL_RETURN(marker);
3875 if (lon) *lon = marker->longitude;
3876 if (lat) *lat = marker->latitude;
3885 elm_map_marker_bring_in(Elm_Map_Marker *marker)
3887 #ifdef HAVE_ELEMENTARY_ECORE_CON
3888 EINA_SAFETY_ON_NULL_RETURN(marker);
3889 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
3896 elm_map_marker_show(Elm_Map_Marker *marker)
3898 #ifdef HAVE_ELEMENTARY_ECORE_CON
3899 EINA_SAFETY_ON_NULL_RETURN(marker);
3900 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
3907 elm_map_markers_list_show(Eina_List *markers)
3909 #ifdef HAVE_ELEMENTARY_ECORE_CON
3913 Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
3914 Evas_Coord rw, rh, xc, yc;
3917 EINA_SAFETY_ON_NULL_RETURN(markers);
3918 EINA_LIST_FOREACH(markers, l, marker)
3922 if ((!m_min_lon) || (marker->longitude < m_min_lon->longitude))
3925 if ((!m_max_lon) || (marker->longitude > m_max_lon->longitude))
3928 if ((!m_min_lat) || (marker->latitude > m_min_lat->latitude))
3931 if ((!m_max_lat) || (marker->latitude < m_max_lat->latitude))
3935 lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
3936 lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
3938 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3939 for (zoom = wd->src->zoom_max; zoom > wd->src->zoom_min; zoom--)
3941 Evas_Coord size = pow(2.0, zoom)*wd->tsize;
3942 elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
3944 if ((m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2)
3945 && (m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2)
3946 && (m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2)
3947 && (m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2))
3951 elm_map_geo_region_show(wd->obj, lon, lat);
3952 elm_map_zoom_set(wd->obj, zoom);
3959 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
3961 #ifdef HAVE_ELEMENTARY_ECORE_CON
3962 ELM_CHECK_WIDTYPE(obj, widtype);
3963 Widget_Data *wd = elm_widget_data_get(obj);
3966 wd->markers_max_num = max;
3974 elm_map_marker_object_get(const Elm_Map_Marker *marker)
3976 #ifdef HAVE_ELEMENTARY_ECORE_CON
3977 EINA_SAFETY_ON_NULL_RETURN_VAL(marker, NULL);
3978 return marker->content;
3986 elm_map_marker_update(Elm_Map_Marker *marker)
3988 #ifdef HAVE_ELEMENTARY_ECORE_CON
3989 EINA_SAFETY_ON_NULL_RETURN(marker);
3990 if (marker->content)
3992 if (marker->clas->func.del)
3993 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
3995 evas_object_del(marker->content);
3996 marker->content = NULL;
3997 _group_bubble_content_update(marker->groups[marker->wd->zoom]);
4005 elm_map_bubbles_close(Evas_Object *obj)
4007 #ifdef HAVE_ELEMENTARY_ECORE_CON
4008 ELM_CHECK_WIDTYPE(obj, widtype);
4009 Widget_Data *wd = elm_widget_data_get(obj);
4010 Marker_Group *group;
4011 Eina_List *l, *l_next;
4014 EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
4015 _group_bubble_free(group);
4021 EAPI Elm_Map_Group_Class *
4022 elm_map_group_class_new(Evas_Object *obj)
4024 #ifdef HAVE_ELEMENTARY_ECORE_CON
4025 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4026 Widget_Data *wd = elm_widget_data_get(obj);
4028 if (!wd) return NULL;
4029 Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
4030 clas->zoom_grouped = wd->zoom_max;
4031 wd->groups_clas = eina_list_append(wd->groups_clas, clas);
4040 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
4042 #ifdef HAVE_ELEMENTARY_ECORE_CON
4043 EINA_SAFETY_ON_NULL_RETURN(clas);
4044 eina_stringshare_replace(&clas->style, style);
4052 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
4054 #ifdef HAVE_ELEMENTARY_ECORE_CON
4055 EINA_SAFETY_ON_NULL_RETURN(clas);
4056 clas->func.icon_get = icon_get;
4064 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
4066 #ifdef HAVE_ELEMENTARY_ECORE_CON
4067 EINA_SAFETY_ON_NULL_RETURN(clas);
4076 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
4078 #ifdef HAVE_ELEMENTARY_ECORE_CON
4079 EINA_SAFETY_ON_NULL_RETURN(clas);
4080 clas->zoom_displayed = zoom;
4088 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
4090 #ifdef HAVE_ELEMENTARY_ECORE_CON
4091 EINA_SAFETY_ON_NULL_RETURN(clas);
4092 clas->zoom_grouped = zoom;
4100 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
4102 #ifdef HAVE_ELEMENTARY_ECORE_CON
4103 ELM_CHECK_WIDTYPE(obj, widtype);
4104 Widget_Data *wd = elm_widget_data_get(obj);
4107 EINA_SAFETY_ON_NULL_RETURN(clas);
4108 if (clas->hide == hide) return;
4113 Evas_Coord ox, oy, ow, oh;
4114 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
4115 g = _get_current_grid(wd);
4116 marker_place(obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4125 EAPI Elm_Map_Marker_Class *
4126 elm_map_marker_class_new(Evas_Object *obj)
4128 #ifdef HAVE_ELEMENTARY_ECORE_CON
4129 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4130 Widget_Data *wd = elm_widget_data_get(obj);
4132 if (!wd) return NULL;
4133 Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
4134 wd->markers_clas = eina_list_append(wd->markers_clas, clas);
4143 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
4145 #ifdef HAVE_ELEMENTARY_ECORE_CON
4146 EINA_SAFETY_ON_NULL_RETURN(clas);
4147 eina_stringshare_replace(&clas->style, style);
4155 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
4157 #ifdef HAVE_ELEMENTARY_ECORE_CON
4158 EINA_SAFETY_ON_NULL_RETURN(clas);
4159 clas->func.icon_get = icon_get;
4167 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
4169 #ifdef HAVE_ELEMENTARY_ECORE_CON
4170 EINA_SAFETY_ON_NULL_RETURN(clas);
4171 clas->func.get = get;
4179 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
4181 #ifdef HAVE_ELEMENTARY_ECORE_CON
4182 EINA_SAFETY_ON_NULL_RETURN(clas);
4183 clas->func.del = del;
4191 elm_map_source_names_get(const Evas_Object *obj)
4193 #ifdef HAVE_ELEMENTARY_ECORE_CON
4194 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4195 Widget_Data *wd = elm_widget_data_get(obj);
4197 if (!wd) return NULL;
4198 return wd->source_names;
4206 elm_map_source_name_set(Evas_Object *obj, const char *source_name)
4208 #ifdef HAVE_ELEMENTARY_ECORE_CON
4209 ELM_CHECK_WIDTYPE(obj, widtype);
4210 Widget_Data *wd = elm_widget_data_get(obj);
4218 if (!strcmp(wd->src->name, source_name)) return;
4219 if (!wd->src->url_cb) return;
4222 grid_clear_all(obj);
4223 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
4225 if (!strcmp(s->name, source_name))
4236 if (wd->src->zoom_max < zoom)
4237 zoom = wd->src->zoom_max;
4238 if (wd->src->zoom_min > zoom)
4239 zoom = wd->src->zoom_min;
4241 grid_create_all(obj);
4242 elm_map_zoom_set(obj, zoom);
4250 elm_map_source_name_get(const Evas_Object *obj)
4252 #ifdef HAVE_ELEMENTARY_ECORE_CON
4253 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4254 Widget_Data *wd = elm_widget_data_get(obj);
4256 if ((!wd) || (!wd->src)) return NULL;
4257 return wd->src->name;
4265 elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
4267 #ifdef HAVE_ELEMENTARY_ECORE_CON
4268 ELM_CHECK_WIDTYPE(obj, widtype);
4269 Widget_Data *wd = elm_widget_data_get(obj);
4272 wd->route_source = source;
4279 EAPI Elm_Map_Route_Sources
4280 elm_map_route_source_get(const Evas_Object *obj)
4282 #ifdef HAVE_ELEMENTARY_ECORE_CON
4283 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS;
4284 Widget_Data *wd = elm_widget_data_get(obj);
4286 if (!wd) return ELM_MAP_ROUTE_SOURCE_YOURS;
4287 return wd->route_source;
4290 return ELM_MAP_ROUTE_SOURCE_YOURS;
4295 elm_map_source_zoom_max_set(Evas_Object *obj, int zoom)
4297 #ifdef HAVE_ELEMENTARY_ECORE_CON
4298 ELM_CHECK_WIDTYPE(obj, widtype);
4299 Widget_Data *wd = elm_widget_data_get(obj);
4301 if ((!wd) || (!wd->src)) return;
4302 if ((zoom > wd->zoom_max) || (zoom < wd->zoom_min)) return;
4303 wd->src->zoom_max = zoom;
4311 elm_map_source_zoom_max_get(const Evas_Object *obj)
4313 #ifdef HAVE_ELEMENTARY_ECORE_CON
4314 ELM_CHECK_WIDTYPE(obj, widtype) 18;
4315 Widget_Data *wd = elm_widget_data_get(obj);
4317 if ((!wd) || (!wd->src)) return 18;
4318 return wd->src->zoom_max;
4326 elm_map_source_zoom_min_set(Evas_Object *obj, int zoom)
4328 #ifdef HAVE_ELEMENTARY_ECORE_CON
4329 ELM_CHECK_WIDTYPE(obj, widtype);
4330 Widget_Data *wd = elm_widget_data_get(obj);
4332 if ((!wd) || (!wd->src)) return;
4333 if ((zoom > wd->zoom_max) || (zoom < wd->zoom_min)) return;
4334 wd->src->zoom_min = zoom;
4342 elm_map_source_zoom_min_get(const Evas_Object *obj)
4344 #ifdef HAVE_ELEMENTARY_ECORE_CON
4345 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4346 Widget_Data *wd = elm_widget_data_get(obj);
4348 if ((!wd) || (!wd->src)) return 0;
4349 return wd->src->zoom_min;
4357 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
4359 #ifdef HAVE_ELEMENTARY_ECORE_CON
4360 ELM_CHECK_WIDTYPE(obj, widtype);
4361 Widget_Data *wd = elm_widget_data_get(obj);
4364 if (!wd->user_agent) wd->user_agent = eina_stringshare_add(user_agent);
4365 else eina_stringshare_replace(&wd->user_agent, user_agent);
4367 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4368 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4376 elm_map_user_agent_get(const Evas_Object *obj)
4378 #ifdef HAVE_ELEMENTARY_ECORE_CON
4379 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4380 Widget_Data *wd = elm_widget_data_get(obj);
4382 if (!wd) return NULL;
4383 return wd->user_agent;
4390 EAPI Elm_Map_Route *
4391 elm_map_route_add(Evas_Object *obj,
4392 Elm_Map_Route_Type type,
4393 Elm_Map_Route_Method method,
4399 #ifdef HAVE_ELEMENTARY_ECORE_CON
4400 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4401 Widget_Data *wd = elm_widget_data_get(obj);
4404 char *type_name = NULL;
4407 if ((!wd) || (!wd->src)) return NULL;
4409 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4410 if (!route) return NULL;
4412 snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE);
4420 route->con_url = ecore_con_url_new(NULL);
4421 route->ud.fname = strdup(buf);
4422 INF("xml file : %s", route->ud.fname);
4424 route->ud.fd = fdopen(fd, "w+");
4425 if ((!route->con_url) || (!route->ud.fd))
4427 ecore_con_url_free(route->con_url);
4433 route->color.r = 255;
4436 route->color.a = 255;
4437 route->handlers = eina_list_append
4438 (route->handlers, (void *)ecore_event_handler_add
4439 (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route));
4441 route->inbound = EINA_FALSE;
4443 route->method = method;
4451 case ELM_MAP_ROUTE_TYPE_MOTOCAR:
4452 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4454 case ELM_MAP_ROUTE_TYPE_BICYCLE:
4455 type_name = strdup(ROUTE_TYPE_BICYCLE);
4457 case ELM_MAP_ROUTE_TYPE_FOOT:
4458 type_name = strdup(ROUTE_TYPE_FOOT);
4464 source = wd->src->route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4465 INF("route url = %s", source);
4467 wd->route = eina_list_append(wd->route, route);
4469 ecore_con_url_url_set(route->con_url, source);
4470 ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd));
4471 ecore_con_url_data_set(route->con_url, route);
4472 ecore_con_url_get(route->con_url);
4473 if (type_name) free(type_name);
4474 if (source) free(source);
4476 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4477 "elm,state,busy,start", "elm");
4478 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL);
4493 elm_map_route_remove(Elm_Map_Route *route)
4495 #ifdef HAVE_ELEMENTARY_ECORE_CON
4496 EINA_SAFETY_ON_NULL_RETURN(route);
4501 Ecore_Event_Handler *h;
4503 EINA_LIST_FREE(route->path, p)
4508 EINA_LIST_FREE(route->waypoint, w)
4510 if (w->point) eina_stringshare_del(w->point);
4514 EINA_LIST_FREE(route->nodes, n)
4516 if (n->pos.address) eina_stringshare_del(n->pos.address);
4520 EINA_LIST_FREE(route->handlers, h)
4522 ecore_event_handler_del(h);
4525 if (route->ud.fname)
4527 ecore_file_remove(route->ud.fname);
4528 free(route->ud.fname);
4529 route->ud.fname = NULL;
4537 elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a)
4539 #ifdef HAVE_ELEMENTARY_ECORE_CON
4540 EINA_SAFETY_ON_NULL_RETURN(route);
4555 elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a)
4557 #ifdef HAVE_ELEMENTARY_ECORE_CON
4558 EINA_SAFETY_ON_NULL_RETURN(route);
4559 if (r) *r = route->color.r;
4560 if (g) *g = route->color.g;
4561 if (b) *b = route->color.b;
4562 if (a) *a = route->color.a;
4573 elm_map_route_distance_get(const Elm_Map_Route *route)
4575 #ifdef HAVE_ELEMENTARY_ECORE_CON
4576 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
4577 return route->info.distance;
4585 elm_map_route_node_get(const Elm_Map_Route *route)
4587 #ifdef HAVE_ELEMENTARY_ECORE_CON
4588 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4589 return route->info.nodes;
4597 elm_map_route_waypoint_get(const Elm_Map_Route *route)
4599 #ifdef HAVE_ELEMENTARY_ECORE_CON
4600 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4601 return route->info.waypoints;
4609 elm_map_name_address_get(const Elm_Map_Name *name)
4611 #ifdef HAVE_ELEMENTARY_ECORE_CON
4612 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
4613 return name->address;
4621 elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
4623 #ifdef HAVE_ELEMENTARY_ECORE_CON
4624 EINA_SAFETY_ON_NULL_RETURN(name);
4625 if (lon) *lon = name->lon;
4626 if (lat) *lat = name->lat;
4635 elm_map_name_remove(Elm_Map_Name *name)
4637 #ifdef HAVE_ELEMENTARY_ECORE_CON
4638 EINA_SAFETY_ON_NULL_RETURN(name);
4641 free(name->address);
4642 name->address = NULL;
4646 ecore_event_handler_del(name->handler);
4647 name->handler = NULL;
4651 ecore_file_remove(name->ud.fname);
4652 free(name->ud.fname);
4653 name->ud.fname = NULL;
4661 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
4663 #ifdef HAVE_ELEMENTARY_ECORE_CON
4664 ELM_CHECK_WIDTYPE(obj, widtype);
4665 Widget_Data *wd = elm_widget_data_get(obj);
4668 wd->rotate.d = degree;
4671 wd->calc_job = ecore_job_add(_calc_job, wd);
4681 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
4683 #ifdef HAVE_ELEMENTARY_ECORE_CON
4684 ELM_CHECK_WIDTYPE(obj, widtype);
4685 Widget_Data *wd = elm_widget_data_get(obj);
4688 if (degree) *degree = wd->rotate.d;
4689 if (cx) *cx = wd->rotate.cx;
4690 if (cy) *cy = wd->rotate.cy;
4700 elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
4702 #ifdef HAVE_ELEMENTARY_ECORE_CON
4703 ELM_CHECK_WIDTYPE(obj, widtype);
4704 Widget_Data *wd = elm_widget_data_get(obj);
4707 if ((!wd->wheel_disabled) && (disabled))
4708 evas_object_event_callback_del_full(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
4709 else if ((wd->wheel_disabled) && (!disabled))
4710 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
4711 wd->wheel_disabled = !!disabled;
4719 elm_map_wheel_disabled_get(const Evas_Object *obj)
4721 #ifdef HAVE_ELEMENTARY_ECORE_CON
4722 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4723 Widget_Data *wd = elm_widget_data_get(obj);
4725 if (!wd) return EINA_FALSE;
4726 return wd->wheel_disabled;
4735 elm_map_track_add(Evas_Object *obj, EMap_Route *emap)
4737 #ifdef HAVE_ELEMENTARY_ECORE_CON
4738 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4739 Widget_Data *wd = elm_widget_data_get(obj);
4741 if (!wd) return EINA_FALSE;
4743 Evas_Object *route = elm_route_add(obj);
4744 elm_route_emap_set(route, emap);
4745 wd->track = eina_list_append(wd->track, route);
4757 elm_map_track_remove(Evas_Object *obj, Evas_Object *route)
4759 #ifdef HAVE_ELEMENTARY_ECORE_CON
4760 ELM_CHECK_WIDTYPE(obj, widtype) ;
4761 Widget_Data *wd = elm_widget_data_get(obj);
4765 wd->track = eina_list_remove(wd->track, route);
4766 evas_object_del(route);
4773 #ifdef HAVE_ELEMENTARY_ECORE_CON
4776 _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4779 // ((x+y+zoom)%3)+'a' is requesting map images from distributed tile servers (eg., a, b, c)
4780 snprintf(buf, sizeof(buf), "http://%c.tile.openstreetmap.org/%d/%d/%d.png", ((x+y+zoom)%3)+'a', zoom, x, y);
4785 _osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4788 snprintf(buf, sizeof(buf), "http://%c.tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png", ((x+y+zoom)%3)+'a', zoom, x, y);
4793 _cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4796 snprintf(buf, sizeof(buf), "http://%c.tile.opencyclemap.org/cycle/%d/%d/%d.png", ((x+y+zoom)%3)+'a', zoom, x, y);
4801 _mapquest_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4804 snprintf(buf, sizeof(buf), "http://otile%d.mqcdn.com/tiles/1.0.0/osm/%d/%d/%d.png", ((x+y+zoom)%4)+1, zoom, x, y);
4809 _mapquest_aerial_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4812 snprintf(buf, sizeof(buf), "http://oatile%d.mqcdn.com/naip/%d/%d/%d.png", ((x+y+zoom)%4)+1, zoom, x, y);
4816 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4819 snprintf(buf, sizeof(buf),
4820 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
4821 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
4826 // TODO: fix monav api
4828 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4831 snprintf(buf, sizeof(buf),
4832 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
4833 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
4839 // TODO: fix ors api
4841 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
4844 snprintf(buf, sizeof(buf),
4845 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
4846 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
4853 _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
4855 ELM_CHECK_WIDTYPE(obj, widtype) strdup("");
4856 Widget_Data *wd = elm_widget_data_get(obj);
4858 unsigned int ele, idx;
4859 char search_url[PATH_MAX];
4862 if (!wd) return strdup("");
4863 if (method == ELM_MAP_NAME_METHOD_SEARCH)
4865 search_url[0] = '\0';
4866 str = eina_str_split_full(name, " ", 0, &ele);
4867 for (idx = 0 ; idx < ele ; idx++)
4869 eina_strlcat(search_url, str[idx], sizeof(search_url));
4870 if (!(idx == (ele-1))) eina_strlcat(search_url, "+", sizeof(search_url));
4872 snprintf(buf, sizeof(buf), "%s/search?q=%s&format=xml&polygon=0&addressdetails=0", NAME_NOMINATIM_URL, search_url);
4880 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);
4881 else strcpy(buf, "");