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 DEST_DIR_ZOOM_PATH "/tmp/elm_map/%d/%d/"
25 #define DEST_DIR_PATH DEST_DIR_ZOOM_PATH"%d/"
26 #define DEST_FILE_PATH "%s%d.png"
27 #define DEST_ROUTE_XML_FILE "/tmp/elm_map-route-XXXXXX"
28 #define DEST_NAME_XML_FILE "/tmp/elm_map-name-XXXXXX"
30 #define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php"
31 #define ROUTE_TYPE_MOTORCAR "motocar"
32 #define ROUTE_TYPE_BICYCLE "bicycle"
33 #define ROUTE_TYPE_FOOT "foot"
34 #define YOURS_DISTANCE "distance"
35 #define YOURS_DESCRIPTION "description"
36 #define YOURS_COORDINATES "coordinates"
38 // TODO: fix monav & ors url
39 #define ROUTE_MONAV_URL "http://"
40 #define ROUTE_ORS_URL "http:///"
42 #define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org"
43 #define NOMINATIM_RESULT "result"
44 #define NOMINATIM_PLACE "place"
45 #define NOMINATIM_ATTR_LON "lon"
46 #define NOMINATIM_ATTR_LAT "lat"
48 #define PINCH_ZOOM_MIN 0.25
49 #define PINCH_ZOOM_MAX 4.0
50 #define MAX_CONCURRENT_DOWNLOAD 10
52 #define GPX_NAME "name>"
53 #define GPX_COORDINATES "trkpt "
56 #define GPX_ELE "ele>"
57 #define GPX_TIME "time>"
60 // Currently the size of a tile must be 256*256
61 // and the size of the map must be pow(2.0, z)*tile_size
62 typedef struct _Map_Sources_Tab
67 ElmMapModuleUrlFunc url_cb;
68 Elm_Map_Route_Sources route_source;
69 ElmMapModuleRouteUrlFunc route_url_cb;
70 ElmMapModuleNameUrlFunc name_url_cb;
71 ElmMapModuleGeoIntoCoordFunc geo_into_coord;
72 ElmMapModuleCoordIntoGeoFunc coord_into_geo;
75 //Zemm min is supposed to be 0
76 static char *_mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
77 static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
78 static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
79 static char *_maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
81 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
83 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
84 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
86 static char *_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat);
88 static Map_Sources_Tab default_map_sources_tab[] =
90 {"Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
91 {"Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
92 {"CycleMap", 0, 17, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
93 {"Maplint", 12, 16, _maplint_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
98 Ecore_Con_Url *con_url;
104 struct _Elm_Map_Marker_Class
109 struct _Elm_Map_Marker_Class_Func {
110 ElmMapMarkerGetFunc get;
111 ElmMapMarkerDelFunc del; //if NULL the object will be destroyed with evas_object_del()
112 ElmMapMarkerIconGetFunc icon_get;
115 struct { //this part is private, do not modify these values
117 Evas_Coord edje_w, edje_h;
121 struct _Elm_Map_Marker
124 Elm_Map_Marker_Class *clas;
125 Elm_Map_Group_Class *clas_group;
126 double longitude, latitude;
131 Marker_Group **groups;
132 Evas_Object *content;
135 struct _Elm_Map_Group_Class
139 int zoom_displayed; // display the group if the zoom is >= to zoom_display
140 int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
144 ElmMapGroupIconGetFunc icon_get;
147 struct { //this part is private, do not modify these values
149 Evas_Coord edje_w, edje_h;
150 Evas_Coord edje_max_w, edje_max_h;
152 Eina_List *objs_used;
153 Eina_List *objs_notused;
160 Eina_Matrixsparse_Cell *cell;
161 Elm_Map_Group_Class *clas;
164 long long sum_x, sum_y;
168 Evas_Object *obj, *bubble, *sc, *bx, *rect;
170 Eina_Bool bringin : 1;
171 Eina_Bool update_nbelems : 1;
172 Eina_Bool update_resize : 1;
173 Eina_Bool update_raise : 1;
174 Eina_Bool delete_object : 1;
177 struct _Elm_Map_Route
183 Ecore_Con_Url *con_url;
188 double flon, flat, tlon, tlat;
190 Eina_List *nodes, *path;
197 const char *waypoints;
198 double distance; /* unit : km */
211 Eina_Bool inbound : 1;
225 struct _Path_Waypoint
236 Ecore_Con_Url *con_url;
241 Ecore_Event_Handler *handler;
256 Eina_Bool download : 1;
258 Ecore_File_Download_Job *job;
265 int tsize; // size of tile (tsize x tsize pixels)
266 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
267 int iw, ih; // size of image in pixels
268 int w, h; // size of grid image in pixels (represented by grid)
269 int gw, gh; // size of grid in tiles
270 Eina_Matrixsparse *grid;
277 Evas_Object *pan_smart;
279 Evas_Object *sep_maps_markers; //map objects are below this object and marker objects are on top
281 Evas_Coord pan_x, pan_y, minw, minh;
286 Elm_Map_Zoom_Mode mode;
289 Ecore_Timer *scr_timer;
290 Ecore_Timer *long_timer;
291 Ecore_Animator *zoom_animator;
302 Evas_Coord x, y ,w ,h;
307 Eina_Bool resized : 1;
308 Eina_Bool on_hold : 1;
309 Eina_Bool paused : 1;
310 Eina_Bool paused_markers : 1;
317 Ecore_Job *markers_place_job;
318 Eina_Matrixsparse **markers;
319 Eina_List *cells_displayed; // list of Eina_Matrixsparse_Cell
320 Evas_Coord markers_max_num;
321 int marker_max_w, marker_max_h;
323 Eina_List *opened_bubbles; //opened bubbles, list of Map_Group *
325 Eina_List *groups_clas; // list of Elm_Map_Group_Class*
326 Eina_List *markers_clas; // list of Elm_Map_Markers_Class*
328 Elm_Map_Route_Sources route_source;
329 Eina_List *s_event_list;
334 const char *user_agent;
337 Evas_Event_Mouse_Down ev;
358 Ecore_Timer *wheel_timer;
359 Eina_Bool wheel_disabled : 1;
362 Eina_List *map_sources_tab;
363 const char **source_names;
365 Ecore_Timer *zoom_timer;
366 Map_Sources_Tab *src;
367 const char *gpx_file;
368 int zoom_min, zoom_max;
369 Eina_List *download_list;
375 Evas_Object_Smart_Clipped_Data __clipped_data;
391 Evas_Coord x, y, w, h;
394 Ecore_Timer *hold_timer;
409 enum _Route_Xml_Attribute
413 ROUTE_XML_DESCRIPTION,
414 ROUTE_XML_COORDINATES,
416 } Route_Xml_Attibute;
426 enum _Name_Xml_Attribute
443 enum _Track_Xml_Attribute
446 TRACK_XML_COORDINATES,
448 } Track_Xml_Attibute;
451 static const char *widtype = NULL;
453 static const char SIG_CHANGED[] = "changed";
454 static const char SIG_CLICKED[] = "clicked";
455 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
456 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
457 static const char SIG_LOAD_DETAIL[] = "load,detail";
458 static const char SIG_LONGPRESSED[] = "longpressed";
459 static const char SIG_PRESS[] = "press";
460 static const char SIG_SCROLL[] = "scroll";
461 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
462 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
463 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
464 static const char SIG_ZOOM_START[] = "zoom,start";
465 static const char SIG_ZOOM_STOP[] = "zoom,stop";
466 static const char SIG_DOWNLOADED[] = "downloaded";
467 static const char SIG_ROUTE_LOAD[] = "route,load";
468 static const char SIG_ROUTE_LOADED[] = "route,loaded";
469 static const char SIG_NAME_LOAD[] = "name,load";
470 static const char SIG_NAME_LOADED[] = "name,loaded";
471 static const Evas_Smart_Cb_Description _signals[] = {
474 {SIG_CLICKED_DOUBLE, ""},
475 {SIG_LOADED_DETAIL, ""},
476 {SIG_LOAD_DETAIL, ""},
477 {SIG_LONGPRESSED, ""},
480 {SIG_SCROLL_DRAG_START, ""},
481 {SIG_SCROLL_DRAG_STOP, ""},
482 {SIG_ZOOM_CHANGE, ""},
483 {SIG_ZOOM_START, ""},
485 {SIG_DOWNLOADED, ""},
486 {SIG_ROUTE_LOAD, ""},
487 {SIG_ROUTE_LOADED, ""},
489 {SIG_NAME_LOADED, ""},
493 static void _pan_calculate(Evas_Object *obj);
495 static Eina_Bool _hold_timer_cb(void *data);
496 static Eina_Bool _wheel_timer_cb(void *data);
497 static void _rect_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
498 static void _del_hook(Evas_Object *obj);
499 static void _theme_hook(Evas_Object *obj);
500 static void _on_focus_hook(void *data, Evas_Object *obj);
501 static void _sizing_eval(Evas_Object *obj);
502 static void _calc_job(void *data);
503 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
504 Evas_Callback_Type type, void *event_info);
505 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);
506 static void grid_clear(Evas_Object *obj, Grid *g);
507 static Grid *grid_create(Evas_Object *obj);
508 static void grid_load(Evas_Object *obj, Grid *g);
510 static void _process_download_list(Evas_Object *obj);
511 static void _add_download_list(Evas_Object *obj, Grid_Item *gi);
513 static void _group_object_create(Marker_Group *group);
514 static void _group_object_free(Marker_Group *group);
515 static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
516 static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
517 static void _group_bubble_create(Marker_Group *group);
518 static void _group_bubble_free(Marker_Group *group);
519 static void _group_bubble_place(Marker_Group *group);
521 static int _group_bubble_content_update(Marker_Group *group);
522 static void _group_bubble_content_free(Marker_Group *group);
523 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);
524 static void _bubble_sc_hints_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
526 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
527 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
528 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
530 static void _mouse_multi_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
531 static void _mouse_multi_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
532 static void _mouse_multi_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
534 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);
535 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);
538 get_multi_device(Evas_Object *obj)
540 Widget_Data *wd = elm_widget_data_get(obj);
544 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
546 if (ev->device) return ev->device;
552 create_event_object(void *data, Evas_Object *obj, int device)
554 Widget_Data *wd = elm_widget_data_get(data);
555 Event *ev = calloc(1, sizeof(Event));
557 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, NULL);
561 evas_object_geometry_get(obj, &ev->x, &ev->y, &ev->w, &ev->h);
562 wd->s_event_list = eina_list_append(wd->s_event_list, ev);
567 get_event_object(void *data, int device)
569 Widget_Data *wd = elm_widget_data_get(data);
573 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
575 if (ev->device == device) break;
582 destroy_event_object(void *data, Event *ev)
584 Widget_Data *wd = elm_widget_data_get(data);
585 EINA_SAFETY_ON_NULL_RETURN(ev);
587 wd->s_event_list = eina_list_remove(wd->s_event_list, ev);
590 ecore_timer_del(ev->hold_timer);
591 ev->hold_timer = NULL;
597 module_list_cb(Eina_Module *m, void *data)
599 ELM_CHECK_WIDTYPE(data, widtype) EINA_FALSE;
600 Widget_Data *wd = elm_widget_data_get(data);
602 ElmMapModuleSourceFunc source;
603 ElmMapModuleZoomMinFunc zoom_min;
604 ElmMapModuleZoomMaxFunc zoom_max;
605 ElmMapModuleUrlFunc url;
606 ElmMapModuleRouteSourceFunc route_source;
607 ElmMapModuleRouteUrlFunc route_url;
608 ElmMapModuleNameUrlFunc name_url;
609 ElmMapModuleGeoIntoCoordFunc geo_into_coord;
610 ElmMapModuleCoordIntoGeoFunc coord_into_geo;
613 if (!wd) return EINA_FALSE;
615 file = eina_module_file_get(m);
616 if (!eina_module_load(m))
618 ERR("could not load module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
622 source = eina_module_symbol_get(m, "map_module_source_get");
623 zoom_min = eina_module_symbol_get(m, "map_module_zoom_min_get");
624 zoom_max = eina_module_symbol_get(m, "map_module_zoom_max_get");
625 url = eina_module_symbol_get(m, "map_module_url_get");
626 route_source = eina_module_symbol_get(m, "map_module_route_source_get");
627 route_url = eina_module_symbol_get(m, "map_module_route_url_get");
628 name_url = eina_module_symbol_get(m, "map_module_name_url_get");
629 geo_into_coord = eina_module_symbol_get(m, "map_module_geo_into_coord");
630 coord_into_geo = eina_module_symbol_get(m, "map_module_coord_into_geo");
631 if ((!source) || (!zoom_min) || (!zoom_max) || (!url) || (!route_source) || (!route_url) || (!name_url) || (!geo_into_coord) || (!coord_into_geo))
633 ERR("could not find map_module_source_get() in module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
634 eina_module_unload(m);
637 s = calloc(1, sizeof(Map_Sources_Tab));
638 EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE);
640 s->zoom_min = zoom_min();
641 s->zoom_max = zoom_max();
643 s->route_source = route_source();
644 s->route_url_cb = route_url;
645 s->name_url_cb = name_url;
646 s->geo_into_coord = geo_into_coord;
647 s->coord_into_geo = coord_into_geo;
648 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
654 module_init(void *data)
656 ELM_CHECK_WIDTYPE(data, widtype);
657 Widget_Data *wd = elm_widget_data_get(data);
660 wd->modules = eina_module_list_get(wd->modules, MODULES_PATH, 1, &module_list_cb, data);
664 source_init(void *data)
666 ELM_CHECK_WIDTYPE(data, widtype);
667 Widget_Data *wd = elm_widget_data_get(data);
673 for (idx = 0; idx < 4; idx++)
675 s = calloc(1, sizeof(Map_Sources_Tab));
676 EINA_SAFETY_ON_NULL_RETURN(s);
677 s->name = default_map_sources_tab[idx].name;
678 s->zoom_min = default_map_sources_tab[idx].zoom_min;
679 s->zoom_max = default_map_sources_tab[idx].zoom_max;
680 s->url_cb = default_map_sources_tab[idx].url_cb;
681 s->route_source = default_map_sources_tab[idx].route_source;
682 s->route_url_cb = default_map_sources_tab[idx].route_url_cb;
683 s->name_url_cb = default_map_sources_tab[idx].name_url_cb;
684 s->geo_into_coord = default_map_sources_tab[idx].geo_into_coord;
685 s->coord_into_geo = default_map_sources_tab[idx].coord_into_geo;
686 wd->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
687 if (!idx) wd->src = s;
691 int n = eina_list_count(wd->map_sources_tab);
692 wd->source_names = malloc(sizeof(char *) * (n + 1));
693 if (!wd->source_names)
695 ERR("init source names failed.");
699 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
701 wd->source_names[idx] = strdup(s->name);
702 INF("source : %s", wd->source_names[idx]);
705 wd->source_names[idx] = NULL;
709 zoom_min_get(void *data)
711 ELM_CHECK_WIDTYPE(data, widtype);
712 Widget_Data *wd = elm_widget_data_get(data);
718 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
721 if (tz < wd->zoom_min) wd->zoom_min = tz;
726 zoom_max_get(void *data)
728 ELM_CHECK_WIDTYPE(data, widtype);
729 Widget_Data *wd = elm_widget_data_get(data);
735 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
738 if (tz > wd->zoom_max) wd->zoom_max = tz;
743 obj_rotate_zoom(void *data, Evas_Object *obj)
745 ELM_CHECK_WIDTYPE(data, widtype);
746 Widget_Data *wd = elm_widget_data_get(data);
748 if ((!wd->pinch.cx) && (!wd->pinch.cy))
750 wd->pinch.cx = wd->rotate.cx;
751 wd->pinch.cy = wd->rotate.cy;
754 evas_map_util_points_populate_from_object_full(wd->map, obj, 0);
755 evas_object_image_size_get(obj, &iw, &ih);
756 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
757 if ((ow < iw) || (oh < ih))
759 ow *= (double)iw / ow;
760 oh *= (double)ih / oh;
761 evas_map_point_image_uv_set(wd->map, 1, ow, 0);
762 evas_map_point_image_uv_set(wd->map, 2, ow, oh);
763 evas_map_point_image_uv_set(wd->map, 3, 0, oh);
765 evas_map_util_zoom(wd->map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy);
766 evas_map_util_rotate(wd->map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
767 evas_object_map_enable_set(obj, EINA_TRUE);
768 evas_object_map_set(obj, wd->map);
773 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)
775 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__)
779 ELM_CHECK_WIDTYPE(obj, widtype);
780 Widget_Data *wd = elm_widget_data_get(obj);
783 int xmin, xmax, ymin, ymax;
786 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
788 EINA_LIST_FOREACH(wd->track, l, route)
790 elm_map_utils_convert_geo_into_coord(wd->obj, elm_route_lon_min_get(route), elm_route_lat_max_get(route), size, &xmin, &ymin);
791 elm_map_utils_convert_geo_into_coord(wd->obj, elm_route_lon_max_get(route), elm_route_lat_min_get(route), size, &xmax, &ymax);
793 if( !(xmin < px && xmax < px) && !(xmin > px+ow && xmax > px+ow))
795 if( !(ymin < py && ymax < py) && !(ymin > py+oh && ymax > py+oh))
798 evas_object_move(route, xmin - px + ox, ymin - py + oy);
799 evas_object_resize(route, xmax - xmin, ymax - ymin);
801 evas_object_raise(route);
802 obj_rotate_zoom(obj, route);
803 evas_object_show(route);
808 //the route is not display
809 evas_object_hide(route);
814 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)
816 ELM_CHECK_WIDTYPE(obj, widtype);
817 Widget_Data *wd = elm_widget_data_get(obj);
818 Eina_List *lr, *lp, *ln;
827 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
829 EINA_LIST_FOREACH(wd->route, lr, r)
831 EINA_LIST_FOREACH(r->path, lp, p)
833 evas_object_polygon_points_clear(p);
836 evas_object_geometry_get(wd->rect, &rx, &ry, NULL, NULL);
837 nodes = eina_list_count(r->nodes);
839 EINA_LIST_FOREACH(r->nodes, ln, n)
841 if ((!wd->zoom) || ((n->idx) &&
842 ((n->idx % (int)ceil((double)nodes/(double)size*100.0))))) continue;
845 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
846 if ((x >= px - ow) && (x <= (px + ow*2)) &&
847 (y >= py - oh) && (y <= (py + oh*2)))
852 p = eina_list_nth(r->path, n->idx);
853 a = (double)(y - r->y) / (double)(x - r->x);
854 if ((abs(a) >= 1) || (r->x == x))
856 evas_object_polygon_point_add(p, r->x - 3, r->y);
857 evas_object_polygon_point_add(p, r->x + 3, r->y);
858 evas_object_polygon_point_add(p, x + 3, y);
859 evas_object_polygon_point_add(p, x - 3, y);
863 evas_object_polygon_point_add(p, r->x, r->y - 3);
864 evas_object_polygon_point_add(p, r->x, r->y + 3);
865 evas_object_polygon_point_add(p, x, y + 3);
866 evas_object_polygon_point_add(p, x, y - 3);
869 evas_object_color_set(p, r->color.r, r->color.g, r->color.b, r->color.a);
870 evas_object_raise(p);
871 obj_rotate_zoom(obj, p);
876 else r->inbound = EINA_FALSE;
880 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
881 if ((x >= px - ow) && (x <= (px + ow*2)) &&
882 (y >= py - oh) && (y <= (py + oh*2)))
886 r->inbound = EINA_TRUE;
888 else r->inbound = EINA_FALSE;
891 r->inbound = EINA_FALSE;
896 rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
898 ELM_CHECK_WIDTYPE(obj, widtype);
899 Widget_Data *wd = elm_widget_data_get(obj);
900 Evas_Coord ax, ay, gw, gh, hh, ww;
903 evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh);
910 if ((ww == gw) && (hh == gh)) return;
912 if (ow > gw) ax = (ow - gw) / 2;
913 if (oh > gh) ay = (oh - gh) / 2;
914 evas_object_move(wd->rect,
917 evas_object_resize(wd->rect, gw, gh);
921 wd->show.show = EINA_FALSE;
922 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
927 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)
929 ELM_CHECK_WIDTYPE(obj, widtype);
930 Widget_Data *wd = elm_widget_data_get(obj);
931 Evas_Coord ax, ay, gw, gh, tx, ty;
932 Eina_List *l, *markers;
933 Eina_Matrixsparse_Cell *cell;
938 int g_xx, g_yy, g_hh, g_ww;
941 if (g != eina_list_data_get(wd->grids)) return;
947 if (ow > gw) ax = (ow - gw) / 2;
948 if (oh > gh) ay = (oh - gh) / 2;
950 if (wd->zoom != wd->marker_zoom)
952 EINA_LIST_FREE(wd->cells_displayed, cell)
954 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
956 if (group->obj) _group_object_free(group);
960 wd->marker_zoom = wd->zoom;
962 if ((wd->paused_markers)
963 && ((wd->size.nw != wd->size.w) || (wd->size.nh != wd->size.h)) )
966 g_xx = wd->pan_x / wd->tsize;
967 if (g_xx < 0) g_xx = 0;
968 g_yy = wd->pan_y / wd->tsize;
969 if (g_yy < 0) g_yy = 0;
970 g_ww = (ow / wd->tsize) + 1;
971 if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
972 g_hh = (oh / wd->tsize) + 1;
973 if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
975 //hide groups no more displayed
976 EINA_LIST_FREE(wd->cells_displayed, cell)
978 eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x);
979 if ((y < g_yy) || (y > g_yy + g_hh) || (x < g_xx) || (x > g_xx + g_ww))
981 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
983 if (group->obj) _group_object_free(group);
988 if (!wd->marker_zoom)
994 for (y = g_yy; y <= g_yy + g_hh; y++)
996 for (x = g_xx; x <= g_xx + g_ww; x++)
998 if (!wd->markers[wd->zoom]) continue;
999 eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell);
1000 if (!cell) continue;
1001 wd->cells_displayed = eina_list_append(wd->cells_displayed, cell);
1002 markers = eina_matrixsparse_cell_data_get(cell);
1003 EINA_LIST_FOREACH(markers, l, group)
1005 if (!group->markers) continue;
1006 if (group->clas->zoom_displayed > wd->zoom) continue;
1013 if (eina_list_count(group->markers) == 1)
1015 Elm_Map_Marker *m = eina_list_data_get(group->markers);
1016 ww = m->clas->priv.edje_w;
1017 hh = m->clas->priv.edje_h;
1020 if (ww <= 0) ww = 1;
1021 if (hh <= 0) hh = 1;
1023 if ((gw != g->w) && (g->w > 0))
1026 xx = ((long long )gw * xx) / g->w;
1027 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1029 if ((gh != g->h) && (g->h > 0))
1032 yy = ((long long)gh * yy) / g->h;
1033 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1036 if ((!group->clas->hide)
1037 && (xx-px+ax+ox >= ox) && (xx-px+ax+ox<= ox+ow)
1038 && (yy-py+ay+oy >= oy) && (yy-py+ay+oy<= oy+oh))
1040 if (!group->obj) _group_object_create(group);
1042 if (group->update_nbelems)
1044 group->update_nbelems = EINA_FALSE;
1045 if (eina_list_count(group->markers) > 1)
1047 snprintf(buf, sizeof(buf), "%d", eina_list_count(group->markers));
1048 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
1051 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", "");
1053 evas_object_move(group->obj,
1054 xx - px + ax + ox - ww/2,
1055 yy - py + ay + oy - hh/2);
1056 if ((!wd->paused_markers) || (group->update_resize))
1058 group->update_resize = EINA_FALSE;
1059 evas_object_resize(group->obj, ww, hh);
1060 obj_rotate_zoom(obj, group->obj);
1062 if (group->update_raise)
1064 group->update_raise = EINA_FALSE;
1065 evas_object_raise(group->obj);
1066 obj_rotate_zoom(obj, group->obj);
1067 evas_object_show(group->obj);
1069 if (group->bubble) _group_bubble_place(group);
1071 else if (group->obj)
1073 _group_object_free(group);
1081 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)
1083 ELM_CHECK_WIDTYPE(obj, widtype);
1084 Widget_Data *wd = elm_widget_data_get(obj);
1085 Evas_Coord ax, ay, gw, gh, tx, ty;
1093 if (ow > gw) ax = (ow - gw) / 2;
1094 if (oh > gh) ay = (oh - gh) / 2;
1096 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1097 Eina_Matrixsparse_Cell *cell;
1099 EINA_ITERATOR_FOREACH(it, cell)
1101 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1107 if ((gw != g->w) && (g->w > 0))
1110 xx = ((long long )gw * xx) / g->w;
1111 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1113 if ((gh != g->h) && (g->h > 0))
1116 yy = ((long long)gh * yy) / g->h;
1117 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1119 evas_object_move(gi->img,
1123 evas_object_resize(gi->img, ww, hh);
1125 obj_rotate_zoom(obj, gi->img);
1126 /*evas_object_move(gi->txt,
1130 evas_object_resize(gi->txt, ww, hh);
1133 eina_iterator_free(it);
1137 grid_clear(Evas_Object *obj, Grid *g)
1139 ELM_CHECK_WIDTYPE(obj, widtype);
1140 Widget_Data *wd = elm_widget_data_get(obj);
1144 if (!g->grid) return;
1146 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1147 Eina_Matrixsparse_Cell *cell;
1149 snprintf(buf, sizeof(buf), DEST_DIR_ZOOM_PATH, wd->id, g->zoom);
1150 ecore_file_recursive_rm(buf);
1152 EINA_ITERATOR_FOREACH(it, cell)
1154 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1155 evas_object_del(gi->img);
1156 //evas_object_del(gi->txt);
1158 wd->download_list = eina_list_remove(wd->download_list, gi);
1159 gi->want = EINA_FALSE;
1163 DBG("DOWNLOAD abort %s", gi->file);
1164 ecore_file_download_abort(gi->job);
1165 ecore_file_remove(gi->file);
1166 gi->have = EINA_FALSE;
1171 eina_stringshare_del(gi->file);
1173 eina_stringshare_del(gi->source);
1177 eina_matrixsparse_free(g->grid);
1178 eina_iterator_free(it);
1185 _tile_update(Grid_Item *gi)
1187 gi->want = EINA_FALSE;
1188 gi->download = EINA_FALSE;
1189 evas_object_image_file_set(gi->img, gi->file, NULL);
1190 if (evas_object_image_load_error_get(gi->img) != EVAS_LOAD_ERROR_NONE)
1192 ERR("Image loading error (%s)", gi->file);
1193 ecore_file_remove(gi->file);
1194 gi->have = EINA_FALSE;
1198 obj_rotate_zoom(gi->wd->obj, gi->img);
1199 evas_object_show(gi->img);
1201 //evas_object_text_text_set(gi->txt, gi->file);
1202 //evas_object_show(gi->txt);
1204 gi->have = EINA_TRUE;
1208 _tile_downloaded(void *data, const char *file __UNUSED__, int status)
1210 Grid_Item *gi = data;
1212 gi->wd->download_num--;
1213 gi->download = EINA_FALSE;
1216 if ((gi->want) && (status == 200))
1219 DBG("DOWNLOAD done %s", gi->file);
1224 DBG("Download failed %s (%d) ", gi->file, status);
1225 ecore_file_remove(gi->file);
1226 gi->have = EINA_FALSE;
1229 gi->wd->finish_num++;
1231 evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL);
1232 if (!gi->wd->download_num)
1234 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr), "elm,state,busy,stop", "elm");
1235 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
1237 _process_download_list(gi->wd->obj);
1241 _process_download_list(Evas_Object *obj)
1243 ELM_CHECK_WIDTYPE(obj, widtype);
1244 Widget_Data *wd = elm_widget_data_get(obj);
1246 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
1249 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
1250 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
1255 EINA_LIST_FOREACH_SAFE(wd->download_list, l, ll, gi)
1262 if ((gw != gi->g->w) && (gi->g->w > 0))
1265 xx = ((long long )gw * xx) / gi->g->w;
1266 ww = (((long long)gw * (tx + ww)) / gi->g->w) - xx;
1268 if ((gh != gi->g->h) && (gi->g->h > 0))
1271 yy = ((long long)gh * yy) / gi->g->h;
1272 hh = (((long long)gh * (ty + hh)) / gi->g->h) - yy;
1274 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
1275 yy - wd->pan_y + oy,
1277 cvx, cvy, cvw, cvh))
1279 gi->download = EINA_FALSE;
1280 wd->download_list = eina_list_remove(wd->download_list, gi);
1284 EINA_LIST_REVERSE_FOREACH_SAFE(wd->download_list, l, ll, gi)
1286 if (gi->wd->download_num >= MAX_CONCURRENT_DOWNLOAD)
1289 Eina_Bool ret = ecore_file_download_full(gi->source, gi->file, _tile_downloaded, NULL, gi, &(gi->job), wd->ua);
1290 if (!ret || !gi->job)
1291 WRN("Can't start to download %s to %s", gi->source, gi->file);
1294 gi->wd->download_num++;
1296 wd->download_list = eina_list_remove(wd->download_list, gi);
1297 if (wd->download_num == 1)
1298 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,state,busy,start", "elm");
1304 _add_download_list(Evas_Object *obj, Grid_Item *gi)
1306 ELM_CHECK_WIDTYPE(obj, widtype);
1307 Widget_Data *wd = elm_widget_data_get(obj);
1309 wd->download_list = eina_list_remove(wd->download_list, gi);
1310 wd->download_list = eina_list_append(wd->download_list, gi);
1311 _process_download_list(obj);
1315 grid_create(Evas_Object *obj)
1317 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1318 Widget_Data *wd = elm_widget_data_get(obj);
1321 if ((!wd) || (!wd->src)) return NULL;
1322 g = calloc(1, sizeof(Grid));
1325 g->tsize = wd->tsize;
1328 if (g->zoom > wd->src->zoom_max) return NULL;
1329 if (g->zoom < wd->src->zoom_min) return NULL;
1331 int size = pow(2.0, wd->zoom);
1335 g->w = g->tsize * g->gw;
1336 g->h = g->tsize * g->gh;
1338 g->grid = eina_matrixsparse_new(g->gh, g->gw, NULL, NULL);
1344 grid_load(Evas_Object *obj, Grid *g)
1346 ELM_CHECK_WIDTYPE(obj, widtype);
1347 Widget_Data *wd = elm_widget_data_get(obj);
1350 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
1352 Eina_Matrixsparse_Cell *cell;
1355 if ((!wd) || (!wd->src)) return;
1356 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
1357 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
1362 if ((gw <= 0) || (gh <= 0)) return;
1365 if ((gw != g->w) && (g->w > 0))
1366 size = ((long long)gw * size) / g->w;
1367 if (size < (g->tsize / 2)) return; // else we will load to much tiles
1369 it = eina_matrixsparse_iterator_new(g->grid);
1371 EINA_ITERATOR_FOREACH(it, cell)
1373 gi = eina_matrixsparse_cell_data_get(cell);
1380 if ((gw != g->w) && (g->w > 0))
1383 xx = ((long long )gw * xx) / g->w;
1384 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
1386 if ((gh != g->h) && (g->h > 0))
1389 yy = ((long long)gh * yy) / g->h;
1390 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
1393 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
1394 yy - wd->pan_y + oy,
1396 cvx, cvy, cvw, cvh))
1400 evas_object_hide(gi->img);
1401 //evas_object_hide(gi->txt);
1402 evas_object_image_file_set(gi->img, NULL, NULL);
1403 gi->want = EINA_FALSE;
1404 gi->have = EINA_FALSE;
1408 DBG("DOWNLOAD abort %s", gi->file);
1409 ecore_file_download_abort(gi->job);
1410 ecore_file_remove(gi->file);
1414 gi->download = EINA_FALSE;
1418 evas_object_hide(gi->img);
1419 //evas_object_hide(gi->txt);
1420 evas_object_image_preload(gi->img, 1);
1421 evas_object_image_file_set(gi->img, NULL, NULL);
1422 gi->have = EINA_FALSE;
1423 gi->want = EINA_FALSE;
1427 eina_iterator_free(it);
1429 xx = wd->pan_x / size - 1;
1432 yy = wd->pan_y / size - 1;
1436 if (xx + ww >= g->gw) ww = g->gw - xx - 1;
1439 if (yy + hh >= g->gh) hh = g->gh - yy - 1;
1441 for (y = yy; y <= yy + hh; y++)
1443 for (x = xx; x <= xx + ww; x++)
1445 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
1447 if ((!gi) && (g != eina_list_data_get(wd->grids)))
1452 gi = calloc(1, sizeof(Grid_Item));
1453 gi->src.x = x * g->tsize;
1454 gi->src.y = y * g->tsize;
1455 gi->src.w = g->tsize;
1456 gi->src.h = g->tsize;
1458 gi->out.x = gi->src.x;
1459 gi->out.y = gi->src.y;
1460 gi->out.w = gi->src.w;
1461 gi->out.h = gi->src.h;
1466 gi->img = evas_object_image_add(evas_object_evas_get(obj));
1467 evas_object_image_scale_hint_set
1468 (gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1469 evas_object_image_filled_set(gi->img, 1);
1471 evas_object_smart_member_add(gi->img, wd->pan_smart);
1472 elm_widget_sub_object_add(obj, gi->img);
1473 evas_object_pass_events_set(gi->img, EINA_TRUE);
1474 evas_object_stack_below(gi->img, wd->sep_maps_markers);
1476 /* gi->txt = evas_object_text_add(evas_object_evas_get(obj));
1477 evas_object_text_font_set(gi->txt, "Vera", 12);
1478 evas_object_color_set(gi->txt, 100, 100, 100, 255);
1479 evas_object_smart_member_add(gi->txt,
1481 elm_widget_sub_object_add(obj, gi->txt);
1482 evas_object_pass_events_set(gi->txt, EINA_TRUE);
1484 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
1487 if ((!gi->have) && (!gi->download))
1489 char buf[PATH_MAX], buf2[PATH_MAX];
1492 gi->want = EINA_TRUE;
1494 snprintf(buf, sizeof(buf), DEST_DIR_PATH, wd->id, g->zoom, x);
1495 if (!ecore_file_exists(buf))
1496 ecore_file_mkpath(buf);
1498 snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y);
1500 source = wd->src->url_cb(obj, x, y, g->zoom);
1501 if ((!source) || (strlen(source)==0)) continue;
1503 eina_stringshare_replace(&gi->file, buf2);
1504 eina_stringshare_replace(&gi->source, source);
1506 if ((ecore_file_exists(buf2)) || (g == eina_list_data_get(wd->grids)))
1508 gi->download = EINA_TRUE;
1509 if (ecore_file_exists(buf2))
1512 _add_download_list(obj, gi);
1514 if (source) free(source);
1518 obj_rotate_zoom(obj, gi->img);
1519 evas_object_show(gi->img);
1526 grid_clearall(Evas_Object *obj)
1528 ELM_CHECK_WIDTYPE(obj, widtype);
1529 Widget_Data *wd = elm_widget_data_get(obj);
1533 EINA_LIST_FREE(wd->grids, g)
1538 wd->download_list = eina_list_free(wd->download_list);
1542 _smooth_update(Evas_Object *obj)
1544 ELM_CHECK_WIDTYPE(obj, widtype);
1545 Widget_Data *wd = elm_widget_data_get(obj);
1550 EINA_LIST_FOREACH(wd->grids, l, g)
1552 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1553 Eina_Matrixsparse_Cell *cell;
1555 EINA_ITERATOR_FOREACH(it, cell)
1557 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1558 evas_object_image_smooth_scale_set(gi->img, (!wd->nosmooth));
1560 eina_iterator_free(it);
1565 _scr_timeout(void *data)
1567 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1568 Widget_Data *wd = elm_widget_data_get(data);
1570 if (!wd) return ECORE_CALLBACK_CANCEL;
1572 if (!wd->nosmooth) _smooth_update(data);
1573 wd->scr_timer = NULL;
1574 return ECORE_CALLBACK_CANCEL;
1578 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1580 ELM_CHECK_WIDTYPE(data, widtype);
1581 Widget_Data *wd = elm_widget_data_get(data);
1587 if (wd->nosmooth == 1) _smooth_update(data);
1589 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1590 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
1594 zoom_do(Evas_Object *obj)
1596 ELM_CHECK_WIDTYPE(obj, widtype);
1597 Widget_Data *wd = elm_widget_data_get(obj);
1598 Evas_Coord xx, yy, ow, oh;
1601 wd->size.w = wd->size.nw;
1602 wd->size.h = wd->size.nh;
1604 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
1606 if (wd->center_on.enabled)
1608 elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy);
1614 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
1615 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
1620 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
1622 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
1624 wd->show.show = EINA_TRUE;
1630 if (wd->calc_job) ecore_job_del(wd->calc_job);
1631 wd->calc_job = ecore_job_add(_calc_job, wd);
1635 _zoom_timeout(void *data)
1637 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1638 Widget_Data *wd = elm_widget_data_get(data);
1640 if (!wd) return ECORE_CALLBACK_CANCEL;
1641 wd->zoom_timer = NULL;
1642 wd->pinch.level = 1.0;
1644 evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
1645 return ECORE_CALLBACK_CANCEL;
1649 _zoom_anim(void *data)
1651 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1652 Evas_Object *obj = data;
1653 Widget_Data *wd = elm_widget_data_get(obj);
1655 if (!wd) return ECORE_CALLBACK_CANCEL;
1656 if (wd->zoom_method == ZOOM_METHOD_IN) wd->t += 0.1 ;
1657 else if (wd->zoom_method == ZOOM_METHOD_OUT) wd->t -= 0.05;
1660 wd->zoom_animator = NULL;
1662 evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
1663 return ECORE_CALLBACK_CANCEL;
1668 wd->zoom_animator = NULL;
1669 wd->pinch.level = 2.0;
1670 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1671 wd->zoom_timer = ecore_timer_add(0.35, _zoom_timeout, obj);
1672 return ECORE_CALLBACK_CANCEL;
1674 else if (wd->t <= 0.5)
1676 wd->zoom_animator = NULL;
1677 wd->pinch.level = 0.5;
1678 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1679 wd->zoom_timer = ecore_timer_add(1.35, _zoom_timeout, obj);
1680 return ECORE_CALLBACK_CANCEL;
1682 else if (wd->t != 1.0)
1684 Evas_Coord x, y, w, h;
1685 float half_w, half_h;
1686 evas_object_geometry_get(data, &x, &y, &w, &h);
1687 half_w = (float)w * 0.5;
1688 half_h = (float)h * 0.5;
1689 wd->pinch.cx = x + half_w;
1690 wd->pinch.cy = y + half_h;
1691 wd->pinch.level = wd->t;
1692 if (wd->calc_job) ecore_job_del(wd->calc_job);
1693 wd->calc_job = ecore_job_add(_calc_job, wd);
1695 return ECORE_CALLBACK_RENEW;
1699 _long_press(void *data)
1701 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
1702 Widget_Data *wd = elm_widget_data_get(data);
1704 if (!wd) return ECORE_CALLBACK_CANCEL;
1705 wd->long_timer = NULL;
1706 evas_object_smart_callback_call(data, SIG_LONGPRESSED, &wd->ev);
1707 return ECORE_CALLBACK_CANCEL;
1711 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1713 ELM_CHECK_WIDTYPE(data, widtype);
1714 Widget_Data *wd = elm_widget_data_get(data);
1715 Evas_Event_Mouse_Down *ev = event_info;
1719 ev0 = get_event_object(data, 0);
1721 ev0 = create_event_object(data, obj, 0);
1724 ev0->hold_timer = NULL;
1725 ev0->prev.x = ev->canvas.x;
1726 ev0->prev.y = ev->canvas.y;
1728 if (ev->button != 1) return;
1729 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1730 else wd->on_hold = EINA_FALSE;
1731 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1732 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, ev);
1734 evas_object_smart_callback_call(data, SIG_PRESS, ev);
1735 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1736 wd->ev.canvas.x = ev->output.x;
1737 wd->ev.canvas.y = ev->output.y;
1738 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1742 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1744 Evas_Event_Mouse_Move *move = event_info;
1747 ev0 = get_event_object(data, 0);
1749 ev0->prev.x = move->cur.canvas.x;
1750 ev0->prev.y = move->cur.canvas.y;
1754 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1756 ELM_CHECK_WIDTYPE(data, widtype);
1757 Widget_Data *wd = elm_widget_data_get(data);
1760 Evas_Event_Mouse_Up *ev = event_info;
1765 ev0 = get_event_object(data, 0);
1768 mdevice = get_multi_device(data);
1771 if (ev0->hold_timer)
1773 ecore_timer_del(ev0->hold_timer);
1774 ev0->hold_timer = NULL;
1776 elm_smart_scroller_hold_set(wd->scr, 0);
1777 elm_smart_scroller_freeze_set(wd->scr, 0);
1781 ev1 = get_event_object(data, mdevice);
1783 ev1->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev1);
1785 destroy_event_object(data, ev0);
1788 if (ev->button != 1) return;
1789 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1790 else wd->on_hold = EINA_FALSE;
1793 ecore_timer_del(wd->long_timer);
1794 wd->long_timer = NULL;
1796 if (!wd->on_hold) evas_object_smart_callback_call(data, SIG_CLICKED, ev);
1797 wd->on_hold = EINA_FALSE;
1801 _mouse_multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
1803 ELM_CHECK_WIDTYPE(data, widtype);
1804 Widget_Data *wd = elm_widget_data_get(data);
1806 Evas_Event_Multi_Down *down = event_info;
1808 elm_smart_scroller_hold_set(wd->scr, 1);
1809 elm_smart_scroller_freeze_set(wd->scr, 1);
1811 ev = create_event_object(data, obj, down->device);
1814 DBG("Failed : create_event_object");
1819 ev->hold_timer = NULL;
1820 ev->start.x = ev->prev.x = down->canvas.x;
1821 ev->start.y = ev->prev.y = down->canvas.y;
1822 ev->pinch_start_dis = 0;
1823 wd->pinch.level = 1.0;
1824 wd->pinch.diff = 1.0;
1829 ecore_timer_del(wd->long_timer);
1830 wd->long_timer = NULL;
1836 _mouse_multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1838 ELM_CHECK_WIDTYPE(data, widtype);
1839 Widget_Data *wd = elm_widget_data_get(data);
1840 Evas_Event_Multi_Move *move = event_info;
1841 int dis_new, dx, dy;
1842 double t, tt, a, a_diff;
1846 if ((!wd) || (!wd->src)) return;
1847 ev = get_event_object(data, move->device);
1850 ev0 = get_event_object(data, 0);
1853 if (wd->multi_count >= 1)
1855 Evas_Coord x, y, w, h;
1856 float half_w, half_h;
1858 evas_object_geometry_get(data, &x, &y, &w, &h);
1859 half_w = (float)w * 0.5;
1860 half_h = (float)h * 0.5;
1861 dx = ev0->prev.x - ev->prev.x;
1862 dy = ev0->prev.y - ev->prev.y;
1863 dis_new = sqrt((dx * dx) + (dy * dy));
1865 if (!ev->pinch_start_dis) ev->pinch_start_dis = dis_new;
1868 ev->pinch_dis = dis_new;
1869 tt = wd->pinch.diff;
1870 wd->pinch.diff = (double)(ev->pinch_dis - ev->pinch_start_dis);
1871 t = (wd->pinch.diff * 0.01) + 1.0;
1872 if ((t > 1.1) || (wd->rotate.doing))
1874 if (((wd->zoom + (int)t - 1) < wd->src->zoom_min) ||
1875 ((wd->zoom + (int)t - 1) > wd->src->zoom_max) ||
1876 (t > PINCH_ZOOM_MAX) || (t < PINCH_ZOOM_MIN))
1878 wd->pinch.diff = tt;
1883 wd->pinch.level = (wd->pinch.diff * 0.01) + 1.0;
1884 wd->pinch.cx = x + half_w;
1885 wd->pinch.cy = y + half_h;
1886 wd->pinch.doing = EINA_TRUE;
1887 if (!wd->rotate.doing) goto do_zoom_only;
1892 if (wd->pinch.doing) goto do_nothing;
1895 a = (double)(ev->prev.y - ev0->prev.y) / (double)(ev->prev.x - ev0->prev.x);
1896 if (!wd->rotate.a) wd->rotate.a = a;
1899 a_diff = wd->rotate.a - a;
1900 if (a_diff > 0) wd->rotate.d -= 1.0;
1901 else if (a_diff < 0) wd->rotate.d += 1.0;
1903 wd->rotate.cx = x + half_w;
1904 wd->rotate.cy = y + half_h;
1905 wd->rotate.doing = EINA_TRUE;
1908 if (wd->calc_job) ecore_job_del(wd->calc_job);
1909 wd->calc_job = ecore_job_add(_calc_job, wd);
1913 ev->prev.x = move->cur.canvas.x;
1914 ev->prev.y = move->cur.canvas.y;
1918 _mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1920 ELM_CHECK_WIDTYPE(data, widtype);
1921 Widget_Data *wd = elm_widget_data_get(data);
1922 Evas_Event_Multi_Up *up = event_info;
1929 if (wd->calc_job) ecore_job_del(wd->calc_job);
1930 if (wd->zoom_animator)
1932 ecore_animator_del(wd->zoom_animator);
1933 wd->zoom_animator = NULL;
1936 wd->paused = EINA_TRUE;
1937 if (wd->pinch.diff >= 0.0) zoom = (int)ceil((wd->pinch.diff * 0.01) - 1.0);
1938 else if (wd->pinch.diff < 0.0) zoom = (int)floor(-1.0 / ((wd->pinch.diff * 0.005) + 1.0));
1939 elm_map_zoom_set(data, wd->zoom + zoom);
1940 wd->pinch.level = 1.0;
1941 wd->pinch.doing = EINA_FALSE;
1944 wd->rotate.doing = EINA_FALSE;
1946 ev = get_event_object(data, up->device);
1949 DBG("Cannot get multi device");
1953 ev0 = get_event_object(data, 0);
1955 ev0->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev0);
1960 ecore_timer_del(ev->hold_timer);
1961 ev->hold_timer = NULL;
1964 destroy_event_object(data, ev);
1968 _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1970 ELM_CHECK_WIDTYPE(data, widtype);
1971 Widget_Data *wd = elm_widget_data_get(data);
1972 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
1973 Evas_Coord x, y, w, h;
1974 float half_w, half_h;
1977 evas_object_geometry_get(data, &x, &y, &w, &h);
1978 half_w = (float)w * 0.5;
1979 half_h = (float)h * 0.5;
1983 wd->zoom_method = ZOOM_METHOD_OUT;
1984 wd->wheel_zoom -= 0.1;
1985 if (wd->wheel_zoom <= -2.0) wd->wheel_zoom = -2.0;
1989 wd->zoom_method = ZOOM_METHOD_IN;
1990 wd->wheel_zoom += 0.1;
1991 if (wd->wheel_zoom >= 2.0) wd->wheel_zoom = 2.0;
1996 wd->pinch.level = pow(2.0, wd->wheel_zoom);
1997 wd->pinch.cx = x + half_w;
1998 wd->pinch.cy = y + half_h;
1999 if (wd->calc_job) ecore_job_del(wd->calc_job);
2000 wd->calc_job = ecore_job_add(_calc_job, wd);
2003 if (wd->wheel_timer) ecore_timer_del(wd->wheel_timer);
2004 wd->wheel_timer = ecore_timer_add(0.35, _wheel_timer_cb, data);
2008 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
2011 _hold_timer_cb(void *data)
2015 ev0->hold_timer = NULL;
2016 return ECORE_CALLBACK_CANCEL;
2020 _wheel_timer_cb(void *data)
2022 ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
2023 Widget_Data *wd = elm_widget_data_get(data);
2026 if (!wd) return ECORE_CALLBACK_CANCEL;
2027 if (wd->zoom_method == ZOOM_METHOD_IN) zoom = (int)ceil(wd->wheel_zoom);
2028 else if (wd->zoom_method == ZOOM_METHOD_OUT) zoom = (int)floor(wd->wheel_zoom);
2031 wd->wheel_timer = NULL;
2032 return ECORE_CALLBACK_CANCEL;
2035 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
2036 wd->pinch.level = 1.0;
2037 elm_map_zoom_set(data, wd->zoom + zoom);
2038 wd->wheel_zoom = 0.0;
2039 wd->wheel_timer = NULL;
2040 wd->zoom_method = ZOOM_METHOD_NONE;
2041 return ECORE_CALLBACK_CANCEL;
2045 _rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2047 ELM_CHECK_WIDTYPE(data, widtype);
2048 Widget_Data *wd = elm_widget_data_get(data);
2051 evas_object_geometry_get(wd->rect, &x, &y, &w, &h);
2052 evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h);
2053 evas_object_resize(wd->rect, w, h);
2054 evas_object_move(wd->rect, x, y);
2058 _del_hook(Evas_Object *obj)
2060 ELM_CHECK_WIDTYPE(obj, widtype);
2061 Widget_Data *wd = elm_widget_data_get(obj);
2062 Elm_Map_Group_Class *group_clas;
2063 Elm_Map_Marker_Class *marker_clas;
2069 Ecore_Event_Handler *h;
2075 EINA_LIST_FREE(wd->groups_clas, group_clas)
2077 if (group_clas->style)
2078 eina_stringshare_del(group_clas->style);
2082 EINA_LIST_FREE(wd->markers_clas, marker_clas)
2084 if (marker_clas->style)
2085 eina_stringshare_del(marker_clas->style);
2089 EINA_LIST_FOREACH(wd->s_event_list, l, ev)
2091 destroy_event_object(obj, ev);
2094 EINA_LIST_FOREACH(wd->route, l, r)
2096 EINA_LIST_FREE(r->path, p)
2101 EINA_LIST_FREE(r->waypoint, w)
2103 if (w->point) eina_stringshare_del(w->point);
2107 EINA_LIST_FREE(r->nodes, n)
2109 if (n->pos.address) eina_stringshare_del(n->pos.address);
2113 EINA_LIST_FREE(r->handlers, h)
2115 ecore_event_handler_del(h);
2118 if (r->con_url) ecore_con_url_free(r->con_url);
2119 if (r->info.nodes) eina_stringshare_del(r->info.nodes);
2120 if (r->info.waypoints) eina_stringshare_del(r->info.waypoints);
2123 EINA_LIST_FREE(wd->names, na)
2125 if (na->address) free(na->address);
2126 if (na->handler) ecore_event_handler_del(na->handler);
2129 ecore_file_remove(na->ud.fname);
2131 na->ud.fname = NULL;
2135 EINA_LIST_FREE(wd->track, route)
2137 evas_object_del(route);
2140 if (wd->map) evas_map_free(wd->map);
2141 if (wd->source_names) free(wd->source_names);
2142 if (wd->calc_job) ecore_job_del(wd->calc_job);
2143 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
2144 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
2145 if (wd->long_timer) ecore_timer_del(wd->long_timer);
2146 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
2147 if (wd->ua) eina_hash_free(wd->ua);
2148 if (wd->markers) free(wd->markers);
2154 _del_pre_hook(Evas_Object *obj)
2156 ELM_CHECK_WIDTYPE(obj, widtype);
2157 Widget_Data *wd = elm_widget_data_get(obj);
2158 Marker_Group *group;
2159 Elm_Map_Marker *marker;
2161 Eina_Bool free_marker = EINA_TRUE;
2166 for (i = 0; i <= wd->zoom_max; i++)
2168 if (!wd->markers[i]) continue;
2169 Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
2170 Eina_Matrixsparse_Cell *cell;
2172 EINA_ITERATOR_FOREACH(it, cell)
2174 l = eina_matrixsparse_cell_data_get(cell);
2175 EINA_LIST_FREE(l, group)
2177 EINA_LIST_FREE(group->markers, marker)
2179 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2180 _bubble_sc_hints_changed_cb, group);
2181 if (free_marker) free(marker);
2185 free_marker = EINA_FALSE;
2187 eina_iterator_free(it);
2188 eina_matrixsparse_free(wd->markers[i]);
2191 evas_object_del(wd->sep_maps_markers);
2192 evas_object_del(wd->pan_smart);
2193 wd->pan_smart = NULL;
2197 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
2199 ELM_CHECK_WIDTYPE(obj, widtype);
2200 Widget_Data *wd = elm_widget_data_get(obj);
2203 if (elm_widget_focus_get(obj))
2205 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
2206 evas_object_focus_set(wd->obj, EINA_TRUE);
2210 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
2211 evas_object_focus_set(wd->obj, EINA_FALSE);
2216 _theme_hook(Evas_Object *obj)
2218 ELM_CHECK_WIDTYPE(obj, widtype);
2219 Widget_Data *wd = elm_widget_data_get(obj);
2222 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
2223 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
2228 _sizing_eval(Evas_Object *obj)
2230 ELM_CHECK_WIDTYPE(obj, widtype);
2231 Widget_Data *wd = elm_widget_data_get(obj);
2232 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
2235 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
2236 evas_object_size_hint_min_set(obj, minw, minh);
2237 evas_object_size_hint_max_set(obj, maxw, maxh);
2241 _calc_job(void *data)
2243 Widget_Data *wd = data;
2244 Evas_Coord minw, minh;
2251 wd->resized = EINA_FALSE;
2252 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
2254 double tz = wd->zoom;
2256 elm_map_zoom_set(wd->obj, tz);
2259 if ((minw != wd->minw) || (minh != wd->minh))
2263 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
2264 _sizing_eval(wd->obj);
2266 wd->calc_job = NULL;
2267 evas_object_smart_changed(wd->pan_smart);
2271 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2273 Pan *sd = evas_object_smart_data_get(obj);
2275 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2278 evas_object_smart_changed(obj);
2282 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2284 Pan *sd = evas_object_smart_data_get(obj);
2286 if (x) *x = sd->wd->pan_x;
2287 if (y) *y = sd->wd->pan_y;
2291 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2293 Pan *sd = evas_object_smart_data_get(obj);
2296 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2297 ow = sd->wd->minw - ow;
2299 oh = sd->wd->minh - oh;
2306 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
2313 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2315 Pan *sd = evas_object_smart_data_get(obj);
2317 if (w) *w = sd->wd->minw;
2318 if (h) *h = sd->wd->minh;
2322 _pan_add(Evas_Object *obj)
2325 Evas_Object_Smart_Clipped_Data *cd;
2327 cd = evas_object_smart_data_get(obj);
2329 sd = calloc(1, sizeof(Pan));
2331 sd->__clipped_data = *cd;
2333 evas_object_smart_data_set(obj, sd);
2337 _pan_del(Evas_Object *obj)
2339 Pan *sd = evas_object_smart_data_get(obj);
2345 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
2347 Pan *sd = evas_object_smart_data_get(obj);
2350 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2351 if ((ow == w) && (oh == h)) return;
2352 sd->wd->resized = EINA_TRUE;
2353 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2354 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2358 _pan_calculate(Evas_Object *obj)
2360 Pan *sd = evas_object_smart_data_get(obj);
2361 Evas_Coord ox, oy, ow, oh;
2365 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2366 rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2367 EINA_LIST_FOREACH(sd->wd->grids, l, g)
2369 if (sd->wd->zoom == g->zoom) grid_load(sd->wd->obj, g);
2370 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2371 marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2372 if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2373 if (!sd->wd->zoom_animator) track_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
2378 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2380 Pan *sd = evas_object_smart_data_get(obj);
2382 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2383 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2387 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2389 ELM_CHECK_WIDTYPE(obj, widtype);
2390 Widget_Data *wd = elm_widget_data_get(obj);
2393 elm_smart_scroller_hold_set(wd->scr, 1);
2397 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2399 ELM_CHECK_WIDTYPE(obj, widtype);
2400 Widget_Data *wd = elm_widget_data_get(obj);
2403 elm_smart_scroller_hold_set(wd->scr, 0);
2407 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2409 ELM_CHECK_WIDTYPE(obj, widtype);
2410 Widget_Data *wd = elm_widget_data_get(obj);
2413 elm_smart_scroller_freeze_set(wd->scr, 1);
2417 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
2419 ELM_CHECK_WIDTYPE(obj, widtype);
2420 Widget_Data *wd = elm_widget_data_get(obj);
2423 elm_smart_scroller_freeze_set(wd->scr, 0);
2427 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2429 evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
2433 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2435 evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
2439 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2441 Widget_Data *wd = elm_widget_data_get(data);
2442 wd->center_on.enabled = EINA_FALSE;
2443 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
2447 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2449 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
2453 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2455 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
2460 _group_object_create(Marker_Group *group)
2462 const char *style = "radio";
2463 Evas_Object *icon = NULL;
2465 if (group->obj) return;
2466 if ((!group->clas->priv.objs_notused) || (eina_list_count(group->markers) == 1))
2468 //set icon and style
2469 if (eina_list_count(group->markers) == 1)
2471 Elm_Map_Marker *m = eina_list_data_get(group->markers);
2473 style = m->clas->style;
2475 if (m->clas->func.icon_get)
2476 icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
2478 group->delete_object = EINA_TRUE;
2482 if (group->clas->style)
2483 style = group->clas->style;
2485 if (group->clas->func.icon_get)
2486 icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
2488 group->delete_object = EINA_FALSE;
2491 group->obj = elm_layout_add(group->wd->obj);
2492 elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
2494 if (icon) elm_object_part_content_set(group->obj, "elm.icon", icon);
2496 evas_object_smart_member_add(group->obj, group->wd->pan_smart);
2497 elm_widget_sub_object_add(group->wd->obj, group->obj);
2498 evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
2500 if (!group->delete_object)
2501 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2505 group->delete_object = EINA_FALSE;
2507 group->obj = eina_list_data_get(group->clas->priv.objs_notused);
2508 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
2509 group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
2510 evas_object_show(group->obj);
2513 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
2514 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
2516 group->update_nbelems = EINA_TRUE;
2517 group->update_resize = EINA_TRUE;
2518 group->update_raise = EINA_TRUE;
2520 if (group->open) _group_bubble_create(group);
2524 _group_object_free(Marker_Group *group)
2526 if (!group->obj) return;
2527 if (!group->delete_object)
2529 group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
2530 group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
2531 evas_object_hide(group->obj);
2533 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
2534 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
2537 evas_object_del(group->obj);
2540 _group_bubble_free(group);
2544 _group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2546 Marker_Group *group = data;
2548 if (!evas_object_above_get(group->rect)) return;
2549 evas_object_raise(group->bubble);
2550 evas_object_raise(group->sc);
2551 evas_object_raise(group->rect);
2555 _group_bubble_create(Marker_Group *group)
2557 if (group->bubble) return;
2559 group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
2560 group->bubble = edje_object_add(evas_object_evas_get(group->obj));
2561 _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
2562 elm_widget_style_get(group->wd->obj));
2563 evas_object_smart_member_add(group->bubble,
2565 elm_widget_sub_object_add(group->wd->obj, group->bubble);
2567 _group_bubble_content_free(group);
2568 if (!_group_bubble_content_update(group))
2570 //no content, we can delete the bubble
2571 _group_bubble_free(group);
2575 group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
2576 evas_object_color_set(group->rect, 0, 0, 0, 0);
2577 evas_object_repeat_events_set(group->rect, EINA_TRUE);
2578 evas_object_smart_member_add(group->rect, group->wd->obj);
2579 elm_widget_sub_object_add(group->wd->obj, group->rect);
2581 evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
2583 _group_bubble_place(group);
2586 static void _bubble_sc_hints_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2588 _group_bubble_place(data);
2592 _group_bubble_content_update(Marker_Group *group)
2595 Elm_Map_Marker *marker;
2598 if (!group->bubble) return 1;
2602 group->sc = elm_scroller_add(group->bubble);
2603 elm_widget_style_set(group->sc, "map_bubble");
2604 elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
2605 elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
2606 elm_scroller_bounce_set(group->sc, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
2607 edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
2608 evas_object_show(group->sc);
2609 evas_object_smart_member_add(group->sc,
2611 elm_widget_sub_object_add(group->wd->obj, group->sc);
2613 group->bx = elm_box_add(group->bubble);
2614 evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2615 evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
2616 elm_box_horizontal_set(group->bx, EINA_TRUE);
2617 evas_object_show(group->bx);
2619 elm_object_content_set(group->sc, group->bx);
2621 evas_object_event_callback_add(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2622 _bubble_sc_hints_changed_cb, group);
2625 EINA_LIST_FOREACH(group->markers, l, marker)
2627 if (i >= group->wd->markers_max_num) break;
2628 if ((!marker->content) && (marker->clas->func.get))
2629 marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
2630 else if (marker->content)
2631 elm_box_unpack(group->bx, marker->content);
2632 if (marker->content)
2634 elm_box_pack_end(group->bx, marker->content);
2642 _group_bubble_content_free(Marker_Group *group)
2645 Elm_Map_Marker *marker;
2647 if (!group->sc) return;
2648 EINA_LIST_FOREACH(group->markers, l, marker)
2650 if ((marker->content) && (marker->clas->func.del))
2651 marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
2652 else if (marker->content)
2653 evas_object_del(marker->content);
2654 marker->content = NULL;
2656 evas_object_del(group->sc);
2661 _group_bubble_free(Marker_Group *group)
2663 if (!group->bubble) return;
2664 group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
2665 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2666 _bubble_sc_hints_changed_cb, group);
2667 evas_object_del(group->bubble);
2668 evas_object_del(group->rect);
2669 group->bubble = NULL;
2670 _group_bubble_content_free(group);
2674 _group_bubble_place(Marker_Group *group)
2677 Evas_Coord xx, yy, ww, hh;
2680 if ((!group->bubble) || (!group->obj)) return;
2682 evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
2683 edje_object_size_min_calc(group->bubble, NULL, &hh);
2685 s = edje_object_data_get(group->bubble, "size_w");
2686 if (s) ww = atoi(s);
2688 xx = x + w / 2 - ww / 2;
2691 evas_object_move(group->bubble, xx, yy);
2692 evas_object_resize(group->bubble, ww, hh);
2693 obj_rotate_zoom(group->wd, group->bubble);
2694 evas_object_show(group->bubble);
2696 evas_object_move(group->rect, xx, yy);
2697 evas_object_resize(group->rect, ww, hh);
2698 obj_rotate_zoom(group->wd, group->rect);
2699 evas_object_show(group->rect);
2703 _group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2705 Marker_Group *group = data;
2706 Elm_Map_Marker *marker = eina_list_data_get(group->markers);
2707 if (!marker) return;
2708 group->bringin = EINA_TRUE;
2709 elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
2713 _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
2715 Marker_Group *group = data;
2719 group->bringin = EINA_FALSE;
2725 group->open = EINA_FALSE;
2726 _group_bubble_free(group);
2729 group->open = EINA_TRUE;
2730 _group_bubble_create(group);
2734 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
2736 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2737 Widget_Data *wd = elm_widget_data_get(obj);
2741 Evas_Coord step_x = 0;
2742 Evas_Coord step_y = 0;
2745 Evas_Coord page_x = 0;
2746 Evas_Coord page_y = 0;
2748 if (!wd) return EINA_FALSE;
2749 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
2750 Evas_Event_Key_Down *ev = event_info;
2751 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
2753 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
2754 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
2755 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
2756 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
2758 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
2762 else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
2766 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
2770 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
2774 else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
2777 y -= -(page_y * v_h) / 100;
2781 else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
2784 y += -(page_y * v_h) / 100;
2788 else if (!strcmp(ev->keyname, "KP_Add"))
2790 zoom = elm_map_zoom_get(obj) + 1;
2791 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2792 elm_map_zoom_set(obj, zoom);
2795 else if (!strcmp(ev->keyname, "KP_Subtract"))
2797 zoom = elm_map_zoom_get(obj) - 1;
2798 elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
2799 elm_map_zoom_set(obj, zoom);
2802 else return EINA_FALSE;
2804 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
2805 elm_smart_scroller_child_pos_set(wd->scr, x, y);
2811 cb_dump_name_attrs(void *data, const char *key, const char *value)
2813 Name_Dump *dump = (Name_Dump*)data;
2814 if (!dump) return EINA_FALSE;
2816 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
2817 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
2824 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2826 Route_Dump *dump = data;
2827 if (!dump) return EINA_FALSE;
2831 case EINA_SIMPLE_XML_OPEN:
2832 case EINA_SIMPLE_XML_OPEN_EMPTY:
2836 attrs = eina_simple_xml_tag_attributes_find(value, length);
2839 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
2840 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
2841 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
2842 else dump->id = ROUTE_XML_NONE;
2846 case EINA_SIMPLE_XML_DATA:
2848 char *buf = malloc(length);
2849 if (!buf) return EINA_FALSE;
2850 snprintf(buf, length, "%s", value);
2851 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
2852 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2853 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2865 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2867 Name_Dump *dump = data;
2868 if (!dump) return EINA_FALSE;
2872 case EINA_SIMPLE_XML_OPEN:
2873 case EINA_SIMPLE_XML_OPEN_EMPTY:
2876 attrs = eina_simple_xml_tag_attributes_find(value, length);
2879 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME;
2880 else dump->id = NAME_XML_NONE;
2882 eina_simple_xml_attributes_parse
2883 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
2887 case EINA_SIMPLE_XML_DATA:
2889 char *buf = malloc(length + 1);
2890 if (!buf) return EINA_FALSE;
2891 snprintf(buf, length + 1, "%s", value);
2892 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2904 _parse_kml(void *data)
2906 Elm_Map_Route *r = (Elm_Map_Route*)data;
2907 if (!r || !r->ud.fname) return;
2911 unsigned int ele, idx;
2915 Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL};
2917 f = fopen(r->ud.fname, "rb");
2922 fseek(f, 0, SEEK_END);
2928 fseek(f, 0, SEEK_SET);
2932 if (fread(buf, 1, sz, f))
2934 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump);
2941 if (dump.distance) r->info.distance = dump.distance;
2942 if (dump.description)
2944 eina_stringshare_replace(&r->info.waypoints, dump.description);
2945 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2946 r->info.waypoint_count = ele;
2947 for (idx = 0 ; idx < ele ; idx++)
2949 Path_Waypoint *wp = ELM_NEW(Path_Waypoint);
2953 wp->point = eina_stringshare_add(str[idx]);
2954 DBG("%s", str[idx]);
2955 r->waypoint = eina_list_append(r->waypoint, wp);
2964 else WRN("description is not found !");
2966 if (dump.coordinates)
2968 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2969 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2970 r->info.node_count = ele;
2971 for (idx = 0 ; idx < ele ; idx++)
2973 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2974 Path_Node *n = ELM_NEW(Path_Node);
2981 DBG("%lf:%lf", lon, lat);
2982 n->pos.address = NULL;
2983 r->nodes = eina_list_append(r->nodes, n);
2985 path = evas_object_polygon_add(evas_object_evas_get(r->wd->obj));
2986 evas_object_smart_member_add(path, r->wd->pan_smart);
2987 r->path = eina_list_append(r->path, path);
3000 _parse_name(void *data)
3002 Elm_Map_Name *n = (Elm_Map_Name*)data;
3003 if (!n || !n->ud.fname) return;
3007 Name_Dump dump = {0, NULL, 0.0, 0.0};
3009 f = fopen(n->ud.fname, "rb");
3014 fseek(f, 0, SEEK_END);
3020 fseek(f, 0, SEEK_SET);
3024 if (fread(buf, 1, sz, f))
3026 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
3035 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
3036 n->address = strdup(dump.address);
3044 _route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
3046 Ecore_Con_Event_Url_Complete *ev = event;
3047 Elm_Map_Route *r = (Elm_Map_Route*)data;
3048 Widget_Data *wd = r->wd;
3050 if ((!r) || (!ev)) return EINA_TRUE;
3051 Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url);
3052 ecore_con_url_data_set(r->con_url, NULL);
3053 if (r!=rr) return EINA_TRUE;
3055 if (r->ud.fd) fclose(r->ud.fd);
3060 Evas_Coord ox, oy, ow, oh;
3061 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
3062 route_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3064 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3065 "elm,state,busy,stop", "elm");
3066 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
3071 _name_complete_cb(void *data, int ev_type __UNUSED__, void *event)
3073 Ecore_Con_Event_Url_Complete *ev = event;
3074 Elm_Map_Name *n = (Elm_Map_Name*)data;
3075 Widget_Data *wd = n->wd;
3077 if ((!n) || (!ev)) return EINA_TRUE;
3078 Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url);
3079 ecore_con_url_data_set(n->con_url, NULL);
3080 if (n!=nn) return EINA_TRUE;
3082 if (n->ud.fd) fclose(n->ud.fd);
3085 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3086 "elm,state,busy,stop", "elm");
3087 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
3091 static Elm_Map_Name *
3092 _utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat)
3094 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3095 Widget_Data *wd = elm_widget_data_get(obj);
3100 if ((!wd) || (!wd->src)) return NULL;
3101 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
3102 if (!name) return NULL;
3104 snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE);
3112 name->con_url = ecore_con_url_new(NULL);
3113 name->ud.fname = strdup(buf);
3114 INF("xml file : %s", name->ud.fname);
3116 name->ud.fd = fdopen(fd, "w+");
3117 if ((!name->con_url) || (!name->ud.fd))
3119 ecore_con_url_free(name->con_url);
3125 name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name);
3126 name->method = method;
3127 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
3128 else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL;
3132 source = wd->src->name_url_cb(wd->obj, method, address, lon, lat);
3133 INF("name url = %s", source);
3135 wd->names = eina_list_append(wd->names, name);
3136 ecore_con_url_url_set(name->con_url, source);
3137 ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd));
3138 ecore_con_url_data_set(name->con_url, name);
3140 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3141 "elm,state,busy,start", "elm");
3142 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL);
3143 ecore_con_url_get(name->con_url);
3144 if (source) free(source);
3150 static int idnum = 1;
3155 elm_map_add(Evas_Object *parent)
3157 #ifdef HAVE_ELEMENTARY_ECORE_CON
3160 Evas_Coord minw, minh;
3162 static Evas_Smart *smart = NULL;
3163 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
3165 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3167 ELM_SET_WIDTYPE(widtype, "map");
3168 elm_widget_type_set(obj, "map");
3169 elm_widget_sub_object_add(parent, obj);
3170 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3171 elm_widget_data_set(obj, wd);
3172 elm_widget_del_hook_set(obj, _del_hook);
3173 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3174 elm_widget_theme_hook_set(obj, _theme_hook);
3175 elm_widget_can_focus_set(obj, EINA_TRUE);
3176 elm_widget_event_hook_set(obj, _event_hook);
3178 wd->scr = elm_smart_scroller_add(e);
3179 elm_smart_scroller_widget_set(wd->scr, obj);
3180 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
3181 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
3182 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
3183 elm_widget_resize_object_set(obj, wd->scr);
3184 elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE);
3186 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
3187 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
3188 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
3189 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
3190 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
3192 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
3196 wd->map = evas_map_new(4);
3197 if (!wd->map) return NULL;
3199 wd->zoom_min = 0xFF;
3200 wd->zoom_max = 0X00;
3201 wd->markers_max_num = 30;
3202 wd->pinch.level = 1.0;
3205 wd->markers = calloc(wd->zoom_max + 1, sizeof(void*));
3207 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3208 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3209 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3210 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3214 static Evas_Smart_Class sc;
3216 evas_object_smart_clipped_smart_set(&_pan_sc);
3218 sc.name = "elm_map_pan";
3219 sc.version = EVAS_SMART_CLASS_VERSION;
3222 sc.resize = _pan_resize;
3223 sc.move = _pan_move;
3224 sc.calculate = _pan_calculate;
3225 smart = evas_smart_class_new(&sc);
3229 wd->pan_smart = evas_object_smart_add(e, smart);
3230 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3234 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3235 _pan_set, _pan_get, _pan_max_get,
3236 _pan_min_get, _pan_child_size_get);
3238 wd->rect = evas_object_rectangle_add(e);
3239 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_RESIZE,
3240 _rect_resize_cb, obj);
3241 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
3243 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_MOVE,
3245 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
3247 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_DOWN,
3248 _mouse_multi_down, obj);
3249 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_MOVE,
3250 _mouse_multi_move, obj);
3251 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP,
3252 _mouse_multi_up, obj);
3253 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL,
3254 _mouse_wheel_cb, obj);
3256 evas_object_smart_member_add(wd->rect, wd->pan_smart);
3257 elm_widget_sub_object_add(obj, wd->rect);
3258 evas_object_show(wd->rect);
3259 evas_object_color_set(wd->rect, 0, 0, 0, 0);
3261 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
3262 wd->id = ((int)getpid() << 16) | idnum;
3266 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3268 evas_object_size_hint_min_set(obj, minw, minh);
3270 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
3271 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
3273 wd->paused = EINA_TRUE;
3274 elm_map_zoom_set(obj, 0);
3275 wd->paused = EINA_FALSE;
3278 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3279 // TODO: and save some bytes, making descriptions per-class and not instance!
3280 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3282 if (!ecore_file_download_protocol_available("http://"))
3284 ERR("Ecore must be built with curl support for the map widget!");
3295 elm_map_zoom_set(Evas_Object *obj, int zoom)
3297 #ifdef HAVE_ELEMENTARY_ECORE_CON
3298 ELM_CHECK_WIDTYPE(obj, widtype);
3299 Widget_Data *wd = elm_widget_data_get(obj);
3301 Grid *g, *g_zoom = NULL;
3302 Evas_Coord rx, ry, rw, rh;
3306 int z = 0, zoom_changed = 0, started = 0;
3308 if ((!wd) || (!wd->src) || (wd->zoom_animator)) return;
3309 if (zoom < 0 ) zoom = 0;
3310 if (zoom > wd->src->zoom_max) zoom = wd->src->zoom_max;
3311 if (zoom < wd->src->zoom_min) zoom = wd->src->zoom_min;
3313 if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT;
3314 else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN;
3315 else wd->zoom_method = ZOOM_METHOD_NONE;
3316 if (wd->zoom != zoom ) zoom_changed = 1;
3318 wd->size.ow = wd->size.w;
3319 wd->size.oh = wd->size.h;
3320 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
3321 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3323 EINA_LIST_FOREACH(wd->route, l, r)
3327 EINA_LIST_FOREACH(r->path, l, p)
3329 evas_object_polygon_points_clear(p);
3334 EINA_LIST_FOREACH(wd->track, l, route)
3336 evas_object_hide(route);
3339 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3346 while (cumulw <= rw)
3355 while (cumulh <= rh)
3362 if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3364 if (p2w < p2h) z = p2w;
3367 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3369 if (p2w > p2h) z = p2w;
3374 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
3375 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
3377 g = grid_create(obj);
3380 if (eina_list_count(wd->grids) > 1)
3382 g_zoom = eina_list_last(wd->grids)->data;
3383 wd->grids = eina_list_remove(wd->grids, g_zoom);
3384 grid_clear(obj, g_zoom);
3387 wd->grids = eina_list_prepend(wd->grids, g);
3391 EINA_LIST_FREE(wd->grids, g)
3399 if ((wd->size.w > 0) && (wd->size.h > 0))
3401 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow;
3402 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.oh;
3406 wd->size.spos.x = 0.5;
3407 wd->size.spos.y = 0.5;
3410 if (rw > wd->size.ow) wd->size.spos.x = 0.5;
3411 if (rh > wd->size.oh) wd->size.spos.y = 0.5;
3412 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
3413 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
3418 if (wd->calc_job) ecore_job_del(wd->calc_job);
3419 wd->calc_job = ecore_job_add(_calc_job, wd);
3423 if (!wd->zoom_animator)
3425 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
3427 if (wd->nosmooth == 1) _smooth_update(obj);
3434 if (started) evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
3435 if (!wd->zoom_animator) evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3438 if (zoom_changed) evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
3446 elm_map_zoom_get(const Evas_Object *obj)
3448 #ifdef HAVE_ELEMENTARY_ECORE_CON
3449 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3450 Widget_Data *wd = elm_widget_data_get(obj);
3461 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
3463 #ifdef HAVE_ELEMENTARY_ECORE_CON
3464 ELM_CHECK_WIDTYPE(obj, widtype);
3465 Widget_Data *wd = elm_widget_data_get(obj);
3468 if (wd->mode == mode) return;
3471 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3475 elm_map_zoom_set(wd->obj, tz);
3483 EAPI Elm_Map_Zoom_Mode
3484 elm_map_zoom_mode_get(const Evas_Object *obj)
3486 #ifdef HAVE_ELEMENTARY_ECORE_CON
3487 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
3488 Widget_Data *wd = elm_widget_data_get(obj);
3490 if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
3494 return ELM_MAP_ZOOM_MODE_MANUAL;
3499 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
3501 #ifdef HAVE_ELEMENTARY_ECORE_CON
3502 ELM_CHECK_WIDTYPE(obj, widtype);
3503 Widget_Data *wd = elm_widget_data_get(obj);
3507 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3508 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3513 if (wd->zoom_animator)
3516 if (!wd->nosmooth) _smooth_update(obj);
3517 ecore_animator_del(wd->zoom_animator);
3518 wd->zoom_animator = NULL;
3520 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3522 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
3524 wd->center_on.enabled = EINA_TRUE;
3525 wd->center_on.lon = lon;
3526 wd->center_on.lat = lat;
3535 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
3537 #ifdef HAVE_ELEMENTARY_ECORE_CON
3538 ELM_CHECK_WIDTYPE(obj, widtype);
3539 Widget_Data *wd = elm_widget_data_get(obj);
3543 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
3544 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
3549 if (wd->zoom_animator)
3552 ecore_animator_del(wd->zoom_animator);
3553 wd->zoom_animator = NULL;
3555 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3557 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
3559 wd->center_on.enabled = EINA_TRUE;
3560 wd->center_on.lon = lon;
3561 wd->center_on.lat = lat;
3570 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
3572 #ifdef HAVE_ELEMENTARY_ECORE_CON
3573 ELM_CHECK_WIDTYPE(obj, widtype);
3574 Widget_Data *wd = elm_widget_data_get(obj);
3575 Evas_Coord sx, sy, sw, sh;
3578 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
3579 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
3583 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
3592 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
3594 #ifdef HAVE_ELEMENTARY_ECORE_CON
3595 ELM_CHECK_WIDTYPE(obj, widtype);
3596 Widget_Data *wd = elm_widget_data_get(obj);
3599 if (wd->paused == !!paused) return;
3600 wd->paused = paused;
3603 if (wd->zoom_animator)
3605 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
3606 wd->zoom_animator = NULL;
3608 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
3618 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
3620 #ifdef HAVE_ELEMENTARY_ECORE_CON
3621 ELM_CHECK_WIDTYPE(obj, widtype);
3622 Widget_Data *wd = elm_widget_data_get(obj);
3625 if (wd->paused_markers == !!paused) return;
3626 wd->paused_markers = paused;
3634 elm_map_paused_get(const Evas_Object *obj)
3636 #ifdef HAVE_ELEMENTARY_ECORE_CON
3637 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3638 Widget_Data *wd = elm_widget_data_get(obj);
3640 if (!wd) return EINA_FALSE;
3649 elm_map_paused_markers_get(const Evas_Object *obj)
3651 #ifdef HAVE_ELEMENTARY_ECORE_CON
3652 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3653 Widget_Data *wd = elm_widget_data_get(obj);
3655 if (!wd) return EINA_FALSE;
3656 return wd->paused_markers;
3664 elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
3666 #ifdef HAVE_ELEMENTARY_ECORE_CON
3667 ELM_CHECK_WIDTYPE(obj, widtype);
3668 Widget_Data *wd = elm_widget_data_get(obj);
3673 *try_num = wd->try_num;
3678 *finish_num = wd->finish_num;
3688 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
3690 #ifdef HAVE_ELEMENTARY_ECORE_CON
3691 ELM_CHECK_WIDTYPE(obj, widtype);
3692 Widget_Data *wd = elm_widget_data_get(obj);
3695 int zoom = floor(log(size / 256) / log(2));
3696 if ((wd->src) && (wd->src->coord_into_geo))
3698 if (wd->src->coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
3703 *lon = x / (double)size * 360.0 - 180;
3707 double n = ELM_PI - 2.0 * ELM_PI * y / size;
3708 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
3721 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
3723 #ifdef HAVE_ELEMENTARY_ECORE_CON
3724 ELM_CHECK_WIDTYPE(obj, widtype);
3725 Widget_Data *wd = elm_widget_data_get(obj);
3728 int zoom = floor(log(size / 256) / log(2));
3729 if ((wd->src) && (wd->src->geo_into_coord))
3731 if (wd->src->geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
3735 *x = floor((lon + 180.0) / 360.0 * size);
3737 *y = floor((1.0 - log( tan(lat * ELM_PI / 180.0) + 1.0 / cos(lat * ELM_PI / 180.0)) / ELM_PI) / 2.0 * size);
3749 elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat)
3751 #ifdef HAVE_ELEMENTARY_ECORE_CON
3752 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3753 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat);
3763 elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address)
3765 #ifdef HAVE_ELEMENTARY_ECORE_CON
3766 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3767 if (!address) return NULL;
3768 return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0);
3777 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)
3779 #ifdef HAVE_ELEMENTARY_ECORE_CON
3780 if ((!xx) || (!yy)) return;
3782 double r = (degree * M_PI) / 180.0;
3783 double tx, ty, ttx, tty;
3790 tx = ttx + (ty * cos(r + M_PI_2));
3791 ty = tty + (ty * sin(r + M_PI_2));
3806 EAPI Elm_Map_Marker *
3807 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
3809 #ifdef HAVE_ELEMENTARY_ECORE_CON
3810 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3811 Widget_Data *wd = elm_widget_data_get(obj);
3814 Marker_Group *group;
3822 if (!wd) return NULL;
3823 EINA_SAFETY_ON_NULL_RETURN_VAL(clas_group, NULL);
3824 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, NULL);
3826 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
3829 marker->clas = clas;
3830 marker->clas_group = clas_group;
3831 marker->longitude = lon;
3832 marker->latitude = lat;
3833 marker->data = data;
3834 marker->x = calloc(wd->zoom_max + 1, sizeof(Evas_Coord));
3835 marker->y = calloc(wd->zoom_max + 1, sizeof(Evas_Coord));
3836 marker->groups = calloc(wd->zoom_max + 1, sizeof(Marker_Group*));
3838 tabi[1] = tabi[4] = tabi[6] = -1;
3839 tabi[2] = tabi[0] = tabi[7] = 0;
3840 tabi[3] = tabi[5] = tabi[8] = 1;
3842 tabj[1] = tabj[2] = tabj[3] = -1;
3843 tabj[4] = tabj[0] = tabj[5] = 0;
3844 tabj[6] = tabj[7] = tabj[8] = 1;
3846 if (!clas_group->priv.set)
3849 if (marker->clas_group && marker->clas_group->style)
3850 style = marker->clas_group->style;
3852 o = edje_object_add(evas_object_evas_get(obj));
3853 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3854 s = edje_object_data_get(o, "size_w");
3855 if (s) clas_group->priv.edje_w = atoi(s);
3856 else clas_group->priv.edje_w = 0;
3857 s = edje_object_data_get(o, "size_h");
3858 if (s) clas_group->priv.edje_h = atoi(s);
3859 else clas_group->priv.edje_h = 0;
3860 s = edje_object_data_get(o, "size_max_w");
3861 if (s) clas_group->priv.edje_max_w = atoi(s);
3862 else clas_group->priv.edje_max_w = 0;
3863 s = edje_object_data_get(o, "size_max_h");
3864 if (s) clas_group->priv.edje_max_h = atoi(s);
3865 else clas_group->priv.edje_max_h = 0;
3868 clas_group->priv.set = EINA_TRUE;
3871 if (!clas->priv.set)
3874 if (marker->clas && marker->clas->style)
3875 style = marker->clas->style;
3877 o = edje_object_add(evas_object_evas_get(obj));
3878 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
3879 s = edje_object_data_get(o, "size_w");
3880 if (s) clas->priv.edje_w = atoi(s);
3881 else clas->priv.edje_w = 0;
3882 s = edje_object_data_get(o, "size_h");
3883 if (s) clas->priv.edje_h = atoi(s);
3884 else clas->priv.edje_h = 0;
3887 clas->priv.set = EINA_TRUE;
3890 for (i = clas_group->zoom_displayed; i <= wd->zoom_max; i++)
3892 elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
3893 &(marker->x[i]), &(marker->y[i]));
3895 //search in the matrixsparse the region where the marker will be
3896 mpi = marker->x[i] / wd->tsize;
3897 mpj = marker->y[i] / wd->tsize;
3899 if (!wd->markers[i])
3901 int size = pow(2.0, i);
3902 wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
3906 if (i <= clas_group->zoom_grouped)
3908 for (j = 0, group = NULL; j < 9 && !group; j++)
3910 EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
3913 if (group->clas == marker->clas_group
3914 && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
3915 marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
3916 group->x-group->w/4, group->y-group->h/4, group->w, group->h))
3918 group->markers = eina_list_append(group->markers, marker);
3919 group->update_nbelems = EINA_TRUE;
3920 group->update_resize = EINA_TRUE;
3922 group->sum_x += marker->x[i];
3923 group->sum_y += marker->y[i];
3924 group->x = group->sum_x / eina_list_count(group->markers);
3925 group->y = group->sum_y / eina_list_count(group->markers);
3927 group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
3928 * eina_list_count(group->markers);
3929 group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
3930 * eina_list_count(group->markers);
3931 if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
3932 if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
3934 if (group->obj && eina_list_count(group->markers) == 2)
3936 _group_object_free(group);
3937 _group_object_create(group);
3940 _group_bubble_content_update(group);
3949 group = calloc(1, sizeof(Marker_Group));
3951 group->sum_x = marker->x[i];
3952 group->sum_y = marker->y[i];
3953 group->x = marker->x[i];
3954 group->y = marker->y[i];
3955 group->w = clas_group->priv.edje_w;
3956 group->h = clas_group->priv.edje_h;
3957 group->clas = clas_group;
3959 group->markers = eina_list_append(group->markers, marker);
3960 group->update_nbelems = EINA_TRUE;
3961 group->update_resize = EINA_TRUE;
3963 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3967 l = eina_list_append(NULL, group);
3968 eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
3969 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
3973 l = eina_matrixsparse_cell_data_get(group->cell);
3974 l = eina_list_append(l, group);
3975 eina_matrixsparse_cell_data_set(group->cell, l);
3978 marker->groups[i] = group;
3983 Evas_Coord ox, oy, ow, oh;
3984 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3985 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4001 elm_map_marker_remove(Elm_Map_Marker *marker)
4003 #ifdef HAVE_ELEMENTARY_ECORE_CON
4008 EINA_SAFETY_ON_NULL_RETURN(marker);
4011 for (i = marker->clas_group->zoom_displayed; i <= wd->zoom_max; i++)
4013 marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
4014 if (!eina_list_count(marker->groups[i]->markers))
4016 groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
4017 groups = eina_list_remove(groups, marker->groups[i]);
4018 eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
4020 _group_object_free(marker->groups[i]);
4021 _group_bubble_free(marker->groups[i]);
4022 free(marker->groups[i]);
4026 marker->groups[i]->sum_x -= marker->x[i];
4027 marker->groups[i]->sum_y -= marker->y[i];
4029 marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
4030 marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
4032 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
4033 + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
4034 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
4035 + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
4036 if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
4037 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
4038 if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
4039 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
4041 if ((marker->groups[i]->obj) && (eina_list_count(marker->groups[i]->markers) == 1))
4043 _group_object_free(marker->groups[i]);
4044 _group_object_create(marker->groups[i]);
4049 if ((marker->content) && (marker->clas->func.del))
4050 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4051 else if (marker->content)
4052 evas_object_del(marker->content);
4054 if (marker->x) free(marker->x);
4055 if (marker->y) free(marker->y);
4056 if (marker->groups) free(marker->groups);
4062 Evas_Coord ox, oy, ow, oh;
4063 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
4064 marker_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4072 elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat)
4074 #ifdef HAVE_ELEMENTARY_ECORE_CON
4075 EINA_SAFETY_ON_NULL_RETURN(marker);
4076 if (lon) *lon = marker->longitude;
4077 if (lat) *lat = marker->latitude;
4086 elm_map_marker_bring_in(Elm_Map_Marker *marker)
4088 #ifdef HAVE_ELEMENTARY_ECORE_CON
4089 EINA_SAFETY_ON_NULL_RETURN(marker);
4090 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
4097 elm_map_marker_show(Elm_Map_Marker *marker)
4099 #ifdef HAVE_ELEMENTARY_ECORE_CON
4100 EINA_SAFETY_ON_NULL_RETURN(marker);
4101 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
4108 elm_map_markers_list_show(Eina_List *markers)
4110 #ifdef HAVE_ELEMENTARY_ECORE_CON
4114 Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
4115 Evas_Coord rw, rh, xc, yc;
4118 EINA_SAFETY_ON_NULL_RETURN(markers);
4119 EINA_LIST_FOREACH(markers, l, marker)
4123 if ((!m_min_lon) || (marker->longitude < m_min_lon->longitude))
4126 if ((!m_max_lon) || (marker->longitude > m_max_lon->longitude))
4129 if ((!m_min_lat) || (marker->latitude > m_min_lat->latitude))
4132 if ((!m_max_lat) || (marker->latitude < m_max_lat->latitude))
4136 lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
4137 lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
4139 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
4140 for (zoom = wd->src->zoom_max; zoom > wd->src->zoom_min; zoom--)
4142 Evas_Coord size = pow(2.0, zoom)*wd->tsize;
4143 elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
4145 if ((m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2)
4146 && (m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2)
4147 && (m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2)
4148 && (m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2))
4152 elm_map_geo_region_show(wd->obj, lon, lat);
4153 elm_map_zoom_set(wd->obj, zoom);
4160 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
4162 #ifdef HAVE_ELEMENTARY_ECORE_CON
4163 ELM_CHECK_WIDTYPE(obj, widtype);
4164 Widget_Data *wd = elm_widget_data_get(obj);
4167 wd->markers_max_num = max;
4175 elm_map_marker_object_get(const Elm_Map_Marker *marker)
4177 #ifdef HAVE_ELEMENTARY_ECORE_CON
4178 EINA_SAFETY_ON_NULL_RETURN_VAL(marker, NULL);
4179 return marker->content;
4187 elm_map_marker_update(Elm_Map_Marker *marker)
4189 #ifdef HAVE_ELEMENTARY_ECORE_CON
4190 EINA_SAFETY_ON_NULL_RETURN(marker);
4191 if (marker->content)
4193 if (marker->clas->func.del)
4194 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
4196 evas_object_del(marker->content);
4197 marker->content = NULL;
4198 _group_bubble_content_update(marker->groups[marker->wd->zoom]);
4206 elm_map_bubbles_close(Evas_Object *obj)
4208 #ifdef HAVE_ELEMENTARY_ECORE_CON
4209 ELM_CHECK_WIDTYPE(obj, widtype);
4210 Widget_Data *wd = elm_widget_data_get(obj);
4211 Marker_Group *group;
4212 Eina_List *l, *l_next;
4215 EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
4216 _group_bubble_free(group);
4222 EAPI Elm_Map_Group_Class *
4223 elm_map_group_class_new(Evas_Object *obj)
4225 #ifdef HAVE_ELEMENTARY_ECORE_CON
4226 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4227 Widget_Data *wd = elm_widget_data_get(obj);
4229 if (!wd) return NULL;
4230 Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
4231 clas->zoom_grouped = wd->zoom_max;
4232 wd->groups_clas = eina_list_append(wd->groups_clas, clas);
4241 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
4243 #ifdef HAVE_ELEMENTARY_ECORE_CON
4244 EINA_SAFETY_ON_NULL_RETURN(clas);
4245 eina_stringshare_replace(&clas->style, style);
4253 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
4255 #ifdef HAVE_ELEMENTARY_ECORE_CON
4256 EINA_SAFETY_ON_NULL_RETURN(clas);
4257 clas->func.icon_get = icon_get;
4265 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
4267 #ifdef HAVE_ELEMENTARY_ECORE_CON
4268 EINA_SAFETY_ON_NULL_RETURN(clas);
4277 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
4279 #ifdef HAVE_ELEMENTARY_ECORE_CON
4280 EINA_SAFETY_ON_NULL_RETURN(clas);
4281 clas->zoom_displayed = zoom;
4289 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
4291 #ifdef HAVE_ELEMENTARY_ECORE_CON
4292 EINA_SAFETY_ON_NULL_RETURN(clas);
4293 clas->zoom_grouped = zoom;
4301 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
4303 #ifdef HAVE_ELEMENTARY_ECORE_CON
4304 ELM_CHECK_WIDTYPE(obj, widtype);
4305 Widget_Data *wd = elm_widget_data_get(obj);
4308 EINA_SAFETY_ON_NULL_RETURN(clas);
4309 if (clas->hide == hide) return;
4313 Evas_Coord ox, oy, ow, oh;
4314 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
4315 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
4324 EAPI Elm_Map_Marker_Class *
4325 elm_map_marker_class_new(Evas_Object *obj)
4327 #ifdef HAVE_ELEMENTARY_ECORE_CON
4328 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4329 Widget_Data *wd = elm_widget_data_get(obj);
4331 if (!wd) return NULL;
4332 Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
4333 wd->markers_clas = eina_list_append(wd->markers_clas, clas);
4342 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
4344 #ifdef HAVE_ELEMENTARY_ECORE_CON
4345 EINA_SAFETY_ON_NULL_RETURN(clas);
4346 eina_stringshare_replace(&clas->style, style);
4354 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
4356 #ifdef HAVE_ELEMENTARY_ECORE_CON
4357 EINA_SAFETY_ON_NULL_RETURN(clas);
4358 clas->func.icon_get = icon_get;
4366 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
4368 #ifdef HAVE_ELEMENTARY_ECORE_CON
4369 EINA_SAFETY_ON_NULL_RETURN(clas);
4370 clas->func.get = get;
4378 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
4380 #ifdef HAVE_ELEMENTARY_ECORE_CON
4381 EINA_SAFETY_ON_NULL_RETURN(clas);
4382 clas->func.del = del;
4390 elm_map_source_names_get(const Evas_Object *obj)
4392 #ifdef HAVE_ELEMENTARY_ECORE_CON
4393 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4394 Widget_Data *wd = elm_widget_data_get(obj);
4396 if (!wd) return NULL;
4397 return wd->source_names;
4405 elm_map_source_name_set(Evas_Object *obj, const char *source_name)
4407 #ifdef HAVE_ELEMENTARY_ECORE_CON
4408 ELM_CHECK_WIDTYPE(obj, widtype);
4409 Widget_Data *wd = elm_widget_data_get(obj);
4418 if (!strcmp(wd->src->name, source_name)) return;
4419 if (!wd->src->url_cb) return;
4422 EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid);
4423 EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
4425 if (!strcmp(s->name, source_name))
4436 if (wd->src->zoom_max < zoom)
4437 zoom = wd->src->zoom_max;
4438 if (wd->src->zoom_min > zoom)
4439 zoom = wd->src->zoom_min;
4441 elm_map_zoom_set(obj, zoom);
4449 elm_map_source_name_get(const Evas_Object *obj)
4451 #ifdef HAVE_ELEMENTARY_ECORE_CON
4452 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4453 Widget_Data *wd = elm_widget_data_get(obj);
4455 if ((!wd) || (!wd->src)) return NULL;
4456 return wd->src->name;
4464 elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
4466 #ifdef HAVE_ELEMENTARY_ECORE_CON
4467 ELM_CHECK_WIDTYPE(obj, widtype);
4468 Widget_Data *wd = elm_widget_data_get(obj);
4471 wd->route_source = source;
4478 EAPI Elm_Map_Route_Sources
4479 elm_map_route_source_get(const Evas_Object *obj)
4481 #ifdef HAVE_ELEMENTARY_ECORE_CON
4482 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS;
4483 Widget_Data *wd = elm_widget_data_get(obj);
4485 if (!wd) return ELM_MAP_ROUTE_SOURCE_YOURS;
4486 return wd->route_source;
4489 return ELM_MAP_ROUTE_SOURCE_YOURS;
4494 elm_map_source_zoom_max_set(Evas_Object *obj, int zoom)
4496 #ifdef HAVE_ELEMENTARY_ECORE_CON
4497 ELM_CHECK_WIDTYPE(obj, widtype);
4498 Widget_Data *wd = elm_widget_data_get(obj);
4500 if ((!wd) || (!wd->src)) return;
4501 if ((zoom > wd->zoom_max) || (zoom < wd->zoom_min)) return;
4502 wd->src->zoom_max = zoom;
4510 elm_map_source_zoom_max_get(const Evas_Object *obj)
4512 #ifdef HAVE_ELEMENTARY_ECORE_CON
4513 ELM_CHECK_WIDTYPE(obj, widtype) 18;
4514 Widget_Data *wd = elm_widget_data_get(obj);
4516 if ((!wd) || (!wd->src)) return 18;
4517 return wd->src->zoom_max;
4525 elm_map_source_zoom_min_set(Evas_Object *obj, int zoom)
4527 #ifdef HAVE_ELEMENTARY_ECORE_CON
4528 ELM_CHECK_WIDTYPE(obj, widtype);
4529 Widget_Data *wd = elm_widget_data_get(obj);
4531 if ((!wd) || (!wd->src)) return;
4532 if ((zoom > wd->zoom_max) || (zoom < wd->zoom_min)) return;
4533 wd->src->zoom_min = zoom;
4541 elm_map_source_zoom_min_get(const Evas_Object *obj)
4543 #ifdef HAVE_ELEMENTARY_ECORE_CON
4544 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4545 Widget_Data *wd = elm_widget_data_get(obj);
4547 if ((!wd) || (!wd->src)) return 0;
4548 return wd->src->zoom_min;
4556 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
4558 #ifdef HAVE_ELEMENTARY_ECORE_CON
4559 ELM_CHECK_WIDTYPE(obj, widtype);
4560 Widget_Data *wd = elm_widget_data_get(obj);
4563 if (!wd->user_agent) wd->user_agent = eina_stringshare_add(user_agent);
4564 else eina_stringshare_replace(&wd->user_agent, user_agent);
4566 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4567 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4575 elm_map_user_agent_get(const Evas_Object *obj)
4577 #ifdef HAVE_ELEMENTARY_ECORE_CON
4578 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4579 Widget_Data *wd = elm_widget_data_get(obj);
4581 if (!wd) return NULL;
4582 return wd->user_agent;
4589 EAPI Elm_Map_Route *
4590 elm_map_route_add(Evas_Object *obj,
4591 Elm_Map_Route_Type type,
4592 Elm_Map_Route_Method method,
4598 #ifdef HAVE_ELEMENTARY_ECORE_CON
4599 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4600 Widget_Data *wd = elm_widget_data_get(obj);
4603 char *type_name = NULL;
4606 if ((!wd) || (!wd->src)) return NULL;
4608 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4609 if (!route) return NULL;
4611 snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE);
4619 route->con_url = ecore_con_url_new(NULL);
4620 route->ud.fname = strdup(buf);
4621 INF("xml file : %s", route->ud.fname);
4623 route->ud.fd = fdopen(fd, "w+");
4624 if ((!route->con_url) || (!route->ud.fd))
4626 ecore_con_url_free(route->con_url);
4632 route->color.r = 255;
4635 route->color.a = 255;
4636 route->handlers = eina_list_append
4637 (route->handlers, (void *)ecore_event_handler_add
4638 (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route));
4640 route->inbound = EINA_FALSE;
4642 route->method = method;
4650 case ELM_MAP_ROUTE_TYPE_MOTOCAR:
4651 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4653 case ELM_MAP_ROUTE_TYPE_BICYCLE:
4654 type_name = strdup(ROUTE_TYPE_BICYCLE);
4656 case ELM_MAP_ROUTE_TYPE_FOOT:
4657 type_name = strdup(ROUTE_TYPE_FOOT);
4663 source = wd->src->route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4664 INF("route url = %s", source);
4666 wd->route = eina_list_append(wd->route, route);
4668 ecore_con_url_url_set(route->con_url, source);
4669 ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd));
4670 ecore_con_url_data_set(route->con_url, route);
4671 ecore_con_url_get(route->con_url);
4672 if (type_name) free(type_name);
4673 if (source) free(source);
4675 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4676 "elm,state,busy,start", "elm");
4677 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL);
4692 elm_map_route_remove(Elm_Map_Route *route)
4694 #ifdef HAVE_ELEMENTARY_ECORE_CON
4695 EINA_SAFETY_ON_NULL_RETURN(route);
4700 Ecore_Event_Handler *h;
4702 EINA_LIST_FREE(route->path, p)
4707 EINA_LIST_FREE(route->waypoint, w)
4709 if (w->point) eina_stringshare_del(w->point);
4713 EINA_LIST_FREE(route->nodes, n)
4715 if (n->pos.address) eina_stringshare_del(n->pos.address);
4719 EINA_LIST_FREE(route->handlers, h)
4721 ecore_event_handler_del(h);
4724 if (route->ud.fname)
4726 ecore_file_remove(route->ud.fname);
4727 free(route->ud.fname);
4728 route->ud.fname = NULL;
4736 elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a)
4738 #ifdef HAVE_ELEMENTARY_ECORE_CON
4739 EINA_SAFETY_ON_NULL_RETURN(route);
4754 elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a)
4756 #ifdef HAVE_ELEMENTARY_ECORE_CON
4757 EINA_SAFETY_ON_NULL_RETURN(route);
4758 if (r) *r = route->color.r;
4759 if (g) *g = route->color.g;
4760 if (b) *b = route->color.b;
4761 if (a) *a = route->color.a;
4772 elm_map_route_distance_get(const Elm_Map_Route *route)
4774 #ifdef HAVE_ELEMENTARY_ECORE_CON
4775 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
4776 return route->info.distance;
4784 elm_map_route_node_get(const Elm_Map_Route *route)
4786 #ifdef HAVE_ELEMENTARY_ECORE_CON
4787 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4788 return route->info.nodes;
4796 elm_map_route_waypoint_get(const Elm_Map_Route *route)
4798 #ifdef HAVE_ELEMENTARY_ECORE_CON
4799 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4800 return route->info.waypoints;
4808 elm_map_name_address_get(const Elm_Map_Name *name)
4810 #ifdef HAVE_ELEMENTARY_ECORE_CON
4811 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
4812 return name->address;
4820 elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
4822 #ifdef HAVE_ELEMENTARY_ECORE_CON
4823 EINA_SAFETY_ON_NULL_RETURN(name);
4824 if (lon) *lon = name->lon;
4825 if (lat) *lat = name->lat;
4834 elm_map_name_remove(Elm_Map_Name *name)
4836 #ifdef HAVE_ELEMENTARY_ECORE_CON
4837 EINA_SAFETY_ON_NULL_RETURN(name);
4840 free(name->address);
4841 name->address = NULL;
4845 ecore_event_handler_del(name->handler);
4846 name->handler = NULL;
4850 ecore_file_remove(name->ud.fname);
4851 free(name->ud.fname);
4852 name->ud.fname = NULL;
4860 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
4862 #ifdef HAVE_ELEMENTARY_ECORE_CON
4863 ELM_CHECK_WIDTYPE(obj, widtype);
4864 Widget_Data *wd = elm_widget_data_get(obj);
4867 wd->rotate.d = degree;
4870 wd->calc_job = ecore_job_add(_calc_job, wd);
4880 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
4882 #ifdef HAVE_ELEMENTARY_ECORE_CON
4883 ELM_CHECK_WIDTYPE(obj, widtype);
4884 Widget_Data *wd = elm_widget_data_get(obj);
4887 if (degree) *degree = wd->rotate.d;
4888 if (cx) *cx = wd->rotate.cx;
4889 if (cy) *cy = wd->rotate.cy;
4899 elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
4901 #ifdef HAVE_ELEMENTARY_ECORE_CON
4902 ELM_CHECK_WIDTYPE(obj, widtype);
4903 Widget_Data *wd = elm_widget_data_get(obj);
4906 if ((!wd->wheel_disabled) && (disabled))
4907 evas_object_event_callback_del_full(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
4908 else if ((wd->wheel_disabled) && (!disabled))
4909 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
4910 wd->wheel_disabled = !!disabled;
4918 elm_map_wheel_disabled_get(const Evas_Object *obj)
4920 #ifdef HAVE_ELEMENTARY_ECORE_CON
4921 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4922 Widget_Data *wd = elm_widget_data_get(obj);
4924 if (!wd) return EINA_FALSE;
4925 return wd->wheel_disabled;
4934 elm_map_track_add(Evas_Object *obj, EMap_Route *emap)
4936 #ifdef HAVE_ELEMENTARY_ECORE_CON
4937 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4938 Widget_Data *wd = elm_widget_data_get(obj);
4940 if (!wd) return EINA_FALSE;
4942 Evas_Object *route = elm_route_add(obj);
4943 elm_route_emap_set(route, emap);
4944 wd->track = eina_list_append(wd->track, route);
4956 elm_map_track_remove(Evas_Object *obj, Evas_Object *route)
4958 #ifdef HAVE_ELEMENTARY_ECORE_CON
4959 ELM_CHECK_WIDTYPE(obj, widtype) ;
4960 Widget_Data *wd = elm_widget_data_get(obj);
4964 wd->track = eina_list_remove(wd->track, route);
4965 evas_object_del(route);
4972 #ifdef HAVE_ELEMENTARY_ECORE_CON
4975 _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4978 snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
4984 _osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4987 snprintf(buf, sizeof(buf),
4988 "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
4994 _cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
4997 snprintf(buf, sizeof(buf),
4998 "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
5004 _maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
5007 snprintf(buf, sizeof(buf),
5008 "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
5013 static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5016 snprintf(buf, sizeof(buf),
5017 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
5018 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
5023 // TODO: fix monav api
5025 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5028 snprintf(buf, sizeof(buf),
5029 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
5030 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
5036 // TODO: fix ors api
5038 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
5041 snprintf(buf, sizeof(buf),
5042 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
5043 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
5050 _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
5052 ELM_CHECK_WIDTYPE(obj, widtype) strdup("");
5053 Widget_Data *wd = elm_widget_data_get(obj);
5055 unsigned int ele, idx;
5056 char search_url[PATH_MAX];
5059 if (!wd) return strdup("");
5060 if (method == ELM_MAP_NAME_METHOD_SEARCH)
5062 search_url[0] = '\0';
5063 str = eina_str_split_full(name, " ", 0, &ele);
5064 for (idx = 0 ; idx < ele ; idx++)
5066 eina_strlcat(search_url, str[idx], sizeof(search_url));
5067 if (!(idx == (ele-1))) eina_strlcat(search_url, "+", sizeof(search_url));
5069 snprintf(buf, sizeof(buf), "%s/search?q=%s&format=xml&polygon=0&addressdetails=0", NAME_NOMINATIM_URL, search_url);
5071 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);
5072 else strcpy(buf, "");