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
154 Elm_Map_Overlay *overlay; // virtual group type overlay
155 Elm_Map_Overlay *clas; // class overlay for this virtual group
156 Overlay_Default *ovl; // rendered overlay
162 struct _Overlay_Default
170 // Display priority is content > icon > clas_obj > clas_icon > layout
171 Evas_Object *content;
175 // if clas_content or icon exists, do not inherit from class
176 Evas_Object *clas_content; // Duplicated from class content
177 Evas_Object *clas_icon; // Duplicated from class icon
181 struct _Overlay_Class
186 Evas_Object *content;
190 struct _Overlay_Bubble
194 Evas_Object *obj, *sc, *bx;
196 Evas_Coord x, y, w, h;
199 struct _Overlay_Route
211 double flon, flat, tlon, tlat;
215 struct _Overlay_Polygon
218 Eina_List *regions; // list of Regions
222 struct _Overlay_Circle
226 double radius; // Intial pixel in intial view
227 double ratio; // initial-radius/map-size
231 struct _Overlay_Scale
239 struct _Elm_Map_Overlay
243 Eina_Bool visible : 1;
244 Eina_Bool paused : 1;
248 void *data; // user set data
250 Elm_Map_Overlay_Type type;
251 void *ovl; // Overlay Data for each type
253 Elm_Map_Overlay_Get_Cb cb;
256 // These are not used if overlay type is class or group
260 struct _Elm_Map_Route
265 Elm_Map_Route_Type type;
266 Elm_Map_Route_Method method;
267 double flon, flat, tlon, tlat;
270 Ecore_File_Download_Job *job;
280 const char *waypoints;
281 double distance; /* unit : km */
300 struct _Path_Waypoint
316 Ecore_File_Download_Job *job;
346 int x, y; // Tile coordinate
347 Eina_Bool file_have : 1;
349 Ecore_File_Download_Job *job;
355 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
356 int tw, th; // size of grid in tiles
357 Eina_Matrixsparse *grid;
362 Evas_Object_Smart_Clipped_Data __clipped_data;
371 Evas_Object *pan_smart;
372 Evas_Object *sep_maps_overlays; // Tiles are below this and overlays are on top
375 Eina_Array *src_mods;
376 Source_Tile *src_tile;
377 Eina_List *src_tiles;
378 const char **src_tile_names;
380 Source_Route *src_route;
381 Eina_List *src_routes;
382 const char **src_route_names;
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;
442 Eina_List *group_overlays;
443 Eina_List *all_overlays;
446 static char *_mapnik_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
447 static char *_osmarender_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
448 static char *_cyclemap_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
449 static char *_mapquest_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
450 static char *_mapquest_aerial_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
451 static char *_yours_url_cb(const Evas_Object *obj __UNUSED__, const char *type_name, int method, double flon, double flat, double tlon, double tlat);
452 static char *_nominatim_url_cb(const Evas_Object *obj, int method, const char *name, double lon, double lat);
454 static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
455 static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
457 static double _scale_cb(const Evas_Object *obj __UNUSED__, double lon __UNUSED__, double lat, int zoom);
459 const Source_Tile src_tiles[] =
461 {"Mapnik", 0, 18, _mapnik_url_cb, NULL, NULL, _scale_cb},
462 {"Osmarender", 0, 17, _osmarender_url_cb, NULL, NULL, _scale_cb},
463 {"CycleMap", 0, 16, _cyclemap_url_cb, NULL, NULL, _scale_cb},
464 {"MapQuest", 0, 18, _mapquest_url_cb, NULL, NULL, _scale_cb},
465 {"MapQuest Open Aerial", 0, 11, _mapquest_aerial_url_cb, NULL, NULL, _scale_cb}
468 // FIXME: Fix more open sources
469 const Source_Route src_routes[] =
471 {"Yours", _yours_url_cb} // http://www.yournavigation.org/
472 //{"Monav", _monav_url_cb},
473 //{"ORS", _ors_url_cb}, // http://www.openrouteservice.org
476 // Refer : http://wiki.openstreetmap.org/wiki/FAQ
477 // meters per pixel when latitude is 0 (equator)
478 // meters per pixel = _osm_scale_meter[zoom] * cos (latitude)
479 const double _osm_scale_meter[] =
480 {78206, 39135.758482, 19567.879241, 9783.939621, 4891.969810,
481 2445.984905, 1222.992453, 611.496226, 305.748113, 152.874057, 76.437028,
482 38.218514, 19.109257, 9.554629, 4.777314, 2.388657, 1.194329, 0.597164,
486 const double _scale_tb[] =
487 {10000000, 5000000, 2000000, 1000000, 500000, 200000, 100000, 50000,
488 20000, 10000, 5000, 2000, 1000, 500, 500, 200, 100, 50, 20, 10, 5, 2, 1};
490 // FIXME: Add more open sources
491 const Source_Name src_names[] =
493 {"Nominatim", _nominatim_url_cb}
496 static const char *widtype = NULL;
497 static Evas_Smart_Class parent_sc = EVAS_SMART_CLASS_INIT_NULL;
498 static Evas_Smart_Class sc;
499 static Evas_Smart *smart;
500 static int idnum = 1;
502 static const char SIG_CLICKED[] = "clicked";
503 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
504 static const char SIG_PRESS[] = "press";
505 static const char SIG_LONGPRESSED[] = "longpressed";
506 static const char SIG_SCROLL[] = "scroll";
507 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
508 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
509 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
510 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
511 static const char SIG_ZOOM_START[] = "zoom,start";
512 static const char SIG_ZOOM_STOP[] = "zoom,stop";
513 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
514 static const char SIG_LOADED[] = "loaded";
515 static const char SIG_TILE_LOAD[] = "tile,load";
516 static const char SIG_TILE_LOADED[] = "tile,loaded";
517 static const char SIG_TILE_LOADED_FAIL[] = "tile,loaded,fail";
518 static const char SIG_ROUTE_LOAD[] = "route,load";
519 static const char SIG_ROUTE_LOADED[] = "route,loaded";
520 static const char SIG_ROUTE_LOADED_FAIL[] = "route,loaded,fail";
521 static const char SIG_NAME_LOAD[] = "name,load";
522 static const char SIG_NAME_LOADED[] = "name,loaded";
523 static const char SIG_NAME_LOADED_FAIL[] = "name,loaded,fail";
524 static const char SIG_OVERLAY_CLICKED[] = "overlay,clicked";
525 static const Evas_Smart_Cb_Description _signals[] = {
527 {SIG_CLICKED_DOUBLE, ""},
529 {SIG_LONGPRESSED, ""},
531 {SIG_SCROLL_DRAG_START, ""},
532 {SIG_SCROLL_DRAG_STOP, ""},
533 {SIG_SCROLL_ANIM_START, ""},
534 {SIG_SCROLL_ANIM_STOP, ""},
535 {SIG_ZOOM_START, ""},
537 {SIG_ZOOM_CHANGE, ""},
540 {SIG_TILE_LOADED, ""},
541 {SIG_TILE_LOADED_FAIL, ""},
542 {SIG_ROUTE_LOAD, ""},
543 {SIG_ROUTE_LOADED, ""},
544 {SIG_ROUTE_LOADED_FAIL, ""},
546 {SIG_NAME_LOADED, ""},
547 {SIG_NAME_LOADED_FAIL, ""},
548 {SIG_OVERLAY_CLICKED, ""},
553 _edj_overlay_size_get(Widget_Data *wd, Evas_Coord *w, Evas_Coord *h)
555 EINA_SAFETY_ON_NULL_RETURN(wd);
556 EINA_SAFETY_ON_NULL_RETURN(w);
557 EINA_SAFETY_ON_NULL_RETURN(h);
562 edj = edje_object_add(evas_object_evas_get(wd->obj));
563 _elm_theme_object_set(wd->obj, edj, "map/marker", "radio",
564 elm_widget_style_get(wd->obj));
565 s = edje_object_data_get(edj, "size_w");
568 s = edje_object_data_get(edj, "size_h");
571 evas_object_del(edj);
575 _rotate(Evas_Coord x, Evas_Coord y, Evas_Coord cx, Evas_Coord cy, double degree, Evas_Coord *xx, Evas_Coord *yy)
577 double r = (degree * M_PI) / 180.0;
578 if (xx) *xx = ((x - cx) * cos(r)) + ((y - cy) * cos(r + M_PI_2)) + cx;
579 if (yy) *yy = ((x - cx) * sin(r)) + ((y - cy) * sin(r + M_PI_2)) + cy;
583 _obj_rotate(Widget_Data *wd, Evas_Object *obj)
585 Evas_Coord w, h, ow, oh;
586 evas_map_util_points_populate_from_object(wd->map, obj);
588 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
589 evas_object_image_size_get(obj, &w, &h);
590 if ((w > ow) || (h > oh))
592 evas_map_point_image_uv_set(wd->map, 0, 0, 0);
593 evas_map_point_image_uv_set(wd->map, 1, w, 0);
594 evas_map_point_image_uv_set(wd->map, 2, w, h);
595 evas_map_point_image_uv_set(wd->map, 3, 0, h);
597 evas_map_util_rotate(wd->map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
599 evas_object_map_set(obj, wd->map);
600 evas_object_map_enable_set(obj, EINA_TRUE);
604 _obj_place(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
606 EINA_SAFETY_ON_NULL_RETURN(obj);
608 evas_object_move(obj, x, y);
609 evas_object_resize(obj, w, h);
610 evas_object_show(obj);
614 _coord_to_region_convert(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord size, double *lon, double *lat)
616 EINA_SAFETY_ON_NULL_RETURN(wd);
617 int zoom = floor(log(size / wd->size.tile) / log(2));
618 if ((wd->src_tile) && (wd->src_tile->coord_to_geo))
620 if (wd->src_tile->coord_to_geo(wd->obj, zoom, x, y, size, lon, lat))
624 if (lon) *lon = (x / (double)size * 360.0) - 180;
627 double n = ELM_PI - (2.0 * ELM_PI * y / size);
628 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
633 _region_to_coord_convert(Widget_Data *wd, double lon, double lat, Evas_Coord size, Evas_Coord *x, Evas_Coord *y)
635 EINA_SAFETY_ON_NULL_RETURN(wd);
637 int zoom = floor(log(size / 256) / log(2));
638 if ((wd->src_tile) && (wd->src_tile->geo_to_coord))
640 if (wd->src_tile->geo_to_coord(wd->obj, zoom, lon, lat, size, x, y)) return;
642 if (x) *x = floor((lon + 180.0) / 360.0 * size);
644 *y = floor((1.0 - log(tan(lat * ELM_PI / 180.0) + (1.0 / cos(lat * ELM_PI / 180.0)))
645 / ELM_PI) / 2.0 * size);
649 _viewport_coord_get(Widget_Data *wd, Evas_Coord *vx, Evas_Coord *vy, Evas_Coord *vw, Evas_Coord *vh)
651 EINA_SAFETY_ON_NULL_RETURN(wd);
653 Evas_Coord x, y, w, h;
654 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
655 elm_smart_scroller_child_viewport_size_get(wd->scr, &w, &h);
656 if (w > wd->size.w) x -= ((w - wd->size.w) / 2);
657 if (h > wd->size.h) y -= ((h - wd->size.h) / 2);
664 // Map coordinates to canvas geometry without rotate
666 _coord_to_canvas_no_rotate(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord *xx, Evas_Coord *yy)
668 Evas_Coord vx, vy, sx, sy;
669 _viewport_coord_get(wd, &vx, &vy, NULL, NULL);
670 evas_object_geometry_get(wd->pan_smart, &sx, &sy, NULL, NULL);
671 if (xx) *xx = x - vx + sx;
672 if (yy) *yy = y - vy + sy;
675 // Map coordinates to canvas geometry
677 _coord_to_canvas(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord *xx, Evas_Coord *yy)
679 _coord_to_canvas_no_rotate(wd, x, y, &x, &y);
680 _rotate(x, y, wd->rotate.cx, wd->rotate.cy, wd->rotate.d, &x, &y);
685 // Canvas geometry to map coordinates
687 _canvas_to_coord(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord *xx, Evas_Coord *yy)
689 Evas_Coord vx, vy, sx, sy;
690 _viewport_coord_get(wd, &vx, &vy, NULL, NULL);
691 evas_object_geometry_get(wd->pan_smart, &sx, &sy, NULL, NULL);
692 _rotate(x - sx + vx, y - sy + vy, wd->rotate.cx - sx + vx,
693 wd->rotate.cy - sy + vy, -wd->rotate.d, &x, &y);
699 _region_show(void *data)
701 EINA_SAFETY_ON_NULL_RETURN(data);
702 Delayed_Data *dd = data;
705 _region_to_coord_convert(dd->wd, dd->lon, dd->lat, dd->wd->size.w, &x, &y);
706 _viewport_coord_get(dd->wd, NULL, NULL, &w, &h);
709 elm_smart_scroller_child_region_show(dd->wd->scr, x, y, w, h);
710 evas_object_smart_changed(dd->wd->pan_smart);
714 _grid_item_coord_get(Grid_Item *gi, int *x, int *y, int *w, int *h)
716 EINA_SAFETY_ON_NULL_RETURN(gi);
718 if (x) *x = gi->x * gi->wd->size.tile;
719 if (y) *y = gi->y * gi->wd->size.tile;
720 if (w) *w = gi->wd->size.tile;
721 if (h) *h = gi->wd->size.tile;
725 _grid_item_in_viewport(Grid_Item *gi)
727 EINA_SAFETY_ON_NULL_RETURN_VAL(gi, EINA_FALSE);
729 Evas_Coord vx, vy, vw, vh;
730 Evas_Coord x, y, w, h;
732 _viewport_coord_get(gi->wd, &vx, &vy, &vw, &vh);
733 _grid_item_coord_get(gi, &x, &y, &w, &h);
734 return ELM_RECTS_INTERSECT(x, y, w, h, vx, vy, vw, vh);
738 _grid_item_update(Grid_Item *gi)
740 evas_object_image_file_set(gi->img, gi->file, NULL);
741 if (!gi->wd->zoom_timer && !gi->wd->scr_timer)
742 evas_object_image_smooth_scale_set(gi->img, EINA_TRUE);
743 else evas_object_image_smooth_scale_set(gi->img, EINA_FALSE);
745 Evas_Load_Error err = evas_object_image_load_error_get(gi->img);
746 if (err != EVAS_LOAD_ERROR_NONE)
748 ERR("Image loading error (%s): %s", gi->file, evas_load_error_str(err));
749 ecore_file_remove(gi->file);
750 gi->file_have = EINA_FALSE;
754 Evas_Coord x, y, w, h;
755 _grid_item_coord_get(gi, &x, &y, &w, &h);
756 _coord_to_canvas_no_rotate(gi->wd, x, y, &x, &y);
757 _obj_place(gi->img, x, y, w, h);
758 _obj_rotate(gi->wd, gi->img);
759 gi->file_have = EINA_TRUE;
764 _grid_item_load(Grid_Item *gi)
766 EINA_SAFETY_ON_NULL_RETURN(gi);
767 if (gi->file_have) _grid_item_update(gi);
770 gi->wd->download_list = eina_list_remove(gi->wd->download_list, gi);
771 gi->wd->download_list = eina_list_append(gi->wd->download_list, gi);
776 _grid_item_unload(Grid_Item *gi)
778 EINA_SAFETY_ON_NULL_RETURN(gi);
781 evas_object_hide(gi->img);
782 evas_object_image_file_set(gi->img, NULL, NULL);
786 ecore_file_download_abort(gi->job);
787 ecore_file_remove(gi->file);
791 else gi->wd->download_list = eina_list_remove(gi->wd->download_list, gi);
796 _grid_item_create(Grid *g, Evas_Coord x, Evas_Coord y)
798 EINA_SAFETY_ON_NULL_RETURN_VAL(g, NULL);
804 gi = ELM_NEW(Grid_Item);
810 gi->file_have = EINA_FALSE;
813 gi->img = evas_object_image_add(evas_object_evas_get(g->wd->obj));
814 evas_object_image_smooth_scale_set(gi->img, EINA_FALSE);
815 evas_object_image_scale_hint_set(gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
816 evas_object_image_filled_set(gi->img, EINA_TRUE);
817 evas_object_smart_member_add(gi->img, g->wd->pan_smart);
818 evas_object_pass_events_set(gi->img, EINA_TRUE);
819 evas_object_stack_below(gi->img, g->wd->sep_maps_overlays);
821 snprintf(buf, sizeof(buf), CACHE_TILE_ROOT, g->wd->id, g->zoom, x);
822 snprintf(buf2, sizeof(buf2), CACHE_TILE_PATH, buf, y);
823 if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
825 eina_stringshare_replace(&gi->file, buf2);
826 url = g->wd->src_tile->url_cb(g->wd->obj, x, y, g->zoom);
827 if ((!url) || (!strlen(url)))
829 eina_stringshare_replace(&gi->url, NULL);
830 ERR("Getting source url failed: %s", gi->file);
832 else eina_stringshare_replace(&gi->url, url);
834 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
839 _grid_item_free(Grid_Item *gi)
841 EINA_SAFETY_ON_NULL_RETURN(gi);
842 _grid_item_unload(gi);
843 if (gi->g && gi->g->grid) eina_matrixsparse_data_idx_set(gi->g->grid,
845 if (gi->url) eina_stringshare_del(gi->url);
846 if (gi->file_have) ecore_file_remove(gi->file);
847 if (gi->file) eina_stringshare_del(gi->file);
848 if (gi->img) evas_object_del(gi->img);
853 _downloaded_cb(void *data, const char *file __UNUSED__, int status)
855 Grid_Item *gi = data;
859 DBG("Download success from %s to %s", gi->url, gi->file);
860 _grid_item_update(gi);
861 gi->wd->finish_num++;
862 evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOADED, NULL);
866 WRN("Download failed from %s to %s (%d) ", gi->url, gi->file, status);
867 ecore_file_remove(gi->file);
868 gi->file_have = EINA_FALSE;
869 evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOADED_FAIL, NULL);
873 gi->wd->download_num--;
874 if (!gi->wd->download_num)
876 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
877 "elm,state,busy,stop", "elm");
878 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED, NULL);
883 _download_job(void *data)
885 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
886 Widget_Data *wd = data;
891 if (!eina_list_count(wd->download_list))
893 wd->download_idler = NULL;
894 return ECORE_CALLBACK_CANCEL;
897 EINA_LIST_REVERSE_FOREACH_SAFE(wd->download_list, l, ll, gi)
899 if ((gi->g->zoom != wd->zoom) || !(_grid_item_in_viewport(gi)))
901 wd->download_list = eina_list_remove(wd->download_list, gi);
904 if (wd->download_num >= MAX_CONCURRENT_DOWNLOAD)
905 return ECORE_CALLBACK_RENEW;
907 Eina_Bool ret = ecore_file_download_full(gi->url, gi->file,
908 _downloaded_cb, NULL,
909 gi, &(gi->job), wd->ua);
910 if ((!ret) || (!gi->job))
911 ERR("Can't start to download from %s to %s", gi->url, gi->file);
914 wd->download_list = eina_list_remove(wd->download_list, gi);
917 evas_object_smart_callback_call(wd->obj, SIG_TILE_LOAD,
919 if (wd->download_num == 1)
920 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
921 "elm,state,busy,start", "elm");
924 return ECORE_CALLBACK_RENEW;
928 _grid_viewport_get(Grid *g, int *x, int *y, int *w, int *h)
930 EINA_SAFETY_ON_NULL_RETURN(g);
932 Evas_Coord vx, vy, vw, vh;
934 _viewport_coord_get(g->wd, &vx, &vy, &vw, &vh);
938 xx = (vx / g->wd->size.tile) - 1;
941 yy = (vy / g->wd->size.tile) - 1;
944 ww = (vw / g->wd->size.tile) + 3;
945 if (xx + ww >= g->tw) ww = g->tw - xx;
947 hh = (vh / g->wd->size.tile) + 3;
948 if (yy + hh >= g->th) hh = g->th - yy;
957 _grid_unload(Grid *g)
959 EINA_SAFETY_ON_NULL_RETURN(g);
961 Eina_Matrixsparse_Cell *cell;
964 it = eina_matrixsparse_iterator_new(g->grid);
965 EINA_ITERATOR_FOREACH(it, cell)
967 gi = eina_matrixsparse_cell_data_get(cell);
968 _grid_item_unload(gi);
970 eina_iterator_free(it);
976 EINA_SAFETY_ON_NULL_RETURN(g);
977 int x, y, xx, yy, ww, hh;
979 Eina_Matrixsparse_Cell *cell;
982 it = eina_matrixsparse_iterator_new(g->grid);
983 EINA_ITERATOR_FOREACH(it, cell)
985 gi = eina_matrixsparse_cell_data_get(cell);
986 if (!_grid_item_in_viewport(gi)) _grid_item_unload(gi);
988 eina_iterator_free(it);
990 _grid_viewport_get(g, &xx, &yy, &ww, &hh);
991 for (y = yy; y < yy + hh; y++)
993 for (x = xx; x < xx + ww; x++)
995 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
996 if (!gi) gi = _grid_item_create(g, x, y);
1003 _grid_place(Widget_Data *wd)
1005 EINA_SAFETY_ON_NULL_RETURN(wd);
1009 EINA_LIST_FOREACH(wd->grids, l, g)
1011 if (wd->zoom == g->zoom) _grid_load(g);
1012 else _grid_unload(g);
1014 if (!wd->download_idler) wd->download_idler = ecore_idler_add(_download_job, wd);
1018 _grid_all_create(Widget_Data *wd)
1020 EINA_SAFETY_ON_NULL_RETURN(wd);
1021 EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
1024 for (zoom = wd->src_tile->zoom_min; zoom <= wd->src_tile->zoom_max; zoom++)
1031 tnum = pow(2.0, g->zoom);
1034 g->grid = eina_matrixsparse_new(g->th, g->tw, NULL, NULL);
1035 wd->grids = eina_list_append(wd->grids, g);
1040 _grid_all_clear(Widget_Data *wd)
1042 EINA_SAFETY_ON_NULL_RETURN(wd);
1045 EINA_LIST_FREE(wd->grids, g)
1047 Eina_Matrixsparse_Cell *cell;
1048 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1049 EINA_ITERATOR_FOREACH(it, cell)
1052 gi = eina_matrixsparse_cell_data_get(cell);
1053 if (gi) _grid_item_free(gi);
1055 eina_iterator_free(it);
1057 eina_matrixsparse_free(g->grid);
1063 _track_place(Widget_Data *wd)
1066 EINA_SAFETY_ON_NULL_RETURN(wd);
1070 int xmin, xmax, ymin, ymax;
1071 Evas_Coord px, py, ow, oh;
1074 _viewport_coord_get(wd, NULL, NULL, &ow, &oh);
1076 Evas_Coord size = wd->size.w;
1078 EINA_LIST_FOREACH(wd->track, l, route)
1080 double lon_min, lon_max;
1081 double lat_min, lat_max;
1082 elm_route_longitude_min_max_get(route, &lon_min, &lon_max);
1083 elm_route_latitude_min_max_get(route, &lat_min, &lat_max);
1084 _region_to_coord_convert(wd, lon_min, lat_max, size, &xmin, &ymin);
1085 _region_to_coord_convert(wd, lon_max, lat_min, size, &xmax, &ymax);
1087 if ( !(xmin < px && xmax < px) && !(xmin > px+ow && xmax > px+ow))
1089 if ( !(ymin < py && ymax < py) && !(ymin > py+oh && ymax > py+oh))
1092 evas_object_move(route, xmin - px, ymin - py);
1093 evas_object_resize(route, xmax - xmin, ymax - ymin);
1095 evas_object_raise(route);
1096 _obj_rotate(wd, route);
1097 evas_object_show(route);
1102 //the route is not display
1103 evas_object_hide(route);
1111 _delayed_do(Widget_Data *wd)
1114 dd = eina_list_nth(wd->delayed_jobs, 0);
1115 if (dd && !dd->wd->zoom_animator)
1118 wd->delayed_jobs = eina_list_remove(wd->delayed_jobs, dd);
1124 _smooth_update(Widget_Data *wd)
1126 EINA_SAFETY_ON_NULL_RETURN(wd);
1130 EINA_LIST_FOREACH(wd->grids, l, g)
1132 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1133 Eina_Matrixsparse_Cell *cell;
1135 EINA_ITERATOR_FOREACH(it, cell)
1137 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1138 if (_grid_item_in_viewport(gi))
1139 evas_object_image_smooth_scale_set(gi->img, EINA_TRUE);
1141 eina_iterator_free(it);
1146 _zoom_timeout(void *data)
1148 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
1149 Widget_Data *wd = data;
1151 wd->zoom_timer = NULL;
1152 evas_object_smart_callback_call(wd->obj, SIG_ZOOM_STOP, NULL);
1153 return ECORE_CALLBACK_CANCEL;
1157 zoom_do(Widget_Data *wd, double zoom)
1159 EINA_SAFETY_ON_NULL_RETURN(wd);
1160 if (zoom > wd->src_tile->zoom_max) zoom = wd->src_tile->zoom_max;
1161 else if (zoom < wd->src_tile->zoom_min) zoom = wd->src_tile->zoom_min;
1162 if (zoom > wd->zoom_max) zoom = wd->zoom_max;
1163 else if (zoom < wd->zoom_min) zoom = wd->zoom_min;
1165 Evas_Coord vx, vy, vw, vh;
1168 wd->zoom = ROUND(zoom);
1169 wd->zoom_detail = zoom;
1172 wd->size.tile = pow(2.0, (zoom - wd->zoom)) * wd->tsize;
1173 wd->size.w = pow(2.0, wd->zoom) * wd->size.tile;
1174 wd->size.h = wd->size.w;;
1176 // Fix to zooming with (viewport center vx, vy) as the center to prevent
1177 // from zooming with (0,0) as the cetner. (scroller default behavior)
1178 _viewport_coord_get(wd, &vx, &vy, &vw, &vh);
1179 if ((vw > 0) && (vh > 0) && (ow > 0) && (oh > 0))
1183 if (vw > ow) sx = 0.5;
1184 else sx = (double)(vx + (double)(vw / 2)) / ow;
1185 if (vh > oh) sy = 0.5;
1186 else sy = (double)(vy + (double)(vh / 2)) / oh;
1188 if (sx > 1.0) sx = 1.0;
1189 if (sy > 1.0) sy = 1.0;
1191 x = ceil((sx * wd->size.w) - (vw / 2));
1192 y = ceil((sy * wd->size.h) - (vh / 2));
1194 else if (x > (wd->size.w - vw)) x = wd->size.w - vw;
1196 else if (y > (wd->size.h - vh)) y = wd->size.h - vh;
1197 elm_smart_scroller_child_region_show(wd->scr, x, y, vw, vh);
1199 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
1200 else evas_object_smart_callback_call(wd->obj, SIG_ZOOM_START, NULL);
1201 wd->zoom_timer = ecore_timer_add(0.25, _zoom_timeout, wd);
1202 evas_object_smart_callback_call(wd->obj, SIG_ZOOM_CHANGE, NULL);
1204 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
1205 evas_object_smart_changed(wd->pan_smart);
1209 _zoom_anim(void *data)
1211 Widget_Data *wd = data;
1212 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, ECORE_CALLBACK_CANCEL);
1214 if (wd->ani.cnt <= 0)
1216 wd->zoom_animator = NULL;
1217 evas_object_smart_changed(wd->pan_smart);
1218 return ECORE_CALLBACK_CANCEL;
1222 wd->ani.zoom += wd->ani.diff;
1224 zoom_do(wd, wd->ani.zoom);
1225 return ECORE_CALLBACK_RENEW;
1230 zoom_with_animation(Widget_Data *wd, double zoom, int cnt)
1232 EINA_SAFETY_ON_NULL_RETURN(wd);
1233 if (cnt == 0) return;
1236 wd->ani.zoom = wd->zoom;
1237 wd->ani.diff = (double)(zoom - wd->zoom) / cnt;
1238 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
1239 wd->zoom_animator = ecore_animator_add(_zoom_anim, wd);
1243 _sizing_eval(Widget_Data *wd)
1245 EINA_SAFETY_ON_NULL_RETURN(wd);
1247 Evas_Coord maxw = -1, maxh = -1;
1249 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
1250 evas_object_size_hint_max_set(wd->obj, maxw, maxh);
1254 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1260 _scr_timeout(void *data)
1262 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
1263 Widget_Data *wd = data;
1265 wd->scr_timer = NULL;
1266 evas_object_smart_callback_call(wd->obj, SIG_SCROLL_DRAG_STOP, NULL);
1267 return ECORE_CALLBACK_CANCEL;
1271 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1273 EINA_SAFETY_ON_NULL_RETURN(data);
1274 Widget_Data *wd = data;
1276 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1277 else evas_object_smart_callback_call(wd->obj, SIG_SCROLL_DRAG_START, NULL);
1278 wd->scr_timer = ecore_timer_add(0.25, _scr_timeout, wd);
1279 evas_object_smart_callback_call(wd->obj, SIG_SCROLL, NULL);
1283 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1285 EINA_SAFETY_ON_NULL_RETURN(data);
1286 Widget_Data *wd = data;
1287 evas_object_smart_callback_call(wd->obj, SIG_SCROLL_ANIM_START, NULL);
1291 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1293 EINA_SAFETY_ON_NULL_RETURN(data);
1294 Widget_Data *wd = data;
1295 evas_object_smart_callback_call(wd->obj, SIG_SCROLL_ANIM_STOP, NULL);
1299 _long_press(void *data)
1301 EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
1302 Widget_Data *wd = data;
1304 wd->long_timer = NULL;
1305 evas_object_smart_callback_call(wd->obj, SIG_LONGPRESSED, &wd->ev);
1306 return ECORE_CALLBACK_CANCEL;
1310 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1312 EINA_SAFETY_ON_NULL_RETURN(data);
1313 Widget_Data *wd = data;
1314 Evas_Event_Mouse_Down *ev = event_info;
1316 if (ev->button != 1) return;
1318 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1319 else wd->on_hold = EINA_FALSE;
1321 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1322 evas_object_smart_callback_call(wd->obj, SIG_CLICKED_DOUBLE, ev);
1323 else evas_object_smart_callback_call(wd->obj, SIG_PRESS, ev);
1325 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1327 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, wd);
1331 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1333 EINA_SAFETY_ON_NULL_RETURN(data);
1334 Widget_Data *wd = data;
1336 Evas_Event_Mouse_Up *ev = event_info;
1337 EINA_SAFETY_ON_NULL_RETURN(ev);
1339 if (ev->button != 1) return;
1340 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1341 else wd->on_hold = EINA_FALSE;
1344 ecore_timer_del(wd->long_timer);
1345 wd->long_timer = NULL;
1347 if (!wd->on_hold) evas_object_smart_callback_call(wd->obj, SIG_CLICKED, ev);
1348 wd->on_hold = EINA_FALSE;
1352 _mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1354 EINA_SAFETY_ON_NULL_RETURN(data);
1355 Widget_Data *wd = data;
1359 Evas_Event_Mouse_Wheel *ev = event_info;
1360 zoom_do(wd, wd->zoom_detail - ((double)ev->z / 10));
1365 _region_max_min_get(Eina_List *overlays, double *max_longitude, double *min_longitude, double *max_latitude, double *min_latitude)
1367 double max_lon = -180, min_lon = 180;
1368 double max_lat = -90, min_lat = 90;
1369 Elm_Map_Overlay *overlay;
1370 EINA_LIST_FREE(overlays, overlay)
1373 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1375 Overlay_Default *ovl = overlay->ovl;
1379 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
1381 // FIXME: class center coord is alright??
1382 Overlay_Class *ovl = overlay->ovl;
1383 double max_lo, min_lo, max_la, min_la;
1384 _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la,
1386 lon = (max_lo + min_lo) / 2;
1387 lat = (max_la + min_la) / 2;
1389 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
1391 Overlay_Bubble *ovl = overlay->ovl;
1397 WRN("Not supported overlay type: %d", overlay->type);
1400 if (lon> max_lon) max_lon = lon;
1401 if (lon< min_lon) min_lon = lon;
1402 if (lat > max_lat) max_lat = lat;
1403 if (lat < min_lat) min_lat = lat;
1405 if (max_longitude) *max_longitude = max_lon;
1406 if (min_longitude) *min_longitude = min_lon;
1407 if (max_latitude) *max_latitude = max_lat;
1408 if (min_latitude) *min_latitude = min_lat;
1411 static Evas_Object *
1412 _icon_dup(const Evas_Object *icon, Evas_Object *parent)
1414 if (!icon || !parent) return NULL;
1415 // Evas_Object do not support object duplication??
1416 const char *file = NULL, *group = NULL;
1417 Eina_Bool size_up, size_down;
1420 dupp = elm_icon_add(parent);
1421 elm_icon_file_get(icon, &file, &group);
1422 elm_icon_file_set(dupp, file, group);
1423 elm_icon_animated_set(dupp, elm_icon_animated_get(icon));
1424 elm_icon_animated_play_set(dupp, elm_icon_animated_play_get(icon));
1425 elm_icon_standard_set(dupp, elm_icon_standard_get(icon));
1426 elm_icon_order_lookup_set(dupp, elm_icon_order_lookup_get(icon));
1427 elm_icon_no_scale_set(dupp, elm_icon_no_scale_get(icon));
1428 elm_icon_resizable_get(icon, &size_up, &size_down);
1429 elm_icon_resizable_set(dupp, size_up, size_down);
1430 elm_icon_fill_outside_set(dupp, elm_icon_fill_outside_get(icon));
1431 elm_icon_prescale_set(dupp, elm_icon_prescale_get(icon));
1432 elm_icon_aspect_fixed_set(dupp, elm_icon_aspect_fixed_get(icon));
1437 _overlay_clicked_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
1439 EINA_SAFETY_ON_NULL_RETURN(data);
1440 Elm_Map_Overlay *overlay = data;
1442 evas_object_smart_callback_call(overlay->wd->obj, SIG_OVERLAY_CLICKED,
1444 if (overlay->cb) overlay->cb(overlay->cb_data, overlay->wd->obj,
1449 _overlay_default_hide(Overlay_Default *ovl)
1451 EINA_SAFETY_ON_NULL_RETURN(ovl);
1452 if (ovl->content) evas_object_hide(ovl->content);
1453 if (ovl->icon) evas_object_hide(ovl->icon);
1454 if (ovl->clas_content) evas_object_hide(ovl->clas_content);
1455 if (ovl->clas_icon) evas_object_hide(ovl->clas_icon);
1456 if (ovl->layout) evas_object_hide(ovl->layout);
1460 _overlay_default_show(Overlay_Default *ovl)
1462 EINA_SAFETY_ON_NULL_RETURN(ovl);
1464 Evas_Coord x, y, w, h;
1466 evas_object_hide(ovl->layout);
1469 disp = ovl->content;
1470 evas_object_geometry_get(disp, NULL, NULL, &w, &h);
1471 if (w <= 0 || h <= 0) evas_object_size_hint_min_get(disp, &w, &h);
1473 else if (!(ovl->icon) && ovl->clas_content)
1475 disp = ovl->clas_content;
1477 evas_object_geometry_get(disp, NULL, NULL, &w, &h);
1478 if (w <= 0 || h <= 0) evas_object_size_hint_min_get(disp, &w, &h);
1482 if (ovl->icon) evas_object_show(ovl->icon);
1483 else if (ovl->clas_icon) evas_object_show(ovl->clas_icon);
1488 _coord_to_canvas(ovl->wd, ovl->x, ovl->y, &x, &y);
1489 _obj_place(disp, x - (w / 2), y - (h / 2), w, h);
1493 _overlay_default_coord_get(Overlay_Default *ovl, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1495 EINA_SAFETY_ON_NULL_RETURN(ovl);
1503 _overlay_default_coord_set(Overlay_Default *ovl, Evas_Coord x, Evas_Coord y)
1505 EINA_SAFETY_ON_NULL_RETURN(ovl);
1511 _overlay_default_coord_update(Overlay_Default *ovl)
1513 EINA_SAFETY_ON_NULL_RETURN(ovl);
1514 _region_to_coord_convert(ovl->wd, ovl->lon, ovl->lat, ovl->wd->size.w,
1519 _overlay_default_layout_text_update(Overlay_Default *ovl, const char *text)
1521 if (!ovl->content && !ovl->icon && !ovl->clas_content && !ovl->clas_icon)
1522 edje_object_part_text_escaped_set(elm_layout_edje_get(ovl->layout), "elm.text",
1527 _overlay_default_content_update(Overlay_Default *ovl, Evas_Object *content, Elm_Map_Overlay *overlay)
1529 EINA_SAFETY_ON_NULL_RETURN(ovl);
1530 if (ovl->content == content) return;
1531 if (ovl->content) evas_object_del(ovl->content);
1532 ovl->content = content;
1535 evas_object_event_callback_add(ovl->content, EVAS_CALLBACK_MOUSE_DOWN,
1536 _overlay_clicked_cb, overlay);
1540 _overlay_default_clas_content_update(Overlay_Default *ovl, const Evas_Object *content __UNUSED__)
1542 EINA_SAFETY_ON_NULL_RETURN(ovl);
1543 if (ovl->clas_content) evas_object_del(ovl->clas_content);
1544 // Evas_Object can not be duplicated.
1545 //ovl->clas_content = _content_dup(content);
1549 _overlay_default_layout_update(Overlay_Default *ovl)
1551 EINA_SAFETY_ON_NULL_RETURN(ovl);
1554 evas_object_color_set(ovl->layout, 255, 255, 255, 255);
1555 elm_layout_theme_set(ovl->layout, "map/marker", "empty",
1556 elm_widget_style_get(ovl->wd->obj));
1557 elm_object_part_content_set(ovl->layout, "elm.icon", ovl->icon);
1559 else if (!ovl->icon && ovl->clas_icon)
1561 evas_object_color_set(ovl->layout, 255, 255, 255, 255);
1562 elm_layout_theme_set(ovl->layout, "map/marker", "empty",
1563 elm_widget_style_get(ovl->wd->obj));
1564 elm_object_part_content_set(ovl->layout, "elm.icon", ovl->clas_icon);
1568 evas_object_color_set(ovl->layout, ovl->c.r, ovl->c.g, ovl->c.b, ovl->c.a);
1569 elm_layout_theme_set(ovl->layout, "map/marker", "radio",
1570 elm_widget_style_get(ovl->wd->obj));
1575 _overlay_default_icon_update(Overlay_Default *ovl, Evas_Object *icon)
1577 EINA_SAFETY_ON_NULL_RETURN(ovl);
1578 if (ovl->icon == icon) return;
1579 if (ovl->icon) evas_object_del(ovl->icon);
1581 _overlay_default_layout_update(ovl);
1585 _overlay_default_clas_icon_update(Overlay_Default *ovl, const Evas_Object *icon)
1587 EINA_SAFETY_ON_NULL_RETURN(ovl);
1588 if (ovl->clas_icon) evas_object_del(ovl->clas_icon);
1589 ovl->clas_icon = _icon_dup(icon, ovl->layout);
1590 _overlay_default_layout_update(ovl);
1594 _overlay_default_color_update(Overlay_Default *ovl, Color c)
1596 EINA_SAFETY_ON_NULL_RETURN(ovl);
1598 _overlay_default_layout_update(ovl);
1602 _overlay_default_free(Overlay_Default *ovl)
1604 EINA_SAFETY_ON_NULL_RETURN(ovl);
1605 if (ovl->content) evas_object_del(ovl->content);
1606 if (ovl->icon) evas_object_del(ovl->icon);
1607 if (ovl->clas_content) evas_object_del(ovl->clas_content);
1608 if (ovl->clas_icon) evas_object_del(ovl->clas_icon);
1609 if (ovl->layout) evas_object_del(ovl->layout);
1613 static Overlay_Default *
1614 _overlay_default_new(Elm_Map_Overlay *overlay, double lon, double lat, Color c, double scale)
1616 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
1618 Overlay_Default *ovl = ELM_NEW(Overlay_Default);
1619 ovl->wd = overlay->wd;
1620 _edj_overlay_size_get(ovl->wd, &(ovl->w), &(ovl->h));
1623 ovl->layout = elm_layout_add(ovl->wd->obj);
1624 evas_object_smart_member_add(ovl->layout, ovl->wd->pan_smart);
1625 evas_object_stack_above(ovl->layout, ovl->wd->sep_maps_overlays);
1626 elm_layout_theme_set(ovl->layout, "map/marker", "radio",
1627 elm_widget_style_get(ovl->wd->obj));
1628 evas_object_event_callback_add(ovl->layout, EVAS_CALLBACK_MOUSE_DOWN,
1629 _overlay_clicked_cb, overlay);
1632 _overlay_default_color_update(ovl, c);
1637 _overlay_group_hide(Overlay_Group *grp)
1639 EINA_SAFETY_ON_NULL_RETURN(grp);
1640 if (grp->ovl) _overlay_default_hide(grp->ovl);
1644 _overlay_group_show(Overlay_Group *grp)
1646 EINA_SAFETY_ON_NULL_RETURN(grp);
1647 if (grp->ovl) _overlay_default_show(grp->ovl);
1651 _overlay_group_coord_member_update(Overlay_Group *grp, Evas_Coord x, Evas_Coord y, Eina_List *members)
1653 EINA_SAFETY_ON_NULL_RETURN(grp);
1654 if (!grp->ovl) return;
1657 _overlay_default_coord_set(grp->ovl, x, y);
1658 _coord_to_region_convert(grp->wd, x, y, grp->wd->size.w, &grp->lon, &grp->lat);
1660 if (grp->members) eina_list_free(grp->members);
1661 grp->members = members;
1662 snprintf(text, sizeof(text), "%d", eina_list_count(members));
1663 _overlay_default_layout_text_update(grp->ovl, text);
1667 _overlay_group_icon_update(Overlay_Group *grp, const Evas_Object *icon)
1669 EINA_SAFETY_ON_NULL_RETURN(grp);
1670 if (grp->ovl) _overlay_default_icon_update(grp->ovl,
1671 _icon_dup(icon, grp->wd->obj));
1675 _overlay_group_content_update(Overlay_Group *grp __UNUSED__, const Evas_Object *content __UNUSED__)
1677 EINA_SAFETY_ON_NULL_RETURN(grp);
1678 // Evas_Object can not be duplicated.
1679 //_overlay_default_content_update(grp->ovl, _content_dup(content));
1684 _overlay_group_color_update(Overlay_Group *grp, Color c)
1686 EINA_SAFETY_ON_NULL_RETURN(grp);
1687 _overlay_default_color_update(grp->ovl, c);
1691 _overlay_group_cb_set(Overlay_Group *grp, Elm_Map_Overlay_Get_Cb cb, void *data)
1693 EINA_SAFETY_ON_NULL_RETURN(grp);
1694 grp->overlay->cb = cb;
1695 grp->overlay->data = data;
1699 _overlay_group_free(Overlay_Group *grp)
1701 EINA_SAFETY_ON_NULL_RETURN(grp);
1702 if (grp->overlay) free(grp->overlay);
1703 if (grp->ovl) _overlay_default_free(grp->ovl);
1704 if (grp->members) eina_list_free(grp->members);
1708 static Overlay_Group *
1709 _overlay_group_new(Widget_Data *wd)
1711 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1713 Overlay_Group *grp = ELM_NEW(Overlay_Group);
1715 grp->overlay = ELM_NEW(Elm_Map_Overlay); // this is a virtual overlay
1716 grp->overlay->wd = wd;
1717 grp->overlay->type = ELM_MAP_OVERLAY_TYPE_GROUP;
1718 grp->overlay->ovl = grp;
1719 Color c = {0x90, 0xee, 0x90, 0xff};
1720 grp->ovl = _overlay_default_new(grp->overlay, -1, -1, c, 1);
1725 _overlay_class_cb_set(Overlay_Class *ovl, Elm_Map_Overlay_Get_Cb cb, void *data)
1727 EINA_SAFETY_ON_NULL_RETURN(ovl);
1730 Elm_Map_Overlay *overlay;
1732 // Update class members' callbacks
1733 EINA_LIST_FOREACH(ovl->members, l, overlay)
1734 _overlay_group_cb_set(overlay->grp, cb, data);
1738 _overlay_class_icon_update(Overlay_Class *ovl, Evas_Object *icon)
1740 EINA_SAFETY_ON_NULL_RETURN(ovl);
1743 Elm_Map_Overlay *overlay;
1744 if (ovl->icon == icon) return;
1745 if (ovl->icon) evas_object_del(ovl->icon);
1748 // Update class members' class icons
1749 EINA_LIST_FOREACH(ovl->members, l, overlay)
1751 _overlay_group_icon_update(overlay->grp, icon);
1753 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1754 _overlay_default_clas_icon_update(overlay->ovl, icon);
1760 _overlay_class_content_update(Overlay_Class *ovl, Evas_Object *content)
1762 EINA_SAFETY_ON_NULL_RETURN(ovl);
1765 Elm_Map_Overlay *overlay;
1766 if (ovl->content == content) return;
1767 if (ovl->content) evas_object_del(ovl->content);
1768 ovl->content = content;
1770 // Update class members' class contents
1771 EINA_LIST_FOREACH(ovl->members, l, overlay)
1773 _overlay_group_content_update(overlay->grp, content);
1775 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1776 _overlay_default_clas_content_update(overlay->ovl, content);
1781 _overlay_class_color_update(Overlay_Class *ovl, Color c)
1783 EINA_SAFETY_ON_NULL_RETURN(ovl);
1786 Elm_Map_Overlay *overlay;
1788 // Update class members' class contents
1789 EINA_LIST_FOREACH(ovl->members, l, overlay)
1790 _overlay_group_color_update(overlay->grp, c);
1794 _overlay_class_free(Overlay_Class *clas)
1796 EINA_SAFETY_ON_NULL_RETURN(clas);
1799 Elm_Map_Overlay *overlay;
1801 // Update class members' class contents
1802 EINA_LIST_FOREACH(clas->members, l, overlay)
1804 overlay->grp->clas = NULL;
1805 _overlay_group_content_update(overlay->grp, NULL);
1806 _overlay_group_icon_update(overlay->grp, NULL);
1808 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1810 _overlay_default_clas_content_update(overlay->ovl, NULL);
1811 _overlay_default_clas_icon_update(overlay->ovl, NULL);
1814 if (clas->icon) evas_object_del(clas->icon);
1815 if (clas->members) eina_list_free(clas->members);
1819 static Overlay_Class *
1820 _overlay_class_new(Widget_Data *wd)
1822 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
1823 Overlay_Class *ovl = ELM_NEW(Overlay_Class);
1826 ovl->zoom_max = OVERLAY_CLASS_ZOOM_MAX;
1831 _overlay_bubble_coord_update(Overlay_Bubble *bubble)
1833 EINA_SAFETY_ON_NULL_RETURN(bubble);
1836 Evas_Coord x, y, w, h;
1837 evas_object_geometry_get(bubble->pobj, &x, &y, &w, &h);
1838 bubble->x = x + (w / 2);
1839 bubble->y = y - (bubble->h / 2);
1840 _canvas_to_coord(bubble->wd, bubble->x, bubble->y,
1841 &(bubble->x), &(bubble->y));
1842 _coord_to_region_convert(bubble->wd, bubble->x, bubble->y,
1844 &(bubble->lon), &(bubble->lat));
1848 _region_to_coord_convert(bubble->wd, bubble->lon, bubble->lat,
1849 bubble->wd->size.w, &bubble->x, &bubble->y);
1854 _overlay_bubble_coord_get(Overlay_Bubble *bubble, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1856 EINA_SAFETY_ON_NULL_RETURN(bubble);
1857 if (!(bubble->pobj))
1859 if (x) *x = bubble->x;
1860 if (y) *y = bubble->y;
1861 if (w) *w = bubble->w;
1862 if (h) *h = bubble->h;
1874 _overlay_bubble_show_hide(Overlay_Bubble *bubble, Eina_Bool visible)
1876 EINA_SAFETY_ON_NULL_RETURN_VAL(bubble, EINA_FALSE);
1877 EINA_SAFETY_ON_NULL_RETURN_VAL(bubble->obj, EINA_FALSE);
1879 if (!visible) evas_object_hide(bubble->obj);
1880 else if (bubble->pobj && !evas_object_visible_get(bubble->pobj))
1882 evas_object_hide(bubble->obj);
1883 visible = EINA_FALSE;
1887 _coord_to_canvas(bubble->wd, bubble->x, bubble->y,
1888 &(bubble->x), &(bubble->y));
1889 _obj_place(bubble->obj, bubble->x - (bubble->w /2),
1890 bubble->y - (bubble->h /2), bubble->w, bubble->h);
1891 evas_object_raise(bubble->obj);
1897 _overlay_bubble_free(Overlay_Bubble* bubble)
1899 EINA_SAFETY_ON_NULL_RETURN(bubble);
1901 evas_object_del(bubble->bx);
1902 evas_object_del(bubble->sc);
1903 evas_object_del(bubble->obj);
1907 static Overlay_Bubble*
1908 _overlay_bubble_new(Elm_Map_Overlay *overlay)
1910 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
1914 Overlay_Bubble *bubble = ELM_NEW(Overlay_Bubble);
1915 bubble->wd = overlay->wd;
1917 bubble->obj = edje_object_add(evas_object_evas_get(overlay->wd->obj));
1918 _elm_theme_object_set(overlay->wd->obj, bubble->obj , "map", "marker_bubble",
1919 elm_widget_style_get(overlay->wd->obj));
1920 evas_object_event_callback_add(bubble->obj, EVAS_CALLBACK_MOUSE_DOWN,
1921 _overlay_clicked_cb, overlay);
1923 bubble->sc = elm_scroller_add(bubble->obj);
1924 elm_widget_style_set(bubble->sc, "map_bubble");
1925 elm_scroller_content_min_limit(bubble->sc, EINA_FALSE, EINA_TRUE);
1926 elm_scroller_policy_set(bubble->sc, ELM_SCROLLER_POLICY_AUTO,
1927 ELM_SCROLLER_POLICY_OFF);
1928 elm_scroller_bounce_set(bubble->sc, _elm_config->thumbscroll_bounce_enable,
1930 edje_object_part_swallow(bubble->obj, "elm.swallow.content", bubble->sc);
1932 bubble->bx = elm_box_add(bubble->sc);
1933 evas_object_size_hint_align_set(bubble->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1934 evas_object_size_hint_weight_set(bubble->bx, EVAS_HINT_EXPAND,
1936 elm_box_horizontal_set(bubble->bx, EINA_TRUE);
1937 elm_object_content_set(bubble->sc, bubble->bx);
1939 s = edje_object_data_get(bubble->obj, "size_w");
1940 if (s) bubble->w = atoi(s);
1943 edje_object_size_min_calc(bubble->obj, NULL, &(bubble->h));
1944 s = edje_object_data_get(bubble->obj, "size_h");
1947 if (bubble->h < h) bubble->h = h;
1957 _overlay_route_color_update(Overlay_Route *ovl, Color c)
1959 EINA_SAFETY_ON_NULL_RETURN(ovl);
1960 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
1964 _overlay_route_hide(Overlay_Route *ovl)
1966 EINA_SAFETY_ON_NULL_RETURN(ovl);
1967 evas_object_hide(ovl->obj);
1971 _overlay_route_show(Overlay_Route *r)
1973 EINA_SAFETY_ON_NULL_RETURN(r);
1974 EINA_SAFETY_ON_NULL_RETURN(r->wd);
1980 evas_object_polygon_points_clear(r->obj);
1981 EINA_LIST_FOREACH(r->nodes, l, n)
1983 p = eina_list_nth(r->paths, n->idx);
1985 _region_to_coord_convert(r->wd, n->pos.lon, n->pos.lat, r->wd->size.w,
1987 _coord_to_canvas(r->wd, p->x, p->y, &p->x, &p->y);
1989 EINA_LIST_FOREACH(r->paths, l, p)
1990 evas_object_polygon_point_add(r->obj, p->x - 3, p->y - 3);
1992 EINA_LIST_REVERSE_FOREACH(r->paths, l, p)
1993 evas_object_polygon_point_add(r->obj, p->x + 3, p->y + 3);
1994 evas_object_show(r->obj);
1998 _overlay_route_free(Overlay_Route* route)
2000 EINA_SAFETY_ON_NULL_RETURN(route);
2004 evas_object_del(route->obj);
2005 EINA_LIST_FREE(route->paths, p) free(p);
2006 EINA_LIST_FREE(route->nodes, n)
2008 if (n->pos.address) eina_stringshare_del(n->pos.address);
2014 static Overlay_Route *
2015 _overlay_route_new(Widget_Data *wd, const Elm_Map_Route *route, Color c)
2017 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2018 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
2023 Overlay_Route *ovl = ELM_NEW(Overlay_Route);
2025 ovl->obj = evas_object_polygon_add(evas_object_evas_get(wd->obj));
2026 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2027 _overlay_route_color_update(ovl, c);
2029 EINA_LIST_FOREACH(route->nodes, l, n)
2034 node = ELM_NEW(Path_Node);
2036 node->pos.lon = n->pos.lon;
2037 node->pos.lat = n->pos.lat;
2038 if (n->pos.address) node->pos.address = strdup(n->pos.address);
2039 ovl->nodes = eina_list_append(ovl->nodes, node);
2041 path = ELM_NEW(Path);
2042 ovl->paths = eina_list_append(ovl->paths, path);
2048 _overlay_line_color_update(Overlay_Line *ovl, Color c)
2050 EINA_SAFETY_ON_NULL_RETURN(ovl);
2051 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2055 _overlay_line_hide(Overlay_Line *ovl)
2057 EINA_SAFETY_ON_NULL_RETURN(ovl);
2058 if (ovl->obj) evas_object_hide(ovl->obj);
2062 _overlay_line_show(Overlay_Line *ovl)
2064 Evas_Coord fx, fy, tx, ty;
2065 Widget_Data *wd = ovl->wd;
2067 _region_to_coord_convert(wd, ovl->flon, ovl->flat, wd->size.w, &fx, &fy);
2068 _region_to_coord_convert(wd, ovl->tlon, ovl->tlat, wd->size.w, &tx, &ty);
2069 _coord_to_canvas(wd, fx, fy, &fx, &fy);
2070 _coord_to_canvas(wd, tx, ty, &tx, &ty);
2071 evas_object_line_xy_set(ovl->obj, fx, fy, tx, ty);
2072 evas_object_show(ovl->obj);
2076 _overlay_line_free(Overlay_Line *ovl)
2078 EINA_SAFETY_ON_NULL_RETURN(ovl);
2079 evas_object_del(ovl->obj);
2083 static Overlay_Line *
2084 _overlay_line_new(Widget_Data *wd, double flon, double flat, double tlon, double tlat, Color c)
2086 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2088 Overlay_Line *ovl = ELM_NEW(Overlay_Line);
2094 ovl->obj = evas_object_line_add(evas_object_evas_get(wd->obj));
2095 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2096 _overlay_line_color_update(ovl, c);
2101 _overlay_polygon_color_update(Overlay_Polygon *ovl, Color c)
2103 EINA_SAFETY_ON_NULL_RETURN(ovl);
2104 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2108 _overlay_polygon_hide(Overlay_Polygon *ovl)
2110 EINA_SAFETY_ON_NULL_RETURN(ovl);
2111 if (ovl->obj) evas_object_hide(ovl->obj);
2115 _overlay_polygon_show(Overlay_Polygon *ovl)
2117 EINA_SAFETY_ON_NULL_RETURN(ovl);
2120 Widget_Data *wd = ovl->wd;
2122 evas_object_polygon_points_clear(ovl->obj);
2123 EINA_LIST_FOREACH(ovl->regions, l, r)
2126 _region_to_coord_convert(wd, r->lon, r->lat, wd->size.w, &x, &y);
2127 _coord_to_canvas(wd, x, y, &x, &y);
2128 evas_object_polygon_point_add(ovl->obj, x, y);
2130 evas_object_show(ovl->obj);
2134 _overlay_polygon_free(Overlay_Polygon *ovl)
2136 EINA_SAFETY_ON_NULL_RETURN(ovl);
2138 evas_object_del(ovl->obj);
2139 EINA_LIST_FREE(ovl->regions, r) free(r);
2143 static Overlay_Polygon *
2144 _overlay_polygon_new(Widget_Data *wd, Color c)
2146 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2148 Overlay_Polygon *ovl = ELM_NEW(Overlay_Polygon);
2150 ovl->obj = evas_object_polygon_add(evas_object_evas_get(wd->obj));
2151 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2152 _overlay_polygon_color_update(ovl, c);
2157 _overlay_circle_color_update(Overlay_Circle *ovl, Color c)
2159 EINA_SAFETY_ON_NULL_RETURN(ovl);
2160 Evas_Object *obj = elm_layout_edje_get(ovl->obj);
2161 evas_object_color_set(obj, c.r, c.g, c.b, c.a);
2165 _overlay_circle_hide(Overlay_Circle *ovl)
2167 EINA_SAFETY_ON_NULL_RETURN(ovl);
2168 if (ovl->obj) evas_object_hide(ovl->obj);
2172 _overlay_circle_show(Overlay_Circle *ovl)
2174 EINA_SAFETY_ON_NULL_RETURN(ovl);
2177 Widget_Data *wd = ovl->wd;
2179 r = (ovl->ratio) * wd->size.w;
2180 _region_to_coord_convert(wd, ovl->lon, ovl->lat, wd->size.w, &x, &y);
2181 _coord_to_canvas(wd, x, y, &x, &y);
2182 _obj_place(ovl->obj, x - r, y - r, r * 2, r * 2);
2186 _overlay_circle_free(Overlay_Circle *ovl)
2188 EINA_SAFETY_ON_NULL_RETURN(ovl);
2189 evas_object_del(ovl->obj);
2193 static Overlay_Circle *
2194 _overlay_circle_new(Widget_Data *wd, double lon, double lat, double radius, Color c)
2196 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2198 Overlay_Circle *ovl = ELM_NEW(Overlay_Circle);
2202 ovl->radius = radius;
2203 ovl->ratio = radius / wd->size.w;
2205 ovl->obj = elm_layout_add(wd->obj);
2206 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2207 evas_object_stack_above(ovl->obj, wd->sep_maps_overlays);
2208 elm_layout_theme_set(ovl->obj, "map/circle", "base",
2209 elm_widget_style_get(wd->obj));
2210 _overlay_circle_color_update(ovl, c);
2215 _overlay_scale_color_update(Overlay_Scale *ovl, Color c)
2217 EINA_SAFETY_ON_NULL_RETURN(ovl);
2218 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2222 _overlay_scale_hide(Overlay_Scale *ovl)
2224 EINA_SAFETY_ON_NULL_RETURN(ovl);
2225 if (ovl->obj) evas_object_hide(ovl->obj);
2229 _overlay_scale_show(Overlay_Scale *ovl)
2231 EINA_SAFETY_ON_NULL_RETURN(ovl);
2237 Widget_Data *wd = ovl->wd;
2239 if ((int)sizeof(_scale_tb) <= wd->zoom)
2241 ERR("Zoom level is too high");
2245 elm_map_region_get(wd->obj, &lon, &lat);
2246 meter = wd->src_tile->scale_cb(wd->obj, lon, lat, wd->zoom);
2248 w = (_scale_tb[wd->zoom] / meter) * (wd->zoom_detail - wd->zoom + 1);
2250 text = _scale_tb[wd->zoom]/1000;
2251 if (text < 1) snprintf(buf, sizeof(buf), "%d m", (int)(text * 1000));
2252 else snprintf(buf, sizeof(buf), "%d km", (int)text);
2254 edje_object_part_text_escaped_set(elm_layout_edje_get(ovl->obj), "elm.text", buf);
2255 _obj_place(ovl->obj, ovl->x, ovl->y, w, ovl->h);
2259 _overlay_scale_free(Overlay_Scale *ovl)
2261 EINA_SAFETY_ON_NULL_RETURN(ovl);
2262 evas_object_del(ovl->obj);
2266 static Overlay_Scale *
2267 _overlay_scale_new(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Color c)
2269 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2272 Overlay_Scale *ovl = ELM_NEW(Overlay_Scale);
2277 ovl->obj = elm_layout_add(wd->obj);
2278 evas_object_smart_member_add(ovl->obj, wd->pan_smart);
2279 evas_object_stack_above(ovl->obj, wd->sep_maps_overlays);
2280 elm_layout_theme_set(ovl->obj, "map/scale", "base",
2281 elm_widget_style_get(wd->obj));
2282 s = edje_object_data_get(elm_layout_edje_get(ovl->obj), "size_w");
2283 if (s) ovl->w = atoi(s);
2285 s = edje_object_data_get(elm_layout_edje_get(ovl->obj), "size_h");
2286 if (s) ovl->h = atoi(s);
2288 _overlay_scale_color_update(ovl, c);
2293 _overlay_grouping(Eina_List *clas_membs, Elm_Map_Overlay *boss)
2295 EINA_SAFETY_ON_NULL_RETURN(clas_membs);
2296 EINA_SAFETY_ON_NULL_RETURN(boss);
2299 Eina_List *grp_membs = NULL;
2300 Elm_Map_Overlay *memb;
2302 int sum_x = 0, sum_y = 0, cnt = 0;
2303 Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
2305 if (boss->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2306 _overlay_default_coord_get(boss->ovl, &bx, &by, &bw, &bh);
2307 else if (boss->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2308 _overlay_bubble_coord_get(boss->ovl, &bx, &by, &bw, &bh);
2310 EINA_LIST_FOREACH(clas_membs, l, memb)
2312 Evas_Coord x = 0, y = 0, w = 0, h = 0;
2314 if (boss == memb || memb->grp->in) continue;
2315 if ((memb->hide) || (memb->zoom_min > memb->wd->zoom)) continue;
2317 if (memb->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2318 _overlay_default_coord_get(memb->ovl, &x, &y, &w, &h);
2319 else if (memb->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2320 _overlay_bubble_coord_get(memb->ovl, &x, &y, &w, &h);
2322 if (bw <= 0 || bh <= 0 || w <= 0 || h <= 0) continue;
2323 if (ELM_RECTS_INTERSECT(x, y, w, h, bx, by,
2324 bw * OVERLAY_GROUPING_SCALE,
2325 bh * OVERLAY_GROUPING_SCALE))
2328 memb->grp->boss = EINA_FALSE;
2329 memb->grp->in = EINA_TRUE;
2333 grp_membs = eina_list_append(grp_membs, memb);
2340 boss->grp->boss = EINA_TRUE;
2341 boss->grp->in = EINA_TRUE;
2342 sum_x = (sum_x + bx) / (cnt + 1);
2343 sum_y = (sum_y + by) / (cnt + 1);
2344 grp_membs = eina_list_append(grp_membs, boss);
2345 _overlay_group_coord_member_update(boss->grp, sum_x, sum_y, grp_membs);
2347 // Append group to all overlay list
2348 boss->wd->group_overlays = eina_list_append(boss->wd->group_overlays,
2349 boss->grp->overlay);
2354 _overlay_show(Elm_Map_Overlay *overlay)
2356 Widget_Data *wd = overlay->wd;
2358 if (overlay->paused) return;
2359 if ((overlay->grp) && (overlay->grp->clas) &&
2360 (overlay->grp->clas->paused)) return;
2362 overlay->visible = EINA_TRUE;
2363 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
2365 overlay->visible = EINA_FALSE;
2370 if ((overlay->grp->in) ||
2371 (overlay->hide) || (overlay->zoom_min > wd->zoom))
2372 overlay->visible = EINA_FALSE;
2374 if ((overlay->grp->clas) &&
2375 ((overlay->grp->clas->hide) ||
2376 (overlay->grp->clas->zoom_min > wd->zoom)))
2377 overlay->visible = EINA_FALSE;
2380 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2382 if (overlay->visible) _overlay_default_show(overlay->ovl);
2383 else _overlay_default_hide(overlay->ovl);
2385 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_GROUP)
2387 if (overlay->visible) _overlay_group_show(overlay->ovl);
2388 else _overlay_group_hide(overlay->ovl);
2390 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2392 overlay->visible = _overlay_bubble_show_hide(overlay->ovl,
2395 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
2397 if (overlay->visible) _overlay_route_show(overlay->ovl);
2398 else _overlay_route_hide(overlay->ovl);
2400 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_LINE)
2402 if (overlay->visible) _overlay_line_show(overlay->ovl);
2403 else _overlay_line_hide(overlay->ovl);
2405 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON)
2407 if (overlay->visible) _overlay_polygon_show(overlay->ovl);
2408 else _overlay_polygon_hide(overlay->ovl);
2410 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CIRCLE)
2412 if (overlay->visible) _overlay_circle_show(overlay->ovl);
2413 else _overlay_circle_hide(overlay->ovl);
2415 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_SCALE)
2417 if (overlay->visible) _overlay_scale_show(overlay->ovl);
2418 else _overlay_scale_hide(overlay->ovl);
2423 _overlay_place(Widget_Data *wd)
2425 EINA_SAFETY_ON_NULL_RETURN(wd);
2428 Elm_Map_Overlay *overlay;
2430 eina_list_free(wd->group_overlays);
2431 wd->group_overlays = NULL;
2433 EINA_LIST_FOREACH(wd->overlays, l, overlay)
2436 if ((overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) ||
2437 (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)) continue;
2438 overlay->grp->in = EINA_FALSE;
2439 overlay->grp->boss = EINA_FALSE;
2440 _overlay_group_hide(overlay->grp);
2442 // Update overlays' coord
2443 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2444 _overlay_default_coord_update(overlay->ovl);
2445 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2446 _overlay_bubble_coord_update(overlay->ovl);
2449 // Classify into group boss or follwer
2450 EINA_LIST_FOREACH(wd->overlays, l, overlay)
2452 Elm_Map_Overlay *boss;
2453 Overlay_Class *clas;
2455 if (overlay->type != ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2456 if (overlay->hide || (overlay->zoom_min > wd->zoom)) continue;
2458 clas = overlay->ovl;
2459 if (clas->zoom_max < wd->zoom) continue;
2460 EINA_LIST_FOREACH(clas->members, ll, boss)
2462 if (boss->type == ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2463 if (boss->hide || (boss->zoom_min > wd->zoom)) continue;
2464 if (boss->grp->in) continue;
2465 _overlay_grouping(clas->members, boss);
2469 // Place group overlays and overlays
2470 EINA_LIST_FOREACH(wd->group_overlays, l, overlay) _overlay_show(overlay);
2471 EINA_LIST_FOREACH(wd->overlays, l, overlay) _overlay_show(overlay);
2474 static Evas_Object *
2475 _overlay_obj_get(const Elm_Map_Overlay *overlay)
2477 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
2478 if (overlay->type == ELM_MAP_OVERLAY_TYPE_GROUP)
2480 Overlay_Group *ovl = overlay->ovl;
2481 Overlay_Default *df = ovl->ovl;
2484 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2486 Overlay_Default *ovl = overlay->ovl;
2491 ERR("Not supported overlay type: %d", overlay->type);
2497 _overlays_show(void *data)
2499 EINA_SAFETY_ON_NULL_RETURN(data);
2500 Delayed_Data *dd = data;
2503 double max_lon, min_lon, max_lat, min_lat;
2506 _region_max_min_get(dd->overlays, &max_lon, &min_lon, &max_lat, &min_lat);
2507 dd->lon = (max_lon + min_lon) / 2;
2508 dd->lat = (max_lat + min_lat) / 2;
2510 zoom = dd->wd->src_tile->zoom_min;
2511 _viewport_coord_get(dd->wd, NULL, NULL, &vw, &vh);
2512 if (dd->wd->src_tile->zoom_max < dd->wd->zoom_max)
2513 zoom_max = dd->wd->src_tile->zoom_max;
2514 else zoom_max = dd->wd->zoom_max;
2515 while (zoom <= zoom_max)
2517 Evas_Coord size, max_x, max_y, min_x, min_y;
2518 size = pow(2.0, zoom) * dd->wd->tsize;
2519 _region_to_coord_convert(dd->wd, min_lon, max_lat, size, &min_x, &max_y);
2520 _region_to_coord_convert(dd->wd, max_lon, min_lat, size, &max_x, &min_y);
2521 if ((max_x - min_x) > vw || (max_y - min_y) > vh) break;
2526 zoom_do(dd->wd, zoom);
2528 evas_object_smart_changed(dd->wd->pan_smart);
2532 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
2534 Pan *sd = evas_object_smart_data_get(obj);
2535 EINA_SAFETY_ON_NULL_RETURN(sd);
2536 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2540 evas_object_smart_changed(obj);
2544 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
2546 Pan *sd = evas_object_smart_data_get(obj);
2547 EINA_SAFETY_ON_NULL_RETURN(sd);
2548 if (x) *x = sd->wd->pan_x;
2549 if (y) *y = sd->wd->pan_y;
2553 _pan_max_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);
2558 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2559 ow = sd->wd->size.w - ow;
2560 oh = sd->wd->size.h - oh;
2568 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
2575 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
2577 Pan *sd = evas_object_smart_data_get(obj);
2578 EINA_SAFETY_ON_NULL_RETURN(sd);
2579 if (w) *w = sd->wd->size.w;
2580 if (h) *h = sd->wd->size.h;
2584 _pan_add(Evas_Object *obj)
2587 Evas_Object_Smart_Clipped_Data *cd;
2589 cd = evas_object_smart_data_get(obj);
2590 EINA_SAFETY_ON_NULL_RETURN(cd);
2592 sd->__clipped_data = *cd;
2594 evas_object_smart_data_set(obj, sd);
2598 _pan_resize(Evas_Object *obj, Evas_Coord w __UNUSED__, Evas_Coord h __UNUSED__)
2600 Pan *sd = evas_object_smart_data_get(obj);
2601 EINA_SAFETY_ON_NULL_RETURN(sd);
2603 _sizing_eval(sd->wd);
2604 elm_map_zoom_mode_set(sd->wd->obj, sd->wd->mode);
2605 evas_object_smart_changed(obj);
2609 _pan_calculate(Evas_Object *obj)
2611 Pan *sd = evas_object_smart_data_get(obj);
2612 EINA_SAFETY_ON_NULL_RETURN(sd);
2615 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
2616 if (w <= 0 || h <= 0) return;
2618 _grid_place(sd->wd);
2619 _overlay_place(sd->wd);
2620 _track_place(sd->wd);
2621 _delayed_do(sd->wd);
2625 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
2627 EINA_SAFETY_ON_NULL_RETURN(obj);
2628 evas_object_smart_changed(obj);
2632 _hold_on(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2634 EINA_SAFETY_ON_NULL_RETURN(data);
2635 Widget_Data *wd = data;
2636 elm_smart_scroller_hold_set(wd->scr, 1);
2640 _hold_off(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2642 EINA_SAFETY_ON_NULL_RETURN(data);
2643 Widget_Data *wd = data;
2644 elm_smart_scroller_hold_set(wd->scr, 0);
2648 _freeze_on(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2650 EINA_SAFETY_ON_NULL_RETURN(data);
2651 Widget_Data *wd = data;
2652 elm_smart_scroller_freeze_set(wd->scr, 1);
2656 _freeze_off(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2658 EINA_SAFETY_ON_NULL_RETURN(data);
2659 Widget_Data *wd = data;
2660 elm_smart_scroller_freeze_set(wd->scr, 0);
2664 cb_dump_name_attrs(void *data, const char *key, const char *value)
2666 Name_Dump *dump = (Name_Dump*)data;
2667 if (!dump) return EINA_FALSE;
2669 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = _elm_atof(value);
2670 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = _elm_atof(value);
2676 cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2678 Route_Dump *dump = data;
2679 if (!dump) return EINA_FALSE;
2683 case EINA_SIMPLE_XML_OPEN:
2684 case EINA_SIMPLE_XML_OPEN_EMPTY:
2688 attrs = eina_simple_xml_tag_attributes_find(value, length);
2691 if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
2692 else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
2693 else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
2694 else dump->id = ROUTE_XML_NONE;
2698 case EINA_SIMPLE_XML_DATA:
2700 char *buf = malloc(length);
2701 if (!buf) return EINA_FALSE;
2702 snprintf(buf, length, "%s", value);
2703 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = _elm_atof(buf);
2704 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2705 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2717 cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
2719 Name_Dump *dump = data;
2720 if (!dump) return EINA_FALSE;
2724 case EINA_SIMPLE_XML_OPEN:
2725 case EINA_SIMPLE_XML_OPEN_EMPTY:
2728 attrs = eina_simple_xml_tag_attributes_find(value, length);
2731 if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME;
2732 else dump->id = NAME_XML_NONE;
2734 eina_simple_xml_attributes_parse
2735 (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
2739 case EINA_SIMPLE_XML_DATA:
2741 char *buf = malloc(length + 1);
2742 if (!buf) return EINA_FALSE;
2743 snprintf(buf, length + 1, "%s", value);
2744 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2756 _kml_parse(Elm_Map_Route *r)
2758 EINA_SAFETY_ON_NULL_RETURN(r);
2759 EINA_SAFETY_ON_NULL_RETURN(r->fname);
2763 unsigned int ele, idx;
2766 Route_Dump dump = {0, r->fname, 0.0, NULL, NULL};
2768 f = fopen(r->fname, "rb");
2773 fseek(f, 0, SEEK_END);
2779 fseek(f, 0, SEEK_SET);
2783 if (fread(buf, 1, sz, f))
2785 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump,
2793 if (dump.distance) r->info.distance = dump.distance;
2794 if (dump.description)
2796 eina_stringshare_replace(&r->info.waypoints, dump.description);
2797 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2798 r->info.waypoint_count = ele;
2799 for (idx = 0; idx < ele; idx++)
2801 Path_Waypoint *wp = ELM_NEW(Path_Waypoint);
2805 wp->point = eina_stringshare_add(str[idx]);
2806 DBG("%s", str[idx]);
2807 r->waypoint = eina_list_append(r->waypoint, wp);
2816 else WRN("description is not found !");
2818 if (dump.coordinates)
2820 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2821 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2822 r->info.node_count = ele;
2823 for (idx = 0; idx < ele; idx++)
2825 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2826 Path_Node *n = ELM_NEW(Path_Node);
2833 DBG("%lf:%lf", lon, lat);
2834 n->pos.address = NULL;
2835 r->nodes = eina_list_append(r->nodes, n);
2848 _name_parse(Elm_Map_Name *n)
2850 EINA_SAFETY_ON_NULL_RETURN(n);
2851 EINA_SAFETY_ON_NULL_RETURN(n->fname);
2855 Name_Dump dump = {0, NULL, 0.0, 0.0};
2857 f = fopen(n->fname, "rb");
2862 fseek(f, 0, SEEK_END);
2868 fseek(f, 0, SEEK_SET);
2872 if (fread(buf, 1, sz, f))
2874 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
2883 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
2884 n->address = strdup(dump.address);
2891 Grid *_get_current_grid(Widget_Data *wd)
2893 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2895 Grid *g = NULL, *ret = NULL;
2896 EINA_LIST_FOREACH(wd->grids, l, g)
2898 if (wd->zoom == g->zoom)
2908 _route_cb(void *data, const char *file, int status)
2910 EINA_SAFETY_ON_NULL_RETURN(data);
2911 EINA_SAFETY_ON_NULL_RETURN(file);
2913 Elm_Map_Route *route = data;
2914 Widget_Data *wd = route->wd;
2915 EINA_SAFETY_ON_NULL_RETURN(wd);
2921 INF("Route request success from (%lf, %lf) to (%lf, %lf)",
2922 route->flon, route->flat, route->tlon, route->tlat);
2923 if (route->cb) route->cb(route->data, wd->obj, route);
2924 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
2928 ERR("Route request failed: %d", status);
2929 if (route->cb) route->cb(route->data, wd->obj, NULL);
2930 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED_FAIL, NULL);
2933 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2934 "elm,state,busy,stop", "elm");
2938 _name_cb(void *data, const char *file, int status)
2940 EINA_SAFETY_ON_NULL_RETURN(data);
2941 EINA_SAFETY_ON_NULL_RETURN(file);
2943 Elm_Map_Name *name = data;
2944 Widget_Data *wd = name->wd;
2945 EINA_SAFETY_ON_NULL_RETURN(wd);
2951 INF("Name request success address:%s, lon:%lf, lat:%lf",
2952 name->address, name->lon, name->lat);
2953 if (name->cb) name->cb(name->data, wd->obj, name);
2954 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
2958 ERR("Name request failed: %d", status);
2959 if (name->cb) name->cb(name->data, wd->obj, NULL);
2960 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED_FAIL, NULL);
2962 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
2963 "elm,state,busy,stop", "elm");
2968 static Elm_Map_Name *
2969 _name_request(const Evas_Object *obj, int method, const char *address, double lon, double lat, Elm_Map_Name_Cb name_cb, void *data)
2971 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2972 Widget_Data *wd = elm_widget_data_get(obj);
2973 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
2974 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_name, NULL);
2978 char fname[PATH_MAX];
2980 if (!ecore_file_exists(CACHE_NAME_ROOT)) ecore_file_mkpath(CACHE_NAME_ROOT);
2982 url = wd->src_name->url_cb(wd->obj, method, address, lon, lat);
2985 ERR("Name URL is NULL");
2989 Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
2991 snprintf(fname, sizeof(fname), CACHE_NAME_ROOT"/%d", rand());
2992 name->fname = strdup(fname);
2993 name->method = method;
2994 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
2995 else if (method == ELM_MAP_NAME_METHOD_REVERSE)
3003 if (!ecore_file_download_full(url, name->fname, _name_cb, NULL, name,
3004 &(name->job), wd->ua) || !(name->job))
3006 ERR("Can't request Name from %s to %s", url, name->fname);
3007 if (name->address) free(name->address);
3012 INF("Name requested from %s to %s", url, name->fname);
3015 wd->names = eina_list_append(wd->names, name);
3016 evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, name);
3017 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
3018 "elm,state,busy,start", "elm");
3022 static Evas_Event_Flags
3023 _pinch_zoom_start_cb(void *data, void *event_info __UNUSED__)
3025 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EVAS_EVENT_FLAG_NONE);
3026 Widget_Data *wd = data;
3028 wd->pinch_zoom = wd->zoom_detail;
3029 return EVAS_EVENT_FLAG_NONE;
3032 static Evas_Event_Flags
3033 _pinch_zoom_cb(void *data, void *event_info)
3035 Widget_Data *wd = data;
3036 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
3040 Elm_Gesture_Zoom_Info *ei = event_info;
3041 zoom_do(wd, wd->pinch_zoom + ei->zoom - 1);
3043 return EVAS_EVENT_FLAG_NONE;
3046 static Evas_Event_Flags
3047 _pinch_rotate_cb(void *data, void *event_info)
3049 Widget_Data *wd = data;
3050 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
3055 Elm_Gesture_Rotate_Info *ei = event_info;
3056 evas_object_geometry_get(wd->obj, &x, &y, &w, &h);
3058 wd->rotate.d = wd->rotate.a + ei->angle - ei->base_angle;
3059 wd->rotate.cx = x + ((double)w * 0.5);
3060 wd->rotate.cy = y + ((double)h * 0.5);
3062 evas_object_smart_changed(wd->pan_smart);
3064 return EVAS_EVENT_FLAG_NONE;
3067 static Evas_Event_Flags
3068 _pinch_rotate_end_cb(void *data, void *event_info __UNUSED__)
3070 Widget_Data *wd = data;
3071 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
3073 wd->rotate.a = wd->rotate.d;
3075 return EVAS_EVENT_FLAG_NONE;
3079 _source_tile_set(Widget_Data *sd,
3080 const char *source_name)
3085 EINA_SAFETY_ON_NULL_RETURN(source_name);
3087 if (sd->src_tile && !strcmp(sd->src_tile->name, source_name))
3090 EINA_LIST_FOREACH (sd->src_tiles, l, s)
3092 if (!strcmp(s->name, source_name))
3100 ERR("source name (%s) is not found", source_name);
3104 if (sd->src_tile->zoom_max < sd->zoom)
3105 sd->zoom = sd->src_tile->zoom_max;
3106 else if (sd->src_tile->zoom_min > sd->zoom)
3107 sd->zoom = sd->src_tile->zoom_min;
3109 if (sd->src_tile->zoom_max < sd->zoom_max)
3110 sd->zoom_max = sd->src_tile->zoom_max;
3111 if (sd->src_tile->zoom_min > sd->zoom_min)
3112 sd->zoom_min = sd->src_tile->zoom_min;
3114 _grid_all_clear(sd);
3115 _grid_all_create(sd);
3116 zoom_do(sd, sd->zoom);
3120 _source_route_set(Widget_Data *sd,
3121 const char *source_name)
3126 EINA_SAFETY_ON_NULL_RETURN(source_name);
3128 if (sd->src_route && !strcmp(sd->src_route->name, source_name))
3131 EINA_LIST_FOREACH (sd->src_routes, l, s)
3133 if (!strcmp(s->name, source_name))
3141 ERR("source name (%s) is not found", source_name);
3147 _source_name_set(Widget_Data *sd,
3148 const char *source_name)
3153 EINA_SAFETY_ON_NULL_RETURN(source_name);
3155 if (sd->src_name && !strcmp(sd->src_name->name, source_name))
3158 EINA_LIST_FOREACH (sd->src_names, l, s)
3160 if (!strcmp(s->name, source_name))
3168 ERR("source name (%s) is not found", source_name);
3174 _source_mod_cb(Eina_Module *m,
3178 Widget_Data *sd = data;
3180 Elm_Map_Module_Source_Name_Func name_cb;
3181 Elm_Map_Module_Tile_Url_Func tile_url_cb;
3182 Elm_Map_Module_Tile_Scale_Func scale_cb;
3183 Elm_Map_Module_Tile_Zoom_Min_Func zoom_min;
3184 Elm_Map_Module_Tile_Zoom_Max_Func zoom_max;
3185 Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord;
3186 Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo;
3187 Elm_Map_Module_Route_Url_Func route_url_cb;
3188 Elm_Map_Module_Name_Url_Func name_url_cb;
3190 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
3192 file = eina_module_file_get(m);
3193 if (!eina_module_load(m))
3195 ERR("Could not load module \"%s\": %s", file,
3196 eina_error_msg_get(eina_error_get()));
3199 name_cb = eina_module_symbol_get(m, "map_module_source_name_get");
3202 WRN("Could not find map module name from module \"%s\": %s",
3203 file, eina_error_msg_get(eina_error_get()));
3204 eina_module_unload(m);
3209 tile_url_cb = eina_module_symbol_get(m, "map_module_tile_url_get");
3210 zoom_min = eina_module_symbol_get(m, "map_module_tile_zoom_min_get");
3211 zoom_max = eina_module_symbol_get(m, "map_module_tile_zoom_max_get");
3212 geo_to_coord = eina_module_symbol_get(m, "map_module_tile_geo_to_coord");
3213 coord_to_geo = eina_module_symbol_get(m, "map_module_tile_coord_to_geo");
3214 scale_cb = eina_module_symbol_get(m, "map_module_tile_scale_get");
3215 if (tile_url_cb && zoom_min && zoom_max && geo_to_coord && coord_to_geo &&
3218 INF("Map TILE module is loaded \"%s\"", file);
3220 s = ELM_NEW(Source_Tile);
3221 s->name = name_cb();
3222 s->url_cb = tile_url_cb;
3223 s->zoom_min = zoom_min();
3224 s->zoom_max = zoom_max();
3225 s->geo_to_coord = geo_to_coord;
3226 s->coord_to_geo = coord_to_geo;
3227 s->scale_cb = scale_cb;
3228 sd->src_tiles = eina_list_append(sd->src_tiles, s);
3231 // Find ROUTE module
3232 route_url_cb = eina_module_symbol_get(m, "map_module_route_url_get");
3235 INF("Map ROUTE module is loaded \"%s\"", file);
3237 s = ELM_NEW(Source_Tile);
3238 s->name = name_cb();
3239 s->url_cb = route_url_cb;
3240 sd->src_routes = eina_list_append(sd->src_routes, s);
3244 name_url_cb = eina_module_symbol_get(m, "map_module_name_url_get");
3247 INF("Map NAME module is loaded \"%s\"", file);
3249 s = ELM_NEW(Source_Tile);
3250 s->name = name_cb();
3251 s->url_cb = name_url_cb;
3252 sd->src_names = eina_list_append(sd->src_names, s);
3258 _source_all_unload(Widget_Data *sd)
3263 for (idx = 0; sd->src_tile_names[idx]; idx++)
3264 eina_stringshare_del(sd->src_tile_names[idx]);
3265 for (idx = 0; sd->src_route_names[idx]; idx++)
3266 eina_stringshare_del(sd->src_route_names[idx]);
3267 for (idx = 0; sd->src_name_names[idx]; idx++)
3268 eina_stringshare_del(sd->src_name_names[idx]);
3270 EINA_LIST_FREE(sd->src_tiles, s) free(s);
3271 EINA_LIST_FREE(sd->src_routes, s) free(s);
3272 EINA_LIST_FREE(sd->src_names, s) free(s);
3274 eina_module_list_free(sd->src_mods);
3278 _source_all_load(Widget_Data *sd)
3280 Source_Tile *src_tile;
3281 Source_Route *src_route;
3282 Source_Name *src_name;
3286 // Load hard coded TILE source
3287 for (idx = 0; idx < (sizeof(src_tiles) / sizeof(Source_Tile)); idx++)
3289 src_tile = ELM_NEW(Source_Tile);
3290 src_tile->name = src_tiles[idx].name;
3291 src_tile->zoom_min = src_tiles[idx].zoom_min;
3292 src_tile->zoom_max = src_tiles[idx].zoom_max;
3293 src_tile->url_cb = src_tiles[idx].url_cb;
3294 src_tile->geo_to_coord = src_tiles[idx].geo_to_coord;
3295 src_tile->coord_to_geo = src_tiles[idx].coord_to_geo;
3296 src_tile->scale_cb = src_tiles[idx].scale_cb;
3297 sd->src_tiles = eina_list_append(sd->src_tiles, src_tile);
3299 // Load hard coded ROUTE source
3300 for (idx = 0; idx < (sizeof(src_routes) / sizeof(Source_Route)); idx++)
3302 src_route = ELM_NEW(Source_Route);
3303 src_route->name = src_routes[idx].name;
3304 src_route->url_cb = src_routes[idx].url_cb;
3305 sd->src_routes = eina_list_append(sd->src_routes, src_route);
3307 // Load from hard coded NAME source
3308 for (idx = 0; idx < (sizeof(src_names) / sizeof(Source_Name)); idx++)
3310 src_name = ELM_NEW(Source_Name);
3311 src_name->name = src_names[idx].name;
3312 src_name->url_cb = src_names[idx].url_cb;
3313 sd->src_names = eina_list_append(sd->src_names, src_name);
3316 // Load from modules
3317 sd->src_mods = eina_module_list_get(sd->src_mods, MODULES_PATH, 1,
3318 &_source_mod_cb, sd);
3320 // Set default source
3321 sd->src_tile = eina_list_nth(sd->src_tiles, 0);
3322 sd->src_route = eina_list_nth(sd->src_routes, 0);
3323 sd->src_name = eina_list_nth(sd->src_names, 0);
3325 // Make name string of sources
3327 sd->src_tile_names = calloc((eina_list_count(sd->src_tiles) + 1),
3328 sizeof(const char *));
3329 EINA_LIST_FOREACH (sd->src_tiles, l, src_tile)
3331 eina_stringshare_replace(&sd->src_tile_names[idx], src_tile->name);
3332 INF("source : %s", sd->src_tile_names[idx]);
3336 sd->src_route_names = calloc((eina_list_count(sd->src_routes) + 1),
3337 sizeof(const char *));
3338 EINA_LIST_FOREACH (sd->src_routes, l, src_route)
3340 eina_stringshare_replace(&sd->src_route_names[idx], src_route->name);
3341 INF("source : %s", sd->src_route_names[idx]);
3345 sd->src_name_names = calloc((eina_list_count(sd->src_names) + 1),
3346 sizeof(const char *));
3347 EINA_LIST_FOREACH (sd->src_names, l, src_name)
3349 eina_stringshare_replace(&sd->src_name_names[idx], src_name->name);
3350 INF("source : %s", sd->src_name_names[idx]);
3356 _zoom_mode_set(void *data)
3358 EINA_SAFETY_ON_NULL_RETURN(data);
3359 Delayed_Data *dd = data;
3361 dd->wd->mode = dd->mode;
3362 if (dd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
3372 zoom = dd->wd->zoom_detail;
3373 _viewport_coord_get(dd->wd, NULL, NULL, &vw, &vh);
3375 if (dd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3377 if ((w < vw) && (h < vh))
3380 while ((w < vw) && (h < vh))
3383 w = pow(2.0, zoom) * dd->wd->tsize;
3384 h = pow(2.0, zoom) * dd->wd->tsize;
3390 while ((w > vw) || (h > vh))
3393 w = pow(2.0, zoom) * dd->wd->tsize;
3394 h = pow(2.0, zoom) * dd->wd->tsize;
3399 else if (dd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3401 if ((w < vw) || (h < vh))
3404 while ((w < vw) || (h < vh))
3407 w = pow(2.0, zoom) * dd->wd->tsize;
3408 h = pow(2.0, zoom) * dd->wd->tsize;
3414 while ((w > vw) && (h > vh))
3417 w = pow(2.0, zoom) * dd->wd->tsize;
3418 h = pow(2.0, zoom) * dd->wd->tsize;
3422 zoom_do(dd->wd, zoom);
3427 _zoom_set(void *data)
3429 EINA_SAFETY_ON_NULL_RETURN(data);
3430 Delayed_Data *dd = data;
3432 if (dd->wd->paused) zoom_do(dd->wd, dd->zoom);
3433 else zoom_with_animation(dd->wd, dd->zoom, 10);
3434 evas_object_smart_changed(dd->wd->pan_smart);
3438 _region_bring_in(void *data)
3440 EINA_SAFETY_ON_NULL_RETURN(data);
3441 Delayed_Data *dd = data;
3444 _region_to_coord_convert(dd->wd, dd->lon, dd->lat, dd->wd->size.w, &x, &y);
3445 _viewport_coord_get(dd->wd, NULL, NULL, &w, &h);
3448 elm_smart_scroller_region_bring_in(dd->wd->scr, x, y, w, h);
3449 evas_object_smart_changed(dd->wd->pan_smart);
3453 _mapnik_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3456 // ((x+y+zoom)%3)+'a' is requesting map images from distributed tile servers (eg., a, b, c)
3457 snprintf(buf, sizeof(buf), "http://%c.tile.openstreetmap.org/%d/%d/%d.png",
3458 ((x + y + zoom) % 3) + 'a', zoom, x, y);
3463 _osmarender_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3466 snprintf(buf, sizeof(buf),
3467 "http://%c.tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
3468 ((x + y + zoom) % 3) + 'a', zoom, x, y);
3473 _cyclemap_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3476 snprintf(buf, sizeof(buf),
3477 "http://%c.tile.opencyclemap.org/cycle/%d/%d/%d.png",
3478 (( x + y + zoom) % 3) + 'a', zoom, x, y);
3483 _mapquest_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3486 snprintf(buf, sizeof(buf),
3487 "http://otile%d.mqcdn.com/tiles/1.0.0/osm/%d/%d/%d.png",
3488 ((x + y + zoom) % 4) + 1, zoom, x, y);
3493 _mapquest_aerial_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
3496 snprintf(buf, sizeof(buf), "http://oatile%d.mqcdn.com/naip/%d/%d/%d.png",
3497 ((x + y + zoom) % 4) + 1, zoom, x, y);
3501 static char *_yours_url_cb(const Evas_Object *obj __UNUSED__, const char *type_name, int method, double flon, double flat, double tlon, double tlat)
3504 snprintf(buf, sizeof(buf),
3505 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
3506 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
3511 // TODO: fix monav api
3513 static char *_monav_url_cb(const Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
3516 snprintf(buf, sizeof(buf),
3517 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
3518 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
3524 // TODO: fix ors api
3526 static char *_ors_url_cb(const Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
3529 snprintf(buf, sizeof(buf),
3530 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
3531 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
3538 _nominatim_url_cb(const Evas_Object *obj, int method, const char *name, double lon, double lat)
3540 ELM_CHECK_WIDTYPE(obj, widtype) strdup("");
3541 Widget_Data *wd = elm_widget_data_get(obj);
3542 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, strdup(""));
3545 unsigned int ele, idx;
3546 char search_url[PATH_MAX];
3549 if (method == ELM_MAP_NAME_METHOD_SEARCH)
3551 search_url[0] = '\0';
3552 str = eina_str_split_full(name, " ", 0, &ele);
3553 for (idx = 0; idx < ele; idx++)
3555 eina_strlcat(search_url, str[idx], sizeof(search_url));
3556 if (!(idx == (ele-1)))
3557 eina_strlcat(search_url, "+", sizeof(search_url));
3559 snprintf(buf, sizeof(buf),
3560 "%s/search?q=%s&format=xml&polygon=0&addressdetails=0",
3561 NAME_NOMINATIM_URL, search_url);
3569 else if (method == ELM_MAP_NAME_METHOD_REVERSE)
3570 snprintf(buf, sizeof(buf),
3571 "%s/reverse?format=xml&lat=%lf&lon=%lf&zoom=%d&addressdetails=0",
3572 NAME_NOMINATIM_URL, lat, lon, (int)wd->zoom);
3573 else strcpy(buf, "");
3579 _scale_cb(const Evas_Object *obj __UNUSED__, double lon __UNUSED__, double lat, int zoom)
3581 if (zoom < 0 || zoom >= (int)sizeof(_osm_scale_meter)) return 0;
3582 return _osm_scale_meter[zoom] / cos(lat * ELM_PI / 180.0);
3586 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
3588 ELM_CHECK_WIDTYPE(obj, widtype);
3589 Widget_Data *wd = elm_widget_data_get(obj);
3590 EINA_SAFETY_ON_NULL_RETURN(wd);
3592 if (elm_widget_focus_get(obj))
3594 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
3595 evas_object_focus_set(wd->obj, EINA_TRUE);
3599 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
3600 evas_object_focus_set(wd->obj, EINA_FALSE);
3605 _del_hook(Evas_Object *obj)
3607 ELM_CHECK_WIDTYPE(obj, widtype);
3608 Widget_Data *wd = elm_widget_data_get(obj);
3609 EINA_SAFETY_ON_NULL_RETURN(wd);
3611 if (wd->map) evas_map_free(wd->map);
3616 _del_pre_hook(Evas_Object *obj)
3618 ELM_CHECK_WIDTYPE(obj, widtype);
3619 Widget_Data *wd = elm_widget_data_get(obj);
3620 EINA_SAFETY_ON_NULL_RETURN(wd);
3626 Elm_Map_Overlay *overlay;
3629 EINA_LIST_FOREACH_SAFE(wd->routes, l, ll, r) elm_map_route_del(r);
3630 eina_list_free(wd->routes);
3632 EINA_LIST_FOREACH_SAFE(wd->names, l, ll, na) elm_map_name_del(na);
3633 eina_list_free(wd->names);
3635 EINA_LIST_FOREACH_SAFE(wd->overlays, l, ll, overlay)
3636 elm_map_overlay_del(overlay);
3637 eina_list_free(wd->overlays);
3638 eina_list_free(wd->group_overlays);
3639 eina_list_free(wd->all_overlays);
3641 EINA_LIST_FREE(wd->track, track) evas_object_del(track);
3643 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
3644 if (wd->long_timer) ecore_timer_del(wd->long_timer);
3646 if (wd->delayed_jobs) EINA_LIST_FREE(wd->delayed_jobs, dd) free(dd);
3648 if (wd->user_agent) eina_stringshare_del(wd->user_agent);
3649 if (wd->ua) eina_hash_free(wd->ua);
3651 if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
3652 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
3654 _grid_all_clear(wd);
3655 // Removal of download list should be after grid clear.
3656 if (wd->download_idler) ecore_idler_del(wd->download_idler);
3657 eina_list_free(wd->download_list);
3659 _source_all_unload(wd);
3661 if (!ecore_file_recursive_rm(CACHE_ROOT))
3662 ERR("Deletion of %s failed", CACHE_ROOT);
3666 _theme_hook(Evas_Object *obj)
3668 ELM_CHECK_WIDTYPE(obj, widtype);
3669 Widget_Data *wd = elm_widget_data_get(obj);
3670 EINA_SAFETY_ON_NULL_RETURN(wd);
3672 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
3677 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
3679 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3680 Widget_Data *wd = elm_widget_data_get(obj);
3681 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
3685 Evas_Coord step_x, step_y, page_x, page_y;
3687 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
3688 Evas_Event_Key_Down *ev = event_info;
3689 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
3691 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
3692 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
3693 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
3694 elm_smart_scroller_child_viewport_size_get(wd->scr, NULL, &vh);
3696 if ((!strcmp(ev->keyname, "Left")) ||
3697 ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string)))
3701 else if ((!strcmp(ev->keyname, "Right")) ||
3702 ((!strcmp(ev->keyname, "KP_Right")) && (!ev->string)))
3706 else if ((!strcmp(ev->keyname, "Up")) ||
3707 ((!strcmp(ev->keyname, "KP_Up")) && (!ev->string)))
3711 else if ((!strcmp(ev->keyname, "Down")) ||
3712 ((!strcmp(ev->keyname, "KP_Down")) && (!ev->string)))
3716 else if ((!strcmp(ev->keyname, "Prior")) ||
3717 ((!strcmp(ev->keyname, "KP_Prior")) && (!ev->string)))
3720 y -= -(page_y * vh) / 100;
3724 else if ((!strcmp(ev->keyname, "Next")) ||
3725 ((!strcmp(ev->keyname, "KP_Next")) && (!ev->string)))
3728 y += -(page_y * vh) / 100;
3732 else if (!strcmp(ev->keyname, "KP_Add"))
3734 zoom_with_animation(wd, wd->zoom + 1, 10);
3737 else if (!strcmp(ev->keyname, "KP_Subtract"))
3739 zoom_with_animation(wd, wd->zoom - 1, 10);
3742 else return EINA_FALSE;
3744 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
3745 elm_smart_scroller_child_pos_set(wd->scr, x, y);
3752 elm_map_add(Evas_Object *parent)
3754 #ifdef HAVE_ELEMENTARY_ECORE_CON
3758 Evas_Coord minw, minh;
3760 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3761 ELM_SET_WIDTYPE(widtype, "map");
3762 elm_widget_type_set(obj, "map");
3763 elm_widget_sub_object_add(parent, obj);
3764 elm_widget_data_set(obj, wd);
3765 elm_widget_can_focus_set(obj, EINA_TRUE);
3766 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3767 elm_widget_del_hook_set(obj, _del_hook);
3768 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3769 elm_widget_theme_hook_set(obj, _theme_hook);
3770 elm_widget_event_hook_set(obj, _event_hook);
3771 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, wd);
3772 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, wd);
3773 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, wd);
3774 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, wd);
3775 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
3777 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
3779 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
3780 _mouse_wheel_cb, wd);
3783 wd->scr = elm_smart_scroller_add(e);
3784 elm_widget_sub_object_add(obj, wd->scr);
3785 elm_smart_scroller_widget_set(wd->scr, obj);
3786 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
3787 elm_widget_resize_object_set(obj, wd->scr);
3788 elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE);
3789 elm_smart_scroller_bounce_allow_set(wd->scr,
3790 _elm_config->thumbscroll_bounce_enable,
3791 _elm_config->thumbscroll_bounce_enable);
3792 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3793 _changed_size_hints, wd);
3794 evas_object_smart_callback_add(wd->scr, "scroll", _scr, wd);
3795 evas_object_smart_callback_add(wd->scr, "drag", _scr, wd);
3796 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, wd);
3797 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, wd);
3801 evas_object_smart_clipped_smart_set(&parent_sc);
3803 sc.name = "elm_map_pan";
3804 sc.version = EVAS_SMART_CLASS_VERSION;
3806 sc.resize = _pan_resize;
3807 sc.move = _pan_move;
3808 sc.calculate = _pan_calculate;
3809 smart = evas_smart_class_new(&sc);
3814 wd->pan_smart = evas_object_smart_add(e, smart);
3815 pan = evas_object_smart_data_get(wd->pan_smart);
3818 elm_widget_sub_object_add(obj, wd->pan_smart);
3820 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3821 _pan_set, _pan_get, _pan_max_get,
3822 _pan_min_get, _pan_child_size_get);
3823 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3825 evas_object_size_hint_min_set(obj, minw, minh);
3827 wd->ges = elm_gesture_layer_add(obj);
3828 if (!wd->ges) ERR("elm_gesture_layer_add() failed");
3829 elm_gesture_layer_attach(wd->ges, obj);
3830 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_START,
3831 _pinch_zoom_start_cb, wd);
3832 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_MOVE,
3833 _pinch_zoom_cb, wd);
3834 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_MOVE,
3835 _pinch_rotate_cb, wd);
3836 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_END,
3837 _pinch_rotate_end_cb, wd);
3838 elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_ABORT,
3839 _pinch_rotate_end_cb, wd);
3841 wd->sep_maps_overlays = evas_object_rectangle_add(evas_object_evas_get(obj));
3842 elm_widget_sub_object_add(obj, wd->sep_maps_overlays);
3843 evas_object_smart_member_add(wd->sep_maps_overlays, wd->pan_smart);
3845 wd->map = evas_map_new(EVAS_MAP_POINT);
3847 _source_all_load(wd);
3848 wd->zoom_min = wd->src_tile->zoom_min;
3849 wd->zoom_max = wd->src_tile->zoom_max;
3850 // FIXME: Tile Provider is better to provide tile size!
3851 wd->tsize = DEFAULT_TILE_SIZE;
3855 wd->id = ((int)getpid() << 16) | idnum;
3857 _grid_all_create(wd);
3861 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
3863 // TODO: convert Elementary to subclassing of Evas_Smart_Class
3864 // TODO: and save some bytes, making descriptions per-class and not instance!
3865 evas_object_smart_callbacks_descriptions_set(obj, _signals);
3867 if (!ecore_file_download_protocol_available("http://"))
3868 ERR("Ecore must be built with curl support for the map widget!");
3878 elm_map_zoom_set(Evas_Object *obj, int zoom)
3880 #ifdef HAVE_ELEMENTARY_ECORE_CON
3881 ELM_CHECK_WIDTYPE(obj, widtype);
3882 Widget_Data *wd = elm_widget_data_get(obj);
3883 EINA_SAFETY_ON_NULL_RETURN(wd);
3884 EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
3886 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL) return;
3887 if (zoom < 0) zoom = 0;
3888 if (wd->zoom == zoom) return;
3889 Delayed_Data *data = ELM_NEW(Delayed_Data);
3890 data->func = _zoom_set;
3893 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
3894 evas_object_smart_changed(data->wd->pan_smart);
3902 elm_map_zoom_get(const Evas_Object *obj)
3904 #ifdef HAVE_ELEMENTARY_ECORE_CON
3905 ELM_CHECK_WIDTYPE(obj, widtype) 0;
3906 Widget_Data *wd = elm_widget_data_get(obj);
3908 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, 0);
3917 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
3919 #ifdef HAVE_ELEMENTARY_ECORE_CON
3920 ELM_CHECK_WIDTYPE(obj, widtype);
3921 Widget_Data *wd = elm_widget_data_get(obj);
3922 EINA_SAFETY_ON_NULL_RETURN(wd);
3924 if ((mode == ELM_MAP_ZOOM_MODE_MANUAL) && (wd->mode == !!mode)) return;
3926 Delayed_Data *data = ELM_NEW(Delayed_Data);
3928 data->func = _zoom_mode_set;
3930 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
3931 evas_object_smart_changed(data->wd->pan_smart);
3938 EAPI Elm_Map_Zoom_Mode
3939 elm_map_zoom_mode_get(const Evas_Object *obj)
3941 #ifdef HAVE_ELEMENTARY_ECORE_CON
3942 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
3943 Widget_Data *wd = elm_widget_data_get(obj);
3944 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, ELM_MAP_ZOOM_MODE_MANUAL);
3949 return ELM_MAP_ZOOM_MODE_MANUAL;
3954 elm_map_zoom_max_set(Evas_Object *obj, int zoom)
3956 #ifdef HAVE_ELEMENTARY_ECORE_CON
3957 ELM_CHECK_WIDTYPE(obj, widtype);
3958 Widget_Data *wd = elm_widget_data_get(obj);
3959 EINA_SAFETY_ON_NULL_RETURN(wd);
3960 EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
3962 wd->zoom_max = zoom;
3970 elm_map_zoom_max_get(const Evas_Object *obj)
3972 #ifdef HAVE_ELEMENTARY_ECORE_CON
3973 ELM_CHECK_WIDTYPE(obj, widtype) -1;
3974 Widget_Data *wd = elm_widget_data_get(obj);
3975 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1);
3976 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, -1);
3978 return wd->zoom_max;
3986 elm_map_zoom_min_set(Evas_Object *obj, int zoom)
3988 #ifdef HAVE_ELEMENTARY_ECORE_CON
3989 ELM_CHECK_WIDTYPE(obj, widtype);
3990 Widget_Data *wd = elm_widget_data_get(obj);
3991 EINA_SAFETY_ON_NULL_RETURN(wd);
3992 EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
3994 wd->zoom_min = zoom;
4002 elm_map_zoom_min_get(const Evas_Object *obj)
4004 #ifdef HAVE_ELEMENTARY_ECORE_CON
4005 ELM_CHECK_WIDTYPE(obj, widtype) -1;
4006 Widget_Data *wd = elm_widget_data_get(obj);
4007 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1);
4008 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, -1);
4010 return wd->zoom_min;
4018 elm_map_region_bring_in(Evas_Object *obj, double lon, double lat)
4020 #ifdef HAVE_ELEMENTARY_ECORE_CON
4021 ELM_CHECK_WIDTYPE(obj, widtype);
4022 Widget_Data *wd = elm_widget_data_get(obj);
4024 Delayed_Data *data = ELM_NEW(Delayed_Data);
4025 data->func = _region_bring_in;
4029 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
4030 evas_object_smart_changed(data->wd->pan_smart);
4039 elm_map_region_show(Evas_Object *obj, double lon, double lat)
4041 #ifdef HAVE_ELEMENTARY_ECORE_CON
4042 ELM_CHECK_WIDTYPE(obj, widtype);
4043 Widget_Data *wd = elm_widget_data_get(obj);
4045 Delayed_Data *data = ELM_NEW(Delayed_Data);
4046 data->func = _region_show;
4050 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
4051 evas_object_smart_changed(data->wd->pan_smart);
4060 elm_map_region_get(const Evas_Object *obj, double *lon, double *lat)
4062 #ifdef HAVE_ELEMENTARY_ECORE_CON
4063 ELM_CHECK_WIDTYPE(obj, widtype);
4064 Widget_Data *wd = elm_widget_data_get(obj);
4065 EINA_SAFETY_ON_NULL_RETURN(wd);
4068 Evas_Coord vx, vy, vw, vh;
4070 _viewport_coord_get(wd, &vx, &vy, &vw, &vh);
4071 _coord_to_region_convert(wd, vx + vw/2, vy + vh/2, wd->size.w, &tlon, &tlat);
4072 if (lon) *lon = tlon;
4073 if (lat) *lat = tlat;
4082 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
4084 #ifdef HAVE_ELEMENTARY_ECORE_CON
4085 ELM_CHECK_WIDTYPE(obj, widtype);
4086 Widget_Data *wd = elm_widget_data_get(obj);
4087 EINA_SAFETY_ON_NULL_RETURN(wd);
4089 if (wd->paused == !!paused) return;
4090 wd->paused = !!paused;
4093 if (wd->zoom_animator)
4095 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
4096 wd->zoom_animator = NULL;
4097 zoom_do(wd, wd->zoom);
4099 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4100 "elm,state,busy,stop", "elm");
4104 if (wd->download_num >= 1)
4105 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4106 "elm,state,busy,start", "elm");
4115 elm_map_paused_get(const Evas_Object *obj)
4117 #ifdef HAVE_ELEMENTARY_ECORE_CON
4118 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4119 Widget_Data *wd = elm_widget_data_get(obj);
4120 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
4130 elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
4132 #ifdef HAVE_ELEMENTARY_ECORE_CON
4133 ELM_CHECK_WIDTYPE(obj, widtype);
4134 Widget_Data *wd = elm_widget_data_get(obj);
4135 EINA_SAFETY_ON_NULL_RETURN(wd);
4137 wd->rotate.d = degree;
4141 evas_object_smart_changed(wd->pan_smart);
4151 elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
4153 #ifdef HAVE_ELEMENTARY_ECORE_CON
4154 ELM_CHECK_WIDTYPE(obj, widtype);
4155 Widget_Data *wd = elm_widget_data_get(obj);
4156 EINA_SAFETY_ON_NULL_RETURN(wd);
4158 if (degree) *degree = wd->rotate.d;
4159 if (cx) *cx = wd->rotate.cx;
4160 if (cy) *cy = wd->rotate.cy;
4170 elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
4172 #ifdef HAVE_ELEMENTARY_ECORE_CON
4173 ELM_CHECK_WIDTYPE(obj, widtype);
4174 Widget_Data *wd = elm_widget_data_get(obj);
4175 EINA_SAFETY_ON_NULL_RETURN(wd);
4177 if ((!wd->wheel_disabled) && (disabled))
4178 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, wd);
4179 else if ((wd->wheel_disabled) && (!disabled))
4180 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, wd);
4181 wd->wheel_disabled = !!disabled;
4189 elm_map_wheel_disabled_get(const Evas_Object *obj)
4191 #ifdef HAVE_ELEMENTARY_ECORE_CON
4192 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4193 Widget_Data *wd = elm_widget_data_get(obj);
4194 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
4196 return wd->wheel_disabled;
4204 elm_map_tile_load_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
4206 #ifdef HAVE_ELEMENTARY_ECORE_CON
4207 ELM_CHECK_WIDTYPE(obj, widtype);
4208 Widget_Data *wd = elm_widget_data_get(obj);
4209 EINA_SAFETY_ON_NULL_RETURN(wd);
4211 if (try_num) *try_num = wd->try_num;
4212 if (finish_num) *finish_num = wd->finish_num;
4221 elm_map_canvas_to_region_convert(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, double *lon, double *lat)
4223 #ifdef HAVE_ELEMENTARY_ECORE_CON
4224 ELM_CHECK_WIDTYPE(obj, widtype);
4225 Widget_Data *wd = elm_widget_data_get(obj);
4226 EINA_SAFETY_ON_NULL_RETURN(wd);
4227 EINA_SAFETY_ON_NULL_RETURN(lon);
4228 EINA_SAFETY_ON_NULL_RETURN(lat);
4230 _canvas_to_coord(wd, x, y, &x, &y);
4231 _coord_to_region_convert(wd, x, y, wd->size.w, lon, lat);
4242 elm_map_region_to_canvas_convert(const Evas_Object *obj, double lon, double lat, Evas_Coord *x, Evas_Coord *y)
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);
4248 EINA_SAFETY_ON_NULL_RETURN(x);
4249 EINA_SAFETY_ON_NULL_RETURN(y);
4251 _region_to_coord_convert(wd, lon, lat, wd->size.w, x, y);
4252 _coord_to_canvas(wd, *x, *y, x, y);
4263 elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
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);
4269 EINA_SAFETY_ON_NULL_RETURN(user_agent);
4271 eina_stringshare_replace(&wd->user_agent, user_agent);
4273 if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
4274 eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
4282 elm_map_user_agent_get(const Evas_Object *obj)
4284 #ifdef HAVE_ELEMENTARY_ECORE_CON
4285 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4286 Widget_Data *wd = elm_widget_data_get(obj);
4287 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4289 return wd->user_agent;
4297 elm_map_source_set(Evas_Object *obj, Elm_Map_Source_Type type, const char *source_name)
4299 #ifdef HAVE_ELEMENTARY_ECORE_CON
4300 ELM_CHECK_WIDTYPE(obj, widtype);
4301 Widget_Data *wd = elm_widget_data_get(obj);
4302 EINA_SAFETY_ON_NULL_RETURN(wd);
4303 EINA_SAFETY_ON_NULL_RETURN(source_name);
4305 if (type == ELM_MAP_SOURCE_TYPE_TILE) _source_tile_set(wd, source_name);
4306 else if (type == ELM_MAP_SOURCE_TYPE_ROUTE)
4307 _source_route_set(wd, source_name);
4308 else if (type == ELM_MAP_SOURCE_TYPE_NAME) _source_name_set(wd, source_name);
4309 else ERR("Not supported map source type: %d", type);
4318 elm_map_source_get(const Evas_Object *obj, Elm_Map_Source_Type type)
4320 #ifdef HAVE_ELEMENTARY_ECORE_CON
4321 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4322 Widget_Data *wd = elm_widget_data_get(obj);
4323 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4324 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, NULL);
4326 if (type == ELM_MAP_SOURCE_TYPE_TILE) return wd->src_tile->name;
4327 else if (type == ELM_MAP_SOURCE_TYPE_ROUTE) return wd->src_route->name;
4328 else if (type == ELM_MAP_SOURCE_TYPE_NAME) return wd->src_name->name;
4329 else ERR("Not supported map source type: %d", type);
4338 elm_map_sources_get(const Evas_Object *obj, Elm_Map_Source_Type type)
4340 #ifdef HAVE_ELEMENTARY_ECORE_CON
4341 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4342 Widget_Data *wd = elm_widget_data_get(obj);
4343 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4345 if (type == ELM_MAP_SOURCE_TYPE_TILE) return wd->src_tile_names;
4346 else if (type == ELM_MAP_SOURCE_TYPE_ROUTE) return wd->src_route_names;
4347 else if (type == ELM_MAP_SOURCE_TYPE_NAME) return wd->src_name_names;
4348 else ERR("Not supported map source type: %d", type);
4356 EAPI Elm_Map_Route *
4357 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)
4359 #ifdef HAVE_ELEMENTARY_ECORE_CON
4360 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4361 Widget_Data *wd = elm_widget_data_get(obj);
4362 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4363 EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_route, NULL);
4367 char fname[PATH_MAX];
4369 if (!ecore_file_exists(CACHE_ROUTE_ROOT))
4370 ecore_file_mkpath(CACHE_ROUTE_ROOT);
4372 if (type == ELM_MAP_ROUTE_TYPE_MOTOCAR)
4373 type_name = strdup(ROUTE_TYPE_MOTORCAR);
4374 else if (type == ELM_MAP_ROUTE_TYPE_BICYCLE)
4375 type_name = strdup(ROUTE_TYPE_BICYCLE);
4376 else if (type == ELM_MAP_ROUTE_TYPE_FOOT)
4377 type_name = strdup(ROUTE_TYPE_FOOT);
4378 else type_name = NULL;
4380 url = wd->src_route->url_cb(obj, type_name, method, flon, flat, tlon, tlat);
4383 ERR("Route URL is NULL");
4384 if (type_name) free(type_name);
4387 if (type_name) free(type_name);
4389 Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
4391 snprintf(fname, sizeof(fname), CACHE_ROUTE_ROOT"/%d", rand());
4392 route->fname = strdup(fname);
4394 route->method = method;
4399 route->cb = route_cb;
4402 if (!ecore_file_download_full(url, route->fname, _route_cb, NULL, route,
4403 &(route->job), wd->ua) || !(route->job))
4405 ERR("Can't request Route from %s to %s", url, route->fname);
4410 INF("Route requested from %s to %s", url, route->fname);
4413 wd->routes = eina_list_append(wd->routes, route);
4414 evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, route);
4415 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
4416 "elm,state,busy,start", "elm");
4434 elm_map_route_del(Elm_Map_Route *route)
4436 #ifdef HAVE_ELEMENTARY_ECORE_CON
4437 EINA_SAFETY_ON_NULL_RETURN(route);
4438 EINA_SAFETY_ON_NULL_RETURN(route->wd);
4439 ELM_CHECK_WIDTYPE(route->wd->obj, widtype);
4444 if (route->job) ecore_file_download_abort(route->job);
4446 EINA_LIST_FREE(route->waypoint, w)
4448 if (w->point) eina_stringshare_del(w->point);
4452 EINA_LIST_FREE(route->nodes, n)
4454 if (n->pos.address) eina_stringshare_del(n->pos.address);
4460 ecore_file_remove(route->fname);
4464 route->wd->routes = eina_list_remove(route->wd->routes, route);
4472 elm_map_route_distance_get(const Elm_Map_Route *route)
4474 #ifdef HAVE_ELEMENTARY_ECORE_CON
4475 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
4476 return route->info.distance;
4484 elm_map_route_node_get(const Elm_Map_Route *route)
4486 #ifdef HAVE_ELEMENTARY_ECORE_CON
4487 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4488 return route->info.nodes;
4496 elm_map_route_waypoint_get(const Elm_Map_Route *route)
4498 #ifdef HAVE_ELEMENTARY_ECORE_CON
4499 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
4500 return route->info.waypoints;
4508 elm_map_name_add(const Evas_Object *obj, const char *address, double lon, double lat, Elm_Map_Name_Cb name_cb, void *data)
4510 #ifdef HAVE_ELEMENTARY_ECORE_CON
4511 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4514 return _name_request(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0, 0,
4517 return _name_request(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat,
4531 elm_map_name_del(Elm_Map_Name *name)
4533 #ifdef HAVE_ELEMENTARY_ECORE_CON
4534 EINA_SAFETY_ON_NULL_RETURN(name);
4535 EINA_SAFETY_ON_NULL_RETURN(name->wd);
4536 ELM_CHECK_WIDTYPE(name->wd->obj, widtype);
4538 if (name->job) ecore_file_download_abort(name->job);
4539 if (name->address) free(name->address);
4542 ecore_file_remove(name->fname);
4546 name->wd->names = eina_list_remove(name->wd->names, name);
4554 elm_map_name_address_get(const Elm_Map_Name *name)
4556 #ifdef HAVE_ELEMENTARY_ECORE_CON
4557 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
4558 EINA_SAFETY_ON_NULL_RETURN_VAL(name->wd, NULL);
4559 ELM_CHECK_WIDTYPE(name->wd->obj, widtype) NULL;
4561 return name->address;
4569 elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
4571 #ifdef HAVE_ELEMENTARY_ECORE_CON
4572 EINA_SAFETY_ON_NULL_RETURN(name);
4573 EINA_SAFETY_ON_NULL_RETURN(name->wd);
4574 ELM_CHECK_WIDTYPE(name->wd->obj, widtype);
4576 if (lon) *lon = name->lon;
4577 if (lat) *lat = name->lat;
4585 EAPI Elm_Map_Overlay *
4586 elm_map_overlay_add(Evas_Object *obj, double lon, double lat)
4588 #ifdef HAVE_ELEMENTARY_ECORE_CON
4589 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4590 Widget_Data *wd = elm_widget_data_get(obj);
4591 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4593 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
4595 overlay->type = ELM_MAP_OVERLAY_TYPE_DEFAULT;
4596 overlay->c.r = 0x87;
4597 overlay->c.g = 0xce;
4598 overlay->c.b = 0xeb;
4600 overlay->ovl = _overlay_default_new(overlay, lon, lat, overlay->c, 1);
4601 overlay->grp = _overlay_group_new(wd);
4602 wd->overlays = eina_list_append(wd->overlays, overlay);
4604 evas_object_smart_changed(wd->pan_smart);
4615 elm_map_overlays_get(Evas_Object *obj)
4617 #ifdef HAVE_ELEMENTARY_ECORE_CON
4618 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4619 Widget_Data *wd = elm_widget_data_get(obj);
4620 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
4623 Elm_Map_Overlay *ovl;
4625 eina_list_free(wd->all_overlays);
4626 wd->all_overlays = NULL;
4628 EINA_LIST_FOREACH(wd->overlays, l, ovl)
4629 wd->all_overlays = eina_list_append(wd->all_overlays, ovl);
4630 EINA_LIST_FOREACH(wd->group_overlays, l, ovl)
4631 wd->all_overlays = eina_list_append(wd->all_overlays, ovl);
4633 return wd->all_overlays;
4641 elm_map_overlay_del(Elm_Map_Overlay *overlay)
4643 #ifdef HAVE_ELEMENTARY_ECORE_CON
4644 EINA_SAFETY_ON_NULL_RETURN(overlay);
4645 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4646 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4650 if (overlay->grp->clas)
4651 elm_map_overlay_class_remove(overlay->grp->clas, overlay);
4652 _overlay_group_free(overlay->grp);
4655 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
4656 _overlay_default_free(overlay->ovl);
4657 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
4658 _overlay_bubble_free(overlay->ovl);
4659 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
4660 _overlay_class_free(overlay->ovl);
4661 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
4662 _overlay_route_free(overlay->ovl);
4663 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_LINE)
4664 _overlay_line_free(overlay->ovl);
4665 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON)
4666 _overlay_polygon_free(overlay->ovl);
4667 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CIRCLE)
4668 _overlay_circle_free(overlay->ovl);
4669 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_SCALE)
4670 _overlay_scale_free(overlay->ovl);
4671 else ERR("Invalid overlay type: %d", overlay->type);
4673 overlay->wd->overlays = eina_list_remove(overlay->wd->overlays, overlay);
4674 evas_object_smart_changed(overlay->wd->pan_smart);
4682 EAPI Elm_Map_Overlay_Type
4683 elm_map_overlay_type_get(const Elm_Map_Overlay *overlay)
4685 #ifdef HAVE_ELEMENTARY_ECORE_CON
4686 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, ELM_MAP_OVERLAY_TYPE_NONE);
4687 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, ELM_MAP_OVERLAY_TYPE_NONE);
4688 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) ELM_MAP_OVERLAY_TYPE_NONE;
4690 return overlay->type;
4693 return ELM_MAP_OVERLAY_TYPE_NONE;
4698 elm_map_overlay_data_set(Elm_Map_Overlay *overlay, void *data)
4700 #ifdef HAVE_ELEMENTARY_ECORE_CON
4701 EINA_SAFETY_ON_NULL_RETURN(overlay);
4702 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4703 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4705 overlay->data = data;
4713 elm_map_overlay_data_get(const Elm_Map_Overlay *overlay)
4715 #ifdef HAVE_ELEMENTARY_ECORE_CON
4716 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
4717 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
4718 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
4720 return overlay->data;
4728 elm_map_overlay_hide_set(Elm_Map_Overlay *overlay, Eina_Bool hide)
4730 #ifdef HAVE_ELEMENTARY_ECORE_CON
4731 EINA_SAFETY_ON_NULL_RETURN(overlay);
4732 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4733 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4735 if (overlay->hide == !!hide) return;
4736 overlay->hide = hide;
4738 evas_object_smart_changed(overlay->wd->pan_smart);
4746 elm_map_overlay_hide_get(const Elm_Map_Overlay *overlay)
4748 #ifdef HAVE_ELEMENTARY_ECORE_CON
4749 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
4750 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE);
4751 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE;
4753 return overlay->hide;
4761 elm_map_overlay_displayed_zoom_min_set(Elm_Map_Overlay *overlay, int zoom)
4763 #ifdef HAVE_ELEMENTARY_ECORE_CON
4764 EINA_SAFETY_ON_NULL_RETURN(overlay);
4765 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4766 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4768 overlay->zoom_min = zoom;
4769 evas_object_smart_changed(overlay->wd->pan_smart);
4777 elm_map_overlay_displayed_zoom_min_get(const Elm_Map_Overlay *overlay)
4779 #ifdef HAVE_ELEMENTARY_ECORE_CON
4780 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, 0);
4781 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, 0);
4782 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) 0;
4784 return overlay->zoom_min;
4792 elm_map_overlay_paused_set(Elm_Map_Overlay *overlay, Eina_Bool paused)
4794 #ifdef HAVE_ELEMENTARY_ECORE_CON
4795 EINA_SAFETY_ON_NULL_RETURN(overlay);
4796 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4797 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4799 if (overlay->paused == !!paused) return;
4800 overlay->paused = paused;
4802 evas_object_smart_changed(overlay->wd->pan_smart);
4810 elm_map_overlay_paused_get(const Elm_Map_Overlay *overlay)
4812 #ifdef HAVE_ELEMENTARY_ECORE_CON
4813 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
4814 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE);
4815 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE;
4817 return overlay->paused;
4825 elm_map_overlay_visible_get(const Elm_Map_Overlay *overlay)
4827 #ifdef HAVE_ELEMENTARY_ECORE_CON
4828 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
4829 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE);
4830 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE;
4832 return overlay->visible;
4840 elm_map_overlay_show(Elm_Map_Overlay *overlay)
4842 #ifdef HAVE_ELEMENTARY_ECORE_CON
4843 EINA_SAFETY_ON_NULL_RETURN(overlay);
4844 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4845 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4847 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
4849 Overlay_Default *ovl = overlay->ovl;
4850 elm_map_region_show(overlay->wd->obj, ovl->lon, ovl->lat);
4852 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
4854 Overlay_Bubble *ovl = overlay->ovl;
4855 elm_map_region_show(overlay->wd->obj, ovl->lon, ovl->lat);
4857 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
4859 Overlay_Class *ovl = overlay->ovl;
4860 double lon, lat, max_lo, min_lo, max_la, min_la;
4861 _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la, &min_la);
4862 lon = (max_lo + min_lo) / 2;
4863 lat = (max_la + min_la) / 2;
4864 elm_map_region_show(overlay->wd->obj, lon, lat);
4866 else ERR("Not supported overlay type: %d", overlay->type);
4868 evas_object_smart_changed(overlay->wd->pan_smart);
4875 elm_map_overlays_show(Eina_List *overlays)
4877 #ifdef HAVE_ELEMENTARY_ECORE_CON
4878 EINA_SAFETY_ON_NULL_RETURN(overlays);
4879 EINA_SAFETY_ON_FALSE_RETURN(eina_list_count(overlays));
4881 Elm_Map_Overlay *overlay;
4882 overlay = eina_list_data_get(overlays);
4884 Delayed_Data *data = ELM_NEW(Delayed_Data);
4885 data->func = _overlays_show;
4886 data->wd = overlay->wd;
4887 data->overlays = eina_list_clone(overlays);
4888 data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
4889 evas_object_smart_changed(data->wd->pan_smart);
4896 elm_map_overlay_region_set(Elm_Map_Overlay *overlay, double lon, double lat)
4898 #ifdef HAVE_ELEMENTARY_ECORE_CON
4899 EINA_SAFETY_ON_NULL_RETURN(overlay);
4900 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4901 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4903 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
4905 Overlay_Default *ovl = overlay->ovl;
4909 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
4911 Overlay_Bubble *ovl = overlay->ovl;
4916 else ERR("Not supported overlay type: %d", overlay->type);
4918 evas_object_smart_changed(overlay->wd->pan_smart);
4927 elm_map_overlay_region_get(const Elm_Map_Overlay *overlay, double *lon, double *lat)
4929 #ifdef HAVE_ELEMENTARY_ECORE_CON
4930 EINA_SAFETY_ON_NULL_RETURN(overlay);
4931 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4932 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4934 if (overlay->type == ELM_MAP_OVERLAY_TYPE_GROUP)
4936 Overlay_Group *ovl = overlay->ovl;
4937 if (lon) *lon = ovl->lon;
4938 if (lat) *lat = ovl->lat;
4940 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
4942 const Overlay_Default *ovl = overlay->ovl;
4943 if (lon) *lon = ovl->lon;
4944 if (lat) *lat = ovl->lat;
4946 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
4948 const Overlay_Bubble *ovl = overlay->ovl;
4949 if (lon) *lon = ovl->lon;
4950 if (lat) *lat = ovl->lat;
4952 else ERR("Not supported overlay type: %d", overlay->type);
4961 elm_map_overlay_icon_set(Elm_Map_Overlay *overlay, Evas_Object *icon)
4963 #ifdef HAVE_ELEMENTARY_ECORE_CON
4964 EINA_SAFETY_ON_NULL_RETURN(overlay);
4965 EINA_SAFETY_ON_NULL_RETURN(icon);
4966 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
4967 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
4969 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
4970 _overlay_default_icon_update(overlay->ovl, icon);
4971 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
4972 _overlay_class_icon_update(overlay->ovl, icon);
4973 else ERR("Not supported overlay type: %d", overlay->type);
4975 evas_object_smart_changed(overlay->wd->pan_smart);
4982 EAPI const Evas_Object *
4983 elm_map_overlay_icon_get(const Elm_Map_Overlay *overlay)
4985 #ifdef HAVE_ELEMENTARY_ECORE_CON
4986 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
4987 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
4988 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
4990 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
4992 const Overlay_Default *ovl = overlay->ovl;
4995 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
4997 const Overlay_Class *ovl = overlay->ovl;
5002 ERR("Not supported overlay type: %d", overlay->type);
5012 elm_map_overlay_content_set(Elm_Map_Overlay *overlay, Evas_Object *content)
5014 #ifdef HAVE_ELEMENTARY_ECORE_CON
5015 EINA_SAFETY_ON_NULL_RETURN(overlay);
5016 EINA_SAFETY_ON_NULL_RETURN(content);
5017 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5018 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5020 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5021 _overlay_default_content_update(overlay->ovl, content, overlay);
5022 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5023 _overlay_class_content_update(overlay->ovl, content);
5024 else ERR("Not supported overlay type: %d", overlay->type);
5026 evas_object_smart_changed(overlay->wd->pan_smart);
5033 EAPI const Evas_Object *
5034 elm_map_overlay_content_get(const Elm_Map_Overlay *overlay)
5036 #ifdef HAVE_ELEMENTARY_ECORE_CON
5037 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
5038 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
5039 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
5041 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5043 const Overlay_Default *ovl = overlay->ovl;
5044 return ovl->content;
5046 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5048 const Overlay_Class *ovl = overlay->ovl;
5049 return ovl->content;
5053 ERR("Not supported overlay type: %d", overlay->type);
5063 elm_map_overlay_color_set(Elm_Map_Overlay *overlay, int r, int g , int b, int a)
5065 #ifdef HAVE_ELEMENTARY_ECORE_CON
5066 EINA_SAFETY_ON_NULL_RETURN(overlay);
5067 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5068 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5075 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5076 _overlay_class_color_update(overlay->ovl, overlay->c);
5077 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5078 _overlay_default_color_update(overlay->ovl, overlay->c);
5079 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
5080 _overlay_route_color_update(overlay->ovl, overlay->c);
5083 ERR("Not supported overlay type: %d", overlay->type);
5096 elm_map_overlay_color_get(const Elm_Map_Overlay *overlay, int *r, int *g , int *b, int *a)
5098 #ifdef HAVE_ELEMENTARY_ECORE_CON
5099 EINA_SAFETY_ON_NULL_RETURN(overlay);
5100 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5101 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5103 if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
5105 if (r) *r = overlay->c.r;
5106 if (g) *g = overlay->c.g;
5107 if (b) *b = overlay->c.b;
5108 if (a) *a = overlay->c.a;
5110 else ERR("Not supported overlay type: %d", overlay->type);
5121 elm_map_overlay_get_cb_set(Elm_Map_Overlay *overlay, Elm_Map_Overlay_Get_Cb get_cb, void *data)
5123 #ifdef HAVE_ELEMENTARY_ECORE_CON
5124 EINA_SAFETY_ON_NULL_RETURN(overlay);
5125 EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
5126 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5128 overlay->cb = get_cb;
5129 overlay->cb_data = data;
5131 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5132 _overlay_class_cb_set(overlay->ovl, get_cb, data);
5140 EAPI Elm_Map_Overlay *
5141 elm_map_overlay_class_add(Evas_Object *obj)
5143 #ifdef HAVE_ELEMENTARY_ECORE_CON
5144 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5145 Widget_Data *wd = elm_widget_data_get(obj);
5146 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5148 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5150 overlay->type = ELM_MAP_OVERLAY_TYPE_CLASS;
5151 overlay->ovl = _overlay_class_new(wd);
5152 overlay->c.r = 0x90;
5153 overlay->c.g = 0xee;
5154 overlay->c.b = 0x90;
5155 overlay->c.a = 0xff;
5156 wd->overlays = eina_list_append(wd->overlays, overlay);
5158 evas_object_smart_changed(wd->pan_smart);
5167 elm_map_overlay_class_append(Elm_Map_Overlay *clas, Elm_Map_Overlay *overlay)
5169 #ifdef HAVE_ELEMENTARY_ECORE_CON
5170 EINA_SAFETY_ON_NULL_RETURN(clas);
5171 EINA_SAFETY_ON_NULL_RETURN(overlay);
5172 EINA_SAFETY_ON_NULL_RETURN(clas->wd);
5173 ELM_CHECK_WIDTYPE(clas->wd->obj, widtype);
5174 EINA_SAFETY_ON_FALSE_RETURN(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS);
5176 Overlay_Class *clas_ovl = clas->ovl;
5177 if (eina_list_data_find(clas_ovl->members, overlay))
5179 ERR("Already added overlay into clas");
5182 clas_ovl->members = eina_list_append(clas_ovl->members, overlay);
5184 // Update group by class
5185 overlay->grp->clas = clas;
5186 _overlay_group_icon_update(overlay->grp, clas_ovl->icon);
5187 _overlay_group_content_update(overlay->grp, clas_ovl->content);
5188 _overlay_group_color_update(overlay->grp, clas->c);
5189 _overlay_group_cb_set(overlay->grp, clas->cb, clas->data);
5190 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5192 _overlay_default_clas_icon_update(overlay->ovl, clas_ovl->icon);
5193 _overlay_default_clas_content_update(overlay->ovl, clas_ovl->content);
5196 evas_object_smart_changed(clas->wd->pan_smart);
5204 elm_map_overlay_class_remove(Elm_Map_Overlay *clas, Elm_Map_Overlay *overlay)
5206 #ifdef HAVE_ELEMENTARY_ECORE_CON
5207 EINA_SAFETY_ON_NULL_RETURN(clas);
5208 EINA_SAFETY_ON_NULL_RETURN(overlay);
5209 EINA_SAFETY_ON_NULL_RETURN(clas->wd);
5210 ELM_CHECK_WIDTYPE(clas->wd->obj, widtype);
5211 EINA_SAFETY_ON_FALSE_RETURN(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS);
5213 Overlay_Class *ovl = clas->ovl;
5214 ovl->members = eina_list_remove(ovl->members, overlay);
5216 overlay->grp->clas = NULL;
5217 _overlay_group_icon_update(overlay->grp, NULL);
5218 _overlay_group_content_update(overlay->grp, NULL);
5219 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5221 _overlay_default_clas_icon_update(overlay->ovl, NULL);
5222 _overlay_default_clas_content_update(overlay->ovl, NULL);
5225 evas_object_smart_changed(clas->wd->pan_smart);
5233 elm_map_overlay_class_zoom_max_set(Elm_Map_Overlay *clas, int zoom)
5235 #ifdef HAVE_ELEMENTARY_ECORE_CON
5236 EINA_SAFETY_ON_NULL_RETURN(clas);
5237 EINA_SAFETY_ON_NULL_RETURN(clas->wd);
5238 ELM_CHECK_WIDTYPE(clas->wd->obj, widtype);
5239 EINA_SAFETY_ON_FALSE_RETURN(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS);
5241 Overlay_Class *ovl = clas->ovl;
5242 if (ovl->zoom_max == !!zoom) return;
5243 ovl->zoom_max = zoom;
5245 evas_object_smart_changed(clas->wd->pan_smart);
5253 elm_map_overlay_class_zoom_max_get(const Elm_Map_Overlay *clas)
5255 #ifdef HAVE_ELEMENTARY_ECORE_CON
5256 EINA_SAFETY_ON_NULL_RETURN_VAL(clas, OVERLAY_CLASS_ZOOM_MAX);
5257 EINA_SAFETY_ON_NULL_RETURN_VAL(clas->wd, OVERLAY_CLASS_ZOOM_MAX);
5258 ELM_CHECK_WIDTYPE(clas->wd->obj, widtype) OVERLAY_CLASS_ZOOM_MAX;
5259 EINA_SAFETY_ON_FALSE_RETURN_VAL(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS, OVERLAY_CLASS_ZOOM_MAX);
5261 const Overlay_Class *ovl = clas->ovl;
5262 return ovl->zoom_max;
5265 return OVERLAY_CLASS_ZOOM_MAX;
5270 elm_map_overlay_group_members_get(const Elm_Map_Overlay *grp)
5272 #ifdef HAVE_ELEMENTARY_ECORE_CON
5273 EINA_SAFETY_ON_NULL_RETURN_VAL(grp, NULL);
5274 EINA_SAFETY_ON_NULL_RETURN_VAL(grp->wd, NULL);
5275 ELM_CHECK_WIDTYPE(grp->wd->obj, widtype) NULL;
5276 EINA_SAFETY_ON_FALSE_RETURN_VAL(grp->type == ELM_MAP_OVERLAY_TYPE_GROUP, NULL);
5278 Overlay_Group *ovl = grp->ovl;
5279 return ovl->members;
5282 return OVERLAY_CLASS_ZOOM_MAX;
5286 EAPI Elm_Map_Overlay *
5287 elm_map_overlay_bubble_add(Evas_Object *obj)
5289 #ifdef HAVE_ELEMENTARY_ECORE_CON
5290 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5291 Widget_Data *wd = elm_widget_data_get(obj);
5292 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5294 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5296 overlay->type = ELM_MAP_OVERLAY_TYPE_BUBBLE;
5301 overlay->ovl = _overlay_bubble_new(overlay);
5302 overlay->grp = _overlay_group_new(wd);
5303 wd->overlays = eina_list_append(wd->overlays, overlay);
5305 evas_object_smart_changed(wd->pan_smart);
5314 elm_map_overlay_bubble_follow(Elm_Map_Overlay *bubble, const Elm_Map_Overlay *parent)
5316 #ifdef HAVE_ELEMENTARY_ECORE_CON
5317 EINA_SAFETY_ON_NULL_RETURN(bubble);
5318 EINA_SAFETY_ON_NULL_RETURN(parent);
5319 ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
5320 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
5322 Overlay_Bubble *ovl = bubble->ovl;
5323 Evas_Object *pobj = _overlay_obj_get(parent);
5327 evas_object_smart_changed(bubble->wd->pan_smart);
5335 elm_map_overlay_bubble_content_append(Elm_Map_Overlay *bubble, Evas_Object *content)
5337 #ifdef HAVE_ELEMENTARY_ECORE_CON
5338 EINA_SAFETY_ON_NULL_RETURN(bubble);
5339 EINA_SAFETY_ON_NULL_RETURN(content);
5340 ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
5341 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
5343 Overlay_Bubble *bb = bubble->ovl;
5344 elm_box_pack_end(bb->bx, content);
5346 evas_object_smart_changed(bubble->wd->pan_smart);
5354 elm_map_overlay_bubble_content_clear(Elm_Map_Overlay *bubble)
5356 #ifdef HAVE_ELEMENTARY_ECORE_CON
5357 EINA_SAFETY_ON_NULL_RETURN(bubble);
5358 ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
5359 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
5361 Overlay_Bubble *bb = bubble->ovl;
5362 elm_box_clear(bb->bx);
5364 evas_object_smart_changed(bubble->wd->pan_smart);
5370 EAPI Elm_Map_Overlay *
5371 elm_map_overlay_route_add(Evas_Object *obj, const Elm_Map_Route *route)
5373 #ifdef HAVE_ELEMENTARY_ECORE_CON
5374 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5375 Widget_Data *wd = elm_widget_data_get(obj);
5376 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5377 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
5378 EINA_SAFETY_ON_NULL_RETURN_VAL(route->wd, NULL);
5379 EINA_SAFETY_ON_FALSE_RETURN_VAL(obj == route->wd->obj, NULL);
5381 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5383 overlay->type = ELM_MAP_OVERLAY_TYPE_ROUTE;
5384 overlay->c.r = 0xff;
5385 overlay->c.g = 0x00;
5386 overlay->c.b = 0x00;
5387 overlay->c.a = 0xff;
5388 overlay->ovl = _overlay_route_new(wd, route, overlay->c);
5389 overlay->grp = _overlay_group_new(wd);
5390 wd->overlays = eina_list_append(wd->overlays, overlay);
5392 evas_object_smart_changed(wd->pan_smart);
5401 EAPI Elm_Map_Overlay *
5402 elm_map_overlay_line_add(Evas_Object *obj, double flon, double flat, double tlon, double tlat)
5404 #ifdef HAVE_ELEMENTARY_ECORE_CON
5405 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5406 Widget_Data *wd = elm_widget_data_get(obj);
5407 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5409 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5411 overlay->type = ELM_MAP_OVERLAY_TYPE_LINE;
5412 overlay->c.r = 0xff;
5413 overlay->c.g = 0x00;
5414 overlay->c.b = 0x00;
5415 overlay->c.a = 0xff;
5416 overlay->ovl = _overlay_line_new(wd, flon, flat, tlon, tlat, overlay->c);
5417 overlay->grp = _overlay_group_new(wd);
5418 wd->overlays = eina_list_append(wd->overlays, overlay);
5420 evas_object_smart_changed(wd->pan_smart);
5432 EAPI Elm_Map_Overlay *
5433 elm_map_overlay_polygon_add(Evas_Object *obj)
5435 #ifdef HAVE_ELEMENTARY_ECORE_CON
5436 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5437 Widget_Data *wd = elm_widget_data_get(obj);
5438 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5440 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5442 overlay->type = ELM_MAP_OVERLAY_TYPE_POLYGON;
5443 overlay->c.r = 0xdc;
5444 overlay->c.g = 0x14;
5445 overlay->c.b = 0x3c;
5447 overlay->ovl = _overlay_polygon_new(wd, overlay->c);
5448 overlay->grp = _overlay_group_new(wd);
5449 wd->overlays = eina_list_append(wd->overlays, overlay);
5450 evas_object_smart_changed(wd->pan_smart);
5459 elm_map_overlay_polygon_region_add(Elm_Map_Overlay *overlay, double lon, double lat)
5461 #ifdef HAVE_ELEMENTARY_ECORE_CON
5462 EINA_SAFETY_ON_NULL_RETURN(overlay);
5463 ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
5464 EINA_SAFETY_ON_FALSE_RETURN(overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON);
5466 Overlay_Polygon *ovl = overlay->ovl;
5467 Region *r = ELM_NEW(Region);
5470 ovl->regions = eina_list_append(ovl->regions, r);
5472 evas_object_smart_changed(ovl->wd->pan_smart);
5480 EAPI Elm_Map_Overlay *
5481 elm_map_overlay_circle_add(Evas_Object *obj, double lon, double lat, double radius)
5483 #ifdef HAVE_ELEMENTARY_ECORE_CON
5484 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5485 Widget_Data *wd = elm_widget_data_get(obj);
5486 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5488 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5490 overlay->type = ELM_MAP_OVERLAY_TYPE_CIRCLE;
5491 overlay->c.r = 0xdc;
5492 overlay->c.g = 0x14;
5493 overlay->c.b = 0x3c;
5495 overlay->ovl = _overlay_circle_new(wd, lon, lat, radius, overlay->c);
5496 overlay->grp = _overlay_group_new(wd);
5497 wd->overlays = eina_list_append(wd->overlays, overlay);
5499 evas_object_smart_changed(wd->pan_smart);
5507 EAPI Elm_Map_Overlay *
5508 elm_map_overlay_scale_add(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
5510 #ifdef HAVE_ELEMENTARY_ECORE_CON
5511 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5512 Widget_Data *wd = elm_widget_data_get(obj);
5513 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
5515 Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
5517 overlay->type = ELM_MAP_OVERLAY_TYPE_SCALE;
5522 overlay->ovl = _overlay_scale_new(wd, x, y, overlay->c);
5523 overlay->grp = _overlay_group_new(wd);
5524 wd->overlays = eina_list_append(wd->overlays, overlay);
5526 evas_object_smart_changed(wd->pan_smart);
5536 elm_map_track_add(Evas_Object *obj, void *emap)
5538 #ifdef HAVE_ELEMENTARY_ECORE_CON
5539 EMap_Route *emapr = emap;
5540 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5541 Widget_Data *wd = elm_widget_data_get(obj);
5542 EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
5544 Evas_Object *route = elm_route_add(obj);
5545 elm_route_emap_set(route, emapr);
5546 wd->track = eina_list_append(wd->track, route);
5557 elm_map_track_remove(Evas_Object *obj, Evas_Object *route)
5559 #ifdef HAVE_ELEMENTARY_ECORE_CON
5560 ELM_CHECK_WIDTYPE(obj, widtype) ;
5561 Widget_Data *wd = elm_widget_data_get(obj);
5562 EINA_SAFETY_ON_NULL_RETURN(wd);
5564 wd->track = eina_list_remove(wd->track, route);
5565 evas_object_del(route);
5573 elm_map_track_add(Evas_Object *obj __UNUSED__, void *emap __UNUSED__)
5579 elm_map_track_remove(Evas_Object *obj __UNUSED__, Evas_Object *route __UNUSED__)