2 # include "elementary_config.h"
5 #include "Elementary.h"
7 #include "els_scroller.h"
9 #define OVERLAY_CLASS_ZOOM_MAX 255
11 #ifdef HAVE_ELEMENTARY_ECORE_CON
13 typedef struct _Widget_Data Widget_Data;
14 typedef struct _Path Path;
15 typedef struct _Color Color;
16 typedef struct _Region Region;
17 typedef struct _Pan Pan;
18 typedef struct _Grid Grid;
19 typedef struct _Grid_Item Grid_Item;
20 typedef struct _Overlay_Default Overlay_Default;
21 typedef struct _Overlay_Class Overlay_Class;
22 typedef struct _Overlay_Group Overlay_Group;
23 typedef struct _Overlay_Bubble Overlay_Bubble;
24 typedef struct _Overlay_Route Overlay_Route;
25 typedef struct _Overlay_Line Overlay_Line;
26 typedef struct _Overlay_Polygon Overlay_Polygon;
27 typedef struct _Overlay_Circle Overlay_Circle;
28 typedef struct _Overlay_Scale Overlay_Scale;
29 typedef struct _Path_Node Path_Node;
30 typedef struct _Path_Waypoint Path_Waypoint;
31 typedef struct _Route_Dump Route_Dump;
32 typedef struct _Name_Dump Name_Dump;
33 typedef struct _Delayed_Data Delayed_Data;
34 typedef struct _Source_Tile Source_Tile;
35 typedef struct _Source_Route Source_Route;
36 typedef struct _Source_Name Source_Name;
38 typedef char *(*Elm_Map_Module_Source_Name_Func)(void);
39 typedef int (*Elm_Map_Module_Tile_Zoom_Min_Func)(void);
40 typedef int (*Elm_Map_Module_Tile_Zoom_Max_Func)(void);
41 typedef char *(*Elm_Map_Module_Tile_Url_Func)(const Evas_Object *obj, int x, int y, int zoom);
42 typedef Eina_Bool (*Elm_Map_Module_Tile_Geo_to_Coord_Func)(const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y);
43 typedef Eina_Bool (*Elm_Map_Module_Tile_Coord_to_Geo_Func)(const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat);
44 typedef double (*Elm_Map_Module_Tile_Scale_Func)(const Evas_Object *obj, double lon, double lat, int zoom);
45 typedef char *(*Elm_Map_Module_Route_Url_Func)(const Evas_Object *obj, const char *type_name, int method, double flon, double flat, double tlon, double tlat);
46 typedef char *(*Elm_Map_Module_Name_Url_Func)(const Evas_Object *obj, int method, const char *name, double lon, double lat);
48 #define ROUND(z) (((z) < 0) ? (int)ceil((z) - 0.005) : (int)floor((z) + 0.005))
49 #define EVAS_MAP_POINT 4
50 #define DEFAULT_TILE_SIZE 256
51 #define MAX_CONCURRENT_DOWNLOAD 10
52 #define MARER_MAX_NUMBER 30
53 #define OVERLAY_GROUPING_SCALE 2
55 #define CACHE_ROOT "/tmp/elm_map"
56 #define CACHE_TILE_ROOT CACHE_ROOT"/%d/%d/%d"
57 #define CACHE_TILE_PATH "%s/%d.png"
58 #define CACHE_ROUTE_ROOT CACHE_ROOT"/route"
59 #define CACHE_NAME_ROOT CACHE_ROOT"/name"
61 #define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php"
62 #define ROUTE_TYPE_MOTORCAR "motocar"
63 #define ROUTE_TYPE_BICYCLE "bicycle"
64 #define ROUTE_TYPE_FOOT "foot"
65 #define YOURS_DISTANCE "distance"
66 #define YOURS_DESCRIPTION "description"
67 #define YOURS_COORDINATES "coordinates"
69 #define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org"
70 #define NOMINATIM_RESULT "result"
71 #define NOMINATIM_PLACE "place"
72 #define NOMINATIM_ATTR_LON "lon"
73 #define NOMINATIM_ATTR_LAT "lat"
75 enum _Route_Xml_Attribute
79 ROUTE_XML_DESCRIPTION,
80 ROUTE_XML_COORDINATES,
84 enum _Name_Xml_Attribute
93 enum _Track_Xml_Attribute
96 TRACK_XML_COORDINATES,
112 void (*func)(void *data);
114 Elm_Map_Zoom_Mode mode;
120 // FIXME: Currently tile size must be 256*256
121 // and the map size is pow(2.0, z) * (tile size)
127 Elm_Map_Module_Tile_Url_Func url_cb;
128 Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord;
129 Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo;
130 Elm_Map_Module_Tile_Scale_Func scale_cb;
136 Elm_Map_Module_Route_Url_Func url_cb;
142 Elm_Map_Module_Name_Url_Func url_cb;
150 struct _Overlay_Group
153 Elm_Map_Overlay *overlay; // virtual group type overlay
154 Elm_Map_Overlay *clas; // class overlay for this virtual group
155 Overlay_Default *ovl; // rendered overlay
161 struct _Overlay_Default
169 // Display priority is content > icon > clas_obj > clas_icon > layout
170 Evas_Object *content;
174 // if clas_content or icon exists, do not inherit from class
175 Evas_Object *clas_content; // Duplicated from class content
176 Evas_Object *clas_icon; // Duplicated from class icon
180 struct _Overlay_Class
185 Evas_Object *content;
189 struct _Overlay_Bubble
193 Evas_Object *obj, *sc, *bx;
195 Evas_Coord x, y, w, h;
198 struct _Overlay_Route
210 double flon, flat, tlon, tlat;
214 struct _Overlay_Polygon
217 Eina_List *regions; // list of Regions
221 struct _Overlay_Circle
225 double radius; // Intial pixel in intial view
226 double ratio; // initial-radius/map-size
230 struct _Overlay_Scale
238 struct _Elm_Map_Overlay
242 Eina_Bool paused : 1;
246 void *data; // user set data
248 Elm_Map_Overlay_Type type;
249 void *ovl; // Overlay Data for each type
251 Elm_Map_Overlay_Get_Cb cb;
254 // These are not used if overlay type is class or group
258 struct _Elm_Map_Route
263 Elm_Map_Route_Type type;
264 Elm_Map_Route_Method method;
265 double flon, flat, tlon, tlat;
268 Ecore_File_Download_Job *job;
278 const char *waypoints;
279 double distance; /* unit : km */
298 struct _Path_Waypoint
314 Ecore_File_Download_Job *job;
344 int x, y; // Tile coordinate
345 Eina_Bool file_have : 1;
347 Ecore_File_Download_Job *job;
353 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
354 int tw, th; // size of grid in tiles
355 Eina_Matrixsparse *grid;
360 Evas_Object_Smart_Clipped_Data __clipped_data;
369 Evas_Object *pan_smart;
370 Evas_Object *sep_maps_overlays; // Tiles are below this and overlays are on top
373 Eina_Array *src_tile_mods;
374 Source_Tile *src_tile;
375 Eina_List *src_tiles;
376 const char **src_tile_names;
378 Eina_Array *src_route_mods;
379 Source_Route *src_route;
380 Eina_List *src_routes;
381 const char **src_route_names;
383 Eina_Array *src_name_mods;
384 Source_Name *src_name;
385 Eina_List *src_names;
386 const char **src_name_names;
388 int zoom_min, zoom_max;
398 int w, h; // Current pixel width, heigth of a grid
399 int tile; // Current pixel size of a grid item
401 Elm_Map_Zoom_Mode mode;
408 Ecore_Timer *zoom_timer;
409 Ecore_Animator *zoom_animator;
414 Eina_List *download_list;
415 Ecore_Idler *download_idler;
417 const char *user_agent;
419 Evas_Coord pan_x, pan_y;
420 Eina_List *delayed_jobs;
422 Ecore_Timer *scr_timer;
423 Ecore_Timer *long_timer;
424 Evas_Event_Mouse_Down ev;
425 Eina_Bool on_hold : 1;
426 Eina_Bool paused : 1;
435 Eina_Bool wheel_disabled : 1;
444 static char *_mapnik_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
445 static char *_osmarender_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
446 static char *_cyclemap_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
447 static char *_mapquest_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
448 static char *_mapquest_aerial_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
449 static char *_yours_url_cb(const Evas_Object *obj __UNUSED__, const char *type_name, int method, double flon, double flat, double tlon, double tlat);
450 static char *_nominatim_url_cb(const Evas_Object *obj, int method, const char *name, double lon, double lat);
452 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
453 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
455 static double _scale_cb(const Evas_Object *obj __UNUSED__, double lon __UNUSED__, double lat, int zoom);
457 const Source_Tile src_tiles[] =
459 {"Mapnik", 0, 18, _mapnik_url_cb, NULL, NULL, _scale_cb},
460 {"Osmarender", 0, 17, _osmarender_url_cb, NULL, NULL, _scale_cb},
461 {"CycleMap", 0, 16, _cyclemap_url_cb, NULL, NULL, _scale_cb},
462 {"MapQuest", 0, 18, _mapquest_url_cb, NULL, NULL, _scale_cb},
463 {"MapQuest Open Aerial", 0, 11, _mapquest_aerial_url_cb, NULL, NULL, _scale_cb}
466 // FIXME: Fix more open sources
467 const Source_Route src_routes[] =
469 {"Yours", _yours_url_cb} // http://www.yournavigation.org/
470 //{"Monav", _monav_url_cb},
471 //{"ORS", _ors_url_cb}, // http://www.openrouteservice.org
474 // Refer : http://wiki.openstreetmap.org/wiki/FAQ
475 // meters per pixel when latitude is 0 (equator)
476 // meters per pixel = _osm_scale_meter[zoom] * cos (latitude)
477 const double _osm_scale_meter[] =
478 {78206, 39135.758482, 19567.879241, 9783.939621, 4891.969810,
479 2445.984905, 1222.992453, 611.496226, 305.748113, 152.874057, 76.437028,
480 38.218514, 19.109257, 9.554629, 4.777314, 2.388657, 1.194329, 0.597164,
484 const double _scale_tb[] =
485 {10000000, 5000000, 2000000, 1000000, 500000, 200000, 100000, 50000,
486 20000, 10000, 5000, 2000, 1000, 500, 500, 200, 100, 50, 20, 10, 5, 2, 1};
488 // FIXME: Add more open sources
489 const Source_Name src_names[] =
491 {"Nominatim", _nominatim_url_cb}
494 static const char *widtype = NULL;
495 static Evas_Smart_Class parent_sc = EVAS_SMART_CLASS_INIT_NULL;
496 static Evas_Smart_Class sc;
497 static Evas_Smart *smart;
498 static int idnum = 1;
500 static const char SIG_CLICKED[] = "clicked";
501 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
502 static const char SIG_PRESS[] = "press";
503 static const char SIG_LONGPRESSED[] = "longpressed";
504 static const char SIG_SCROLL[] = "scroll";
505 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
506 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
507 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
508 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
509 static const char SIG_ZOOM_START[] = "zoom,start";
510 static const char SIG_ZOOM_STOP[] = "zoom,stop";
511 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
512 static const char SIG_TILE_LOAD[] = "tile,load";
513 static const char SIG_TILE_LOADED[] = "tile,loaded";
514 static const char SIG_TILE_LOADED_FAIL[] = "tile,loaded,fail";
515 static const char SIG_ROUTE_LOAD[] = "route,load";
516 static const char SIG_ROUTE_LOADED[] = "route,loaded";
517 static const char SIG_ROUTE_LOADED_FAIL[] = "route,loaded,fail";
518 static const char SIG_NAME_LOAD[] = "name,load";
519 static const char SIG_NAME_LOADED[] = "name,loaded";
520 static const char SIG_NAME_LOADED_FAIL[] = "name,loaded,fail";
521 static const char SIG_OVERLAY_CLICKED[] = "overlay,clicked";
522 static const Evas_Smart_Cb_Description _signals[] = {
524 {SIG_CLICKED_DOUBLE, ""},
526 {SIG_LONGPRESSED, ""},
528 {SIG_SCROLL_DRAG_START, ""},
529 {SIG_SCROLL_DRAG_STOP, ""},
530 {SIG_SCROLL_ANIM_START, ""},
531 {SIG_SCROLL_ANIM_STOP, ""},
532 {SIG_ZOOM_START, ""},
534 {SIG_ZOOM_CHANGE, ""},
536 {SIG_TILE_LOADED, ""},
537 {SIG_TILE_LOADED_FAIL, ""},
538 {SIG_ROUTE_LOAD, ""},
539 {SIG_ROUTE_LOADED, ""},
540 {SIG_ROUTE_LOADED_FAIL, ""},
542 {SIG_NAME_LOADED, ""},
543 {SIG_NAME_LOADED_FAIL, ""},
544 {SIG_OVERLAY_CLICKED, ""},
549 _edj_overlay_size_get(Widget_Data *wd, Evas_Coord *w, Evas_Coord *h)
551 EINA_SAFETY_ON_NULL_RETURN(wd);
552 EINA_SAFETY_ON_NULL_RETURN(w);
553 EINA_SAFETY_ON_NULL_RETURN(h);
558 edj = edje_object_add(evas_object_evas_get(wd->obj));
559 _elm_theme_object_set(wd->obj, edj, "map/marker", "radio",
560 elm_widget_style_get(wd->obj));
561 s = edje_object_data_get(edj, "size_w");
564 s = edje_object_data_get(edj, "size_h");
567 evas_object_del(edj);
571 _rotate(Evas_Coord x, Evas_Coord y, Evas_Coord cx, Evas_Coord cy, double degree, Evas_Coord *xx, Evas_Coord *yy)
573 double r = (degree * M_PI) / 180.0;
574 if (xx) *xx = ((x - cx) * cos(r)) + ((y - cy) * cos(r + M_PI_2)) + cx;
575 if (yy) *yy = ((x - cx) * sin(r)) + ((y - cy) * sin(r + M_PI_2)) + cy;
579 _obj_rotate(Widget_Data *wd, Evas_Object *obj)
581 Evas_Coord w, h, ow, oh;
582 evas_map_util_points_populate_from_object(wd->map, obj);
584 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
585 evas_object_image_size_get(obj, &w, &h);
586 if ((w > ow) || (h > oh))
588 evas_map_point_image_uv_set(wd->map, 0, 0, 0);
589 evas_map_point_image_uv_set(wd->map, 1, w, 0);
590 evas_map_point_image_uv_set(wd->map, 2, w, h);
591 evas_map_point_image_uv_set(wd->map, 3, 0, h);
593 evas_map_util_rotate(wd->map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
595 evas_object_map_set(obj, wd->map);
596 evas_object_map_enable_set(obj, EINA_TRUE);
600 _obj_place(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
602 EINA_SAFETY_ON_NULL_RETURN(obj);
604 evas_object_move(obj, x, y);
605 evas_object_resize(obj, w, h);
606 evas_object_show(obj);
610 _coord_to_region_convert(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord size, double *lon, double *lat)
612 EINA_SAFETY_ON_NULL_RETURN(wd);
613 int zoom = floor(log(size / wd->size.tile) / log(2));
614 if ((wd->src_tile) && (wd->src_tile->coord_to_geo))
616 if (wd->src_tile->coord_to_geo(wd->obj, zoom, x, y, size, lon, lat))
620 if (lon) *lon = (x / (double)size * 360.0) - 180;
623 double n = ELM_PI - (2.0 * ELM_PI * y / size);
624 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
629 _region_to_coord_convert(Widget_Data *wd, double lon, double lat, Evas_Coord size, Evas_Coord *x, Evas_Coord *y)
631 EINA_SAFETY_ON_NULL_RETURN(wd);
633 int zoom = floor(log(size / 256) / log(2));
634 if ((wd->src_tile) && (wd->src_tile->geo_to_coord))
636 if (wd->src_tile->geo_to_coord(wd->obj, zoom, lon, lat, size, x, y)) return;
639 if (x) *x = floor((lon + 180.0) / 360.0 * size);
641 *y = floor((1.0 - log(tan(lat * ELM_PI / 180.0) + (1.0 / cos(lat * ELM_PI / 180.0)))
642 / ELM_PI) / 2.0 * size);
646 _viewport_coord_get(Widget_Data *wd, Evas_Coord *vx, Evas_Coord *vy, Evas_Coord *vw, Evas_Coord *vh)
648 EINA_SAFETY_ON_NULL_RETURN(wd);
650 Evas_Coord x, y, w, h;
651 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
652 elm_smart_scroller_child_viewport_size_get(wd->scr, &w, &h);
653 if (w > wd->size.w) x -= ((w - wd->size.w) / 2);
654 if (h > wd->size.h) y -= ((h - wd->size.h) / 2);
661 // Map coordinates to canvas geometry without rotate
663 _coord_to_canvas_no_rotate(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord *xx, Evas_Coord *yy)
665 Evas_Coord vx, vy, sx, sy;
666 _viewport_coord_get(wd, &vx, &vy, NULL, NULL);
667 evas_object_geometry_get(wd->pan_smart, &sx, &sy, NULL, NULL);
668 if (xx) *xx = x - vx + sx;
669 if (yy) *yy = y - vy + sy;
672 // Map coordinates to canvas geometry
674 _coord_to_canvas(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord *xx, Evas_Coord *yy)
676 _coord_to_canvas_no_rotate(wd, x, y, &x, &y);
677 _rotate(x, y, wd->rotate.cx, wd->rotate.cy, wd->rotate.d, &x, &y);
682 // Canvas geometry to map coordinates
684 _canvas_to_coord(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord *xx, Evas_Coord *yy)
686 Evas_Coord vx, vy, sx, sy;
687 _viewport_coord_get(wd, &vx, &vy, NULL, NULL);
688 evas_object_geometry_get(wd->pan_smart, &sx, &sy, NULL, NULL);
689 _rotate(x - sx + vx, y - sy + vy, wd->rotate.cx - sx + vx,
690 wd->rotate.cy - sy + vy, -wd->rotate.d, &x, &y);
696 _region_show(void *data)
698 EINA_SAFETY_ON_NULL_RETURN(data);
699 Delayed_Data *dd = data;
702 _region_to_coord_convert(dd->wd, dd->lon, dd->lat, dd->wd->size.w, &x, &y);
703 _viewport_coord_get(dd->wd, NULL, NULL, &w, &h);
706 elm_smart_scroller_child_region_show(dd->wd->scr, x, y, w, h);
707 evas_object_smart_changed(dd->wd->pan_smart);
711 _grid_item_coord_get(Grid_Item *gi, int *x, int *y, int *w, int *h)
713 EINA_SAFETY_ON_NULL_RETURN(gi);
715 if (x) *x = gi->x * gi->wd->size.tile;
716 if (y) *y = gi->y * gi->wd->size.tile;
717 if (w) *w = gi->wd->size.tile;
718 if (h) *h = gi->wd->size.tile;
722 _grid_item_in_viewport(Grid_Item *gi)
724 EINA_SAFETY_ON_NULL_RETURN_VAL(gi, EINA_FALSE);
726 Evas_Coord vx, vy, vw, vh;
727 Evas_Coord x, y, w, h;
729 _viewport_coord_get(gi->wd, &vx, &vy, &vw, &vh);
730 _grid_item_coord_get(gi, &x, &y, &w, &h);
731 return ELM_RECTS_INTERSECT(x, y, w, h, vx, vy, vw, vh);
735 _grid_item_update(Grid_Item *gi)
737 evas_object_image_file_set(gi->img, gi->file, NULL);
738 if (!gi->wd->zoom_timer && !gi->wd->scr_timer)
739 evas_object_image_smooth_scale_set(gi->img, EINA_TRUE);
740 else evas_object_image_smooth_scale_set(gi->img, EINA_FALSE);
742 Evas_Load_Error err = evas_object_image_load_error_get(gi->img);
743 if (err != EVAS_LOAD_ERROR_NONE)
745 ERR("Image loading error (%s): %s", gi->file, evas_load_error_str(err));
746 ecore_file_remove(gi->file);
747 gi->file_have = EINA_FALSE;
751 Evas_Coord x, y, w, h;
752 _grid_item_coord_get(gi, &x, &y, &w, &h);
753 _coord_to_canvas_no_rotate(gi->wd, x, y, &x, &y);
754 _obj_place(gi->img, x, y, w, h);
755 _obj_rotate(gi->wd, gi->img);
756 gi->file_have = EINA_TRUE;
761 _grid_item_load(Grid_Item *gi)
763 EINA_SAFETY_ON_NULL_RETURN(gi);
764 if (gi->file_have) _grid_item_update(gi);
767 gi->wd->download_list = eina_list_remove(gi->wd->download_list, gi);
768 gi->wd->download_list = eina_list_append(gi->wd->download_list, gi);
773 _grid_item_unload(Grid_Item *gi)
775 EINA_SAFETY_ON_NULL_RETURN(gi);
778 evas_object_hide(gi->img);
779 evas_object_image_file_set(gi->img, NULL, NULL);
783 ecore_file_download_abort(gi->job);
784 ecore_file_remove(gi->file);
788 else gi->wd->download_list = eina_list_remove(gi->wd->download_list, gi);
793 _grid_item_create(Grid *g, Evas_Coord x, Evas_Coord y)
795 EINA_SAFETY_ON_NULL_RETURN_VAL(g, NULL);
801 gi = ELM_NEW(Grid_Item);
807 gi->file_have = EINA_FALSE;
810 gi->img = evas_object_image_add(evas_object_evas_get(g->wd->obj));
811 evas_object_image_smooth_scale_set(gi->img, EINA_FALSE);
812 evas_object_image_scale_hint_set(gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
813 evas_object_image_filled_set(gi->img, EINA_TRUE);
814 evas_object_smart_member_add(gi->img, g->wd->pan_smart);
815 evas_object_pass_events_set(gi->img, EINA_TRUE);
816 evas_object_stack_below(gi->img, g->wd->sep_maps_overlays);
818 snprintf(buf, sizeof(buf), CACHE_TILE_ROOT, g->wd->id, g->zoom, x);
819 snprintf(buf2, sizeof(buf2), CACHE_TILE_PATH, buf, y);
820 if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
822 eina_stringshare_replace(&gi->file, buf2);
823 url = g->wd->src_tile->url_cb(g->wd->obj, x, y, g->zoom);
824 if ((!url) || (!strlen(url)))
826 eina_stringshare_replace(&gi->url, NULL);
827 ERR("Getting source url failed: %s", gi->file);
829 else eina_stringshare_replace(&gi->url, url);
831 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
836 _grid_item_free(Grid_Item *gi)
838 EINA_SAFETY_ON_NULL_RETURN(gi);
839 _grid_item_unload(gi);
840 if (gi->g && gi->g->grid) eina_matrixsparse_data_idx_set(gi->g->grid,
842 if (gi->url) eina_stringshare_del(gi->url);
843 if (gi->file) eina_stringshare_del(gi->file);
844 if (gi->img) evas_object_del(gi->img);
845 if (gi->file_have) ecore_file_remove(gi->file);
850 _downloaded_cb(void *data, const char *file __UNUSED__, int status)
852 Grid_Item *gi = data;
856 DBG("Download success from %s to %s", gi->url, gi->file);
857 _grid_item_update(gi);
858 gi->wd->finish_num++;
859 evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOADED, NULL);
863 WRN("Download failed from %s to %s (%d) ", gi->url, gi->file, status);
864 ecore_file_remove(gi->file);
865 gi->file_have = EINA_FALSE;
866 evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOADED_FAIL, NULL);
870 gi->wd->download_num--;
871 if (!gi->wd->download_num)
872 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
873 "elm,state,busy,stop", "elm");
877 _download_job(void *data)
879 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
880 Widget_Data *wd = data;
885 if (!eina_list_count(wd->download_list))
887 wd->download_idler = NULL;
888 return ECORE_CALLBACK_CANCEL;
891 EINA_LIST_REVERSE_FOREACH_SAFE(wd->download_list, l, ll, gi)
893 if ((gi->g->zoom != wd->zoom) || !(_grid_item_in_viewport(gi)))
895 wd->download_list = eina_list_remove(wd->download_list, gi);
898 if (wd->download_num >= MAX_CONCURRENT_DOWNLOAD)
899 return ECORE_CALLBACK_RENEW;
901 Eina_Bool ret = ecore_file_download_full(gi->url, gi->file,
902 _downloaded_cb, NULL,
903 gi, &(gi->job), wd->ua);
904 if ((!ret) || (!gi->job))
905 ERR("Can't start to download from %s to %s", gi->url, gi->file);
908 wd->download_list = eina_list_remove(wd->download_list, gi);
911 evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOAD,
913 if (wd->download_num == 1)
914 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
915 "elm,state,busy,start", "elm");
918 return ECORE_CALLBACK_RENEW;
922 _grid_viewport_get(Grid *g, int *x, int *y, int *w, int *h)
924 EINA_SAFETY_ON_NULL_RETURN(g);
926 Evas_Coord vx, vy, vw, vh;
928 _viewport_coord_get(g->wd, &vx, &vy, &vw, &vh);
932 xx = (vx / g->wd->size.tile) - 1;
935 yy = (vy / g->wd->size.tile) - 1;
938 ww = (vw / g->wd->size.tile) + 3;
939 if (xx + ww >= g->tw) ww = g->tw - xx;
941 hh = (vh / g->wd->size.tile) + 3;
942 if (yy + hh >= g->th) hh = g->th - yy;
951 _grid_unload(Grid *g)
953 EINA_SAFETY_ON_NULL_RETURN(g);
955 Eina_Matrixsparse_Cell *cell;
958 it = eina_matrixsparse_iterator_new(g->grid);
959 EINA_ITERATOR_FOREACH(it, cell)
961 gi = eina_matrixsparse_cell_data_get(cell);
962 _grid_item_unload(gi);
964 eina_iterator_free(it);
970 EINA_SAFETY_ON_NULL_RETURN(g);
971 int x, y, xx, yy, ww, hh;
973 Eina_Matrixsparse_Cell *cell;
976 it = eina_matrixsparse_iterator_new(g->grid);
977 EINA_ITERATOR_FOREACH(it, cell)
979 gi = eina_matrixsparse_cell_data_get(cell);
980 if (!_grid_item_in_viewport(gi)) _grid_item_unload(gi);
982 eina_iterator_free(it);
984 _grid_viewport_get(g, &xx, &yy, &ww, &hh);
985 for (y = yy; y < yy + hh; y++)
987 for (x = xx; x < xx + ww; x++)
989 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
990 if (!gi) gi = _grid_item_create(g, x, y);
997 _grid_place(Widget_Data *wd)
999 EINA_SAFETY_ON_NULL_RETURN(wd);
1003 EINA_LIST_FOREACH(wd->grids, l, g)
1005 if (wd->zoom == g->zoom) _grid_load(g);
1006 else _grid_unload(g);
1008 if (!wd->download_idler) wd->download_idler = ecore_idler_add(_download_job, wd);
1012 _grid_all_create(Widget_Data *wd)
1014 EINA_SAFETY_ON_NULL_RETURN(wd);
1015 EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
1018 for (zoom = wd->src_tile->zoom_min; zoom <= wd->src_tile->zoom_max; zoom++)
1025 tnum = pow(2.0, g->zoom);
1028 g->grid = eina_matrixsparse_new(g->th, g->tw, NULL, NULL);
1029 wd->grids = eina_list_append(wd->grids, g);
1034 _grid_all_clear(Widget_Data *wd)
1036 EINA_SAFETY_ON_NULL_RETURN(wd);
1039 EINA_LIST_FREE(wd->grids, g)
1041 Eina_Matrixsparse_Cell *cell;
1042 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1043 EINA_ITERATOR_FOREACH(it, cell)
1046 gi = eina_matrixsparse_cell_data_get(cell);
1047 if (gi) _grid_item_free(gi);
1049 eina_iterator_free(it);
1051 eina_matrixsparse_free(g->grid);
1057 _track_place(Widget_Data *wd)
1060 EINA_SAFETY_ON_NULL_RETURN(wd);
1064 int xmin, xmax, ymin, ymax;
1065 Evas_Coord px, py, ow, oh;
1068 _viewport_coord_get(wd, NULL, NULL, &ow, &oh);
1070 Evas_Coord size = wd->size.w;
1072 EINA_LIST_FOREACH(wd->track, l, route)
1074 double lon_min, lon_max;
1075 double lat_min, lat_max;
1076 elm_route_longitude_min_max_get(route, &lon_min, &lon_max);
1077 elm_route_latitude_min_max_get(route, &lat_min, &lat_max);
1078 _region_to_coord_convert(wd, lon_min, lat_max, size, &xmin, &ymin);
1079 _region_to_coord_convert(wd, lon_max, lat_min, size, &xmax, &ymax);
1081 if ( !(xmin < px && xmax < px) && !(xmin > px+ow && xmax > px+ow))
1083 if ( !(ymin < py && ymax < py) && !(ymin > py+oh && ymax > py+oh))
1086 evas_object_move(route, xmin - px, ymin - py);
1087 evas_object_resize(route, xmax - xmin, ymax - ymin);
1089 evas_object_raise(route);
1090 _obj_rotate(wd, route);
1091 evas_object_show(route);
1096 //the route is not display
1097 evas_object_hide(route);
1105 _delayed_do(Widget_Data *wd)
1108 dd = eina_list_nth(wd->delayed_jobs, 0);
1109 if (dd && !dd->wd->zoom_animator)
1112 wd->delayed_jobs = eina_list_remove(wd->delayed_jobs, dd);
1118 _smooth_update(Widget_Data *wd)
1120 EINA_SAFETY_ON_NULL_RETURN(wd);
1124 EINA_LIST_FOREACH(wd->grids, l, g)
1126 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1127 Eina_Matrixsparse_Cell *cell;
1129 EINA_ITERATOR_FOREACH(it, cell)
1131 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1132 if (_grid_item_in_viewport(gi))
1133 evas_object_image_smooth_scale_set(gi->img, EINA_TRUE);
1135 eina_iterator_free(it);
1140 _zoom_timeout(void *data)
1142 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
1143 Widget_Data *wd = data;
1145 wd->zoom_timer = NULL;
1146 evas_object_smart_callback_call(wd->obj, SIG_ZOOM_STOP, NULL);
1147 return ECORE_CALLBACK_CANCEL;
1151 zoom_do(Widget_Data *wd, double zoom)
1153 EINA_SAFETY_ON_NULL_RETURN(wd);
1154 if (zoom > wd->src_tile->zoom_max) zoom = wd->src_tile->zoom_max;
1155 else if (zoom < wd->src_tile->zoom_min) zoom = wd->src_tile->zoom_min;
1156 if (zoom > wd->zoom_max) zoom = wd->zoom_max;
1157 else if (zoom < wd->zoom_min) zoom = wd->zoom_min;
1159 Evas_Coord vx, vy, vw, vh;
1162 wd->zoom = ROUND(zoom);
1163 wd->zoom_detail = zoom;
1166 wd->size.tile = pow(2.0, (zoom - wd->zoom)) * wd->tsize;
1167 wd->size.w = pow(2.0, wd->zoom) * wd->size.tile;
1168 wd->size.h = wd->size.w;;
1170 // Fix to zooming with (viewport center vx, vy) as the center to prevent
1171 // from zooming with (0,0) as the cetner. (scroller default behavior)
1172 _viewport_coord_get(wd, &vx, &vy, &vw, &vh);
1173 if ((vw > 0) && (vh > 0) && (ow > 0) && (oh > 0))
1177 if (vw > ow) sx = 0.5;
1178 else sx = (double)(vx + (double)(vw / 2)) / ow;
1179 if (vh > oh) sy = 0.5;
1180 else sy = (double)(vy + (double)(vh / 2)) / oh;
1182 if (sx > 1.0) sx = 1.0;
1183 if (sy > 1.0) sy = 1.0;
1185 x = ceil((sx * wd->size.w) - (vw / 2));
1186 y = ceil((sy * wd->size.h) - (vh / 2));
1188 else if (x > (wd->size.w - vw)) x = wd->size.w - vw;
1190 else if (y > (wd->size.h - vh)) y = wd->size.h - vh;
1191 elm_smart_scroller_child_region_show(wd->scr, x, y, vw, vh);
1193 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1194 else evas_object_smart_callback_call(wd->obj, SIG_ZOOM_START, NULL);
1195 wd->zoom_timer = ecore_timer_add(0.25, _zoom_timeout, wd);
1196 evas_object_smart_callback_call(wd->obj, SIG_ZOOM_CHANGE, NULL);
1198 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1199 evas_object_smart_changed(wd->pan_smart);
1203 _zoom_anim(void *data)
1205 Widget_Data *wd = data;
1206 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, ECORE_CALLBACK_CANCEL);
1208 if (wd->ani.cnt <= 0)
1210 wd->zoom_animator = NULL;
1211 evas_object_smart_changed(wd->pan_smart);
1212 return ECORE_CALLBACK_CANCEL;
1216 wd->ani.zoom += wd->ani.diff;
1218 zoom_do(wd, wd->ani.zoom);
1219 return ECORE_CALLBACK_RENEW;
1224 zoom_with_animation(Widget_Data *wd, double zoom, int cnt)
1226 EINA_SAFETY_ON_NULL_RETURN(wd);
1227 if (cnt == 0) return;
1230 wd->ani.zoom = wd->zoom;
1231 wd->ani.diff = (double)(zoom - wd->zoom) / cnt;
1232 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
1233 wd->zoom_animator = ecore_animator_add(_zoom_anim, wd);
1237 _sizing_eval(Widget_Data *wd)
1239 EINA_SAFETY_ON_NULL_RETURN(wd);
1241 Evas_Coord maxw = -1, maxh = -1;
1243 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
1244 evas_object_size_hint_max_set(wd->obj, maxw, maxh);
1248 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1254 _scr_timeout(void *data)
1256 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
1257 Widget_Data *wd = data;
1259 wd->scr_timer = NULL;
1260 evas_object_smart_callback_call(wd->obj, SIG_SCROLL_DRAG_STOP, NULL);
1261 return ECORE_CALLBACK_CANCEL;
1265 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1267 EINA_SAFETY_ON_NULL_RETURN(data);
1268 Widget_Data *wd = data;
1270 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1271 else evas_object_smart_callback_call(wd->obj, SIG_SCROLL_DRAG_START, NULL);
1272 wd->scr_timer = ecore_timer_add(0.25, _scr_timeout, wd);
1273 evas_object_smart_callback_call(wd->obj, SIG_SCROLL, NULL);
1277 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1279 EINA_SAFETY_ON_NULL_RETURN(data);
1280 Widget_Data *wd = data;
1281 evas_object_smart_callback_call(wd->obj, SIG_SCROLL_ANIM_START, NULL);
1285 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1287 EINA_SAFETY_ON_NULL_RETURN(data);
1288 Widget_Data *wd = data;
1289 evas_object_smart_callback_call(wd->obj, SIG_SCROLL_ANIM_STOP, NULL);
1293 _long_press(void *data)
1295 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
1296 Widget_Data *wd = data;
1298 wd->long_timer = NULL;
1299 evas_object_smart_callback_call(wd->obj, SIG_LONGPRESSED, &wd->ev);
1300 return ECORE_CALLBACK_CANCEL;
1304 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1306 EINA_SAFETY_ON_NULL_RETURN(data);
1307 Widget_Data *wd = data;
1308 Evas_Event_Mouse_Down *ev = event_info;
1310 if (ev->button != 1) return;
1312 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1313 else wd->on_hold = EINA_FALSE;
1315 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1316 evas_object_smart_callback_call(wd->obj, SIG_CLICKED_DOUBLE, ev);
1317 else evas_object_smart_callback_call(wd->obj, SIG_PRESS, ev);
1319 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1321 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, wd);
1325 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1327 EINA_SAFETY_ON_NULL_RETURN(data);
1328 Widget_Data *wd = data;
1330 Evas_Event_Mouse_Up *ev = event_info;
1331 EINA_SAFETY_ON_NULL_RETURN(ev);
1333 if (ev->button != 1) return;
1334 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1335 else wd->on_hold = EINA_FALSE;
1338 ecore_timer_del(wd->long_timer);
1339 wd->long_timer = NULL;
1341 if (!wd->on_hold) evas_object_smart_callback_call(wd->obj, SIG_CLICKED, ev);
1342 wd->on_hold = EINA_FALSE;
1346 _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1348 EINA_SAFETY_ON_NULL_RETURN(data);
1349 Widget_Data *wd = data;
1353 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
1354 zoom_do(wd, wd->zoom_detail - ((double)ev->z / 10));
1359 _region_max_min_get(Eina_List *overlays, double *max_longitude, double *min_longitude, double *max_latitude, double *min_latitude)
1361 double max_lon = -180, min_lon = 180;
1362 double max_lat = -90, min_lat = 90;
1363 Elm_Map_Overlay *overlay;
1364 EINA_LIST_FREE(overlays, overlay)
1367 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1369 Overlay_Default *ovl = overlay->ovl;
1373 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
1375 // FIXME: class center coord is alright??
1376 Overlay_Class *ovl = overlay->ovl;
1377 double max_lo, min_lo, max_la, min_la;
1378 _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la,
1380 lon = (max_lo + min_lo) / 2;
1381 lat = (max_la + min_la) / 2;
1383 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
1385 Overlay_Bubble *ovl = overlay->ovl;
1391 WRN("Not supported overlay type: %d", overlay->type);
1394 if (lon> max_lon) max_lon = lon;
1395 if (lon< min_lon) min_lon = lon;
1396 if (lat > max_lat) max_lat = lat;
1397 if (lat < min_lat) min_lat = lat;
1399 if (max_longitude) *max_longitude = max_lon;
1400 if (min_longitude) *min_longitude = min_lon;
1401 if (max_latitude) *max_latitude = max_lat;
1402 if (min_latitude) *min_latitude = min_lat;
1405 static Evas_Object *
1406 _icon_dup(const Evas_Object *icon, Evas_Object *parent)
1408 if (!icon || !parent) return NULL;
1409 // Evas_Object do not support object duplication??
1410 const char *file = NULL, *group = NULL;
1411 Eina_Bool size_up, size_down;
1414 dupp = elm_icon_add(parent);
1415 elm_icon_file_get(icon, &file, &group);
1416 elm_icon_file_set(dupp, file, group);
1417 elm_icon_animated_set(dupp, elm_icon_animated_get(icon));
1418 elm_icon_animated_play_set(dupp, elm_icon_animated_play_get(icon));
1419 elm_icon_standard_set(dupp, elm_icon_standard_get(icon));
1420 elm_icon_order_lookup_set(dupp, elm_icon_order_lookup_get(icon));
1421 elm_icon_no_scale_set(dupp, elm_icon_no_scale_get(icon));
1422 elm_icon_resizable_get(icon, &size_up, &size_down);
1423 elm_icon_resizable_set(dupp, size_up, size_down);
1424 elm_icon_fill_outside_set(dupp, elm_icon_fill_outside_get(icon));
1425 elm_icon_prescale_set(dupp, elm_icon_prescale_get(icon));
1426 elm_icon_aspect_fixed_set(dupp, elm_icon_aspect_fixed_get(icon));
1431 _overlay_clicked_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
1433 EINA_SAFETY_ON_NULL_RETURN(data);
1434 Elm_Map_Overlay *overlay = data;
1436 evas_object_smart_callback_call(overlay->wd->obj, SIG_OVERLAY_CLICKED,
1438 if (overlay->cb) overlay->cb(overlay->cb_data, overlay->wd->obj,
1443 _overlay_default_hide(Overlay_Default *ovl)
1445 EINA_SAFETY_ON_NULL_RETURN(ovl);
1446 if (ovl->content) evas_object_hide(ovl->content);
1447 if (ovl->icon) evas_object_hide(ovl->icon);
1448 if (ovl->clas_content) evas_object_hide(ovl->clas_content);
1449 if (ovl->clas_icon) evas_object_hide(ovl->clas_icon);
1450 if (ovl->layout) evas_object_hide(ovl->layout);
1454 _overlay_default_show(Overlay_Default *ovl)
1456 EINA_SAFETY_ON_NULL_RETURN(ovl);
1458 Evas_Coord x, y, w, h;
1460 evas_object_hide(ovl->layout);
1463 disp = ovl->content;
1464 evas_object_geometry_get(disp, NULL, NULL, &w, &h);
1465 if (w <= 0 || h <= 0) evas_object_size_hint_min_get(disp, &w, &h);
1467 else if (!(ovl->icon) && ovl->clas_content)
1469 disp = ovl->clas_content;
1471 evas_object_geometry_get(disp, NULL, NULL, &w, &h);
1472 if (w <= 0 || h <= 0) evas_object_size_hint_min_get(disp, &w, &h);
1476 if (ovl->icon) evas_object_show(ovl->icon);
1477 else if (ovl->clas_icon) evas_object_show(ovl->clas_icon);
1482 _coord_to_canvas(ovl->wd, ovl->x, ovl->y, &x, &y);
1483 _obj_place(disp, x - (w / 2), y - (h / 2), w, h);
1487 _overlay_default_coord_get(Overlay_Default *ovl, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1489 EINA_SAFETY_ON_NULL_RETURN(ovl);
1497 _overlay_default_coord_set(Overlay_Default *ovl, Evas_Coord x, Evas_Coord y)
1499 EINA_SAFETY_ON_NULL_RETURN(ovl);
1505 _overlay_default_coord_update(Overlay_Default *ovl)
1507 EINA_SAFETY_ON_NULL_RETURN(ovl);
1508 _region_to_coord_convert(ovl->wd, ovl->lon, ovl->lat, ovl->wd->size.w,
1513 _overlay_default_layout_text_update(Overlay_Default *ovl, const char *text)
1515 if (!ovl->content && !ovl->icon && !ovl->clas_content && !ovl->clas_icon)
1516 edje_object_part_text_escaped_set(elm_layout_edje_get(ovl->layout), "elm.text",
1521 _overlay_default_content_update(Overlay_Default *ovl, Evas_Object *content, Elm_Map_Overlay *overlay)
1523 EINA_SAFETY_ON_NULL_RETURN(ovl);
1524 if (ovl->content == content) return;
1525 if (ovl->content) evas_object_del(ovl->content);
1526 ovl->content = content;
1529 evas_object_event_callback_add(ovl->content, EVAS_CALLBACK_MOUSE_DOWN,
1530 _overlay_clicked_cb, overlay);
1534 _overlay_default_clas_content_update(Overlay_Default *ovl, const Evas_Object *content __UNUSED__)
1536 EINA_SAFETY_ON_NULL_RETURN(ovl);
1537 if (ovl->clas_content) evas_object_del(ovl->clas_content);
1538 // Evas_Object can not be duplicated.
1539 //ovl->clas_content = _content_dup(content);
1543 _overlay_default_layout_update(Overlay_Default *ovl)
1545 EINA_SAFETY_ON_NULL_RETURN(ovl);
1548 evas_object_color_set(ovl->layout, 255, 255, 255, 255);
1549 elm_layout_theme_set(ovl->layout, "map/marker", "empty",
1550 elm_widget_style_get(ovl->wd->obj));
1551 elm_object_part_content_set(ovl->layout, "elm.icon", ovl->icon);
1553 else if (!ovl->icon && ovl->clas_icon)
1555 evas_object_color_set(ovl->layout, 255, 255, 255, 255);
1556 elm_layout_theme_set(ovl->layout, "map/marker", "empty",
1557 elm_widget_style_get(ovl->wd->obj));
1558 elm_object_part_content_set(ovl->layout, "elm.icon", ovl->clas_icon);
1562 evas_object_color_set(ovl->layout, ovl->c.r, ovl->c.g, ovl->c.b, ovl->c.a);
1563 elm_layout_theme_set(ovl->layout, "map/marker", "radio",
1564 elm_widget_style_get(ovl->wd->obj));
1569 _overlay_default_icon_update(Overlay_Default *ovl, Evas_Object *icon)
1571 EINA_SAFETY_ON_NULL_RETURN(ovl);
1572 if (ovl->icon == icon) return;
1573 if (ovl->icon) evas_object_del(ovl->icon);
1575 _overlay_default_layout_update(ovl);
1579 _overlay_default_clas_icon_update(Overlay_Default *ovl, const Evas_Object *icon)
1581 EINA_SAFETY_ON_NULL_RETURN(ovl);
1582 if (ovl->clas_icon) evas_object_del(ovl->clas_icon);
1583 ovl->clas_icon = _icon_dup(icon, ovl->layout);
1584 _overlay_default_layout_update(ovl);
1588 _overlay_default_color_update(Overlay_Default *ovl, Color c)
1590 EINA_SAFETY_ON_NULL_RETURN(ovl);
1592 _overlay_default_layout_update(ovl);
1596 _overlay_default_free(Overlay_Default *ovl)
1598 EINA_SAFETY_ON_NULL_RETURN(ovl);
1599 if (ovl->content) evas_object_del(ovl->content);
1600 if (ovl->icon) evas_object_del(ovl->icon);
1601 if (ovl->clas_content) evas_object_del(ovl->clas_content);
1602 if (ovl->clas_icon) evas_object_del(ovl->clas_icon);
1603 if (ovl->layout) evas_object_del(ovl->layout);
1607 static Overlay_Default *
1608 _overlay_default_new(Elm_Map_Overlay *overlay, double lon, double lat, Color c, double scale)
1610 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
1612 Overlay_Default *ovl = ELM_NEW(Overlay_Default);
1613 ovl->wd = overlay->wd;
1614 _edj_overlay_size_get(ovl->wd, &(ovl->w), &(ovl->h));
1617 ovl->layout = elm_layout_add(ovl->wd->obj);
1618 evas_object_smart_member_add(ovl->layout, ovl->wd->pan_smart);
1619 evas_object_stack_above(ovl->layout, ovl->wd->sep_maps_overlays);
1620 elm_layout_theme_set(ovl->layout, "map/marker", "radio",
1621 elm_widget_style_get(ovl->wd->obj));
1622 evas_object_event_callback_add(ovl->layout, EVAS_CALLBACK_MOUSE_DOWN,
1623 _overlay_clicked_cb, overlay);
1626 _overlay_default_color_update(ovl, c);
1631 _overlay_group_hide(Overlay_Group *grp)
1633 EINA_SAFETY_ON_NULL_RETURN(grp);
1634 if (grp->ovl) _overlay_default_hide(grp->ovl);
1638 _overlay_group_show(Overlay_Group *grp)
1640 EINA_SAFETY_ON_NULL_RETURN(grp);
1641 if (grp->ovl) _overlay_default_show(grp->ovl);
1645 _overlay_group_coord_member_update(Overlay_Group *grp, Evas_Coord x, Evas_Coord y, Eina_List *members)
1647 EINA_SAFETY_ON_NULL_RETURN(grp);
1648 if (!grp->ovl) return;
1651 _overlay_default_coord_set(grp->ovl, x, y);
1652 if (grp->members) eina_list_free(grp->members);
1653 grp->members = members;
1654 snprintf(text, sizeof(text), "%d", eina_list_count(members));
1655 _overlay_default_layout_text_update(grp->ovl, text);
1659 _overlay_group_region_get(Overlay_Group *grp, double *lon, double *lat)
1661 EINA_SAFETY_ON_NULL_RETURN(grp);
1663 _overlay_default_coord_get(grp->ovl, &xx, &yy, NULL, NULL);
1664 _coord_to_canvas(grp->wd, xx, yy, &xx, &yy);
1665 elm_map_canvas_to_region_convert(grp->wd->obj, xx, yy, lon, lat);
1669 _overlay_group_icon_update(Overlay_Group *grp, const Evas_Object *icon)
1671 EINA_SAFETY_ON_NULL_RETURN(grp);
1672 if (grp->ovl) _overlay_default_icon_update(grp->ovl,
1673 _icon_dup(icon, grp->wd->obj));
1677 _overlay_group_content_update(Overlay_Group *grp __UNUSED__, const Evas_Object *content __UNUSED__)
1679 EINA_SAFETY_ON_NULL_RETURN(grp);
1680 // Evas_Object can not be duplicated.
1681 //_overlay_default_content_update(grp->ovl, _content_dup(content));
1686 _overlay_group_color_update(Overlay_Group *grp, Color c)
1688 EINA_SAFETY_ON_NULL_RETURN(grp);
1689 _overlay_default_color_update(grp->ovl, c);
1693 _overlay_group_cb_set(Overlay_Group *grp, Elm_Map_Overlay_Get_Cb cb, void *data)
1695 EINA_SAFETY_ON_NULL_RETURN(grp);
1696 grp->overlay->cb = cb;
1697 grp->overlay->data = data;
1701 _overlay_group_free(Overlay_Group *grp)
1703 EINA_SAFETY_ON_NULL_RETURN(grp);
1704 if (grp->overlay) free(grp->overlay);
1705 if (grp->ovl) _overlay_default_free(grp->ovl);
1706 if (grp->members) eina_list_free(grp->members);
1710 static Overlay_Group *
1711 _overlay_group_new(Widget_Data *wd)
1713 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1715 Overlay_Group *grp = ELM_NEW(Overlay_Group);
1717 grp->overlay = ELM_NEW(Elm_Map_Overlay); // this is a virtual overlay
1718 grp->overlay->wd = wd;
1719 grp->overlay->type = ELM_MAP_OVERLAY_TYPE_GROUP;
1720 grp->overlay->ovl = grp;
1721 Color c = {0x90, 0xee, 0x90, 0xff};
1722 grp->ovl = _overlay_default_new(grp->overlay, -1, -1, c, 2);
1727 _overlay_class_cb_set(Overlay_Class *ovl, Elm_Map_Overlay_Get_Cb cb, void *data)
1729 EINA_SAFETY_ON_NULL_RETURN(ovl);
1732 Elm_Map_Overlay *overlay;
1734 // Update class members' callbacks
1735 EINA_LIST_FOREACH(ovl->members, l, overlay)
1736 _overlay_group_cb_set(overlay->grp, cb, data);
1740 _overlay_class_icon_update(Overlay_Class *ovl, Evas_Object *icon)
1742 EINA_SAFETY_ON_NULL_RETURN(ovl);
1745 Elm_Map_Overlay *overlay;
1746 if (ovl->icon == icon) return;
1747 if (ovl->icon) evas_object_del(ovl->icon);
1750 // Update class members' class icons
1751 EINA_LIST_FOREACH(ovl->members, l, overlay)
1753 _overlay_group_icon_update(overlay->grp, icon);
1755 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1756 _overlay_default_clas_icon_update(overlay->ovl, icon);
1762 _overlay_class_content_update(Overlay_Class *ovl, Evas_Object *content)
1764 EINA_SAFETY_ON_NULL_RETURN(ovl);
1767 Elm_Map_Overlay *overlay;
1768 if (ovl->content == content) return;
1769 if (ovl->content) evas_object_del(ovl->content);
1770 ovl->content = content;
1772 // Update class members' class contents
1773 EINA_LIST_FOREACH(ovl->members, l, overlay)
1775 _overlay_group_content_update(overlay->grp, content);
1777 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1778 _overlay_default_clas_content_update(overlay->ovl, content);
1783 _overlay_class_color_update(Overlay_Class *ovl, Color c)
1785 EINA_SAFETY_ON_NULL_RETURN(ovl);
1788 Elm_Map_Overlay *overlay;
1790 // Update class members' class contents
1791 EINA_LIST_FOREACH(ovl->members, l, overlay)
1792 _overlay_group_color_update(overlay->grp, c);
1796 _overlay_class_free(Overlay_Class *clas)
1798 EINA_SAFETY_ON_NULL_RETURN(clas);
1801 Elm_Map_Overlay *overlay;
1803 // Update class members' class contents
1804 EINA_LIST_FOREACH(clas->members, l, overlay)
1806 overlay->grp->clas = NULL;
1807 _overlay_group_content_update(overlay->grp, NULL);
1808 _overlay_group_icon_update(overlay->grp, NULL);
1810 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1812 _overlay_default_clas_content_update(overlay->ovl, NULL);
1813 _overlay_default_clas_icon_update(overlay->ovl, NULL);
1816 if (clas->icon) evas_object_del(clas->icon);
1817 if (clas->members) eina_list_free(clas->members);
1821 static Overlay_Class *
1822 _overlay_class_new(Widget_Data *wd)
1824 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1825 Overlay_Class *ovl = ELM_NEW(Overlay_Class);
1828 ovl->zoom_max = OVERLAY_CLASS_ZOOM_MAX;
1833 _overlay_bubble_hide(Overlay_Bubble *bubble)
1835 EINA_SAFETY_ON_NULL_RETURN(bubble);
1836 if (bubble->obj) evas_object_hide(bubble->obj);
1840 _overlay_bubble_coord_update(Overlay_Bubble *bubble)
1842 EINA_SAFETY_ON_NULL_RETURN(bubble);
1843 if (!(bubble->pobj))
1845 _region_to_coord_convert(bubble->wd, bubble->lon, bubble->lat,
1846 bubble->wd->size.w, &bubble->x, &bubble->y);
1851 _overlay_bubble_coord_get(Overlay_Bubble *bubble, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1853 EINA_SAFETY_ON_NULL_RETURN(bubble);
1854 if (!(bubble->pobj))
1856 if (x) *x = bubble->x;
1857 if (y) *y = bubble->y;
1858 if (w) *w = bubble->w;
1859 if (h) *h = bubble->h;
1871 _overlay_bubble_show(Overlay_Bubble *bubble)
1873 EINA_SAFETY_ON_NULL_RETURN(bubble);
1874 if (!(bubble->pobj))
1876 _coord_to_canvas(bubble->wd, bubble->x, bubble->y,
1877 &(bubble->x), &(bubble->y));
1878 _obj_place(bubble->obj, bubble->x - (bubble->w /2),
1879 bubble->y - (bubble->h /2), bubble->w, bubble->h);
1884 _overlay_bubble_chase(Overlay_Bubble *bubble)
1886 EINA_SAFETY_ON_NULL_RETURN(bubble);
1887 EINA_SAFETY_ON_NULL_RETURN(bubble->pobj);
1890 evas_object_geometry_get(bubble->pobj, &x, &y, &w, NULL);
1891 x = x + (w / 2) - (bubble->w / 2);
1893 _obj_place(bubble->obj, x, y, bubble->w, bubble->h);
1894 evas_object_raise(bubble->obj);
1898 _overlay_bubble_hide_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1900 EINA_SAFETY_ON_NULL_RETURN(data);
1901 _overlay_bubble_hide(data);
1905 _overlay_bubble_chase_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1907 EINA_SAFETY_ON_NULL_RETURN(data);
1908 _overlay_bubble_chase(data);
1912 _overlay_bubble_free(Overlay_Bubble* bubble)
1914 EINA_SAFETY_ON_NULL_RETURN(bubble);
1916 evas_object_del(bubble->bx);
1917 evas_object_del(bubble->sc);
1918 evas_object_del(bubble->obj);
1921 evas_object_event_callback_del_full(bubble->pobj, EVAS_CALLBACK_HIDE,
1922 _overlay_bubble_hide_cb, bubble);
1923 evas_object_event_callback_del_full(bubble->pobj, EVAS_CALLBACK_SHOW,
1924 _overlay_bubble_chase_cb, bubble);
1925 evas_object_event_callback_del_full(bubble->pobj, EVAS_CALLBACK_MOVE,
1926 _overlay_bubble_chase_cb, bubble);
1931 static Overlay_Bubble*
1932 _overlay_bubble_new(Elm_Map_Overlay *overlay)
1934 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
1938 Overlay_Bubble *bubble = ELM_NEW(Overlay_Bubble);
1939 bubble->wd = overlay->wd;
1941 bubble->obj = edje_object_add(evas_object_evas_get(overlay->wd->obj));
1942 _elm_theme_object_set(overlay->wd->obj, bubble->obj , "map", "marker_bubble",
1943 elm_widget_style_get(overlay->wd->obj));
1944 evas_object_event_callback_add(bubble->obj, EVAS_CALLBACK_MOUSE_UP,
1945 _overlay_bubble_chase_cb, bubble);
1946 evas_object_event_callback_add(bubble->obj, EVAS_CALLBACK_MOUSE_DOWN,
1947 _overlay_clicked_cb, overlay);
1949 bubble->sc = elm_scroller_add(bubble->obj);
1950 elm_widget_style_set(bubble->sc, "map_bubble");
1951 elm_scroller_content_min_limit(bubble->sc, EINA_FALSE, EINA_TRUE);
1952 elm_scroller_policy_set(bubble->sc, ELM_SCROLLER_POLICY_AUTO,
1953 ELM_SCROLLER_POLICY_OFF);
1954 elm_scroller_bounce_set(bubble->sc, _elm_config->thumbscroll_bounce_enable,
1956 edje_object_part_swallow(bubble->obj, "elm.swallow.content", bubble->sc);
1958 bubble->bx = elm_box_add(bubble->sc);
1959 evas_object_size_hint_align_set(bubble->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1960 evas_object_size_hint_weight_set(bubble->bx, EVAS_HINT_EXPAND,
1962 elm_box_horizontal_set(bubble->bx, EINA_TRUE);
1963 elm_object_content_set(bubble->sc, bubble->bx);
1965 s = edje_object_data_get(bubble->obj, "size_w");
1966 if (s) bubble->w = atoi(s);
1969 edje_object_size_min_calc(bubble->obj, NULL, &(bubble->h));
1970 s = edje_object_data_get(bubble->obj, "size_h");
1973 if (bubble->h < h) bubble->h = h;
1983 _overlay_route_color_update(Overlay_Route *ovl, Color c)
1985 EINA_SAFETY_ON_NULL_RETURN(ovl);
1986 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
1990 _overlay_route_hide(Overlay_Route *ovl)
1992 EINA_SAFETY_ON_NULL_RETURN(ovl);
1993 evas_object_hide(ovl->obj);
1997 _overlay_route_show(Overlay_Route *r)
1999 EINA_SAFETY_ON_NULL_RETURN(r);
2000 EINA_SAFETY_ON_NULL_RETURN(r->wd);
2006 evas_object_polygon_points_clear(r->obj);
2007 EINA_LIST_FOREACH(r->nodes, l, n)
2009 p = eina_list_nth(r->paths, n->idx);
2011 _region_to_coord_convert(r->wd, n->pos.lon, n->pos.lat, r->wd->size.w,
2013 _coord_to_canvas(r->wd, p->x, p->y, &p->x, &p->y);
2015 EINA_LIST_FOREACH(r->paths, l, p)
2016 evas_object_polygon_point_add(r->obj, p->x - 3, p->y - 3);
2018 EINA_LIST_REVERSE_FOREACH(r->paths, l, p)
2019 evas_object_polygon_point_add(r->obj, p->x + 3, p->y + 3);
2020 evas_object_show(r->obj);
2024 _overlay_route_free(Overlay_Route* route)
2026 EINA_SAFETY_ON_NULL_RETURN(route);
2030 evas_object_del(route->obj);
2031 EINA_LIST_FREE(route->paths, p) free(p);
2032 EINA_LIST_FREE(route->nodes, n)
2034 if (n->pos.address) eina_stringshare_del(n->pos.address);
2040 static Overlay_Route *
2041 _overlay_route_new(Widget_Data *wd, const Elm_Map_Route *route, Color c)
2043 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2044 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
2049 Overlay_Route *ovl = ELM_NEW(Overlay_Route);
2051 ovl->obj = evas_object_polygon_add(evas_object_evas_get(wd->obj));
2052 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2053 _overlay_route_color_update(ovl, c);
2055 EINA_LIST_FOREACH(route->nodes, l, n)
2060 node = ELM_NEW(Path_Node);
2062 node->pos.lon = n->pos.lon;
2063 node->pos.lat = n->pos.lat;
2064 if (n->pos.address) node->pos.address = strdup(n->pos.address);
2065 ovl->nodes = eina_list_append(ovl->nodes, node);
2067 path = ELM_NEW(Path);
2068 ovl->paths = eina_list_append(ovl->paths, path);
2074 _overlay_line_color_update(Overlay_Line *ovl, Color c)
2076 EINA_SAFETY_ON_NULL_RETURN(ovl);
2077 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2081 _overlay_line_hide(Overlay_Line *ovl)
2083 EINA_SAFETY_ON_NULL_RETURN(ovl);
2084 if (ovl->obj) evas_object_hide(ovl->obj);
2088 _overlay_line_show(Overlay_Line *ovl)
2090 Evas_Coord fx, fy, tx, ty;
2091 Widget_Data *wd = ovl->wd;
2093 _region_to_coord_convert(wd, ovl->flon, ovl->flat, wd->size.w, &fx, &fy);
2094 _region_to_coord_convert(wd, ovl->tlon, ovl->tlat, wd->size.w, &tx, &ty);
2095 _coord_to_canvas(wd, fx, fy, &fx, &fy);
2096 _coord_to_canvas(wd, tx, ty, &tx, &ty);
2097 evas_object_line_xy_set(ovl->obj, fx, fy, tx, ty);
2098 evas_object_show(ovl->obj);
2102 _overlay_line_free(Overlay_Line *ovl)
2104 EINA_SAFETY_ON_NULL_RETURN(ovl);
2105 evas_object_del(ovl->obj);
2109 static Overlay_Line *
2110 _overlay_line_new(Widget_Data *wd, double flon, double flat, double tlon, double tlat, Color c)
2112 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2114 Overlay_Line *ovl = ELM_NEW(Overlay_Line);
2120 ovl->obj = evas_object_line_add(evas_object_evas_get(wd->obj));
2121 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2122 _overlay_line_color_update(ovl, c);
2127 _overlay_polygon_color_update(Overlay_Polygon *ovl, Color c)
2129 EINA_SAFETY_ON_NULL_RETURN(ovl);
2130 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2134 _overlay_polygon_hide(Overlay_Polygon *ovl)
2136 EINA_SAFETY_ON_NULL_RETURN(ovl);
2137 if (ovl->obj) evas_object_hide(ovl->obj);
2141 _overlay_polygon_show(Overlay_Polygon *ovl)
2143 EINA_SAFETY_ON_NULL_RETURN(ovl);
2146 Widget_Data *wd = ovl->wd;
2148 evas_object_polygon_points_clear(ovl->obj);
2149 EINA_LIST_FOREACH(ovl->regions, l, r)
2152 _region_to_coord_convert(wd, r->lon, r->lat, wd->size.w, &x, &y);
2153 _coord_to_canvas(wd, x, y, &x, &y);
2154 evas_object_polygon_point_add(ovl->obj, x, y);
2156 evas_object_show(ovl->obj);
2160 _overlay_polygon_free(Overlay_Polygon *ovl)
2162 EINA_SAFETY_ON_NULL_RETURN(ovl);
2164 evas_object_del(ovl->obj);
2165 EINA_LIST_FREE(ovl->regions, r) free(r);
2169 static Overlay_Polygon *
2170 _overlay_polygon_new(Widget_Data *wd, Color c)
2172 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2174 Overlay_Polygon *ovl = ELM_NEW(Overlay_Polygon);
2176 ovl->obj = evas_object_polygon_add(evas_object_evas_get(wd->obj));
2177 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2178 _overlay_polygon_color_update(ovl, c);
2183 _overlay_circle_color_update(Overlay_Circle *ovl, Color c)
2185 EINA_SAFETY_ON_NULL_RETURN(ovl);
2186 Evas_Object *obj = elm_layout_edje_get(ovl->obj);
2187 evas_object_color_set(obj, c.r, c.g, c.b, c.a);
2191 _overlay_circle_hide(Overlay_Circle *ovl)
2193 EINA_SAFETY_ON_NULL_RETURN(ovl);
2194 if (ovl->obj) evas_object_hide(ovl->obj);
2198 _overlay_circle_show(Overlay_Circle *ovl)
2200 EINA_SAFETY_ON_NULL_RETURN(ovl);
2203 Widget_Data *wd = ovl->wd;
2205 r = (ovl->ratio) * wd->size.w;
2206 _region_to_coord_convert(wd, ovl->lon, ovl->lat, wd->size.w, &x, &y);
2207 _coord_to_canvas(wd, x, y, &x, &y);
2208 _obj_place(ovl->obj, x - r, y - r, r * 2, r * 2);
2212 _overlay_circle_free(Overlay_Circle *ovl)
2214 EINA_SAFETY_ON_NULL_RETURN(ovl);
2215 evas_object_del(ovl->obj);
2219 static Overlay_Circle *
2220 _overlay_circle_new(Widget_Data *wd, double lon, double lat, double radius, Color c)
2222 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2224 Overlay_Circle *ovl = ELM_NEW(Overlay_Circle);
2228 ovl->radius = radius;
2229 ovl->ratio = radius / wd->size.w;
2231 ovl->obj = elm_layout_add(wd->obj);
2232 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2233 evas_object_stack_above(ovl->obj, wd->sep_maps_overlays);
2234 elm_layout_theme_set(ovl->obj, "map/circle", "base",
2235 elm_widget_style_get(wd->obj));
2236 _overlay_circle_color_update(ovl, c);
2241 _overlay_scale_color_update(Overlay_Scale *ovl, Color c)
2243 EINA_SAFETY_ON_NULL_RETURN(ovl);
2244 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2248 _overlay_scale_hide(Overlay_Scale *ovl)
2250 EINA_SAFETY_ON_NULL_RETURN(ovl);
2251 if (ovl->obj) evas_object_hide(ovl->obj);
2255 _overlay_scale_show(Overlay_Scale *ovl)
2257 EINA_SAFETY_ON_NULL_RETURN(ovl);
2263 Widget_Data *wd = ovl->wd;
2265 if ((int)sizeof(_scale_tb) <= wd->zoom)
2267 ERR("Zoom level is too high");
2271 elm_map_region_get(wd->obj, &lon, &lat);
2272 meter = wd->src_tile->scale_cb(wd->obj, lon, lat, wd->zoom);
2274 w = (_scale_tb[wd->zoom] / meter) * (wd->zoom_detail - wd->zoom + 1);
2276 text = _scale_tb[wd->zoom]/1000;
2277 if (text < 1) snprintf(buf, sizeof(buf), "%d m", (int)(text * 1000));
2278 else snprintf(buf, sizeof(buf), "%d km", (int)text);
2280 edje_object_part_text_escaped_set(elm_layout_edje_get(ovl->obj), "elm.text", buf);
2281 _obj_place(ovl->obj, ovl->x, ovl->y, w, ovl->h);
2285 _overlay_scale_free(Overlay_Scale *ovl)
2287 EINA_SAFETY_ON_NULL_RETURN(ovl);
2288 evas_object_del(ovl->obj);
2292 static Overlay_Scale *
2293 _overlay_scale_new(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Color c)
2295 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2298 Overlay_Scale *ovl = ELM_NEW(Overlay_Scale);
2303 ovl->obj = elm_layout_add(wd->obj);
2304 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2305 evas_object_stack_above(ovl->obj, wd->sep_maps_overlays);
2306 elm_layout_theme_set(ovl->obj, "map/scale", "base",
2307 elm_widget_style_get(wd->obj));
2308 s = edje_object_data_get(elm_layout_edje_get(ovl->obj), "size_w");
2309 if (s) ovl->w = atoi(s);
2311 s = edje_object_data_get(elm_layout_edje_get(ovl->obj), "size_h");
2312 if (s) ovl->h = atoi(s);
2314 _overlay_scale_color_update(ovl, c);
2319 _overlay_grouping(Eina_List *clas_membs, Elm_Map_Overlay *boss)
2321 EINA_SAFETY_ON_NULL_RETURN(clas_membs);
2322 EINA_SAFETY_ON_NULL_RETURN(boss);
2325 Eina_List *grp_membs = NULL;
2326 Elm_Map_Overlay *memb;
2328 int sum_x = 0, sum_y = 0, cnt = 0;
2329 Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
2331 if (boss->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2332 _overlay_default_coord_get(boss->ovl, &bx, &by, &bw, &bh);
2333 else if (boss->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2334 _overlay_bubble_coord_get(boss->ovl, &bx, &by, &bw, &bh);
2336 EINA_LIST_FOREACH(clas_membs, l, memb)
2338 Evas_Coord x = 0, y = 0, w = 0, h = 0;
2340 if (boss == memb || memb->grp->in) continue;
2341 if ((memb->hide) || (memb->zoom_min > memb->wd->zoom)) continue;
2343 if (memb->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2344 _overlay_default_coord_get(memb->ovl, &x, &y, &w, &h);
2345 else if (memb->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2346 _overlay_bubble_coord_get(memb->ovl, &x, &y, &w, &h);
2348 if (bw <= 0 || bh <= 0 || w <= 0 || h <= 0) continue;
2349 if (ELM_RECTS_INTERSECT(x, y, w, h, bx, by,
2350 bw * OVERLAY_GROUPING_SCALE,
2351 bh * OVERLAY_GROUPING_SCALE))
2354 memb->grp->boss = EINA_FALSE;
2355 memb->grp->in = EINA_TRUE;
2359 grp_membs = eina_list_append(grp_membs, memb);
2366 boss->grp->boss = EINA_TRUE;
2367 boss->grp->in = EINA_TRUE;
2368 sum_x = (sum_x + bx) / (cnt + 1);
2369 sum_y = (sum_y + by) / (cnt + 1);
2370 grp_membs = eina_list_append(grp_membs, boss);
2371 _overlay_group_coord_member_update(boss->grp, sum_x, sum_y, grp_membs);
2376 _overlay_show(Elm_Map_Overlay *overlay)
2378 Widget_Data *wd = overlay->wd;
2379 Eina_Bool hide = EINA_FALSE;
2381 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) return;
2383 if (overlay->paused) return;
2384 if ((overlay->grp->clas) && (overlay->grp->clas->paused)) return;
2386 if (((overlay->grp->in) || (overlay->hide) ||
2387 (overlay->zoom_min > wd->zoom)))
2389 if ((overlay->grp->clas) && ((overlay->grp->clas->hide) ||
2390 (overlay->grp->clas->zoom_min > wd->zoom)))
2393 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2395 if (hide) _overlay_default_hide(overlay->ovl);
2396 else _overlay_default_show(overlay->ovl);
2398 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2400 if (hide) _overlay_bubble_hide(overlay->ovl);
2401 else _overlay_bubble_show(overlay->ovl);
2403 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
2405 if (hide) _overlay_route_hide(overlay->ovl);
2406 else _overlay_route_show(overlay->ovl);
2408 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_LINE)
2410 if (hide) _overlay_line_hide(overlay->ovl);
2411 else _overlay_line_show(overlay->ovl);
2413 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON)
2415 if (hide) _overlay_polygon_hide(overlay->ovl);
2416 else _overlay_polygon_show(overlay->ovl);
2418 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CIRCLE)
2420 if (hide) _overlay_circle_hide(overlay->ovl);
2421 else _overlay_circle_show(overlay->ovl);
2423 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_SCALE)
2425 if (hide) _overlay_scale_hide(overlay->ovl);
2426 else _overlay_scale_show(overlay->ovl);
2431 _overlay_place(Widget_Data *wd)
2433 EINA_SAFETY_ON_NULL_RETURN(wd);
2436 Elm_Map_Overlay *overlay;
2438 // Reset group & Update overlays coord
2439 EINA_LIST_FOREACH(wd->overlays, l, overlay)
2441 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2442 overlay->grp->in = EINA_FALSE;
2443 overlay->grp->boss = EINA_FALSE;
2445 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2446 _overlay_default_coord_update(overlay->ovl);
2447 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2448 _overlay_bubble_coord_update(overlay->ovl);
2451 // Classify into group boss or follwer
2452 EINA_LIST_FOREACH(wd->overlays, l, overlay)
2454 Elm_Map_Overlay *boss;
2455 Overlay_Class *clas;
2457 if (overlay->type != ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2458 if (overlay->hide || (overlay->zoom_min > wd->zoom)) continue;
2460 clas = overlay->ovl;
2461 if (clas->zoom_max < wd->zoom) continue;
2462 EINA_LIST_FOREACH(clas->members, ll, boss)
2464 if (boss->type == ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2465 if (boss->hide || (boss->zoom_min > wd->zoom)) continue;
2466 if (boss->grp->in) continue;
2467 _overlay_grouping(clas->members, boss);
2472 EINA_LIST_FOREACH(wd->overlays, l, overlay) _overlay_show(overlay);
2474 // Place group overlays on top of overlays
2475 EINA_LIST_FOREACH(wd->overlays, l, overlay)
2477 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2478 if (overlay->grp->boss) _overlay_group_show(overlay->grp);
2479 else _overlay_group_hide(overlay->grp);
2483 static Evas_Object *
2484 _overlay_obj_get(const Elm_Map_Overlay *overlay)
2486 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
2487 if (overlay->type == ELM_MAP_OVERLAY_TYPE_GROUP)
2489 Overlay_Group *ovl = overlay->ovl;
2490 Overlay_Default *df = ovl->ovl;
2493 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2495 Overlay_Default *ovl = overlay->ovl;
2500 ERR("Not supported overlay type: %d", overlay->type);
2506 _overlays_show(void *data)
2508 EINA_SAFETY_ON_NULL_RETURN(data);
2509 Delayed_Data *dd = data;
2512 double max_lon, min_lon, max_lat, min_lat;
2515 _region_max_min_get(dd->overlays, &max_lon, &min_lon, &max_lat, &min_lat);
2516 dd->lon = (max_lon + min_lon) / 2;
2517 dd->lat = (max_lat + min_lat) / 2;
2519 zoom = dd->wd->src_tile->zoom_min;
2520 _viewport_coord_get(dd->wd, NULL, NULL, &vw, &vh);
2521 if (dd->wd->src_tile->zoom_max < dd->wd->zoom_max)
2522 zoom_max = dd->wd->src_tile->zoom_max;
2523 else zoom_max = dd->wd->zoom_max;
2524 while (zoom <= zoom_max)
2526 Evas_Coord size, max_x, max_y, min_x, min_y;
2527 size = pow(2.0, zoom) * dd->wd->tsize;
2528 _region_to_coord_convert(dd->wd, min_lon, max_lat, size, &min_x, &max_y);
2529 _region_to_coord_convert(dd->wd, max_lon, min_lat, size, &max_x, &min_y);
2530 if ((max_x - min_x) > vw || (max_y - min_y) > vh) break;
2535 zoom_do(dd->wd, zoom);
2537 evas_object_smart_changed(dd->wd->pan_smart);
2541 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2543 Pan *sd = evas_object_smart_data_get(obj);
2544 EINA_SAFETY_ON_NULL_RETURN(sd);
2545 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2549 evas_object_smart_changed(obj);
2553 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2555 Pan *sd = evas_object_smart_data_get(obj);
2556 EINA_SAFETY_ON_NULL_RETURN(sd);
2557 if (x) *x = sd->wd->pan_x;
2558 if (y) *y = sd->wd->pan_y;
2562 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2564 Pan *sd = evas_object_smart_data_get(obj);
2565 EINA_SAFETY_ON_NULL_RETURN(sd);
2567 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2568 ow = sd->wd->size.w - ow;
2569 oh = sd->wd->size.h - oh;
2577 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
2584 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2586 Pan *sd = evas_object_smart_data_get(obj);
2587 EINA_SAFETY_ON_NULL_RETURN(sd);
2588 if (w) *w = sd->wd->size.w;
2589 if (h) *h = sd->wd->size.h;
2593 _pan_add(Evas_Object *obj)
2596 Evas_Object_Smart_Clipped_Data *cd;
2598 cd = evas_object_smart_data_get(obj);
2599 EINA_SAFETY_ON_NULL_RETURN(cd);
2601 sd->__clipped_data = *cd;
2603 evas_object_smart_data_set(obj, sd);
2607 _pan_resize(Evas_Object *obj, Evas_Coord w __UNUSED__, Evas_Coord h __UNUSED__)
2609 Pan *sd = evas_object_smart_data_get(obj);
2610 EINA_SAFETY_ON_NULL_RETURN(sd);
2612 _sizing_eval(sd->wd);
2613 elm_map_zoom_mode_set(sd->wd->obj, sd->wd->mode);
2614 evas_object_smart_changed(obj);
2618 _pan_calculate(Evas_Object *obj)
2620 Pan *sd = evas_object_smart_data_get(obj);
2621 EINA_SAFETY_ON_NULL_RETURN(sd);
2624 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
2625 if (w <= 0 || h <= 0) return;
2627 _grid_place(sd->wd);
2628 _overlay_place(sd->wd);
2629 _track_place(sd->wd);
2630 _delayed_do(sd->wd);
2634 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2636 EINA_SAFETY_ON_NULL_RETURN(obj);
2637 evas_object_smart_changed(obj);
2641 _hold_on(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2643 EINA_SAFETY_ON_NULL_RETURN(data);
2644 Widget_Data *wd = data;
2645 elm_smart_scroller_hold_set(wd->scr, 1);
2649 _hold_off(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2651 EINA_SAFETY_ON_NULL_RETURN(data);
2652 Widget_Data *wd = data;
2653 elm_smart_scroller_hold_set(wd->scr, 0);
2657 _freeze_on(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2659 EINA_SAFETY_ON_NULL_RETURN(data);
2660 Widget_Data *wd = data;
2661 elm_smart_scroller_freeze_set(wd->scr, 1);
2665 _freeze_off(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2667 EINA_SAFETY_ON_NULL_RETURN(data);
2668 Widget_Data *wd = data;
2669 elm_smart_scroller_freeze_set(wd->scr, 0);
2673 cb_dump_name_attrs(void *data, const char *key, const char *value)
2675 Name_Dump *dump = (Name_Dump*)data;
2676 if (!dump) return EINA_FALSE;
2678 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
2679 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
2685 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2687 Route_Dump *dump = data;
2688 if (!dump) return EINA_FALSE;
2692 case EINA_SIMPLE_XML_OPEN:
2693 case EINA_SIMPLE_XML_OPEN_EMPTY:
2697 attrs = eina_simple_xml_tag_attributes_find(value, length);
2700 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
2701 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
2702 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
2703 else dump->id = ROUTE_XML_NONE;
2707 case EINA_SIMPLE_XML_DATA:
2709 char *buf = malloc(length);
2710 if (!buf) return EINA_FALSE;
2711 snprintf(buf, length, "%s", value);
2712 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
2713 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2714 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2726 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2728 Name_Dump *dump = data;
2729 if (!dump) return EINA_FALSE;
2733 case EINA_SIMPLE_XML_OPEN:
2734 case EINA_SIMPLE_XML_OPEN_EMPTY:
2737 attrs = eina_simple_xml_tag_attributes_find(value, length);
2740 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME;
2741 else dump->id = NAME_XML_NONE;
2743 eina_simple_xml_attributes_parse
2744 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
2748 case EINA_SIMPLE_XML_DATA:
2750 char *buf = malloc(length + 1);
2751 if (!buf) return EINA_FALSE;
2752 snprintf(buf, length + 1, "%s", value);
2753 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2765 _kml_parse(Elm_Map_Route *r)
2767 EINA_SAFETY_ON_NULL_RETURN(r);
2768 EINA_SAFETY_ON_NULL_RETURN(r->fname);
2772 unsigned int ele, idx;
2775 Route_Dump dump = {0, r->fname, 0.0, NULL, NULL};
2777 f = fopen(r->fname, "rb");
2782 fseek(f, 0, SEEK_END);
2788 fseek(f, 0, SEEK_SET);
2792 if (fread(buf, 1, sz, f))
2794 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump,
2802 if (dump.distance) r->info.distance = dump.distance;
2803 if (dump.description)
2805 eina_stringshare_replace(&r->info.waypoints, dump.description);
2806 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2807 r->info.waypoint_count = ele;
2808 for (idx = 0; idx < ele; idx++)
2810 Path_Waypoint *wp = ELM_NEW(Path_Waypoint);
2814 wp->point = eina_stringshare_add(str[idx]);
2815 DBG("%s", str[idx]);
2816 r->waypoint = eina_list_append(r->waypoint, wp);
2825 else WRN("description is not found !");
2827 if (dump.coordinates)
2829 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2830 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2831 r->info.node_count = ele;
2832 for (idx = 0; idx < ele; idx++)
2834 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2835 Path_Node *n = ELM_NEW(Path_Node);
2842 DBG("%lf:%lf", lon, lat);
2843 n->pos.address = NULL;
2844 r->nodes = eina_list_append(r->nodes, n);
2857 _name_parse(Elm_Map_Name *n)
2859 EINA_SAFETY_ON_NULL_RETURN(n);
2860 EINA_SAFETY_ON_NULL_RETURN(n->fname);
2864 Name_Dump dump = {0, NULL, 0.0, 0.0};
2866 f = fopen(n->fname, "rb");
2871 fseek(f, 0, SEEK_END);
2877 fseek(f, 0, SEEK_SET);
2881 if (fread(buf, 1, sz, f))
2883 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
2892 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
2893 n->address = strdup(dump.address);
2900 Grid *_get_current_grid(Widget_Data *wd)
2902 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2904 Grid *g = NULL, *ret = NULL;
2905 EINA_LIST_FOREACH(wd->grids, l, g)
2907 if (wd->zoom == g->zoom)
2917 _route_cb(void *data, const char *file, int status)
2919 EINA_SAFETY_ON_NULL_RETURN(data);
2920 EINA_SAFETY_ON_NULL_RETURN(file);
2922 Elm_Map_Route *route = data;
2923 Widget_Data *wd = route->wd;
2924 EINA_SAFETY_ON_NULL_RETURN(wd);
2930 INF("Route request success from (%lf, %lf) to (%lf, %lf)",
2931 route->flon, route->flat, route->tlon, route->tlat);
2932 if (route->cb) route->cb(route->data, wd->obj, route);
2933 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
2937 ERR("Route request failed: %d", status);
2938 if (route->cb) route->cb(route->data, wd->obj, NULL);
2939 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED_FAIL, NULL);
2942 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2943 "elm,state,busy,stop", "elm");
2947 _name_cb(void *data, const char *file, int status)
2949 EINA_SAFETY_ON_NULL_RETURN(data);
2950 EINA_SAFETY_ON_NULL_RETURN(file);
2952 Elm_Map_Name *name = data;
2953 Widget_Data *wd = name->wd;
2954 EINA_SAFETY_ON_NULL_RETURN(wd);
2960 INF("Name request success address:%s, lon:%lf, lat:%lf",
2961 name->address, name->lon, name->lat);
2962 if (name->cb) name->cb(name->data, wd->obj, name);
2963 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
2967 ERR("Name request failed: %d", status);
2968 if (name->cb) name->cb(name->data, wd->obj, NULL);
2969 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED_FAIL, NULL);
2971 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2972 "elm,state,busy,stop", "elm");
2977 static Elm_Map_Name *
2978 _name_request(const Evas_Object *obj, int method, const char *address, double lon, double lat, Elm_Map_Name_Cb name_cb, void *data)
2980 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2981 Widget_Data *wd = elm_widget_data_get(obj);
2982 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2983 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_name, NULL);
2987 char fname[PATH_MAX];
2989 if (!ecore_file_exists(CACHE_NAME_ROOT)) ecore_file_mkpath(CACHE_NAME_ROOT);
2991 url = wd->src_name->url_cb(wd->obj, method, address, lon, lat);
2994 ERR("Name URL is NULL");
2998 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
3000 snprintf(fname, sizeof(fname), CACHE_NAME_ROOT"/%d", rand());
3001 name->fname = strdup(fname);
3002 name->method = method;
3003 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
3004 else if (method == ELM_MAP_NAME_METHOD_REVERSE)
3012 if (!ecore_file_download_full(url, name->fname, _name_cb, NULL, name,
3013 &(name->job), wd->ua) || !(name->job))
3015 ERR("Can't request Name from %s to %s", url, name->fname);
3016 if (name->address) free(name->address);
3021 INF("Name requested from %s to %s", url, name->fname);
3024 wd->names = eina_list_append(wd->names, name);
3025 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, name);
3026 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3027 "elm,state,busy,start", "elm");
3031 static Evas_Event_Flags
3032 _pinch_zoom_start_cb(void *data, void *event_info __UNUSED__)
3034 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EVAS_EVENT_FLAG_NONE);
3035 Widget_Data *wd = data;
3037 wd->pinch_zoom = wd->zoom_detail;
3038 return EVAS_EVENT_FLAG_NONE;
3041 static Evas_Event_Flags
3042 _pinch_zoom_cb(void *data, void *event_info)
3044 Widget_Data *wd = data;
3045 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
3049 Elm_Gesture_Zoom_Info *ei = event_info;
3050 zoom_do(wd, wd->pinch_zoom + ei->zoom - 1);
3052 return EVAS_EVENT_FLAG_NONE;
3055 static Evas_Event_Flags
3056 _pinch_rotate_cb(void *data, void *event_info)
3058 Widget_Data *wd = data;
3059 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
3064 Elm_Gesture_Rotate_Info *ei = event_info;
3065 evas_object_geometry_get(wd->obj, &x, &y, &w, &h);
3067 wd->rotate.d = wd->rotate.a + ei->angle - ei->base_angle;
3068 wd->rotate.cx = x + ((double)w * 0.5);
3069 wd->rotate.cy = y + ((double)h * 0.5);
3071 evas_object_smart_changed(wd->pan_smart);
3073 return EVAS_EVENT_FLAG_NONE;
3076 static Evas_Event_Flags
3077 _pinch_rotate_end_cb(void *data, void *event_info __UNUSED__)
3079 Widget_Data *wd = data;
3080 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
3082 wd->rotate.a = wd->rotate.d;
3084 return EVAS_EVENT_FLAG_NONE;
3088 _source_tile_mod_cb(Eina_Module *m, void *data)
3090 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
3092 Widget_Data *wd = data;
3094 Elm_Map_Module_Source_Name_Func name_cb;
3095 Elm_Map_Module_Tile_Zoom_Min_Func zoom_min;
3096 Elm_Map_Module_Tile_Zoom_Max_Func zoom_max;
3097 Elm_Map_Module_Tile_Url_Func url_cb;
3098 Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord;
3099 Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo;
3100 Elm_Map_Module_Tile_Scale_Func scale_cb;
3103 file = eina_module_file_get(m);
3104 if (!eina_module_load(m))
3106 ERR("Could not load module \"%s\": %s", file,
3107 eina_error_msg_get(eina_error_get()));
3111 name_cb = eina_module_symbol_get(m, "map_module_source_name_get");
3112 zoom_min = eina_module_symbol_get(m, "map_module_tile_zoom_min_get");
3113 zoom_max = eina_module_symbol_get(m, "map_module_tile_zoom_max_get");
3114 url_cb = eina_module_symbol_get(m, "map_module_tile_url_get");
3115 geo_to_coord = eina_module_symbol_get(m, "map_module_tile_geo_to_coord");
3116 coord_to_geo = eina_module_symbol_get(m, "map_module_tile_coord_to_geo");
3117 scale_cb = eina_module_symbol_get(m, "map_module_tile_scale_get");
3118 if ((!name_cb) || (!zoom_min) || (!zoom_max) || (!url_cb) ||
3119 (!geo_to_coord) || (!coord_to_geo) || (!scale_cb))
3121 WRN("Could not find map module functions from module \"%s\": %s",
3122 file, eina_error_msg_get(eina_error_get()));
3123 eina_module_unload(m);
3126 s = ELM_NEW(Source_Tile);
3127 s->name = name_cb();
3128 s->zoom_min = zoom_min();
3129 s->zoom_max = zoom_max();
3131 s->geo_to_coord = geo_to_coord;
3132 s->coord_to_geo = coord_to_geo;
3133 s->scale_cb = scale_cb;
3134 wd->src_tiles = eina_list_append(wd->src_tiles, s);
3140 _source_tile_load(Widget_Data *wd)
3146 // Load from hard coded data
3147 for (idx = 0; idx < (sizeof(src_tiles) / sizeof(Source_Tile)); idx++)
3149 s= ELM_NEW(Source_Tile);
3150 s->name = src_tiles[idx].name;
3151 s->zoom_min = src_tiles[idx].zoom_min;
3152 s->zoom_max = src_tiles[idx].zoom_max;
3153 s->url_cb = src_tiles[idx].url_cb;
3154 s->geo_to_coord = src_tiles[idx].geo_to_coord;
3155 s->coord_to_geo = src_tiles[idx].coord_to_geo;
3156 s->scale_cb = src_tiles[idx].scale_cb;
3157 wd->src_tiles = eina_list_append(wd->src_tiles, s);
3160 // Load from modules
3161 wd->src_tile_mods = eina_module_list_get(wd->src_tile_mods, MODULES_PATH, 1,
3162 &_source_tile_mod_cb, wd);
3164 // Set default source
3165 wd->src_tile = eina_list_nth(wd->src_tiles, 0);
3167 // Make name strings
3169 wd->src_tile_names = calloc((eina_list_count(wd->src_tiles) + 1),
3171 EINA_LIST_FOREACH(wd->src_tiles, l, s)
3173 eina_stringshare_replace(&wd->src_tile_names[idx], s->name);
3174 INF("source : %s", wd->src_tile_names[idx]);
3180 _source_tile_unload(Widget_Data *wd)
3185 for (idx = 0; wd->src_tile_names[idx]; idx++)
3186 eina_stringshare_del(wd->src_tile_names[idx]);
3187 EINA_LIST_FREE(wd->src_tiles, s) free(s);
3188 eina_module_list_free(wd->src_tile_mods);
3192 _source_tile_set(Widget_Data *wd, const char *source_name)
3194 EINA_SAFETY_ON_NULL_RETURN(wd);
3195 EINA_SAFETY_ON_NULL_RETURN(source_name);
3199 if (wd->src_tile && !strcmp(wd->src_tile->name, source_name)) return;
3201 EINA_LIST_FOREACH(wd->src_tiles, l, s)
3203 if (!strcmp(s->name, source_name))
3211 ERR("source name (%s) is not found", source_name);
3215 if (wd->src_tile->zoom_max < wd->zoom)
3216 wd->zoom = wd->src_tile->zoom_max;
3217 else if (wd->src_tile->zoom_min > wd->zoom)
3218 wd->zoom = wd->src_tile->zoom_min;
3220 if (wd->src_tile->zoom_max < wd->zoom_max)
3221 wd->zoom_max = wd->src_tile->zoom_max;
3222 if (wd->src_tile->zoom_min > wd->zoom_min)
3223 wd->zoom_min = wd->src_tile->zoom_min;
3225 _grid_all_clear(wd);
3226 _grid_all_create(wd);
3227 zoom_do(wd, wd->zoom);
3231 _source_route_mod_cb(Eina_Module *m, void *data)
3233 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
3235 Widget_Data *wd = data;
3237 Elm_Map_Module_Source_Name_Func name_cb;
3238 Elm_Map_Module_Route_Url_Func url_cb;
3241 file = eina_module_file_get(m);
3242 if (!eina_module_load(m))
3244 ERR("Could not load module \"%s\": %s", file,
3245 eina_error_msg_get(eina_error_get()));
3249 name_cb = eina_module_symbol_get(m, "map_module_source_name_get");
3250 url_cb = eina_module_symbol_get(m, "map_module_route_url_get");
3252 if ((!name_cb) || (!url_cb))
3254 WRN("Could not find map module functions from module \"%s\": %s",
3255 file, eina_error_msg_get(eina_error_get()));
3256 eina_module_unload(m);
3259 s = ELM_NEW(Source_Tile);
3260 s->name = name_cb();
3262 wd->src_routes = eina_list_append(wd->src_routes, s);
3264 eina_module_unload(m);
3269 _source_route_load(Widget_Data *wd)
3275 // Load from hard coded data
3276 for (idx = 0; idx < (sizeof(src_routes) / sizeof(Source_Route)); idx++)
3278 s= ELM_NEW(Source_Route);
3279 s->name = src_routes[idx].name;
3280 s->url_cb = src_routes[idx].url_cb;
3281 wd->src_routes = eina_list_append(wd->src_routes, s);
3284 // Load from modules
3285 wd->src_route_mods = eina_module_list_get(wd->src_route_mods, MODULES_PATH,
3286 1, &_source_route_mod_cb, wd);
3288 // Set default source
3289 wd->src_route = eina_list_nth(wd->src_routes, 0);
3291 // Make name strings
3293 wd->src_route_names = calloc((eina_list_count(wd->src_routes) + 1),
3295 EINA_LIST_FOREACH(wd->src_routes, l, s)
3297 eina_stringshare_replace(&wd->src_route_names[idx], s->name);
3298 INF("source : %s", wd->src_route_names[idx]);
3304 _source_route_unload(Widget_Data *wd)
3309 for (idx = 0; wd->src_route_names[idx]; idx++)
3310 eina_stringshare_del(wd->src_route_names[idx]);
3311 EINA_LIST_FREE(wd->src_routes, s) free(s);
3312 eina_module_list_free(wd->src_route_mods);
3316 _source_route_set(Widget_Data *wd, const char *source_name)
3318 EINA_SAFETY_ON_NULL_RETURN(wd);
3319 EINA_SAFETY_ON_NULL_RETURN(source_name);
3323 if (wd->src_route && !strcmp(wd->src_route->name, source_name)) return;
3325 EINA_LIST_FOREACH(wd->src_routes, l, s)
3327 if (!strcmp(s->name, source_name))
3335 ERR("source name (%s) is not found", source_name);
3341 _source_name_mod_cb(Eina_Module *m, void *data)
3343 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
3345 Widget_Data *wd = data;
3347 Elm_Map_Module_Source_Name_Func name_cb;
3348 Elm_Map_Module_Name_Url_Func url_cb;
3351 file = eina_module_file_get(m);
3352 if (!eina_module_load(m))
3354 ERR("Could not load module \"%s\": %s", file,
3355 eina_error_msg_get(eina_error_get()));
3359 name_cb = eina_module_symbol_get(m, "map_module_source_name_get");
3360 url_cb = eina_module_symbol_get(m, "map_module_name_url_get");
3362 if ((!name_cb) || (!url_cb))
3364 WRN("Could not find map module functions from module \"%s\": %s",
3365 file, eina_error_msg_get(eina_error_get()));
3366 eina_module_unload(m);
3369 s = ELM_NEW(Source_Tile);
3370 s->name = name_cb();
3372 wd->src_names = eina_list_append(wd->src_names, s);
3374 eina_module_unload(m);
3379 _source_name_load(Widget_Data *wd)
3385 // Load from hard coded data
3386 for (idx = 0; idx < (sizeof(src_names) / sizeof(Source_Name)); idx++)
3388 s= ELM_NEW(Source_Name);
3389 s->name = src_names[idx].name;
3390 s->url_cb = src_names[idx].url_cb;
3391 wd->src_names = eina_list_append(wd->src_names, s);
3394 // Load from modules
3395 wd->src_name_mods = eina_module_list_get(wd->src_name_mods, MODULES_PATH, 1,
3396 &_source_name_mod_cb, wd);
3398 // Set default source
3399 wd->src_name = eina_list_nth(wd->src_names, 0);
3401 // Make name strings
3403 wd->src_name_names = calloc((eina_list_count(wd->src_names) + 1),
3405 EINA_LIST_FOREACH(wd->src_names, l, s)
3407 eina_stringshare_replace(&wd->src_name_names[idx], s->name);
3408 INF("source : %s", wd->src_name_names[idx]);
3414 _source_name_unload(Widget_Data *wd)
3419 for (idx = 0; wd->src_name_names[idx]; idx++)
3420 eina_stringshare_del(wd->src_name_names[idx]);
3421 EINA_LIST_FREE(wd->src_names, s) free(s);
3422 eina_module_list_free(wd->src_name_mods);
3426 _source_name_set(Widget_Data *wd, const char *source_name)
3428 EINA_SAFETY_ON_NULL_RETURN(wd);
3429 EINA_SAFETY_ON_NULL_RETURN(source_name);
3434 if (wd->src_name && !strcmp(wd->src_name->name, source_name)) return;
3436 EINA_LIST_FOREACH(wd->src_names, l, s)
3438 if (!strcmp(s->name, source_name))
3446 ERR("source name (%s) is not found", source_name);
3452 _source_all_load(Widget_Data *wd)
3454 EINA_SAFETY_ON_NULL_RETURN(wd);
3455 _source_tile_load(wd);
3456 _source_route_load(wd);
3457 _source_name_load(wd);
3461 _source_all_unload(Widget_Data *wd)
3463 EINA_SAFETY_ON_NULL_RETURN(wd);
3464 _source_tile_unload(wd);
3465 _source_route_unload(wd);
3466 _source_name_unload(wd);
3470 _zoom_mode_set(void *data)
3472 EINA_SAFETY_ON_NULL_RETURN(data);
3473 Delayed_Data *dd = data;
3475 dd->wd->mode = dd->mode;
3476 if (dd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3486 zoom = dd->wd->zoom_detail;
3487 _viewport_coord_get(dd->wd, NULL, NULL, &vw, &vh);
3489 if (dd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3491 if ((w < vw) && (h < vh))
3494 while ((w < vw) && (h < vh))
3497 w = pow(2.0, zoom) * dd->wd->tsize;
3498 h = pow(2.0, zoom) * dd->wd->tsize;
3504 while ((w > vw) || (h > vh))
3507 w = pow(2.0, zoom) * dd->wd->tsize;
3508 h = pow(2.0, zoom) * dd->wd->tsize;
3513 else if (dd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3515 if ((w < vw) || (h < vh))
3518 while ((w < vw) || (h < vh))
3521 w = pow(2.0, zoom) * dd->wd->tsize;
3522 h = pow(2.0, zoom) * dd->wd->tsize;
3528 while ((w > vw) && (h > vh))
3531 w = pow(2.0, zoom) * dd->wd->tsize;
3532 h = pow(2.0, zoom) * dd->wd->tsize;
3536 zoom_do(dd->wd, zoom);
3541 _zoom_set(void *data)
3543 EINA_SAFETY_ON_NULL_RETURN(data);
3544 Delayed_Data *dd = data;
3546 if (dd->wd->paused) zoom_do(dd->wd, dd->zoom);
3547 else zoom_with_animation(dd->wd, dd->zoom, 10);
3548 evas_object_smart_changed(dd->wd->pan_smart);
3552 _region_bring_in(void *data)
3554 EINA_SAFETY_ON_NULL_RETURN(data);
3555 Delayed_Data *dd = data;
3558 _region_to_coord_convert(dd->wd, dd->lon, dd->lat, dd->wd->size.w, &x, &y);
3559 _viewport_coord_get(dd->wd, NULL, NULL, &w, &h);
3562 elm_smart_scroller_region_bring_in(dd->wd->scr, x, y, w, h);
3563 evas_object_smart_changed(dd->wd->pan_smart);
3567 _mapnik_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3570 // ((x+y+zoom)%3)+'a' is requesting map images from distributed tile servers (eg., a, b, c)
3571 snprintf(buf, sizeof(buf), "http://%c.tile.openstreetmap.org/%d/%d/%d.png",
3572 ((x + y + zoom) % 3) + 'a', zoom, x, y);
3577 _osmarender_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3580 snprintf(buf, sizeof(buf),
3581 "http://%c.tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
3582 ((x + y + zoom) % 3) + 'a', zoom, x, y);
3587 _cyclemap_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3590 snprintf(buf, sizeof(buf),
3591 "http://%c.tile.opencyclemap.org/cycle/%d/%d/%d.png",
3592 (( x + y + zoom) % 3) + 'a', zoom, x, y);
3597 _mapquest_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3600 snprintf(buf, sizeof(buf),
3601 "http://otile%d.mqcdn.com/tiles/1.0.0/osm/%d/%d/%d.png",
3602 ((x + y + zoom) % 4) + 1, zoom, x, y);
3607 _mapquest_aerial_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3610 snprintf(buf, sizeof(buf), "http://oatile%d.mqcdn.com/naip/%d/%d/%d.png",
3611 ((x + y + zoom) % 4) + 1, zoom, x, y);
3615 static char *_yours_url_cb(const Evas_Object *obj __UNUSED__, const char *type_name, int method, double flon, double flat, double tlon, double tlat)
3618 snprintf(buf, sizeof(buf),
3619 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
3620 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
3625 // TODO: fix monav api
3627 static char *_monav_url_cb(const Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
3630 snprintf(buf, sizeof(buf),
3631 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
3632 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
3638 // TODO: fix ors api
3640 static char *_ors_url_cb(const Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
3643 snprintf(buf, sizeof(buf),
3644 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
3645 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
3652 _nominatim_url_cb(const Evas_Object *obj, int method, const char *name, double lon, double lat)
3654 ELM_CHECK_WIDTYPE(obj, widtype) strdup("");
3655 Widget_Data *wd = elm_widget_data_get(obj);
3656 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, strdup(""));
3659 unsigned int ele, idx;
3660 char search_url[PATH_MAX];
3663 if (method == ELM_MAP_NAME_METHOD_SEARCH)
3665 search_url[0] = '\0';
3666 str = eina_str_split_full(name, " ", 0, &ele);
3667 for (idx = 0; idx < ele; idx++)
3669 eina_strlcat(search_url, str[idx], sizeof(search_url));
3670 if (!(idx == (ele-1)))
3671 eina_strlcat(search_url, "+", sizeof(search_url));
3673 snprintf(buf, sizeof(buf),
3674 "%s/search?q=%s&format=xml&polygon=0&addressdetails=0",
3675 NAME_NOMINATIM_URL, search_url);
3683 else if (method == ELM_MAP_NAME_METHOD_REVERSE)
3684 snprintf(buf, sizeof(buf),
3685 "%s/reverse?format=xml&lat=%lf&lon=%lf&zoom=%d&addressdetails=0",
3686 NAME_NOMINATIM_URL, lat, lon, (int)wd->zoom);
3687 else strcpy(buf, "");
3693 _scale_cb(const Evas_Object *obj __UNUSED__, double lon __UNUSED__, double lat, int zoom)
3695 if (zoom < 0 || zoom >= (int)sizeof(_osm_scale_meter)) return 0;
3696 return _osm_scale_meter[zoom] / cos(lat * ELM_PI / 180.0);
3700 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
3702 ELM_CHECK_WIDTYPE(obj, widtype);
3703 Widget_Data *wd = elm_widget_data_get(obj);
3704 EINA_SAFETY_ON_NULL_RETURN(wd);
3706 if (elm_widget_focus_get(obj))
3708 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
3709 evas_object_focus_set(wd->obj, EINA_TRUE);
3713 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
3714 evas_object_focus_set(wd->obj, EINA_FALSE);
3719 _del_hook(Evas_Object *obj)
3721 ELM_CHECK_WIDTYPE(obj, widtype);
3722 Widget_Data *wd = elm_widget_data_get(obj);
3723 EINA_SAFETY_ON_NULL_RETURN(wd);
3725 if (wd->map) evas_map_free(wd->map);
3730 _del_pre_hook(Evas_Object *obj)
3732 ELM_CHECK_WIDTYPE(obj, widtype);
3733 Widget_Data *wd = elm_widget_data_get(obj);
3734 EINA_SAFETY_ON_NULL_RETURN(wd);
3740 Elm_Map_Overlay *overlay;
3743 EINA_LIST_FOREACH_SAFE(wd->routes, l, ll, r) elm_map_route_del(r);
3744 eina_list_free(wd->routes);
3746 EINA_LIST_FOREACH_SAFE(wd->names, l, ll, na) elm_map_name_del(na);
3747 eina_list_free(wd->names);
3749 EINA_LIST_FOREACH_SAFE(wd->overlays, l, ll, overlay)
3750 elm_map_overlay_del(overlay);
3751 eina_list_free(wd->overlays);
3753 EINA_LIST_FREE(wd->track, track) evas_object_del(track);
3755 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
3756 if (wd->long_timer) ecore_timer_del(wd->long_timer);
3758 if (wd->delayed_jobs) EINA_LIST_FREE(wd->delayed_jobs, dd) free(dd);
3760 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
3761 if (wd->ua) eina_hash_free(wd->ua);
3763 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
3764 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
3766 _grid_all_clear(wd);
3767 // Removal of download list should be after grid clear.
3768 if (wd->download_idler) ecore_idler_del(wd->download_idler);
3769 eina_list_free(wd->download_list);
3771 _source_all_unload(wd);
3773 if (!ecore_file_recursive_rm(CACHE_ROOT))
3774 ERR("Deletion of %s failed", CACHE_ROOT);
3778 _theme_hook(Evas_Object *obj)
3780 ELM_CHECK_WIDTYPE(obj, widtype);
3781 Widget_Data *wd = elm_widget_data_get(obj);
3782 EINA_SAFETY_ON_NULL_RETURN(wd);
3784 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
3789 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
3791 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3792 Widget_Data *wd = elm_widget_data_get(obj);
3793 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
3797 Evas_Coord step_x, step_y, page_x, page_y;
3799 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
3800 Evas_Event_Key_Down *ev = event_info;
3801 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
3803 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
3804 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
3805 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
3806 elm_smart_scroller_child_viewport_size_get(wd->scr, NULL, &vh);
3808 if ((!strcmp(ev->keyname, "Left")) ||
3809 ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string)))
3813 else if ((!strcmp(ev->keyname, "Right")) ||
3814 ((!strcmp(ev->keyname, "KP_Right")) && (!ev->string)))
3818 else if ((!strcmp(ev->keyname, "Up")) ||
3819 ((!strcmp(ev->keyname, "KP_Up")) && (!ev->string)))
3823 else if ((!strcmp(ev->keyname, "Down")) ||
3824 ((!strcmp(ev->keyname, "KP_Down")) && (!ev->string)))
3828 else if ((!strcmp(ev->keyname, "Prior")) ||
3829 ((!strcmp(ev->keyname, "KP_Prior")) && (!ev->string)))
3832 y -= -(page_y * vh) / 100;
3836 else if ((!strcmp(ev->keyname, "Next")) ||
3837 ((!strcmp(ev->keyname, "KP_Next")) && (!ev->string)))
3840 y += -(page_y * vh) / 100;
3844 else if (!strcmp(ev->keyname, "KP_Add"))
3846 zoom_with_animation(wd, wd->zoom + 1, 10);
3849 else if (!strcmp(ev->keyname, "KP_Subtract"))
3851 zoom_with_animation(wd, wd->zoom - 1, 10);
3854 else return EINA_FALSE;
3856 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
3857 elm_smart_scroller_child_pos_set(wd->scr, x, y);
3864 elm_map_add(Evas_Object *parent)
3866 #ifdef HAVE_ELEMENTARY_ECORE_CON
3870 Evas_Coord minw, minh;
3872 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3873 ELM_SET_WIDTYPE(widtype, "map");
3874 elm_widget_type_set(obj, "map");
3875 elm_widget_sub_object_add(parent, obj);
3876 elm_widget_data_set(obj, wd);
3877 elm_widget_can_focus_set(obj, EINA_TRUE);
3878 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3879 elm_widget_del_hook_set(obj, _del_hook);
3880 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3881 elm_widget_theme_hook_set(obj, _theme_hook);
3882 elm_widget_event_hook_set(obj, _event_hook);
3883 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, wd);
3884 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, wd);
3885 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, wd);
3886 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, wd);
3887 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
3889 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
3891 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
3892 _mouse_wheel_cb,wd);
3895 wd->scr = elm_smart_scroller_add(e);
3896 elm_widget_sub_object_add(obj, wd->scr);
3897 elm_smart_scroller_widget_set(wd->scr, obj);
3898 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
3899 elm_widget_resize_object_set(obj, wd->scr);
3900 elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE);
3901 elm_smart_scroller_bounce_allow_set(wd->scr,
3902 _elm_config->thumbscroll_bounce_enable,
3903 _elm_config->thumbscroll_bounce_enable);
3904 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3905 _changed_size_hints, wd);
3906 evas_object_smart_callback_add(wd->scr, "scroll", _scr, wd);
3907 evas_object_smart_callback_add(wd->scr, "drag", _scr, wd);
3908 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, wd);
3909 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, wd);
3913 evas_object_smart_clipped_smart_set(&parent_sc);
3915 sc.name = "elm_map_pan";
3916 sc.version = EVAS_SMART_CLASS_VERSION;
3918 sc.resize = _pan_resize;
3919 sc.move = _pan_move;
3920 sc.calculate = _pan_calculate;
3921 smart = evas_smart_class_new(&sc);
3926 wd->pan_smart = evas_object_smart_add(e, smart);
3927 pan = evas_object_smart_data_get(wd->pan_smart);
3930 elm_widget_sub_object_add(obj, wd->pan_smart);
3932 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3933 _pan_set, _pan_get, _pan_max_get,
3934 _pan_min_get, _pan_child_size_get);
3935 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3937 evas_object_size_hint_min_set(obj, minw, minh);
3939 wd->ges = elm_gesture_layer_add(obj);
3940 if (!wd->ges) ERR("elm_gesture_layer_add() failed");
3941 elm_gesture_layer_attach(wd->ges, obj);
3942 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_START,
3943 _pinch_zoom_start_cb, wd);
3944 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_MOVE,
3945 _pinch_zoom_cb, wd);
3946 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_MOVE,
3947 _pinch_rotate_cb, wd);
3948 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_END,
3949 _pinch_rotate_end_cb, wd);
3950 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_ABORT,
3951 _pinch_rotate_end_cb, wd);
3953 wd->sep_maps_overlays = evas_object_rectangle_add(evas_object_evas_get(obj));
3954 elm_widget_sub_object_add(obj, wd->sep_maps_overlays);
3955 evas_object_smart_member_add(wd->sep_maps_overlays, wd->pan_smart);
3957 wd->map = evas_map_new(EVAS_MAP_POINT);
3959 _source_all_load(wd);
3960 wd->zoom_min = wd->src_tile->zoom_min;
3961 wd->zoom_max = wd->src_tile->zoom_max;
3962 // FIXME: Tile Provider is better to provide tile size!
3963 wd->tsize = DEFAULT_TILE_SIZE;
3967 wd->id = ((int)getpid() << 16) | idnum;
3969 _grid_all_create(wd);
3973 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
3975 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3976 // TODO: and save some bytes, making descriptions per-class and not instance!
3977 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3979 if (!ecore_file_download_protocol_available("http://"))
3980 ERR("Ecore must be built with curl support for the map widget!");
3990 elm_map_zoom_set(Evas_Object *obj, int zoom)
3992 #ifdef HAVE_ELEMENTARY_ECORE_CON
3993 ELM_CHECK_WIDTYPE(obj, widtype);
3994 Widget_Data *wd = elm_widget_data_get(obj);
3995 EINA_SAFETY_ON_NULL_RETURN(wd);
3996 EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
3998 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL) return;
3999 if (zoom < 0) zoom = 0;
4000 if (wd->zoom == zoom) return;
4001 Delayed_Data *data = ELM_NEW(Delayed_Data);
4002 data->func = _zoom_set;
4005 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
4006 evas_object_smart_changed(data->wd->pan_smart);
4014 elm_map_zoom_get(const Evas_Object *obj)
4016 #ifdef HAVE_ELEMENTARY_ECORE_CON
4017 ELM_CHECK_WIDTYPE(obj, widtype) 0;
4018 Widget_Data *wd = elm_widget_data_get(obj);
4020 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, 0);
4029 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
4031 #ifdef HAVE_ELEMENTARY_ECORE_CON
4032 ELM_CHECK_WIDTYPE(obj, widtype);
4033 Widget_Data *wd = elm_widget_data_get(obj);
4034 EINA_SAFETY_ON_NULL_RETURN(wd);
4036 if ((mode == ELM_MAP_ZOOM_MODE_MANUAL) && (wd->mode == !!mode)) return;
4038 Delayed_Data *data = ELM_NEW(Delayed_Data);
4040 data->func = _zoom_mode_set;
4042 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
4043 evas_object_smart_changed(data->wd->pan_smart);
4050 EAPI Elm_Map_Zoom_Mode
4051 elm_map_zoom_mode_get(const Evas_Object *obj)
4053 #ifdef HAVE_ELEMENTARY_ECORE_CON
4054 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
4055 Widget_Data *wd = elm_widget_data_get(obj);
4056 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, ELM_MAP_ZOOM_MODE_MANUAL);
4061 return ELM_MAP_ZOOM_MODE_MANUAL;
4066 elm_map_zoom_max_set(Evas_Object *obj, int zoom)
4068 #ifdef HAVE_ELEMENTARY_ECORE_CON
4069 ELM_CHECK_WIDTYPE(obj, widtype);
4070 Widget_Data *wd = elm_widget_data_get(obj);
4071 EINA_SAFETY_ON_NULL_RETURN(wd);
4072 EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
4074 wd->zoom_max = zoom;
4082 elm_map_zoom_max_get(const Evas_Object *obj)
4084 #ifdef HAVE_ELEMENTARY_ECORE_CON
4085 ELM_CHECK_WIDTYPE(obj, widtype) -1;
4086 Widget_Data *wd = elm_widget_data_get(obj);
4087 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1);
4088 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, -1);
4090 return wd->zoom_max;
4098 elm_map_zoom_min_set(Evas_Object *obj, int zoom)
4100 #ifdef HAVE_ELEMENTARY_ECORE_CON
4101 ELM_CHECK_WIDTYPE(obj, widtype);
4102 Widget_Data *wd = elm_widget_data_get(obj);
4103 EINA_SAFETY_ON_NULL_RETURN(wd);
4104 EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
4106 wd->zoom_min = zoom;
4114 elm_map_zoom_min_get(const Evas_Object *obj)
4116 #ifdef HAVE_ELEMENTARY_ECORE_CON
4117 ELM_CHECK_WIDTYPE(obj, widtype) -1;
4118 Widget_Data *wd = elm_widget_data_get(obj);
4119 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1);
4120 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, -1);
4122 return wd->zoom_min;
4130 elm_map_region_bring_in(Evas_Object *obj, double lon, double lat)
4132 #ifdef HAVE_ELEMENTARY_ECORE_CON
4133 ELM_CHECK_WIDTYPE(obj, widtype);
4134 Widget_Data *wd = elm_widget_data_get(obj);
4136 Delayed_Data *data = ELM_NEW(Delayed_Data);
4137 data->func = _region_bring_in;
4141 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
4142 evas_object_smart_changed(data->wd->pan_smart);
4151 elm_map_region_show(Evas_Object *obj, double lon, double lat)
4153 #ifdef HAVE_ELEMENTARY_ECORE_CON
4154 ELM_CHECK_WIDTYPE(obj, widtype);
4155 Widget_Data *wd = elm_widget_data_get(obj);
4157 Delayed_Data *data = ELM_NEW(Delayed_Data);
4158 data->func = _region_show;
4162 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
4163 evas_object_smart_changed(data->wd->pan_smart);
4172 elm_map_region_get(const Evas_Object *obj, double *lon, double *lat)
4174 #ifdef HAVE_ELEMENTARY_ECORE_CON
4175 ELM_CHECK_WIDTYPE(obj, widtype);
4176 Widget_Data *wd = elm_widget_data_get(obj);
4177 EINA_SAFETY_ON_NULL_RETURN(wd);
4180 Evas_Coord vx, vy, vw, vh;
4182 _viewport_coord_get(wd, &vx, &vy, &vw, &vh);
4183 _coord_to_region_convert(wd, vx + vw/2, vy + vh/2, wd->size.w, &tlon, &tlat);
4184 if (lon) *lon = tlon;
4185 if (lat) *lat = tlat;
4194 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
4196 #ifdef HAVE_ELEMENTARY_ECORE_CON
4197 ELM_CHECK_WIDTYPE(obj, widtype);
4198 Widget_Data *wd = elm_widget_data_get(obj);
4199 EINA_SAFETY_ON_NULL_RETURN(wd);
4201 if (wd->paused == !!paused) return;
4202 wd->paused = !!paused;
4205 if (wd->zoom_animator)
4207 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
4208 wd->zoom_animator = NULL;
4209 zoom_do(wd, wd->zoom);
4211 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4212 "elm,state,busy,stop", "elm");
4216 if (wd->download_num >= 1)
4217 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4218 "elm,state,busy,start", "elm");
4227 elm_map_paused_get(const Evas_Object *obj)
4229 #ifdef HAVE_ELEMENTARY_ECORE_CON
4230 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4231 Widget_Data *wd = elm_widget_data_get(obj);
4232 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
4242 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
4244 #ifdef HAVE_ELEMENTARY_ECORE_CON
4245 ELM_CHECK_WIDTYPE(obj, widtype);
4246 Widget_Data *wd = elm_widget_data_get(obj);
4247 EINA_SAFETY_ON_NULL_RETURN(wd);
4249 wd->rotate.d = degree;
4253 evas_object_smart_changed(wd->pan_smart);
4263 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
4265 #ifdef HAVE_ELEMENTARY_ECORE_CON
4266 ELM_CHECK_WIDTYPE(obj, widtype);
4267 Widget_Data *wd = elm_widget_data_get(obj);
4268 EINA_SAFETY_ON_NULL_RETURN(wd);
4270 if (degree) *degree = wd->rotate.d;
4271 if (cx) *cx = wd->rotate.cx;
4272 if (cy) *cy = wd->rotate.cy;
4282 elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
4284 #ifdef HAVE_ELEMENTARY_ECORE_CON
4285 ELM_CHECK_WIDTYPE(obj, widtype);
4286 Widget_Data *wd = elm_widget_data_get(obj);
4287 EINA_SAFETY_ON_NULL_RETURN(wd);
4289 if ((!wd->wheel_disabled) && (disabled))
4290 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, wd);
4291 else if ((wd->wheel_disabled) && (!disabled))
4292 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, wd);
4293 wd->wheel_disabled = !!disabled;
4301 elm_map_wheel_disabled_get(const Evas_Object *obj)
4303 #ifdef HAVE_ELEMENTARY_ECORE_CON
4304 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4305 Widget_Data *wd = elm_widget_data_get(obj);
4306 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
4308 return wd->wheel_disabled;
4316 elm_map_tile_load_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
4318 #ifdef HAVE_ELEMENTARY_ECORE_CON
4319 ELM_CHECK_WIDTYPE(obj, widtype);
4320 Widget_Data *wd = elm_widget_data_get(obj);
4321 EINA_SAFETY_ON_NULL_RETURN(wd);
4323 if (try_num) *try_num = wd->try_num;
4324 if (finish_num) *finish_num = wd->finish_num;
4333 elm_map_canvas_to_region_convert(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, double *lon, double *lat)
4335 #ifdef HAVE_ELEMENTARY_ECORE_CON
4336 ELM_CHECK_WIDTYPE(obj, widtype);
4337 Widget_Data *wd = elm_widget_data_get(obj);
4338 EINA_SAFETY_ON_NULL_RETURN(wd);
4339 EINA_SAFETY_ON_NULL_RETURN(lon);
4340 EINA_SAFETY_ON_NULL_RETURN(lat);
4342 _canvas_to_coord(wd, x, y, &x, &y);
4343 _coord_to_region_convert(wd, x, y, wd->size.w, lon, lat);
4354 elm_map_region_to_canvas_convert(const Evas_Object *obj, double lon, double lat, Evas_Coord *x, Evas_Coord *y)
4356 #ifdef HAVE_ELEMENTARY_ECORE_CON
4357 ELM_CHECK_WIDTYPE(obj, widtype);
4358 Widget_Data *wd = elm_widget_data_get(obj);
4359 EINA_SAFETY_ON_NULL_RETURN(wd);
4360 EINA_SAFETY_ON_NULL_RETURN(x);
4361 EINA_SAFETY_ON_NULL_RETURN(y);
4363 _region_to_coord_convert(wd, lon, lat, wd->size.w, x, y);
4364 _coord_to_canvas(wd, *x, *y, x, y);
4375 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
4377 #ifdef HAVE_ELEMENTARY_ECORE_CON
4378 ELM_CHECK_WIDTYPE(obj, widtype);
4379 Widget_Data *wd = elm_widget_data_get(obj);
4380 EINA_SAFETY_ON_NULL_RETURN(wd);
4381 EINA_SAFETY_ON_NULL_RETURN(user_agent);
4383 eina_stringshare_replace(&wd->user_agent, user_agent);
4385 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4386 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4394 elm_map_user_agent_get(const Evas_Object *obj)
4396 #ifdef HAVE_ELEMENTARY_ECORE_CON
4397 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4398 Widget_Data *wd = elm_widget_data_get(obj);
4399 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4401 return wd->user_agent;
4409 elm_map_source_set(Evas_Object *obj, Elm_Map_Source_Type type, const char *source_name)
4411 #ifdef HAVE_ELEMENTARY_ECORE_CON
4412 ELM_CHECK_WIDTYPE(obj, widtype);
4413 Widget_Data *wd = elm_widget_data_get(obj);
4414 EINA_SAFETY_ON_NULL_RETURN(wd);
4415 EINA_SAFETY_ON_NULL_RETURN(source_name);
4417 if (type == ELM_MAP_SOURCE_TYPE_TILE) _source_tile_set(wd, source_name);
4418 else if (type == ELM_MAP_SOURCE_TYPE_ROUTE)
4419 _source_route_set(wd, source_name);
4420 else if (type == ELM_MAP_SOURCE_TYPE_NAME) _source_name_set(wd, source_name);
4421 else ERR("Not supported map source type: %d", type);
4430 elm_map_source_get(const Evas_Object *obj, Elm_Map_Source_Type type)
4432 #ifdef HAVE_ELEMENTARY_ECORE_CON
4433 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4434 Widget_Data *wd = elm_widget_data_get(obj);
4435 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4436 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, NULL);
4438 if (type == ELM_MAP_SOURCE_TYPE_TILE) return wd->src_tile->name;
4439 else if (type == ELM_MAP_SOURCE_TYPE_ROUTE) return wd->src_route->name;
4440 else if (type == ELM_MAP_SOURCE_TYPE_NAME) return wd->src_name->name;
4441 else ERR("Not supported map source type: %d", type);
4450 elm_map_sources_get(const Evas_Object *obj, Elm_Map_Source_Type type)
4452 #ifdef HAVE_ELEMENTARY_ECORE_CON
4453 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4454 Widget_Data *wd = elm_widget_data_get(obj);
4455 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4457 if (type == ELM_MAP_SOURCE_TYPE_TILE) return wd->src_tile_names;
4458 else if (type == ELM_MAP_SOURCE_TYPE_ROUTE) return wd->src_route_names;
4459 else if (type == ELM_MAP_SOURCE_TYPE_NAME) return wd->src_name_names;
4460 else ERR("Not supported map source type: %d", type);
4468 EAPI Elm_Map_Route *
4469 elm_map_route_add(Evas_Object *obj, Elm_Map_Route_Type type, Elm_Map_Route_Method method, double flon, double flat, double tlon, double tlat, Elm_Map_Route_Cb route_cb, void *data)
4471 #ifdef HAVE_ELEMENTARY_ECORE_CON
4472 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4473 Widget_Data *wd = elm_widget_data_get(obj);
4474 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4475 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_route, NULL);
4479 char fname[PATH_MAX];
4481 if (!ecore_file_exists(CACHE_ROUTE_ROOT))
4482 ecore_file_mkpath(CACHE_ROUTE_ROOT);
4484 if (type == ELM_MAP_ROUTE_TYPE_MOTOCAR)
4485 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4486 else if (type == ELM_MAP_ROUTE_TYPE_BICYCLE)
4487 type_name = strdup(ROUTE_TYPE_BICYCLE);
4488 else if (type == ELM_MAP_ROUTE_TYPE_FOOT)
4489 type_name = strdup(ROUTE_TYPE_FOOT);
4490 else type_name = NULL;
4492 url = wd->src_route->url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4495 ERR("Route URL is NULL");
4496 if (type_name) free(type_name);
4499 if (type_name) free(type_name);
4501 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4503 snprintf(fname, sizeof(fname), CACHE_ROUTE_ROOT"/%d", rand());
4504 route->fname = strdup(fname);
4506 route->method = method;
4511 route->cb = route_cb;
4514 if (!ecore_file_download_full(url, route->fname, _route_cb, NULL, route,
4515 &(route->job), wd->ua) || !(route->job))
4517 ERR("Can't request Route from %s to %s", url, route->fname);
4522 INF("Route requested from %s to %s", url, route->fname);
4525 wd->routes = eina_list_append(wd->routes, route);
4526 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, route);
4527 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4528 "elm,state,busy,start", "elm");
4546 elm_map_route_del(Elm_Map_Route *route)
4548 #ifdef HAVE_ELEMENTARY_ECORE_CON
4549 EINA_SAFETY_ON_NULL_RETURN(route);
4550 EINA_SAFETY_ON_NULL_RETURN(route->wd);
4551 ELM_CHECK_WIDTYPE(route->wd->obj, widtype);
4556 if (route->job) ecore_file_download_abort(route->job);
4558 EINA_LIST_FREE(route->waypoint, w)
4560 if (w->point) eina_stringshare_del(w->point);
4564 EINA_LIST_FREE(route->nodes, n)
4566 if (n->pos.address) eina_stringshare_del(n->pos.address);
4572 ecore_file_remove(route->fname);
4576 route->wd->routes = eina_list_remove(route->wd->routes, route);
4584 elm_map_route_distance_get(const Elm_Map_Route *route)
4586 #ifdef HAVE_ELEMENTARY_ECORE_CON
4587 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
4588 return route->info.distance;
4596 elm_map_route_node_get(const Elm_Map_Route *route)
4598 #ifdef HAVE_ELEMENTARY_ECORE_CON
4599 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4600 return route->info.nodes;
4608 elm_map_route_waypoint_get(const Elm_Map_Route *route)
4610 #ifdef HAVE_ELEMENTARY_ECORE_CON
4611 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4612 return route->info.waypoints;
4620 elm_map_name_add(const Evas_Object *obj, const char *address, double lon, double lat, Elm_Map_Name_Cb name_cb, void *data)
4622 #ifdef HAVE_ELEMENTARY_ECORE_CON
4623 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4626 return _name_request(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0, 0,
4629 return _name_request(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat,
4643 elm_map_name_del(Elm_Map_Name *name)
4645 #ifdef HAVE_ELEMENTARY_ECORE_CON
4646 EINA_SAFETY_ON_NULL_RETURN(name);
4647 EINA_SAFETY_ON_NULL_RETURN(name->wd);
4648 ELM_CHECK_WIDTYPE(name->wd->obj, widtype);
4650 if (name->job) ecore_file_download_abort(name->job);
4651 if (name->address) free(name->address);
4654 ecore_file_remove(name->fname);
4658 name->wd->names = eina_list_remove(name->wd->names, name);
4666 elm_map_name_address_get(const Elm_Map_Name *name)
4668 #ifdef HAVE_ELEMENTARY_ECORE_CON
4669 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
4670 EINA_SAFETY_ON_NULL_RETURN_VAL(name->wd, NULL);
4671 ELM_CHECK_WIDTYPE(name->wd->obj, widtype) NULL;
4673 return name->address;
4681 elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
4683 #ifdef HAVE_ELEMENTARY_ECORE_CON
4684 EINA_SAFETY_ON_NULL_RETURN(name);
4685 EINA_SAFETY_ON_NULL_RETURN(name->wd);
4686 ELM_CHECK_WIDTYPE(name->wd->obj, widtype);
4688 if (lon) *lon = name->lon;
4689 if (lat) *lat = name->lat;
4697 EAPI Elm_Map_Overlay *
4698 elm_map_overlay_add(Evas_Object *obj, double lon, double lat)
4700 #ifdef HAVE_ELEMENTARY_ECORE_CON
4701 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4702 Widget_Data *wd = elm_widget_data_get(obj);
4703 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4705 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
4707 overlay->type = ELM_MAP_OVERLAY_TYPE_DEFAULT;
4708 overlay->c.r = 0x87;
4709 overlay->c.g = 0xce;
4710 overlay->c.b = 0xeb;
4712 overlay->ovl = _overlay_default_new(overlay, lon, lat, overlay->c, 1);
4713 overlay->grp = _overlay_group_new(wd);
4714 wd->overlays = eina_list_append(wd->overlays, overlay);
4716 evas_object_smart_changed(wd->pan_smart);
4727 elm_map_overlay_del(Elm_Map_Overlay *overlay)
4729 #ifdef HAVE_ELEMENTARY_ECORE_CON
4730 EINA_SAFETY_ON_NULL_RETURN(overlay);
4731 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4732 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4736 if (overlay->grp->clas)
4737 elm_map_overlay_class_remove(overlay->grp->clas, overlay);
4738 _overlay_group_free(overlay->grp);
4741 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
4742 _overlay_default_free(overlay->ovl);
4743 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
4744 _overlay_bubble_free(overlay->ovl);
4745 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
4746 _overlay_class_free(overlay->ovl);
4747 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
4748 _overlay_route_free(overlay->ovl);
4749 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_LINE)
4750 _overlay_line_free(overlay->ovl);
4751 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON)
4752 _overlay_polygon_free(overlay->ovl);
4753 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CIRCLE)
4754 _overlay_circle_free(overlay->ovl);
4755 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_SCALE)
4756 _overlay_scale_free(overlay->ovl);
4757 else ERR("Invalid overlay type: %d", overlay->type);
4759 overlay->wd->overlays = eina_list_remove(overlay->wd->overlays, overlay);
4760 evas_object_smart_changed(overlay->wd->pan_smart);
4768 EAPI Elm_Map_Overlay_Type
4769 elm_map_overlay_type_get(const Elm_Map_Overlay *overlay)
4771 #ifdef HAVE_ELEMENTARY_ECORE_CON
4772 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, ELM_MAP_OVERLAY_TYPE_NONE);
4773 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, ELM_MAP_OVERLAY_TYPE_NONE);
4774 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) ELM_MAP_OVERLAY_TYPE_NONE;
4776 return overlay->type;
4779 return ELM_MAP_OVERLAY_TYPE_NONE;
4784 elm_map_overlay_data_set(Elm_Map_Overlay *overlay, void *data)
4786 #ifdef HAVE_ELEMENTARY_ECORE_CON
4787 EINA_SAFETY_ON_NULL_RETURN(overlay);
4788 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4789 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4791 overlay->data = data;
4799 elm_map_overlay_data_get(const Elm_Map_Overlay *overlay)
4801 #ifdef HAVE_ELEMENTARY_ECORE_CON
4802 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
4803 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
4804 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
4806 return overlay->data;
4814 elm_map_overlay_hide_set(Elm_Map_Overlay *overlay, Eina_Bool hide)
4816 #ifdef HAVE_ELEMENTARY_ECORE_CON
4817 EINA_SAFETY_ON_NULL_RETURN(overlay);
4818 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4819 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4821 if (overlay->hide == !!hide) return;
4822 overlay->hide = hide;
4824 evas_object_smart_changed(overlay->wd->pan_smart);
4832 elm_map_overlay_hide_get(const Elm_Map_Overlay *overlay)
4834 #ifdef HAVE_ELEMENTARY_ECORE_CON
4835 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
4836 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE);
4837 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE;
4839 return overlay->hide;
4847 elm_map_overlay_displayed_zoom_min_set(Elm_Map_Overlay *overlay, int zoom)
4849 #ifdef HAVE_ELEMENTARY_ECORE_CON
4850 EINA_SAFETY_ON_NULL_RETURN(overlay);
4851 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4852 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4854 overlay->zoom_min = zoom;
4855 evas_object_smart_changed(overlay->wd->pan_smart);
4863 elm_map_overlay_displayed_zoom_min_get(const Elm_Map_Overlay *overlay)
4865 #ifdef HAVE_ELEMENTARY_ECORE_CON
4866 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, 0);
4867 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, 0);
4868 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) 0;
4870 return overlay->zoom_min;
4878 elm_map_overlay_paused_set(Elm_Map_Overlay *overlay, Eina_Bool paused)
4880 #ifdef HAVE_ELEMENTARY_ECORE_CON
4881 EINA_SAFETY_ON_NULL_RETURN(overlay);
4882 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4883 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4885 if (overlay->paused == !!paused) return;
4886 overlay->paused = paused;
4888 evas_object_smart_changed(overlay->wd->pan_smart);
4896 elm_map_overlay_paused_get(const Elm_Map_Overlay *overlay)
4898 #ifdef HAVE_ELEMENTARY_ECORE_CON
4899 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
4900 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE);
4901 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE;
4903 return overlay->paused;
4911 elm_map_overlay_show(Elm_Map_Overlay *overlay)
4913 #ifdef HAVE_ELEMENTARY_ECORE_CON
4914 EINA_SAFETY_ON_NULL_RETURN(overlay);
4915 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4916 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4918 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
4920 Overlay_Default *ovl = overlay->ovl;
4921 elm_map_region_show(overlay->wd->obj, ovl->lon, ovl->lat);
4923 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
4925 Overlay_Bubble *ovl = overlay->ovl;
4926 elm_map_region_show(overlay->wd->obj, ovl->lon, ovl->lat);
4928 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
4930 Overlay_Class *ovl = overlay->ovl;
4931 double lon, lat, max_lo, min_lo, max_la, min_la;
4932 _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la, &min_la);
4933 lon = (max_lo + min_lo) / 2;
4934 lat = (max_la + min_la) / 2;
4935 elm_map_region_show(overlay->wd->obj, lon, lat);
4937 else ERR("Not supported overlay type: %d", overlay->type);
4939 evas_object_smart_changed(overlay->wd->pan_smart);
4946 elm_map_overlays_show(Eina_List *overlays)
4948 #ifdef HAVE_ELEMENTARY_ECORE_CON
4949 EINA_SAFETY_ON_NULL_RETURN(overlays);
4950 EINA_SAFETY_ON_FALSE_RETURN(eina_list_count(overlays));
4952 Elm_Map_Overlay *overlay;
4953 overlay = eina_list_data_get(overlays);
4955 Delayed_Data *data = ELM_NEW(Delayed_Data);
4956 data->func = _overlays_show;
4957 data->wd = overlay->wd;
4958 data->overlays = eina_list_clone(overlays);
4959 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
4960 evas_object_smart_changed(data->wd->pan_smart);
4967 elm_map_overlay_region_set(Elm_Map_Overlay *overlay, double lon, double lat)
4969 #ifdef HAVE_ELEMENTARY_ECORE_CON
4970 EINA_SAFETY_ON_NULL_RETURN(overlay);
4971 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4972 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4974 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
4976 Overlay_Default *ovl = overlay->ovl;
4980 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
4982 Overlay_Bubble *ovl = overlay->ovl;
4986 else ERR("Not supported overlay type: %d", overlay->type);
4988 evas_object_smart_changed(overlay->wd->pan_smart);
4997 elm_map_overlay_region_get(const Elm_Map_Overlay *overlay, double *lon, double *lat)
4999 #ifdef HAVE_ELEMENTARY_ECORE_CON
5000 EINA_SAFETY_ON_NULL_RETURN(overlay);
5001 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5002 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5004 if (overlay->type == ELM_MAP_OVERLAY_TYPE_GROUP)
5006 Overlay_Group *ovl = overlay->ovl;
5007 _overlay_group_region_get(ovl, lon, lat);
5009 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5011 const Overlay_Default *ovl = overlay->ovl;
5012 if (lon) *lon = ovl->lon;
5013 if (lat) *lat = ovl->lat;
5015 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
5017 const Overlay_Bubble *ovl = overlay->ovl;
5018 if (lon) *lon = ovl->lon;
5019 if (lat) *lat = ovl->lat;
5021 else ERR("Not supported overlay type: %d", overlay->type);
5030 elm_map_overlay_icon_set(Elm_Map_Overlay *overlay, Evas_Object *icon)
5032 #ifdef HAVE_ELEMENTARY_ECORE_CON
5033 EINA_SAFETY_ON_NULL_RETURN(overlay);
5034 EINA_SAFETY_ON_NULL_RETURN(icon);
5035 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5036 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5038 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5039 _overlay_default_icon_update(overlay->ovl, icon);
5040 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5041 _overlay_class_icon_update(overlay->ovl, icon);
5042 else ERR("Not supported overlay type: %d", overlay->type);
5044 evas_object_smart_changed(overlay->wd->pan_smart);
5051 EAPI const Evas_Object *
5052 elm_map_overlay_icon_get(const Elm_Map_Overlay *overlay)
5054 #ifdef HAVE_ELEMENTARY_ECORE_CON
5055 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
5056 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
5057 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
5059 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5061 const Overlay_Default *ovl = overlay->ovl;
5064 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5066 const Overlay_Class *ovl = overlay->ovl;
5071 ERR("Not supported overlay type: %d", overlay->type);
5081 elm_map_overlay_content_set(Elm_Map_Overlay *overlay, Evas_Object *content)
5083 #ifdef HAVE_ELEMENTARY_ECORE_CON
5084 EINA_SAFETY_ON_NULL_RETURN(overlay);
5085 EINA_SAFETY_ON_NULL_RETURN(content);
5086 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5087 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5089 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5090 _overlay_default_content_update(overlay->ovl, content, overlay);
5091 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5092 _overlay_class_content_update(overlay->ovl, content);
5093 else ERR("Not supported overlay type: %d", overlay->type);
5095 evas_object_smart_changed(overlay->wd->pan_smart);
5102 EAPI const Evas_Object *
5103 elm_map_overlay_content_get(const Elm_Map_Overlay *overlay)
5105 #ifdef HAVE_ELEMENTARY_ECORE_CON
5106 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
5107 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
5108 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
5110 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5112 const Overlay_Default *ovl = overlay->ovl;
5113 return ovl->content;
5115 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5117 const Overlay_Class *ovl = overlay->ovl;
5118 return ovl->content;
5122 ERR("Not supported overlay type: %d", overlay->type);
5132 elm_map_overlay_color_set(Elm_Map_Overlay *overlay, int r, int g , int b, int a)
5134 #ifdef HAVE_ELEMENTARY_ECORE_CON
5135 EINA_SAFETY_ON_NULL_RETURN(overlay);
5136 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5137 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5144 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5145 _overlay_class_color_update(overlay->ovl, overlay->c);
5146 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5147 _overlay_default_color_update(overlay->ovl, overlay->c);
5148 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
5149 _overlay_route_color_update(overlay->ovl, overlay->c);
5152 ERR("Not supported overlay type: %d", overlay->type);
5165 elm_map_overlay_color_get(const Elm_Map_Overlay *overlay, int *r, int *g , int *b, int *a)
5167 #ifdef HAVE_ELEMENTARY_ECORE_CON
5168 EINA_SAFETY_ON_NULL_RETURN(overlay);
5169 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5170 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5172 if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
5174 if (r) *r = overlay->c.r;
5175 if (g) *g = overlay->c.g;
5176 if (b) *b = overlay->c.b;
5177 if (a) *a = overlay->c.a;
5179 else ERR("Not supported overlay type: %d", overlay->type);
5190 elm_map_overlay_get_cb_set(Elm_Map_Overlay *overlay, Elm_Map_Overlay_Get_Cb get_cb, void *data)
5192 #ifdef HAVE_ELEMENTARY_ECORE_CON
5193 EINA_SAFETY_ON_NULL_RETURN(overlay);
5194 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5195 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5197 overlay->cb = get_cb;
5198 overlay->cb_data = data;
5200 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5201 _overlay_class_cb_set(overlay->ovl, get_cb, data);
5209 EAPI Elm_Map_Overlay *
5210 elm_map_overlay_class_add(Evas_Object *obj)
5212 #ifdef HAVE_ELEMENTARY_ECORE_CON
5213 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5214 Widget_Data *wd = elm_widget_data_get(obj);
5215 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5217 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5219 overlay->type = ELM_MAP_OVERLAY_TYPE_CLASS;
5220 overlay->ovl = _overlay_class_new(wd);
5221 overlay->c.r = 0x90;
5222 overlay->c.g = 0xee;
5223 overlay->c.b = 0x90;
5224 overlay->c.a = 0xff;
5225 wd->overlays = eina_list_append(wd->overlays, overlay);
5227 evas_object_smart_changed(wd->pan_smart);
5236 elm_map_overlay_class_append(Elm_Map_Overlay *clas, Elm_Map_Overlay *overlay)
5238 #ifdef HAVE_ELEMENTARY_ECORE_CON
5239 EINA_SAFETY_ON_NULL_RETURN(clas);
5240 EINA_SAFETY_ON_NULL_RETURN(overlay);
5241 EINA_SAFETY_ON_NULL_RETURN(clas->wd);
5242 ELM_CHECK_WIDTYPE(clas->wd->obj, widtype);
5243 EINA_SAFETY_ON_FALSE_RETURN(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS);
5245 Overlay_Class *clas_ovl = clas->ovl;
5246 if (eina_list_data_find(clas_ovl->members, overlay))
5248 ERR("Already added overlay into clas");
5251 clas_ovl->members = eina_list_append(clas_ovl->members, overlay);
5253 // Update group by class
5254 overlay->grp->clas = clas;
5255 _overlay_group_icon_update(overlay->grp, clas_ovl->icon);
5256 _overlay_group_content_update(overlay->grp, clas_ovl->content);
5257 _overlay_group_color_update(overlay->grp, clas->c);
5258 _overlay_group_cb_set(overlay->grp, clas->cb, clas->data);
5259 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5261 _overlay_default_clas_icon_update(overlay->ovl, clas_ovl->icon);
5262 _overlay_default_clas_content_update(overlay->ovl, clas_ovl->content);
5265 evas_object_smart_changed(clas->wd->pan_smart);
5273 elm_map_overlay_class_remove(Elm_Map_Overlay *clas, Elm_Map_Overlay *overlay)
5275 #ifdef HAVE_ELEMENTARY_ECORE_CON
5276 EINA_SAFETY_ON_NULL_RETURN(clas);
5277 EINA_SAFETY_ON_NULL_RETURN(overlay);
5278 EINA_SAFETY_ON_NULL_RETURN(clas->wd);
5279 ELM_CHECK_WIDTYPE(clas->wd->obj, widtype);
5280 EINA_SAFETY_ON_FALSE_RETURN(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS);
5282 Overlay_Class *ovl = clas->ovl;
5283 ovl->members = eina_list_remove(ovl->members, overlay);
5285 overlay->grp->clas = NULL;
5286 _overlay_group_icon_update(overlay->grp, NULL);
5287 _overlay_group_content_update(overlay->grp, NULL);
5288 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5290 _overlay_default_clas_icon_update(overlay->ovl, NULL);
5291 _overlay_default_clas_content_update(overlay->ovl, NULL);
5294 evas_object_smart_changed(clas->wd->pan_smart);
5302 elm_map_overlay_class_zoom_max_set(Elm_Map_Overlay *clas, int zoom)
5304 #ifdef HAVE_ELEMENTARY_ECORE_CON
5305 EINA_SAFETY_ON_NULL_RETURN(clas);
5306 EINA_SAFETY_ON_NULL_RETURN(clas->wd);
5307 ELM_CHECK_WIDTYPE(clas->wd->obj, widtype);
5308 EINA_SAFETY_ON_FALSE_RETURN(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS);
5310 Overlay_Class *ovl = clas->ovl;
5311 if (ovl->zoom_max == !!zoom) return;
5312 ovl->zoom_max = zoom;
5314 evas_object_smart_changed(clas->wd->pan_smart);
5322 elm_map_overlay_class_zoom_max_get(const Elm_Map_Overlay *clas)
5324 #ifdef HAVE_ELEMENTARY_ECORE_CON
5325 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, OVERLAY_CLASS_ZOOM_MAX);
5326 EINA_SAFETY_ON_NULL_RETURN_VAL(clas->wd, OVERLAY_CLASS_ZOOM_MAX);
5327 ELM_CHECK_WIDTYPE(clas->wd->obj, widtype) OVERLAY_CLASS_ZOOM_MAX;
5328 EINA_SAFETY_ON_FALSE_RETURN_VAL(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS, OVERLAY_CLASS_ZOOM_MAX);
5330 const Overlay_Class *ovl = clas->ovl;
5331 return ovl->zoom_max;
5334 return OVERLAY_CLASS_ZOOM_MAX;
5339 elm_map_overlay_group_members_get(const Elm_Map_Overlay *grp)
5341 #ifdef HAVE_ELEMENTARY_ECORE_CON
5342 EINA_SAFETY_ON_NULL_RETURN_VAL(grp, NULL);
5343 EINA_SAFETY_ON_NULL_RETURN_VAL(grp->wd, NULL);
5344 ELM_CHECK_WIDTYPE(grp->wd->obj, widtype) NULL;
5345 EINA_SAFETY_ON_FALSE_RETURN_VAL(grp->type == ELM_MAP_OVERLAY_TYPE_GROUP, NULL);
5347 Overlay_Group *ovl = grp->ovl;
5348 return ovl->members;
5351 return OVERLAY_CLASS_ZOOM_MAX;
5355 EAPI Elm_Map_Overlay *
5356 elm_map_overlay_bubble_add(Evas_Object *obj)
5358 #ifdef HAVE_ELEMENTARY_ECORE_CON
5359 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5360 Widget_Data *wd = elm_widget_data_get(obj);
5361 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5363 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5365 overlay->type = ELM_MAP_OVERLAY_TYPE_BUBBLE;
5370 overlay->ovl = _overlay_bubble_new(overlay);
5371 overlay->grp = _overlay_group_new(wd);
5372 wd->overlays = eina_list_append(wd->overlays, overlay);
5374 evas_object_smart_changed(wd->pan_smart);
5383 elm_map_overlay_bubble_follow(Elm_Map_Overlay *bubble, const Elm_Map_Overlay *parent)
5385 #ifdef HAVE_ELEMENTARY_ECORE_CON
5386 EINA_SAFETY_ON_NULL_RETURN(bubble);
5387 EINA_SAFETY_ON_NULL_RETURN(parent);
5388 ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
5389 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
5391 Overlay_Bubble *ovl = bubble->ovl;
5392 Evas_Object *pobj = _overlay_obj_get(parent);
5397 evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_HIDE,
5398 _overlay_bubble_hide_cb, ovl);
5399 evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_SHOW,
5400 _overlay_bubble_chase_cb, ovl);
5401 evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_MOVE,
5402 _overlay_bubble_chase_cb, ovl);
5406 evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_HIDE,
5407 _overlay_bubble_hide_cb, ovl);
5408 evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_SHOW,
5409 _overlay_bubble_chase_cb, ovl);
5410 evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_MOVE,
5411 _overlay_bubble_chase_cb, ovl);
5413 _overlay_bubble_chase(ovl);
5414 evas_object_smart_changed(bubble->wd->pan_smart);
5422 elm_map_overlay_bubble_content_append(Elm_Map_Overlay *bubble, Evas_Object *content)
5424 #ifdef HAVE_ELEMENTARY_ECORE_CON
5425 EINA_SAFETY_ON_NULL_RETURN(bubble);
5426 EINA_SAFETY_ON_NULL_RETURN(content);
5427 ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
5428 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
5430 Overlay_Bubble *bb = bubble->ovl;
5431 elm_box_pack_end(bb->bx, content);
5433 evas_object_smart_changed(bubble->wd->pan_smart);
5441 elm_map_overlay_bubble_content_clear(Elm_Map_Overlay *bubble)
5443 #ifdef HAVE_ELEMENTARY_ECORE_CON
5444 EINA_SAFETY_ON_NULL_RETURN(bubble);
5445 ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
5446 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
5448 Overlay_Bubble *bb = bubble->ovl;
5449 elm_box_clear(bb->bx);
5451 evas_object_smart_changed(bubble->wd->pan_smart);
5457 EAPI Elm_Map_Overlay *
5458 elm_map_overlay_route_add(Evas_Object *obj, const Elm_Map_Route *route)
5460 #ifdef HAVE_ELEMENTARY_ECORE_CON
5461 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5462 Widget_Data *wd = elm_widget_data_get(obj);
5463 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5464 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
5465 EINA_SAFETY_ON_NULL_RETURN_VAL(route->wd, NULL);
5466 EINA_SAFETY_ON_FALSE_RETURN_VAL(obj == route->wd->obj, NULL);
5468 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5470 overlay->type = ELM_MAP_OVERLAY_TYPE_ROUTE;
5471 overlay->c.r = 0xff;
5472 overlay->c.g = 0x00;
5473 overlay->c.b = 0x00;
5474 overlay->c.a = 0xff;
5475 overlay->ovl = _overlay_route_new(wd, route, overlay->c);
5476 overlay->grp = _overlay_group_new(wd);
5477 wd->overlays = eina_list_append(wd->overlays, overlay);
5479 evas_object_smart_changed(wd->pan_smart);
5488 EAPI Elm_Map_Overlay *
5489 elm_map_overlay_line_add(Evas_Object *obj, double flon, double flat, double tlon, double tlat)
5491 #ifdef HAVE_ELEMENTARY_ECORE_CON
5492 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5493 Widget_Data *wd = elm_widget_data_get(obj);
5494 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5496 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5498 overlay->type = ELM_MAP_OVERLAY_TYPE_LINE;
5499 overlay->c.r = 0xff;
5500 overlay->c.g = 0x00;
5501 overlay->c.b = 0x00;
5502 overlay->c.a = 0xff;
5503 overlay->ovl = _overlay_line_new(wd, flon, flat, tlon, tlat, overlay->c);
5504 overlay->grp = _overlay_group_new(wd);
5505 wd->overlays = eina_list_append(wd->overlays, overlay);
5507 evas_object_smart_changed(wd->pan_smart);
5519 EAPI Elm_Map_Overlay *
5520 elm_map_overlay_polygon_add(Evas_Object *obj)
5522 #ifdef HAVE_ELEMENTARY_ECORE_CON
5523 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5524 Widget_Data *wd = elm_widget_data_get(obj);
5525 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5527 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5529 overlay->type = ELM_MAP_OVERLAY_TYPE_POLYGON;
5530 overlay->c.r = 0xdc;
5531 overlay->c.g = 0x14;
5532 overlay->c.b = 0x3c;
5534 overlay->ovl = _overlay_polygon_new(wd, overlay->c);
5535 overlay->grp = _overlay_group_new(wd);
5536 wd->overlays = eina_list_append(wd->overlays, overlay);
5537 evas_object_smart_changed(wd->pan_smart);
5546 elm_map_overlay_polygon_region_add(Elm_Map_Overlay *overlay, double lon, double lat)
5548 #ifdef HAVE_ELEMENTARY_ECORE_CON
5549 EINA_SAFETY_ON_NULL_RETURN(overlay);
5550 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5551 EINA_SAFETY_ON_FALSE_RETURN(overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON);
5553 Overlay_Polygon *ovl = overlay->ovl;
5554 Region *r = ELM_NEW(Region);
5557 ovl->regions = eina_list_append(ovl->regions, r);
5559 evas_object_smart_changed(ovl->wd->pan_smart);
5567 EAPI Elm_Map_Overlay *
5568 elm_map_overlay_circle_add(Evas_Object *obj, double lon, double lat, double radius)
5570 #ifdef HAVE_ELEMENTARY_ECORE_CON
5571 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5572 Widget_Data *wd = elm_widget_data_get(obj);
5573 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5575 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5577 overlay->type = ELM_MAP_OVERLAY_TYPE_CIRCLE;
5578 overlay->c.r = 0xdc;
5579 overlay->c.g = 0x14;
5580 overlay->c.b = 0x3c;
5582 overlay->ovl = _overlay_circle_new(wd, lon, lat, radius, overlay->c);
5583 overlay->grp = _overlay_group_new(wd);
5584 wd->overlays = eina_list_append(wd->overlays, overlay);
5586 evas_object_smart_changed(wd->pan_smart);
5594 EAPI Elm_Map_Overlay *
5595 elm_map_overlay_scale_add(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
5597 #ifdef HAVE_ELEMENTARY_ECORE_CON
5598 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5599 Widget_Data *wd = elm_widget_data_get(obj);
5600 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5602 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5604 overlay->type = ELM_MAP_OVERLAY_TYPE_SCALE;
5609 overlay->ovl = _overlay_scale_new(wd, x, y, overlay->c);
5610 overlay->grp = _overlay_group_new(wd);
5611 wd->overlays = eina_list_append(wd->overlays, overlay);
5613 evas_object_smart_changed(wd->pan_smart);
5623 elm_map_track_add(Evas_Object *obj, void *emap)
5625 #ifdef HAVE_ELEMENTARY_ECORE_CON
5626 EMap_Route *emapr = emap;
5627 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5628 Widget_Data *wd = elm_widget_data_get(obj);
5629 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
5631 Evas_Object *route = elm_route_add(obj);
5632 elm_route_emap_set(route, emapr);
5633 wd->track = eina_list_append(wd->track, route);
5644 elm_map_track_remove(Evas_Object *obj, Evas_Object *route)
5646 #ifdef HAVE_ELEMENTARY_ECORE_CON
5647 ELM_CHECK_WIDTYPE(obj, widtype) ;
5648 Widget_Data *wd = elm_widget_data_get(obj);
5649 EINA_SAFETY_ON_NULL_RETURN(wd);
5651 wd->track = eina_list_remove(wd->track, route);
5652 evas_object_del(route);
5660 elm_map_track_add(Evas_Object *obj __UNUSED__, void *emap __UNUSED__)
5666 elm_map_track_remove(Evas_Object *obj __UNUSED__, Evas_Object *route __UNUSED__)