1 #include <Elementary.h>
3 #include "elm_widget_map.h"
5 EAPI const char ELM_MAP_SMART_NAME[] = "elm_map";
6 EAPI const char ELM_MAP_PAN_SMART_NAME[] = "elm_map_pan";
8 #define INTERNAL_ENGINE_NAME "Elm_Map_Tile"
9 #define OVERLAY_CLASS_ZOOM_MAX 255
10 #define MAX_CONCURRENT_DOWNLOAD 10
12 #define ROUND(z) (((z) < 0) ? (int)ceil((z) - 0.005) : (int)floor((z) + 0.005))
13 #define EVAS_MAP_POINT 4
14 #define DEFAULT_TILE_SIZE 256
15 #define MARER_MAX_NUMBER 30
16 #define OVERLAY_GROUPING_SCALE 2
18 #define CACHE_ROOT "/elm_map"
19 #define CACHE_TILE_ROOT CACHE_ROOT "/%d/%d/%d"
20 #define CACHE_TILE_PATH "%s/%d.png"
21 #define CACHE_ROUTE_ROOT CACHE_ROOT "/route"
22 #define CACHE_NAME_ROOT CACHE_ROOT "/name"
24 #define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php"
25 #define ROUTE_TYPE_MOTORCAR "motocar"
26 #define ROUTE_TYPE_BICYCLE "bicycle"
27 #define ROUTE_TYPE_FOOT "foot"
28 #define YOURS_DISTANCE "distance"
29 #define YOURS_DESCRIPTION "description"
30 #define YOURS_COORDINATES "coordinates"
32 #define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org"
33 #define NOMINATIM_RESULT "result"
34 #define NOMINATIM_PLACE "place"
35 #define NOMINATIM_ATTR_LON "lon"
36 #define NOMINATIM_ATTR_LAT "lat"
37 #define NOMINATIM_ATTR_ADDRESS "display_name"
39 #ifdef HAVE_ELEMENTARY_ECORE_CON
41 static void _overlay_place(Elm_Map_Smart_Data *sd);
44 _mapnik_url_cb(const Evas_Object *obj __UNUSED__,
51 // ((x+y+zoom)%3)+'a' is requesting map images from distributed
52 // tile servers (eg., a, b, c)
53 snprintf(buf, sizeof(buf), "http://%c.tile.openstreetmap.org/%d/%d/%d.png",
54 ((x + y + zoom) % 3) + 'a', zoom, x, y);
59 _osmarender_url_cb(const Evas_Object *obj __UNUSED__,
66 snprintf(buf, sizeof(buf),
67 "http://%c.tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
68 ((x + y + zoom) % 3) + 'a', zoom, x, y);
74 _cyclemap_url_cb(const Evas_Object *obj __UNUSED__,
81 snprintf(buf, sizeof(buf),
82 "http://%c.tile.opencyclemap.org/cycle/%d/%d/%d.png",
83 ((x + y + zoom) % 3) + 'a', zoom, x, y);
89 _mapquest_url_cb(const Evas_Object *obj __UNUSED__,
96 snprintf(buf, sizeof(buf),
97 "http://otile%d.mqcdn.com/tiles/1.0.0/osm/%d/%d/%d.png",
98 ((x + y + zoom) % 4) + 1, zoom, x, y);
104 _mapquest_aerial_url_cb(const Evas_Object *obj __UNUSED__,
111 snprintf(buf, sizeof(buf), "http://oatile%d.mqcdn.com/naip/%d/%d/%d.png",
112 ((x + y + zoom) % 4) + 1, zoom, x, y);
118 _yours_url_cb(const Evas_Object *obj __UNUSED__,
119 const char *type_name,
130 "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
131 ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
136 // TODO: fix monav api
139 _monav_url_cb(const Evas_Object *obj __UNUSED__,
149 snprintf(buf, sizeof(buf),
150 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
151 ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
159 _ors_url_cb(const Evas_Object *obj __UNUSED__,
169 snprintf(buf, sizeof(buf),
170 "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
171 ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
178 _nominatim_url_cb(const Evas_Object *obj,
186 unsigned int ele, idx;
187 char search_url[PATH_MAX];
189 ELM_MAP_DATA_GET(obj, sd);
191 if (method == ELM_MAP_NAME_METHOD_SEARCH)
193 search_url[0] = '\0';
194 str = eina_str_split_full(name, " ", 0, &ele);
195 for (idx = 0; idx < ele; idx++)
197 eina_strlcat(search_url, str[idx], sizeof(search_url));
198 if (!(idx == (ele - 1)))
199 eina_strlcat(search_url, "+", sizeof(search_url));
201 snprintf(buf, sizeof(buf),
202 "%s/search?q=%s&format=xml&polygon=0&addressdetails=0",
203 NAME_NOMINATIM_URL, search_url);
207 if (str[0]) free(str[0]);
211 else if (method == ELM_MAP_NAME_METHOD_REVERSE)
212 snprintf(buf, sizeof(buf),
213 "%s/reverse?format=xml&lat=%lf&lon=%lf&zoom=%d&addressdetails=0",
214 NAME_NOMINATIM_URL, lat, lon, (int)sd->zoom);
215 else strcpy(buf, "");
220 // Refer : http://wiki.openstreetmap.org/wiki/FAQ
221 // meters per pixel when latitude is 0 (equator)
222 // meters per pixel = _osm_scale_meter[zoom] * cos (latitude)
223 const double _osm_scale_meter[] =
225 78206, 39135.758482, 19567.879241, 9783.939621, 4891.969810,
226 2445.984905, 1222.992453, 611.496226, 305.748113, 152.874057, 76.437028,
227 38.218514, 19.109257, 9.554629, 4.777314, 2.388657, 1.194329, 0.597164,
232 _scale_cb(const Evas_Object *obj __UNUSED__,
233 double lon __UNUSED__,
237 if (zoom < 0 || zoom >= (int)(sizeof(_osm_scale_meter)/sizeof(_osm_scale_meter[0]))) return 0;
238 return _osm_scale_meter[zoom] / cos(lat * ELM_PI / 180.0);
241 const Source_Tile src_tiles[] =
243 {"Mapnik", 0, 18, _mapnik_url_cb, NULL, NULL, _scale_cb},
244 {"Osmarender", 0, 17, _osmarender_url_cb, NULL, NULL, _scale_cb},
245 {"CycleMap", 0, 16, _cyclemap_url_cb, NULL, NULL, _scale_cb},
246 {"MapQuest", 0, 18, _mapquest_url_cb, NULL, NULL, _scale_cb},
247 {"MapQuest Open Aerial", 0, 11, _mapquest_aerial_url_cb, NULL, NULL,
251 // FIXME: Fix more open sources
252 const Source_Route src_routes[] =
254 {"Yours", _yours_url_cb} // http://www.yournavigation.org/
255 //{"Monav", _monav_url_cb},
256 //{"ORS", _ors_url_cb}, // http://www.openrouteservice.org
260 const double _scale_tb[] =
262 10000000, 5000000, 2000000, 1000000, 500000, 200000, 100000, 50000,
263 20000, 10000, 5000, 2000, 1000, 500, 500, 200, 100, 50, 20, 10, 5, 2, 1
266 // FIXME: Add more open sources
267 const Source_Name src_names[] =
269 {"Nominatim", _nominatim_url_cb}
272 static int id_num = 1;
274 static const char SIG_CLICKED[] = "clicked";
275 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
276 static const char SIG_PRESS[] = "press";
277 static const char SIG_LONGPRESSED[] = "longpressed";
278 static const char SIG_SCROLL[] = "scroll";
279 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
280 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
281 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
282 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
283 static const char SIG_ZOOM_START[] = "zoom,start";
284 static const char SIG_ZOOM_STOP[] = "zoom,stop";
285 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
286 static const char SIG_LOADED[] = "loaded";
287 static const char SIG_TILE_LOAD[] = "tile,load";
288 static const char SIG_TILE_LOADED[] = "tile,loaded";
289 static const char SIG_TILE_LOADED_FAIL[] = "tile,loaded,fail";
290 static const char SIG_ROUTE_LOAD[] = "route,load";
291 static const char SIG_ROUTE_LOADED[] = "route,loaded";
292 static const char SIG_ROUTE_LOADED_FAIL[] = "route,loaded,fail";
293 static const char SIG_NAME_LOAD[] = "name,load";
294 static const char SIG_NAME_LOADED[] = "name,loaded";
295 static const char SIG_NAME_LOADED_FAIL[] = "name,loaded,fail";
296 static const char SIG_OVERLAY_CLICKED[] = "overlay,clicked";
297 static const char SIG_OVERLAY_DEL[] = "overlay,del";
298 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
300 {SIG_CLICKED_DOUBLE, ""},
302 {SIG_LONGPRESSED, ""},
304 {SIG_SCROLL_DRAG_START, ""},
305 {SIG_SCROLL_DRAG_STOP, ""},
306 {SIG_SCROLL_ANIM_START, ""},
307 {SIG_SCROLL_ANIM_STOP, ""},
308 {SIG_ZOOM_START, ""},
310 {SIG_ZOOM_CHANGE, ""},
313 {SIG_TILE_LOADED, ""},
314 {SIG_TILE_LOADED_FAIL, ""},
315 {SIG_ROUTE_LOAD, ""},
316 {SIG_ROUTE_LOADED, ""},
317 {SIG_ROUTE_LOADED_FAIL, ""},
319 {SIG_NAME_LOADED, ""},
320 {SIG_NAME_LOADED_FAIL, ""},
321 {SIG_OVERLAY_CLICKED, ""},
322 {SIG_OVERLAY_DEL, ""},
326 static const Evas_Smart_Interface *_smart_interfaces[] =
328 (Evas_Smart_Interface *)&ELM_SCROLLABLE_IFACE, NULL
331 EVAS_SMART_SUBCLASS_IFACE_NEW
332 (ELM_MAP_SMART_NAME, _elm_map, Elm_Map_Smart_Class,
333 Elm_Widget_Smart_Class, elm_widget_smart_class_get, _smart_callbacks,
336 ELM_INTERNAL_SMART_SUBCLASS_NEW
337 (ELM_MAP_PAN_SMART_NAME, _elm_map_pan, Elm_Map_Pan_Smart_Class,
338 Elm_Pan_Smart_Class, elm_pan_smart_class_get, NULL);
341 _edj_overlay_size_get(Elm_Map_Smart_Data *sd,
348 EINA_SAFETY_ON_NULL_RETURN(w);
349 EINA_SAFETY_ON_NULL_RETURN(h);
351 edj = edje_object_add(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
352 elm_widget_theme_object_set
353 (ELM_WIDGET_DATA(sd)->obj, edj, "map/marker", "radio",
354 elm_widget_style_get(ELM_WIDGET_DATA(sd)->obj));
356 s = edje_object_data_get(edj, "size_w");
360 s = edje_object_data_get(edj, "size_h");
364 evas_object_del(edj);
368 _rotate_do(Evas_Coord x,
376 double r = (degree * M_PI) / 180.0;
378 if (xx) *xx = ((x - cx) * cos(r)) + ((y - cy) * cos(r + M_PI_2)) + cx;
379 if (yy) *yy = ((x - cx) * sin(r)) + ((y - cy) * sin(r + M_PI_2)) + cy;
383 _obj_rotate(Elm_Map_Smart_Data *sd,
386 Evas_Coord w, h, ow, oh;
388 evas_map_util_points_populate_from_object(sd->map, obj);
390 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
391 evas_object_image_size_get(obj, &w, &h);
392 if ((w > ow) || (h > oh))
394 evas_map_point_image_uv_set(sd->map, 0, 0, 0);
395 evas_map_point_image_uv_set(sd->map, 1, w, 0);
396 evas_map_point_image_uv_set(sd->map, 2, w, h);
397 evas_map_point_image_uv_set(sd->map, 3, 0, h);
399 evas_map_util_rotate(sd->map, sd->pan_rotate.d, sd->pan_rotate.cx,
402 evas_object_map_set(obj, sd->map);
403 evas_object_map_enable_set(obj, EINA_TRUE);
407 _obj_place(Evas_Object *obj,
413 EINA_SAFETY_ON_NULL_RETURN(obj);
415 evas_object_move(obj, x, y);
416 evas_object_resize(obj, w, h);
417 evas_object_show(obj);
421 _coord_to_region_convert(Elm_Map_Smart_Data *sd,
430 EINA_SAFETY_ON_NULL_RETURN(sd);
432 zoom = floor(log(size / sd->size.tile) / log(2));
433 if ((sd->src_tile) && (sd->src_tile->coord_to_geo))
435 if (sd->src_tile->coord_to_geo
436 (ELM_WIDGET_DATA(sd)->obj, zoom, x, y, size, lon, lat))
440 if (lon) *lon = (x / (double)size * 360.0) - 180;
443 double n = ELM_PI - (2.0 * ELM_PI * y / size);
444 *lat = 180.0 / ELM_PI *atan(0.5 * (exp(n) - exp(-n)));
449 _region_to_coord_convert(Elm_Map_Smart_Data *sd,
458 EINA_SAFETY_ON_NULL_RETURN(sd);
460 zoom = floor(log(size / 256) / log(2));
462 if (strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
464 sd->engine->region_to_canvas
465 (ELM_WIDGET_DATA(sd)->obj, lon, lat, x, y);
469 if ((sd->src_tile) && (sd->src_tile->geo_to_coord))
471 if (sd->src_tile->geo_to_coord
472 (ELM_WIDGET_DATA(sd)->obj, zoom, lon, lat, size, x, y)) return;
475 if (x) *x = floor((lon + 180.0) / 360.0 * size);
477 *y = floor((1.0 - log(tan(lat * ELM_PI / 180.0) +
478 (1.0 / cos(lat * ELM_PI / 180.0)))
479 / ELM_PI) / 2.0 * size);
483 _viewport_coord_get(Elm_Map_Smart_Data *sd,
489 Evas_Coord x, y, w, h;
491 EINA_SAFETY_ON_NULL_RETURN(sd);
493 sd->s_iface->content_pos_get(ELM_WIDGET_DATA(sd)->obj, &x, &y);
494 sd->s_iface->content_viewport_size_get(ELM_WIDGET_DATA(sd)->obj, &w, &h);
496 if (w > sd->size.w) x -= ((w - sd->size.w) / 2);
497 if (h > sd->size.h) y -= ((h - sd->size.h) / 2);
504 // Map coordinates to canvas geometry without rotate
506 _coord_to_canvas_no_rotation(Elm_Map_Smart_Data *sd,
512 Evas_Coord vx, vy, sx, sy;
514 _viewport_coord_get(sd, &vx, &vy, NULL, NULL);
515 evas_object_geometry_get(sd->pan_obj, &sx, &sy, NULL, NULL);
516 if (xx) *xx = x - vx + sx;
517 if (yy) *yy = y - vy + sy;
520 // Map coordinates to canvas geometry
522 _coord_to_canvas(Elm_Map_Smart_Data *sd,
528 _coord_to_canvas_no_rotation(sd, x, y, &x, &y);
529 _rotate_do(x, y, sd->pan_rotate.cx, sd->pan_rotate.cy, sd->pan_rotate.d, &x, &y);
534 // Canvas geometry to map coordinates
536 _canvas_to_coord(Elm_Map_Smart_Data *sd,
542 Evas_Coord vx, vy, sx, sy;
544 _viewport_coord_get(sd, &vx, &vy, NULL, NULL);
545 evas_object_geometry_get(sd->pan_obj, &sx, &sy, NULL, NULL);
546 _rotate_do(x - sx + vx, y - sy + vy, sd->pan_rotate.cx - sx + vx,
547 sd->pan_rotate.cy - sy + vy, -sd->pan_rotate.d, &x, &y);
553 _grid_item_coord_get(Grid_Item *gi,
559 EINA_SAFETY_ON_NULL_RETURN(gi);
561 if (x) *x = gi->x * gi->wsd->size.tile;
562 if (y) *y = gi->y * gi->wsd->size.tile;
563 if (w) *w = gi->wsd->size.tile;
564 if (h) *h = gi->wsd->size.tile;
568 _grid_item_in_viewport(Grid_Item *gi)
570 Evas_Coord vx, vy, vw, vh;
571 Evas_Coord x, y, w, h;
573 EINA_SAFETY_ON_NULL_RETURN_VAL(gi, EINA_FALSE);
575 _viewport_coord_get(gi->wsd, &vx, &vy, &vw, &vh);
576 _grid_item_coord_get(gi, &x, &y, &w, &h);
578 return ELM_RECTS_INTERSECT(x, y, w, h, vx, vy, vw, vh);
582 _loaded_timeout_cb(void *data)
584 Elm_Map_Smart_Data *sd = data;
586 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
588 sd->loaded_timer = NULL;
589 if (!(sd->download_num) && !(sd->download_idler))
590 evas_object_smart_callback_call
591 (ELM_WIDGET_DATA(sd)->obj, SIG_LOADED, NULL);
592 return ECORE_CALLBACK_CANCEL;
596 _grid_item_update(Grid_Item *gi)
600 EINA_SAFETY_ON_NULL_RETURN(gi);
602 evas_object_image_file_set(gi->img, gi->file, NULL);
603 if (!gi->wsd->zoom_timer && !gi->wsd->scr_timer)
604 evas_object_image_smooth_scale_set(gi->img, EINA_TRUE);
605 else evas_object_image_smooth_scale_set(gi->img, EINA_FALSE);
607 err = evas_object_image_load_error_get(gi->img);
608 if (err != EVAS_LOAD_ERROR_NONE)
610 ERR("Image loading error (%s): %s", gi->file, evas_load_error_str(err));
611 ecore_file_remove(gi->file);
612 gi->file_have = EINA_FALSE;
616 Evas_Coord x, y, w, h;
618 _grid_item_coord_get(gi, &x, &y, &w, &h);
619 _coord_to_canvas_no_rotation(gi->wsd, x, y, &x, &y);
620 _obj_place(gi->img, x, y, w, h);
621 _obj_rotate(gi->wsd, gi->img);
622 gi->file_have = EINA_TRUE;
625 if (gi->wsd->loaded_timer) ecore_timer_del(gi->wsd->loaded_timer);
626 gi->wsd->loaded_timer = ecore_timer_add(0.25, _loaded_timeout_cb, gi->wsd);
630 _grid_item_load(Grid_Item *gi)
632 EINA_SAFETY_ON_NULL_RETURN(gi);
634 if (gi->file_have) _grid_item_update(gi);
637 gi->wsd->download_list = eina_list_remove(gi->wsd->download_list, gi);
638 gi->wsd->download_list = eina_list_append(gi->wsd->download_list, gi);
643 _grid_item_unload(Grid_Item *gi)
645 EINA_SAFETY_ON_NULL_RETURN(gi);
649 evas_object_hide(gi->img);
650 evas_object_image_file_set(gi->img, NULL, NULL);
654 ecore_file_download_abort(gi->job);
655 ecore_file_remove(gi->file);
659 else gi->wsd->download_list = eina_list_remove(gi->wsd->download_list, gi);
663 _grid_item_create(Grid *g,
672 EINA_SAFETY_ON_NULL_RETURN_VAL(g, NULL);
674 gi = ELM_NEW(Grid_Item);
680 gi->file_have = EINA_FALSE;
683 gi->img = evas_object_image_add
684 (evas_object_evas_get(ELM_WIDGET_DATA(g->wsd)->obj));
685 evas_object_image_smooth_scale_set(gi->img, EINA_FALSE);
686 evas_object_image_scale_hint_set(gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
687 evas_object_image_filled_set(gi->img, EINA_TRUE);
688 evas_object_smart_member_add(gi->img, g->wsd->pan_obj);
689 evas_object_pass_events_set(gi->img, EINA_TRUE);
690 evas_object_stack_below(gi->img, g->wsd->sep_maps_overlays);
693 const char *cachedir;
696 snprintf(buf, sizeof(buf), "%s" CACHE_TILE_ROOT, efreet_cache_home_get(),
697 g->wsd->id, g->zoom, x);
700 cachedir = getenv("XDG_CACHE_HOME");
701 snprintf(buf, sizeof(buf), "%s/%s" CACHE_TILE_ROOT, getenv("HOME"),
702 cachedir ? : "/.config", g->wsd->id, g->zoom, x);
706 snprintf(buf2, sizeof(buf2), CACHE_TILE_PATH, buf, y);
707 if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
709 eina_stringshare_replace(&gi->file, buf2);
710 url = g->wsd->src_tile->url_cb(ELM_WIDGET_DATA(g->wsd)->obj, x, y, g->zoom);
711 if ((!url) || (!strlen(url)))
713 eina_stringshare_replace(&gi->url, NULL);
714 ERR("Getting source url failed: %s", gi->file);
716 else eina_stringshare_replace(&gi->url, url);
719 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
725 _grid_item_free(Grid_Item *gi)
727 EINA_SAFETY_ON_NULL_RETURN(gi);
729 _grid_item_unload(gi);
730 if (gi->g && gi->g->grid)
731 eina_matrixsparse_data_idx_set(gi->g->grid, gi->y, gi->x, NULL);
732 if (gi->url) eina_stringshare_del(gi->url);
733 if (gi->file_have) ecore_file_remove(gi->file);
734 if (gi->file) eina_stringshare_del(gi->file);
735 if (gi->img) evas_object_del(gi->img);
741 _downloaded_cb(void *data,
742 const char *file __UNUSED__,
745 Grid_Item *gi = data;
749 DBG("Download success from %s to %s", gi->url, gi->file);
751 _grid_item_update(gi);
752 gi->wsd->finish_num++;
753 evas_object_smart_callback_call
754 (ELM_WIDGET_DATA(gi->wsd)->obj, SIG_TILE_LOADED, NULL);
758 WRN("Download failed from %s to %s (%d) ", gi->url, gi->file, status);
760 ecore_file_remove(gi->file);
761 gi->file_have = EINA_FALSE;
762 evas_object_smart_callback_call
763 (ELM_WIDGET_DATA(gi->wsd)->obj, SIG_TILE_LOADED_FAIL, NULL);
767 gi->wsd->download_num--;
768 if (!gi->wsd->download_num)
769 edje_object_signal_emit(ELM_WIDGET_DATA(gi->wsd)->resize_obj,
770 "elm,state,busy,stop", "elm");
774 _download_job(void *data)
776 Elm_Map_Smart_Data *sd = data;
780 if (!eina_list_count(sd->download_list))
782 sd->download_idler = NULL;
783 return ECORE_CALLBACK_CANCEL;
786 EINA_LIST_REVERSE_FOREACH_SAFE(sd->download_list, l, ll, gi)
790 if ((gi->g->zoom != sd->zoom) || !(_grid_item_in_viewport(gi)))
792 sd->download_list = eina_list_remove(sd->download_list, gi);
795 if (sd->download_num >= MAX_CONCURRENT_DOWNLOAD)
796 return ECORE_CALLBACK_RENEW;
798 ret = ecore_file_download_full
799 (gi->url, gi->file, _downloaded_cb, NULL, gi, &(gi->job), sd->ua);
801 if ((!ret) || (!gi->job))
802 ERR("Can't start to download from %s to %s", gi->url, gi->file);
805 sd->download_list = eina_list_remove(sd->download_list, gi);
808 evas_object_smart_callback_call
809 (ELM_WIDGET_DATA(sd)->obj, SIG_TILE_LOAD, NULL);
810 if (sd->download_num == 1)
811 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
812 "elm,state,busy,start", "elm");
816 return ECORE_CALLBACK_RENEW;
820 _grid_viewport_get(Grid *g,
827 Evas_Coord vx, vy, vw, vh;
829 EINA_SAFETY_ON_NULL_RETURN(g);
831 _viewport_coord_get(g->wsd, &vx, &vy, &vw, &vh);
835 xx = (vx / g->wsd->size.tile) - 1;
838 yy = (vy / g->wsd->size.tile) - 1;
841 ww = (vw / g->wsd->size.tile) + 3;
842 if (xx + ww >= g->tw) ww = g->tw - xx;
844 hh = (vh / g->wsd->size.tile) + 3;
845 if (yy + hh >= g->th) hh = g->th - yy;
854 _grid_unload(Grid *g)
856 Eina_Matrixsparse_Cell *cell;
860 EINA_SAFETY_ON_NULL_RETURN(g);
862 it = eina_matrixsparse_iterator_new(g->grid);
863 EINA_ITERATOR_FOREACH(it, cell)
865 gi = eina_matrixsparse_cell_data_get(cell);
866 _grid_item_unload(gi);
868 eina_iterator_free(it);
874 Eina_Matrixsparse_Cell *cell;
875 int x, y, xx, yy, ww, hh;
879 EINA_SAFETY_ON_NULL_RETURN(g);
881 it = eina_matrixsparse_iterator_new(g->grid);
882 EINA_ITERATOR_FOREACH(it, cell)
884 gi = eina_matrixsparse_cell_data_get(cell);
885 if (!_grid_item_in_viewport(gi)) _grid_item_unload(gi);
887 eina_iterator_free(it);
889 _grid_viewport_get(g, &xx, &yy, &ww, &hh);
890 for (y = yy; y < yy + hh; y++)
892 for (x = xx; x < xx + ww; x++)
894 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
895 if (!gi) gi = _grid_item_create(g, x, y);
902 _grid_place(Elm_Map_Smart_Data *sd)
907 EINA_SAFETY_ON_NULL_RETURN(sd);
909 EINA_LIST_FOREACH(sd->grids, l, g)
911 if (sd->zoom == g->zoom) _grid_load(g);
912 else _grid_unload(g);
914 if (!sd->download_idler)
915 sd->download_idler = ecore_idler_add(_download_job, sd);
919 _grid_all_create(Elm_Map_Smart_Data *sd)
923 EINA_SAFETY_ON_NULL_RETURN(sd->src_tile);
925 for (zoom = sd->src_tile->zoom_min; zoom <= sd->src_tile->zoom_max; zoom++)
933 tnum = pow(2.0, g->zoom);
936 g->grid = eina_matrixsparse_new(g->th, g->tw, NULL, NULL);
937 sd->grids = eina_list_append(sd->grids, g);
942 _grid_all_clear(Elm_Map_Smart_Data *sd)
946 EINA_SAFETY_ON_NULL_RETURN(sd);
948 EINA_LIST_FREE (sd->grids, g)
950 Eina_Matrixsparse_Cell *cell;
951 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
953 EINA_ITERATOR_FOREACH(it, cell)
957 gi = eina_matrixsparse_cell_data_get(cell);
958 if (gi) _grid_item_free(gi);
960 eina_iterator_free(it);
962 eina_matrixsparse_free(g->grid);
968 _track_place(Elm_Map_Smart_Data *sd)
974 Evas_Coord px, py, ow, oh;
975 int xmin, xmax, ymin, ymax;
979 _viewport_coord_get(sd, NULL, NULL, &ow, &oh);
983 EINA_LIST_FOREACH(sd->track, l, route)
985 double lon_min, lon_max;
986 double lat_min, lat_max;
988 elm_route_longitude_min_max_get(route, &lon_min, &lon_max);
989 elm_route_latitude_min_max_get(route, &lat_min, &lat_max);
990 _region_to_coord_convert(sd, lon_min, lat_max, size, &xmin, &ymin);
991 _region_to_coord_convert(sd, lon_max, lat_min, size, &xmax, &ymax);
993 if ( !(xmin < px && xmax < px) && !(xmin > px + ow && xmax > px + ow))
995 if ((ymin < py && ymax < py) ||
996 (ymin > py + oh && ymax > py + oh))
999 evas_object_move(route, xmin - px, ymin - py);
1000 evas_object_resize(route, xmax - xmin, ymax - ymin);
1002 evas_object_raise(route);
1003 _obj_rotate(sd, route);
1004 evas_object_show(route);
1009 //the route is not display
1010 evas_object_hide(route);
1018 _smooth_update(Elm_Map_Smart_Data *sd)
1023 EINA_LIST_FOREACH(sd->grids, l, g)
1025 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1026 Eina_Matrixsparse_Cell *cell;
1028 EINA_ITERATOR_FOREACH(it, cell)
1030 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1031 if (_grid_item_in_viewport(gi))
1032 evas_object_image_smooth_scale_set(gi->img, EINA_TRUE);
1034 eina_iterator_free(it);
1039 _zoom_timeout_cb(void *data)
1041 Elm_Map_Smart_Data *sd = data;
1044 sd->zoom_timer = NULL;
1045 evas_object_smart_callback_call
1046 (ELM_WIDGET_DATA(sd)->obj, SIG_ZOOM_STOP, NULL);
1048 return ECORE_CALLBACK_CANCEL;
1052 _zoom(Elm_Map_Smart_Data *sd, double zoom, int animation)
1054 if (zoom > sd->zoom_max) zoom = sd->zoom_max;
1055 else if (zoom < sd->zoom_min) zoom = sd->zoom_min;
1057 sd->engine->zoom(ELM_WIDGET_DATA(sd)->obj, zoom, animation);
1058 sd->zoom_detail = zoom;
1059 sd->zoom = ROUND(sd->zoom_detail);
1061 if (strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
1064 if (sd->zoom_timer) ecore_timer_del(sd->zoom_timer);
1066 evas_object_smart_callback_call
1067 (ELM_WIDGET_DATA(sd)->obj, SIG_ZOOM_START, NULL);
1069 sd->zoom_timer = ecore_timer_add(0.25, _zoom_timeout_cb, sd);
1070 evas_object_smart_callback_call
1071 (ELM_WIDGET_DATA(sd)->obj, SIG_ZOOM_CHANGE, NULL);
1075 _sizing_eval(Elm_Map_Smart_Data *sd)
1077 Evas_Coord maxw = -1, maxh = -1;
1079 evas_object_size_hint_max_get(ELM_WIDGET_DATA(sd)->obj, &maxw, &maxh);
1080 evas_object_size_hint_max_set(ELM_WIDGET_DATA(sd)->obj, maxw, maxh);
1084 _changed_size_hints_cb(void *data,
1086 Evas_Object *obj __UNUSED__,
1087 void *event_info __UNUSED__)
1093 _scr_timeout_cb(void *data)
1095 Elm_Map_Smart_Data *sd = data;
1098 sd->scr_timer = NULL;
1099 evas_object_smart_callback_call
1100 (ELM_WIDGET_DATA(sd)->obj, SIG_SCROLL_DRAG_STOP, NULL);
1102 return ECORE_CALLBACK_CANCEL;
1106 _scroll_cb(Evas_Object *obj,
1107 void *data __UNUSED__)
1109 ELM_MAP_DATA_GET(obj, sd);
1111 if (sd->scr_timer) ecore_timer_del(sd->scr_timer);
1113 evas_object_smart_callback_call
1114 (ELM_WIDGET_DATA(sd)->obj, SIG_SCROLL_DRAG_START, NULL);
1115 sd->scr_timer = ecore_timer_add(0.25, _scr_timeout_cb, sd);
1116 evas_object_smart_callback_call(ELM_WIDGET_DATA(sd)->obj, SIG_SCROLL, NULL);
1120 _scroll_animate_start_cb(Evas_Object *obj,
1121 void *data __UNUSED__)
1123 ELM_MAP_DATA_GET(obj, sd);
1125 evas_object_smart_callback_call
1126 (ELM_WIDGET_DATA(sd)->obj, SIG_SCROLL_ANIM_START, NULL);
1130 _scroll_animate_stop_cb(Evas_Object *obj,
1131 void *data __UNUSED__)
1133 ELM_MAP_DATA_GET(obj, sd);
1135 evas_object_smart_callback_call
1136 (ELM_WIDGET_DATA(sd)->obj, SIG_SCROLL_ANIM_STOP, NULL);
1140 _long_press_cb(void *data)
1142 Elm_Map_Smart_Data *sd = data;
1144 sd->long_timer = NULL;
1145 evas_object_smart_callback_call
1146 (ELM_WIDGET_DATA(sd)->obj, SIG_LONGPRESSED, &sd->ev);
1148 return ECORE_CALLBACK_CANCEL;
1152 _mouse_down_cb(void *data,
1153 Evas *evas __UNUSED__,
1154 Evas_Object *obj __UNUSED__,
1157 Elm_Map_Smart_Data *sd = data;
1158 Evas_Event_Mouse_Down *ev = event_info;
1160 if (ev->button != 1) return;
1161 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE;
1162 else sd->on_hold = EINA_FALSE;
1164 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1165 evas_object_smart_callback_call
1166 (ELM_WIDGET_DATA(sd)->obj, SIG_CLICKED_DOUBLE, ev);
1168 evas_object_smart_callback_call
1169 (ELM_WIDGET_DATA(sd)->obj, SIG_PRESS, ev);
1171 if (sd->long_timer) ecore_timer_del(sd->long_timer);
1174 ecore_timer_add(_elm_config->longpress_timeout, _long_press_cb, sd);
1178 _mouse_up_cb(void *data,
1179 Evas *evas __UNUSED__,
1180 Evas_Object *obj __UNUSED__,
1183 Elm_Map_Smart_Data *sd = data;
1184 Evas_Event_Mouse_Up *ev = event_info;
1186 EINA_SAFETY_ON_NULL_RETURN(ev);
1188 if (ev->button != 1) return;
1190 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) sd->on_hold = EINA_TRUE;
1191 else sd->on_hold = EINA_FALSE;
1195 ecore_timer_del(sd->long_timer);
1196 sd->long_timer = NULL;
1200 evas_object_smart_callback_call
1201 (ELM_WIDGET_DATA(sd)->obj, SIG_CLICKED, ev);
1202 sd->on_hold = EINA_FALSE;
1206 _mouse_wheel_cb(void *data,
1208 Evas_Object *obj __UNUSED__,
1211 Elm_Map_Smart_Data *sd = data;
1215 Evas_Event_Mouse_Wheel *ev = event_info;
1217 _zoom(sd, sd->zoom_detail - ((double)ev->z /10), 0);
1222 _region_max_min_get(Eina_List *overlays,
1223 double *max_longitude,
1224 double *min_longitude,
1225 double *max_latitude,
1226 double *min_latitude)
1228 double max_lon = -180, min_lon = 180;
1229 double max_lat = -90, min_lat = 90;
1230 Elm_Map_Overlay *overlay;
1232 EINA_LIST_FREE (overlays, overlay)
1236 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1238 Overlay_Default *ovl = overlay->ovl;
1243 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
1245 // FIXME: class center coord is alright??
1246 Overlay_Class *ovl = overlay->ovl;
1247 double max_lo, min_lo, max_la, min_la;
1250 (ovl->members, &max_lo, &min_lo, &max_la, &min_la);
1251 lon = (max_lo + min_lo) / 2;
1252 lat = (max_la + min_la) / 2;
1254 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
1256 Overlay_Bubble *ovl = overlay->ovl;
1263 WRN("Not supported overlay type: %d", overlay->type);
1266 if (lon > max_lon) max_lon = lon;
1267 if (lon < min_lon) min_lon = lon;
1268 if (lat > max_lat) max_lat = lat;
1269 if (lat < min_lat) min_lat = lat;
1272 if (max_longitude) *max_longitude = max_lon;
1273 if (min_longitude) *min_longitude = min_lon;
1274 if (max_latitude) *max_latitude = max_lat;
1275 if (min_latitude) *min_latitude = min_lat;
1278 static Evas_Object *
1279 _icon_dup(Evas_Object *icon,
1280 Evas_Object *parent)
1285 if (!icon || !parent) return NULL;
1286 dupp = evas_object_image_filled_add(evas_object_evas_get(parent));
1287 evas_object_image_source_set(dupp, icon);
1288 // Set size as origin' sizse for proxy
1289 evas_object_geometry_get(icon, NULL, NULL, &w, &h);
1290 if (w <= 0 || h <= 0)
1292 evas_object_size_hint_min_get(icon, &w, &h);
1293 evas_object_size_hint_min_set(dupp, w, h);
1295 else evas_object_resize(dupp, w, h);
1296 // Original should have size for proxy
1297 evas_object_resize(icon, w, h);
1303 _overlay_clicked_cb(void *data,
1305 Evas_Object *obj __UNUSED__,
1306 void *ev __UNUSED__)
1308 Elm_Map_Overlay *overlay = data;
1310 EINA_SAFETY_ON_NULL_RETURN(data);
1312 evas_object_smart_callback_call
1313 (ELM_WIDGET_DATA(overlay->wsd)->obj, SIG_OVERLAY_CLICKED, overlay);
1315 overlay->cb(overlay->cb_data, ELM_WIDGET_DATA(overlay->wsd)->obj, overlay);
1319 _overlay_default_hide(Overlay_Default *ovl)
1321 EINA_SAFETY_ON_NULL_RETURN(ovl);
1323 if (ovl->content) evas_object_hide(ovl->content);
1324 if (ovl->icon) evas_object_hide(ovl->icon);
1325 if (ovl->clas_content) evas_object_hide(ovl->clas_content);
1326 if (ovl->clas_icon) evas_object_hide(ovl->clas_icon);
1327 if (ovl->layout) evas_object_hide(ovl->layout);
1331 _overlay_default_show(Overlay_Default *ovl)
1334 Evas_Coord x, y, w, h;
1336 EINA_SAFETY_ON_NULL_RETURN(ovl);
1338 evas_object_hide(ovl->layout);
1341 disp = ovl->content;
1342 evas_object_geometry_get(disp, NULL, NULL, &w, &h);
1343 if (w <= 0 || h <= 0) evas_object_size_hint_min_get(disp, &w, &h);
1347 else if (!(ovl->icon) && ovl->clas_content)
1349 disp = ovl->clas_content;
1351 evas_object_geometry_get(disp, NULL, NULL, &w, &h);
1352 if (w <= 0 || h <= 0) evas_object_size_hint_min_get(disp, &w, &h);
1356 if (ovl->icon) evas_object_show(ovl->icon);
1357 else if (ovl->clas_icon)
1358 evas_object_show(ovl->clas_icon);
1363 _coord_to_canvas(ovl->wsd, ovl->x, ovl->y, &x, &y);
1365 if (!strcmp(ovl->wsd->engine->name, INTERNAL_ENGINE_NAME))
1366 _obj_place(disp, x - (w / 2), y - (h / 2), w, h);
1368 _obj_place(disp, ovl->x - (w / 2), ovl->y - (h / 2), w, h);
1372 _overlay_default_coord_get(Overlay_Default *ovl,
1378 EINA_SAFETY_ON_NULL_RETURN(ovl);
1387 _overlay_default_coord_set(Overlay_Default *ovl,
1391 EINA_SAFETY_ON_NULL_RETURN(ovl);
1398 _overlay_default_coord_update(Overlay_Default *ovl)
1400 EINA_SAFETY_ON_NULL_RETURN(ovl);
1402 _region_to_coord_convert
1403 (ovl->wsd, ovl->lon, ovl->lat, ovl->wsd->size.w, &ovl->x, &ovl->y);
1407 _overlay_default_layout_text_update(Overlay_Default *ovl,
1410 if (!ovl->content && !ovl->icon && !ovl->clas_content && !ovl->clas_icon)
1411 elm_layout_text_set(ovl->layout, "elm.text", text);
1415 _overlay_default_content_update(Overlay_Default *ovl,
1416 Evas_Object *content,
1417 Elm_Map_Overlay *overlay)
1419 EINA_SAFETY_ON_NULL_RETURN(ovl);
1421 if (ovl->content == content) return;
1422 if (ovl->content) evas_object_del(ovl->content);
1423 ovl->content = content;
1424 if (!strcmp(ovl->wsd->engine->name, INTERNAL_ENGINE_NAME))
1425 evas_object_smart_member_add(ovl->content, ovl->wsd->pan_obj);
1427 evas_object_smart_member_add(ovl->content, ELM_WIDGET_DATA(ovl->wsd)->obj);
1428 evas_object_stack_above(ovl->content, ovl->wsd->sep_maps_overlays);
1431 evas_object_event_callback_add(ovl->content, EVAS_CALLBACK_MOUSE_DOWN,
1432 _overlay_clicked_cb, overlay);
1436 _overlay_default_layout_update(Overlay_Default *ovl)
1438 EINA_SAFETY_ON_NULL_RETURN(ovl);
1442 evas_object_color_set(ovl->layout, 255, 255, 255, 255);
1443 elm_layout_theme_set
1444 (ovl->layout, "map/marker", "empty",
1445 elm_widget_style_get(ELM_WIDGET_DATA(ovl->wsd)->obj));
1446 elm_object_part_content_set(ovl->layout, "elm.icon", ovl->icon);
1448 else if (!ovl->icon && ovl->clas_icon)
1450 evas_object_color_set(ovl->layout, 255, 255, 255, 255);
1451 elm_layout_theme_set
1452 (ovl->layout, "map/marker", "empty",
1453 elm_widget_style_get(ELM_WIDGET_DATA(ovl->wsd)->obj));
1454 elm_object_part_content_set(ovl->layout, "elm.icon", ovl->clas_icon);
1458 evas_object_color_set
1459 (ovl->layout, ovl->c.r, ovl->c.g, ovl->c.b, ovl->c.a);
1460 elm_layout_theme_set
1461 (ovl->layout, "map/marker", "radio",
1462 elm_widget_style_get(ELM_WIDGET_DATA(ovl->wsd)->obj));
1467 _overlay_default_class_content_update(Overlay_Default *ovl,
1468 Evas_Object *content)
1470 EINA_SAFETY_ON_NULL_RETURN(ovl);
1472 if (ovl->clas_content) evas_object_del(ovl->clas_content);
1473 ovl->clas_content = _icon_dup(content, ovl->layout);
1474 if (!strcmp(ovl->wsd->engine->name, INTERNAL_ENGINE_NAME))
1475 evas_object_smart_member_add(ovl->clas_content, ovl->wsd->pan_obj);
1477 evas_object_smart_member_add(ovl->clas_content, ELM_WIDGET_DATA(ovl->wsd)->obj);
1478 evas_object_stack_above(ovl->clas_content, ovl->wsd->sep_maps_overlays);
1479 _overlay_default_layout_update(ovl);
1483 _overlay_default_icon_update(Overlay_Default *ovl,
1486 EINA_SAFETY_ON_NULL_RETURN(ovl);
1488 if (ovl->icon == icon) return;
1490 if (ovl->icon) evas_object_del(ovl->icon);
1492 _overlay_default_layout_update(ovl);
1496 _overlay_default_class_icon_update(Overlay_Default *ovl,
1499 EINA_SAFETY_ON_NULL_RETURN(ovl);
1501 if (ovl->clas_icon) evas_object_del(ovl->clas_icon);
1502 ovl->clas_icon = _icon_dup(icon, ovl->layout);
1503 _overlay_default_layout_update(ovl);
1507 _overlay_default_color_update(Overlay_Default *ovl,
1510 EINA_SAFETY_ON_NULL_RETURN(ovl);
1513 _overlay_default_layout_update(ovl);
1517 _overlay_default_free(Overlay_Default *ovl)
1519 EINA_SAFETY_ON_NULL_RETURN(ovl);
1521 if (ovl->content) evas_object_del(ovl->content);
1522 if (ovl->icon) evas_object_del(ovl->icon);
1523 if (ovl->clas_content) evas_object_del(ovl->clas_content);
1524 if (ovl->clas_icon) evas_object_del(ovl->clas_icon);
1525 if (ovl->layout) evas_object_del(ovl->layout);
1530 static Overlay_Default *
1531 _overlay_default_new(Elm_Map_Overlay *overlay,
1537 Overlay_Default *ovl;
1539 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
1541 ovl = ELM_NEW(Overlay_Default);
1542 ovl->wsd = overlay->wsd;
1543 _edj_overlay_size_get(ovl->wsd, &(ovl->w), &(ovl->h));
1546 ovl->layout = elm_layout_add(ELM_WIDGET_DATA(ovl->wsd)->obj);
1547 if (!strcmp(ovl->wsd->engine->name, INTERNAL_ENGINE_NAME))
1548 evas_object_smart_member_add(ovl->layout, ovl->wsd->pan_obj);
1550 evas_object_smart_member_add(ovl->layout, ELM_WIDGET_DATA(ovl->wsd)->obj);
1551 evas_object_stack_above(ovl->layout, ovl->wsd->sep_maps_overlays);
1552 elm_layout_theme_set(ovl->layout, "map/marker", "radio",
1553 elm_widget_style_get(ELM_WIDGET_DATA(ovl->wsd)->obj));
1554 evas_object_event_callback_add(ovl->layout, EVAS_CALLBACK_MOUSE_DOWN,
1555 _overlay_clicked_cb, overlay);
1558 _overlay_default_color_update(ovl, c);
1564 _overlay_group_hide(Overlay_Group *grp)
1566 EINA_SAFETY_ON_NULL_RETURN(grp);
1568 if (grp->ovl) _overlay_default_hide(grp->ovl);
1572 _overlay_group_show(Overlay_Group *grp)
1574 EINA_SAFETY_ON_NULL_RETURN(grp);
1576 if (grp->ovl) _overlay_default_show(grp->ovl);
1580 _overlay_group_coord_member_update(Overlay_Group *grp,
1587 EINA_SAFETY_ON_NULL_RETURN(grp);
1589 if (!grp->ovl) return;
1591 _overlay_default_coord_set(grp->ovl, x, y);
1592 _coord_to_region_convert
1593 (grp->wsd, x, y, grp->wsd->size.w, &grp->lon, &grp->lat);
1595 if (grp->members) eina_list_free(grp->members);
1596 grp->members = members;
1597 snprintf(text, sizeof(text), "%d", eina_list_count(members));
1599 _overlay_default_layout_text_update(grp->ovl, text);
1603 _overlay_group_icon_update(Overlay_Group *grp,
1606 EINA_SAFETY_ON_NULL_RETURN(grp);
1609 _overlay_default_icon_update
1610 (grp->ovl, _icon_dup(icon, ELM_WIDGET_DATA(grp->wsd)->obj));
1614 _overlay_group_content_update(Overlay_Group *grp,
1615 Evas_Object *content,
1616 Elm_Map_Overlay *overlay)
1618 EINA_SAFETY_ON_NULL_RETURN(grp);
1620 _overlay_default_content_update
1621 (grp->ovl, _icon_dup(content, ELM_WIDGET_DATA(grp->wsd)->obj), overlay);
1627 _overlay_group_color_update(Overlay_Group *grp,
1630 EINA_SAFETY_ON_NULL_RETURN(grp);
1632 _overlay_default_color_update(grp->ovl, c);
1636 _overlay_group_cb_set(Overlay_Group *grp,
1637 Elm_Map_Overlay_Get_Cb cb,
1640 EINA_SAFETY_ON_NULL_RETURN(grp);
1642 grp->overlay->cb = cb;
1643 grp->overlay->data = data;
1647 _overlay_group_free(Overlay_Group *grp)
1649 EINA_SAFETY_ON_NULL_RETURN(grp);
1651 if (grp->overlay) free(grp->overlay);
1652 if (grp->ovl) _overlay_default_free(grp->ovl);
1653 if (grp->members) eina_list_free(grp->members);
1658 static Overlay_Group *
1659 _overlay_group_new(Elm_Map_Smart_Data *sd)
1662 Color c = {0x90, 0xee, 0x90, 0xff};
1664 grp = ELM_NEW(Overlay_Group);
1666 grp->overlay = ELM_NEW(Elm_Map_Overlay); // this is a virtual overlay
1667 grp->overlay->wsd = sd;
1668 grp->overlay->type = ELM_MAP_OVERLAY_TYPE_GROUP;
1669 grp->overlay->ovl = grp;
1670 grp->ovl = _overlay_default_new(grp->overlay, -1, -1, c, 1);
1676 _overlay_class_cb_set(Overlay_Class *ovl,
1677 Elm_Map_Overlay_Get_Cb cb,
1681 Elm_Map_Overlay *overlay;
1683 EINA_SAFETY_ON_NULL_RETURN(ovl);
1685 // Update class members' callbacks
1686 EINA_LIST_FOREACH(ovl->members, l, overlay)
1687 _overlay_group_cb_set(overlay->grp, cb, data);
1691 _overlay_class_icon_update(Overlay_Class *ovl,
1695 Elm_Map_Overlay *overlay;
1697 EINA_SAFETY_ON_NULL_RETURN(ovl);
1699 if (ovl->icon == icon) return;
1700 if (ovl->icon) evas_object_del(ovl->icon);
1702 // For using proxy, it should have size and be shown but moved away to hide.
1703 evas_object_resize(icon, 32, 32);
1704 evas_object_move(icon, -9999, -9999);
1705 evas_object_show(icon);
1707 // Update class members' class icons
1708 EINA_LIST_FOREACH(ovl->members, l, overlay)
1710 _overlay_group_icon_update(overlay->grp, icon);
1712 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1713 _overlay_default_class_icon_update(overlay->ovl, icon);
1718 _overlay_class_content_update(Overlay_Class *ovl,
1719 Evas_Object *content)
1722 Elm_Map_Overlay *overlay;
1724 EINA_SAFETY_ON_NULL_RETURN(ovl);
1726 if (ovl->content == content) return;
1727 if (ovl->content) evas_object_del(ovl->content);
1728 ovl->content = content;
1729 // For using proxy, it should have size and be shown but moved away to hide.
1730 // content should have it's own size
1731 evas_object_move(content, -9999, -9999);
1733 // Update class members' class contents
1734 EINA_LIST_FOREACH(ovl->members, l, overlay)
1736 _overlay_group_content_update(overlay->grp, content, overlay);
1738 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1739 _overlay_default_class_content_update(overlay->ovl, content);
1744 _overlay_class_color_update(Overlay_Class *ovl,
1748 Elm_Map_Overlay *overlay;
1750 EINA_SAFETY_ON_NULL_RETURN(ovl);
1752 // Update class members' class contents
1753 EINA_LIST_FOREACH(ovl->members, l, overlay)
1754 _overlay_group_color_update(overlay->grp, c);
1758 _overlay_class_free(Overlay_Class *clas)
1761 Elm_Map_Overlay *overlay;
1763 EINA_SAFETY_ON_NULL_RETURN(clas);
1765 // Update class members' class contents
1766 EINA_LIST_FOREACH(clas->members, l, overlay)
1768 overlay->grp->klass = NULL;
1769 _overlay_group_content_update(overlay->grp, NULL, NULL);
1770 _overlay_group_icon_update(overlay->grp, NULL);
1772 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
1774 _overlay_default_class_content_update(overlay->ovl, NULL);
1775 _overlay_default_class_icon_update(overlay->ovl, NULL);
1778 if (clas->icon) evas_object_del(clas->icon);
1779 if (clas->members) eina_list_free(clas->members);
1784 static Overlay_Class *
1785 _overlay_class_new(Elm_Map_Smart_Data *sd)
1789 ovl = ELM_NEW(Overlay_Class);
1792 ovl->zoom_max = OVERLAY_CLASS_ZOOM_MAX;
1798 _overlay_bubble_coord_update(Overlay_Bubble *bubble)
1800 EINA_SAFETY_ON_NULL_RETURN(bubble);
1804 Evas_Coord x, y, w, h;
1806 evas_object_geometry_get(bubble->pobj, &x, &y, &w, &h);
1807 bubble->x = x + (w / 2);
1808 bubble->y = y - (bubble->h / 2);
1810 (bubble->wsd, bubble->x, bubble->y, &(bubble->x), &(bubble->y));
1811 _coord_to_region_convert
1812 (bubble->wsd, bubble->x, bubble->y, bubble->wsd->size.w,
1813 &(bubble->lon), &(bubble->lat));
1817 _region_to_coord_convert(bubble->wsd, bubble->lon, bubble->lat,
1818 bubble->wsd->size.w, &bubble->x, &bubble->y);
1823 _overlay_bubble_coord_get(Overlay_Bubble *bubble,
1829 EINA_SAFETY_ON_NULL_RETURN(bubble);
1831 if (!(bubble->pobj))
1833 if (x) *x = bubble->x;
1834 if (y) *y = bubble->y;
1835 if (w) *w = bubble->w;
1836 if (h) *h = bubble->h;
1848 _overlay_bubble_show_hide(Overlay_Bubble *bubble,
1851 EINA_SAFETY_ON_NULL_RETURN_VAL(bubble, EINA_FALSE);
1852 EINA_SAFETY_ON_NULL_RETURN_VAL(bubble->obj, EINA_FALSE);
1854 if (!visible) evas_object_hide(bubble->obj);
1855 else if (bubble->pobj && !evas_object_visible_get(bubble->pobj))
1857 evas_object_hide(bubble->obj);
1858 visible = EINA_FALSE;
1863 (bubble->wsd, bubble->x, bubble->y, &(bubble->x), &(bubble->y));
1864 _obj_place(bubble->obj, bubble->x - (bubble->w / 2),
1865 bubble->y - (bubble->h / 2), bubble->w, bubble->h);
1866 evas_object_raise(bubble->obj);
1872 _overlay_bubble_free(Overlay_Bubble *bubble)
1874 EINA_SAFETY_ON_NULL_RETURN(bubble);
1876 evas_object_del(bubble->bx);
1877 evas_object_del(bubble->sc);
1878 evas_object_del(bubble->obj);
1883 static Overlay_Bubble *
1884 _overlay_bubble_new(Elm_Map_Overlay *overlay)
1888 Overlay_Bubble *bubble;
1890 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
1892 bubble = ELM_NEW(Overlay_Bubble);
1893 bubble->wsd = overlay->wsd;
1896 edje_object_add(evas_object_evas_get(ELM_WIDGET_DATA(overlay->wsd)->obj));
1897 elm_widget_theme_object_set
1898 (ELM_WIDGET_DATA(overlay->wsd)->obj, bubble->obj, "map", "marker_bubble",
1899 elm_widget_style_get(ELM_WIDGET_DATA(overlay->wsd)->obj));
1901 evas_object_event_callback_add(bubble->obj, EVAS_CALLBACK_MOUSE_DOWN,
1902 _overlay_clicked_cb, overlay);
1904 bubble->sc = elm_scroller_add(bubble->obj);
1905 elm_widget_style_set(bubble->sc, "map_bubble");
1906 elm_scroller_content_min_limit(bubble->sc, EINA_FALSE, EINA_TRUE);
1907 elm_scroller_policy_set
1908 (bubble->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
1909 elm_scroller_bounce_set
1910 (bubble->sc, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
1911 edje_object_part_swallow(bubble->obj, "elm.swallow.content", bubble->sc);
1913 bubble->bx = elm_box_add(bubble->sc);
1914 evas_object_size_hint_align_set(bubble->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1915 evas_object_size_hint_weight_set
1916 (bubble->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1917 elm_box_horizontal_set(bubble->bx, EINA_TRUE);
1918 elm_object_content_set(bubble->sc, bubble->bx);
1920 s = edje_object_data_get(bubble->obj, "size_w");
1921 if (s) bubble->w = atoi(s);
1924 edje_object_size_min_calc(bubble->obj, NULL, &(bubble->h));
1925 s = edje_object_data_get(bubble->obj, "size_h");
1929 if (bubble->h < h) bubble->h = h;
1940 _overlay_route_color_update(Overlay_Route *ovl,
1943 EINA_SAFETY_ON_NULL_RETURN(ovl);
1945 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
1949 _overlay_route_hide(Overlay_Route *ovl)
1951 EINA_SAFETY_ON_NULL_RETURN(ovl);
1953 evas_object_hide(ovl->obj);
1957 _overlay_route_show(Overlay_Route *r)
1963 EINA_SAFETY_ON_NULL_RETURN(r);
1964 EINA_SAFETY_ON_NULL_RETURN(r->wsd);
1966 evas_object_polygon_points_clear(r->obj);
1967 EINA_LIST_FOREACH(r->nodes, l, n)
1969 p = eina_list_nth(r->paths, n->idx);
1972 _region_to_coord_convert
1973 (r->wsd, n->pos.lon, n->pos.lat, r->wsd->size.w, &p->x, &p->y);
1974 _coord_to_canvas(r->wsd, p->x, p->y, &p->x, &p->y);
1976 EINA_LIST_FOREACH(r->paths, l, p)
1977 evas_object_polygon_point_add(r->obj, p->x - 3, p->y - 3);
1979 EINA_LIST_REVERSE_FOREACH(r->paths, l, p)
1980 evas_object_polygon_point_add(r->obj, p->x + 3, p->y + 3);
1982 evas_object_show(r->obj);
1986 _overlay_route_free(Overlay_Route *route)
1991 EINA_SAFETY_ON_NULL_RETURN(route);
1993 evas_object_del(route->obj);
1995 EINA_LIST_FREE (route->paths, p)
1998 EINA_LIST_FREE (route->nodes, n)
2000 if (n->pos.address) eina_stringshare_del(n->pos.address);
2007 static Overlay_Route *
2008 _overlay_route_new(Elm_Map_Smart_Data *sd,
2009 const Elm_Map_Route *route,
2016 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
2018 ovl = ELM_NEW(Overlay_Route);
2021 evas_object_polygon_add(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
2022 if (!strcmp(ovl->wsd->engine->name, INTERNAL_ENGINE_NAME))
2023 evas_object_smart_member_add(ovl->obj, sd->pan_obj);
2025 evas_object_smart_member_add(ovl->obj, ELM_WIDGET_DATA(ovl->wsd)->obj);
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);
2049 _overlay_line_color_update(Overlay_Line *ovl,
2052 EINA_SAFETY_ON_NULL_RETURN(ovl);
2054 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2058 _overlay_line_hide(Overlay_Line *ovl)
2060 EINA_SAFETY_ON_NULL_RETURN(ovl);
2062 if (ovl->obj) evas_object_hide(ovl->obj);
2066 _overlay_line_show(Overlay_Line *ovl)
2068 Evas_Coord fx, fy, tx, ty;
2069 Elm_Map_Smart_Data *sd = ovl->wsd;
2071 _region_to_coord_convert(sd, ovl->flon, ovl->flat, sd->size.w, &fx, &fy);
2072 _region_to_coord_convert(sd, ovl->tlon, ovl->tlat, sd->size.w, &tx, &ty);
2073 _coord_to_canvas(sd, fx, fy, &fx, &fy);
2074 _coord_to_canvas(sd, tx, ty, &tx, &ty);
2075 evas_object_line_xy_set(ovl->obj, fx, fy, tx, ty);
2076 evas_object_show(ovl->obj);
2080 _overlay_line_free(Overlay_Line *ovl)
2082 EINA_SAFETY_ON_NULL_RETURN(ovl);
2084 evas_object_del(ovl->obj);
2088 static Overlay_Line *
2089 _overlay_line_new(Elm_Map_Smart_Data *sd,
2098 ovl = ELM_NEW(Overlay_Line);
2105 evas_object_line_add(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
2106 evas_object_smart_member_add(ovl->obj, sd->pan_obj);
2107 _overlay_line_color_update(ovl, c);
2113 _overlay_polygon_color_update(Overlay_Polygon *ovl,
2116 EINA_SAFETY_ON_NULL_RETURN(ovl);
2118 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2122 _overlay_polygon_hide(Overlay_Polygon *ovl)
2124 EINA_SAFETY_ON_NULL_RETURN(ovl);
2126 if (ovl->obj) evas_object_hide(ovl->obj);
2130 _overlay_polygon_show(Overlay_Polygon *ovl)
2134 Elm_Map_Smart_Data *sd;
2136 EINA_SAFETY_ON_NULL_RETURN(ovl);
2140 evas_object_polygon_points_clear(ovl->obj);
2141 EINA_LIST_FOREACH(ovl->regions, l, r)
2145 _region_to_coord_convert(sd, r->lon, r->lat, sd->size.w, &x, &y);
2146 _coord_to_canvas(sd, x, y, &x, &y);
2147 evas_object_polygon_point_add(ovl->obj, x, y);
2149 evas_object_show(ovl->obj);
2153 _overlay_polygon_free(Overlay_Polygon *ovl)
2157 EINA_SAFETY_ON_NULL_RETURN(ovl);
2159 evas_object_del(ovl->obj);
2161 EINA_LIST_FREE (ovl->regions, r)
2167 static Overlay_Polygon *
2168 _overlay_polygon_new(Elm_Map_Smart_Data *sd, Color c)
2170 Overlay_Polygon *ovl;
2172 ovl = ELM_NEW(Overlay_Polygon);
2175 evas_object_polygon_add(evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj));
2176 evas_object_smart_member_add(ovl->obj, sd->pan_obj);
2177 _overlay_polygon_color_update(ovl, c);
2183 _overlay_circle_color_update(Overlay_Circle *ovl,
2188 EINA_SAFETY_ON_NULL_RETURN(ovl);
2190 obj = elm_layout_edje_get(ovl->obj);
2191 evas_object_color_set(obj, c.r, c.g, c.b, c.a);
2195 _overlay_circle_hide(Overlay_Circle *ovl)
2197 EINA_SAFETY_ON_NULL_RETURN(ovl);
2199 if (ovl->obj) evas_object_hide(ovl->obj);
2203 _overlay_circle_show(Overlay_Circle *ovl)
2207 Elm_Map_Smart_Data *sd;
2209 EINA_SAFETY_ON_NULL_RETURN(ovl);
2213 r = (ovl->ratio) * sd->size.w;
2214 _region_to_coord_convert(sd, ovl->lon, ovl->lat, sd->size.w, &x, &y);
2215 _coord_to_canvas(sd, x, y, &x, &y);
2216 _obj_place(ovl->obj, x - r, y - r, r * 2, r * 2);
2220 _overlay_circle_free(Overlay_Circle *ovl)
2222 EINA_SAFETY_ON_NULL_RETURN(ovl);
2224 evas_object_del(ovl->obj);
2228 static Overlay_Circle *
2229 _overlay_circle_new(Elm_Map_Smart_Data *sd,
2235 Overlay_Circle *ovl;
2237 ovl = ELM_NEW(Overlay_Circle);
2241 ovl->radius = radius;
2242 ovl->ratio = radius / sd->size.w;
2244 ovl->obj = elm_layout_add(ELM_WIDGET_DATA(sd)->obj);
2245 evas_object_smart_member_add(ovl->obj, sd->pan_obj);
2246 evas_object_stack_above(ovl->obj, sd->sep_maps_overlays);
2247 elm_layout_theme_set(ovl->obj, "map/circle", "base",
2248 elm_widget_style_get(ELM_WIDGET_DATA(sd)->obj));
2249 _overlay_circle_color_update(ovl, c);
2255 _overlay_scale_color_update(Overlay_Scale *ovl,
2258 EINA_SAFETY_ON_NULL_RETURN(ovl);
2260 evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
2264 _overlay_scale_hide(Overlay_Scale *ovl)
2266 EINA_SAFETY_ON_NULL_RETURN(ovl);
2268 if (ovl->obj) evas_object_hide(ovl->obj);
2272 _overlay_scale_show(Overlay_Scale *ovl)
2279 Elm_Map_Smart_Data *sd;
2281 EINA_SAFETY_ON_NULL_RETURN(ovl);
2285 if ((int)(sizeof(_scale_tb)/sizeof(double)) <= sd->zoom)
2287 ERR("Zoom level is too high");
2291 elm_map_region_get(ELM_WIDGET_DATA(sd)->obj, &lon, &lat);
2293 sd->src_tile->scale_cb(ELM_WIDGET_DATA(sd)->obj, lon, lat, sd->zoom);
2297 ERR("Scale callback returns a value below zero");
2301 w = (_scale_tb[sd->zoom] / meter) * (sd->zoom_detail - sd->zoom + 1);
2303 text = _scale_tb[sd->zoom] / 1000;
2304 if (text < 1) snprintf(buf, sizeof(buf), "%d m", (int)(text * 1000));
2305 else snprintf(buf, sizeof(buf), "%d km", (int)text);
2307 elm_layout_text_set(ovl->obj, "elm.text", buf);
2308 _obj_place(ovl->obj, ovl->x, ovl->y, w, ovl->h);
2312 _overlay_scale_free(Overlay_Scale *ovl)
2314 EINA_SAFETY_ON_NULL_RETURN(ovl);
2316 evas_object_del(ovl->obj);
2320 static Overlay_Scale *
2321 _overlay_scale_new(Elm_Map_Smart_Data *sd,
2329 ovl = ELM_NEW(Overlay_Scale);
2334 ovl->obj = elm_layout_add(ELM_WIDGET_DATA(sd)->obj);
2335 evas_object_smart_member_add(ovl->obj, sd->pan_obj);
2336 evas_object_stack_above(ovl->obj, sd->sep_maps_overlays);
2337 elm_layout_theme_set(ovl->obj, "map/scale", "base",
2338 elm_widget_style_get(ELM_WIDGET_DATA(sd)->obj));
2339 s = edje_object_data_get(elm_layout_edje_get(ovl->obj), "size_w");
2341 if (s) ovl->w = atoi(s);
2344 s = edje_object_data_get(elm_layout_edje_get(ovl->obj), "size_h");
2345 if (s) ovl->h = atoi(s);
2348 _overlay_scale_color_update(ovl, c);
2354 _overlay_grouping(Eina_List *clas_membs,
2355 Elm_Map_Overlay *boss)
2358 Elm_Map_Overlay *memb;
2359 Eina_List *grp_membs = NULL;
2360 int sum_x = 0, sum_y = 0, cnt = 0;
2361 Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
2363 EINA_SAFETY_ON_NULL_RETURN(clas_membs);
2364 EINA_SAFETY_ON_NULL_RETURN(boss);
2366 if (boss->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2367 _overlay_default_coord_get(boss->ovl, &bx, &by, &bw, &bh);
2368 else if (boss->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2369 _overlay_bubble_coord_get(boss->ovl, &bx, &by, &bw, &bh);
2371 EINA_LIST_FOREACH(clas_membs, l, memb)
2373 Evas_Coord x = 0, y = 0, w = 0, h = 0;
2375 if (boss == memb || memb->grp->in) continue;
2376 if ((memb->hide) || (memb->zoom_min > memb->wsd->zoom)) continue;
2378 if (memb->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2379 _overlay_default_coord_get(memb->ovl, &x, &y, &w, &h);
2380 else if (memb->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2381 _overlay_bubble_coord_get(memb->ovl, &x, &y, &w, &h);
2383 if (bw <= 0 || bh <= 0 || w <= 0 || h <= 0) continue;
2384 if (ELM_RECTS_INTERSECT(x, y, w, h, bx, by,
2385 bw * OVERLAY_GROUPING_SCALE,
2386 bh * OVERLAY_GROUPING_SCALE))
2389 memb->grp->boss = EINA_FALSE;
2390 memb->grp->in = EINA_TRUE;
2394 grp_membs = eina_list_append(grp_membs, memb);
2401 boss->grp->boss = EINA_TRUE;
2402 boss->grp->in = EINA_TRUE;
2403 sum_x = (sum_x + bx) / (cnt + 1);
2404 sum_y = (sum_y + by) / (cnt + 1);
2405 grp_membs = eina_list_append(grp_membs, boss);
2406 _overlay_group_coord_member_update(boss->grp, sum_x, sum_y, grp_membs);
2408 // Append group to all overlay list
2409 boss->wsd->group_overlays =
2410 eina_list_append(boss->wsd->group_overlays, boss->grp->overlay);
2415 _overlay_show(Elm_Map_Overlay *overlay)
2417 Elm_Map_Smart_Data *sd = overlay->wsd;
2419 if (overlay->paused) return;
2420 if ((overlay->grp) && (overlay->grp->klass) && (overlay->grp->klass->paused))
2423 overlay->visible = EINA_TRUE;
2424 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
2426 overlay->visible = EINA_FALSE;
2431 if ((overlay->grp->in) ||
2432 (overlay->hide) || (overlay->zoom_min > sd->zoom))
2433 overlay->visible = EINA_FALSE;
2435 if ((overlay->grp->klass) &&
2436 ((overlay->grp->klass->hide) ||
2437 (overlay->grp->klass->zoom_min > sd->zoom)))
2438 overlay->visible = EINA_FALSE;
2441 switch (overlay->type)
2443 case ELM_MAP_OVERLAY_TYPE_DEFAULT:
2444 if (overlay->visible) _overlay_default_show(overlay->ovl);
2445 else _overlay_default_hide(overlay->ovl);
2448 case ELM_MAP_OVERLAY_TYPE_GROUP:
2449 if (overlay->visible) _overlay_group_show(overlay->ovl);
2450 else _overlay_group_hide(overlay->ovl);
2453 case ELM_MAP_OVERLAY_TYPE_BUBBLE:
2455 _overlay_bubble_show_hide(overlay->ovl, overlay->visible);
2458 case ELM_MAP_OVERLAY_TYPE_ROUTE:
2459 if (overlay->visible) _overlay_route_show(overlay->ovl);
2460 else _overlay_route_hide(overlay->ovl);
2463 case ELM_MAP_OVERLAY_TYPE_LINE:
2464 if (overlay->visible) _overlay_line_show(overlay->ovl);
2465 else _overlay_line_hide(overlay->ovl);
2468 case ELM_MAP_OVERLAY_TYPE_POLYGON:
2469 if (overlay->visible) _overlay_polygon_show(overlay->ovl);
2470 else _overlay_polygon_hide(overlay->ovl);
2473 case ELM_MAP_OVERLAY_TYPE_CIRCLE:
2474 if (overlay->visible) _overlay_circle_show(overlay->ovl);
2475 else _overlay_circle_hide(overlay->ovl);
2478 case ELM_MAP_OVERLAY_TYPE_SCALE:
2479 if (overlay->visible) _overlay_scale_show(overlay->ovl);
2480 else _overlay_scale_hide(overlay->ovl);
2484 ERR("Invalid overlay type to show: %d", overlay->type);
2489 _overlay_place(Elm_Map_Smart_Data *sd)
2492 Elm_Map_Overlay *overlay;
2494 eina_list_free(sd->group_overlays);
2495 sd->group_overlays = NULL;
2497 EINA_LIST_FOREACH(sd->overlays, l, overlay)
2500 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2501 overlay->grp->in = EINA_FALSE;
2502 overlay->grp->boss = EINA_FALSE;
2503 _overlay_group_hide(overlay->grp);
2505 // Update overlays' coord
2506 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2507 _overlay_default_coord_update(overlay->ovl);
2508 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
2509 _overlay_bubble_coord_update(overlay->ovl);
2512 // Classify into group boss or follwer
2513 EINA_LIST_FOREACH(sd->overlays, l, overlay)
2515 Elm_Map_Overlay *boss;
2516 Overlay_Class *clas;
2518 if (overlay->type != ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2519 if (overlay->hide || (overlay->zoom_min > sd->zoom)) continue;
2521 clas = overlay->ovl;
2522 if (clas->zoom_max < sd->zoom) continue;
2523 EINA_LIST_FOREACH(clas->members, ll, boss)
2525 if (boss->type == ELM_MAP_OVERLAY_TYPE_CLASS) continue;
2526 if (boss->hide || (boss->zoom_min > sd->zoom)) continue;
2527 if (boss->grp->in) continue;
2528 _overlay_grouping(clas->members, boss);
2532 // Place group overlays and overlays
2533 EINA_LIST_FOREACH(sd->group_overlays, l, overlay)
2534 _overlay_show(overlay);
2535 EINA_LIST_FOREACH(sd->overlays, l, overlay)
2536 _overlay_show(overlay);
2539 static Evas_Object *
2540 _overlay_obj_get(const Elm_Map_Overlay *overlay)
2542 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
2544 if (overlay->type == ELM_MAP_OVERLAY_TYPE_GROUP)
2546 Overlay_Group *ovl = overlay->ovl;
2547 Overlay_Default *df = ovl->ovl;
2551 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
2553 Overlay_Default *ovl = overlay->ovl;
2559 ERR("Not supported overlay type: %d", overlay->type);
2565 _xml_name_attrs_dump_cb(void *data,
2569 Name_Dump *dump = (Name_Dump *)data;
2571 EINA_SAFETY_ON_NULL_RETURN_VAL(dump, EINA_FALSE);
2572 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
2573 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
2575 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON)))
2576 dump->lon = _elm_atof(value);
2577 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT)))
2578 dump->lat = _elm_atof(value);
2579 else if (!strncmp(key, NOMINATIM_ATTR_ADDRESS, sizeof(NOMINATIM_ATTR_ADDRESS)))
2582 dump->address = strdup(value);
2589 _xml_route_dump_cb(void *data,
2590 Eina_Simple_XML_Type type,
2592 unsigned offset __UNUSED__,
2595 Route_Dump *dump = data;
2597 EINA_SAFETY_ON_NULL_RETURN_VAL(dump, EINA_FALSE);
2598 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
2602 case EINA_SIMPLE_XML_OPEN:
2603 case EINA_SIMPLE_XML_OPEN_EMPTY:
2607 attrs = eina_simple_xml_tag_attributes_find(value, length);
2610 if (!strncmp(value, YOURS_DISTANCE, length))
2611 dump->id = ROUTE_XML_DISTANCE;
2612 else if (!strncmp(value, YOURS_DESCRIPTION, length))
2613 dump->id = ROUTE_XML_DESCRIPTION;
2614 else if (!strncmp(value, YOURS_COORDINATES, length))
2615 dump->id = ROUTE_XML_COORDINATES;
2616 else dump->id = ROUTE_XML_NONE;
2621 case EINA_SIMPLE_XML_DATA:
2623 char *buf = malloc(length);
2625 if (!buf) return EINA_FALSE;
2627 snprintf(buf, length, "%s", value);
2628 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = _elm_atof(buf);
2629 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION))
2630 dump->description = strdup(buf);
2631 else if (dump->id == ROUTE_XML_COORDINATES)
2632 dump->coordinates = strdup(buf);
2646 _xml_name_dump_cb(void *data,
2647 Eina_Simple_XML_Type type,
2649 unsigned offset __UNUSED__,
2652 Name_Dump *dump = data;
2654 EINA_SAFETY_ON_NULL_RETURN_VAL(dump, EINA_FALSE);
2655 EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
2659 case EINA_SIMPLE_XML_OPEN:
2660 case EINA_SIMPLE_XML_OPEN_EMPTY:
2663 attrs = eina_simple_xml_tag_attributes_find(value, length);
2666 if (!strncmp(value, NOMINATIM_RESULT,
2667 sizeof(NOMINATIM_RESULT) - 1))
2668 dump->id = NAME_XML_NAME;
2669 else dump->id = NAME_XML_NONE;
2671 eina_simple_xml_attributes_parse
2672 (attrs, length - (attrs - value), _xml_name_attrs_dump_cb,
2678 case EINA_SIMPLE_XML_DATA:
2680 char *buf = malloc(length + 1);
2682 if (!buf) return EINA_FALSE;
2683 snprintf(buf, length + 1, "%s", value);
2684 if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
2697 _xml_name_dump_list_cb(void *data,
2698 Eina_Simple_XML_Type type,
2703 Elm_Map_Name_List *name_list = data;
2705 Name_Dump dump = {0, NULL, 0.0, 0.0};
2706 _xml_name_dump_cb(&dump, type, value, offset, length);
2707 name = calloc(1, sizeof(Elm_Map_Name));
2708 if (!name) return EINA_FALSE;
2711 name->address = strdup(dump.address);
2712 name->lon = dump.lon;
2713 name->lat = dump.lat;
2714 name->wsd = name_list->wsd;
2715 name_list->names = eina_list_append(name_list->names, name);
2716 name->wsd->names = eina_list_append(name->wsd->names, name);
2726 _kml_parse(Elm_Map_Route *r)
2731 unsigned int ele, idx;
2733 EINA_SAFETY_ON_NULL_RETURN(r);
2734 EINA_SAFETY_ON_NULL_RETURN(r->fname);
2736 Route_Dump dump = {0, r->fname, 0.0, NULL, NULL};
2738 f = fopen(r->fname, "rb");
2743 fseek(f, 0, SEEK_END);
2749 fseek(f, 0, SEEK_SET);
2753 if (fread(buf, 1, sz, f))
2755 eina_simple_xml_parse
2756 (buf, sz, EINA_TRUE, _xml_route_dump_cb, &dump);
2763 if (dump.distance) r->info.distance = dump.distance;
2764 if (dump.description)
2766 eina_stringshare_replace(&r->info.waypoints, dump.description);
2767 str = eina_str_split_full(dump.description, "\n", 0, &ele);
2768 r->info.waypoint_count = ele;
2769 for (idx = 0; idx < ele; idx++)
2771 Path_Waypoint *wp = ELM_NEW(Path_Waypoint);
2776 wp->point = eina_stringshare_add(str[idx]);
2777 DBG("%s", str[idx]);
2778 r->waypoint = eina_list_append(r->waypoint, wp);
2787 else WRN("description is not found !");
2789 if (dump.coordinates)
2791 eina_stringshare_replace(&r->info.nodes, dump.coordinates);
2792 str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
2793 r->info.node_count = ele;
2794 for (idx = 0; idx < ele; idx++)
2796 Path_Node *n = ELM_NEW(Path_Node);
2798 sscanf(str[idx], "%lf,%lf", &lon, &lat);
2805 DBG("%lf:%lf", lon, lat);
2806 n->pos.address = NULL;
2807 r->nodes = eina_list_append(r->nodes, n);
2820 _name_parse(Elm_Map_Name *n)
2824 EINA_SAFETY_ON_NULL_RETURN(n);
2825 EINA_SAFETY_ON_NULL_RETURN(n->fname);
2827 Name_Dump dump = {0, NULL, 0.0, 0.0};
2829 f = fopen(n->fname, "rb");
2834 fseek(f, 0, SEEK_END);
2840 fseek(f, 0, SEEK_SET);
2844 if (fread(buf, 1, sz, f))
2846 eina_simple_xml_parse
2847 (buf, sz, EINA_TRUE, _xml_name_dump_cb, &dump);
2856 INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
2857 n->address = strdup(dump.address);
2865 _name_list_parse(Elm_Map_Name_List *nl)
2868 EINA_SAFETY_ON_NULL_RETURN(nl);
2869 EINA_SAFETY_ON_NULL_RETURN(nl->fname);
2871 f = fopen(nl->fname, "rb");
2876 fseek(f, 0, SEEK_END);
2882 fseek(f, 0, SEEK_SET);
2886 if (fread(buf, 1, sz, f))
2888 eina_simple_xml_parse
2889 (buf, sz, EINA_TRUE, _xml_name_dump_list_cb, nl);
2900 _route_cb(void *data,
2904 Elm_Map_Route *route;
2905 Elm_Map_Smart_Data *sd;
2907 EINA_SAFETY_ON_NULL_RETURN(data);
2908 EINA_SAFETY_ON_NULL_RETURN(file);
2917 INF("Route request success from (%lf, %lf) to (%lf, %lf)",
2918 route->flon, route->flat, route->tlon, route->tlat);
2919 if (route->cb) route->cb(route->data, ELM_WIDGET_DATA(sd)->obj, route);
2920 evas_object_smart_callback_call
2921 (ELM_WIDGET_DATA(sd)->obj, SIG_ROUTE_LOADED, NULL);
2925 ERR("Route request failed: %d", status);
2926 if (route->cb) route->cb(route->data, ELM_WIDGET_DATA(sd)->obj, NULL);
2927 evas_object_smart_callback_call
2928 (ELM_WIDGET_DATA(sd)->obj, SIG_ROUTE_LOADED_FAIL, NULL);
2931 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
2932 "elm,state,busy,stop", "elm");
2936 _name_cb(void *data,
2941 Elm_Map_Smart_Data *sd;
2943 EINA_SAFETY_ON_NULL_RETURN(data);
2944 EINA_SAFETY_ON_NULL_RETURN(file);
2953 INF("Name request success address:%s, lon:%lf, lat:%lf",
2954 name->address, name->lon, name->lat);
2955 if (name->cb) name->cb(name->data, ELM_WIDGET_DATA(sd)->obj, name);
2956 evas_object_smart_callback_call
2957 (ELM_WIDGET_DATA(sd)->obj, SIG_NAME_LOADED, NULL);
2961 ERR("Name request failed: %d", status);
2962 if (name->cb) name->cb(name->data, ELM_WIDGET_DATA(sd)->obj, NULL);
2963 evas_object_smart_callback_call
2964 (ELM_WIDGET_DATA(sd)->obj, SIG_NAME_LOADED_FAIL, NULL);
2966 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
2967 "elm,state,busy,stop", "elm");
2971 _name_list_cb(void *data,
2975 Elm_Map_Name_List *name_list;
2976 Elm_Map_Smart_Data *sd;
2978 EINA_SAFETY_ON_NULL_RETURN(data);
2979 EINA_SAFETY_ON_NULL_RETURN(file);
2982 sd = name_list->wsd;
2984 name_list->job = NULL;
2987 _name_list_parse(name_list);
2988 INF("Name List request success address");
2990 name_list->cb(name_list->data, ELM_WIDGET_DATA(sd)->obj,
2992 evas_object_smart_callback_call
2993 (ELM_WIDGET_DATA(sd)->obj, SIG_NAME_LOADED, NULL);
2997 ERR("Name List request failed: %d", status);
2999 name_list->cb(name_list->data, ELM_WIDGET_DATA(sd)->obj, NULL);
3000 evas_object_smart_callback_call
3001 (ELM_WIDGET_DATA(sd)->obj, SIG_NAME_LOADED_FAIL, NULL);
3003 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
3004 "elm,state,busy,stop", "elm");
3005 free(name_list->fname);
3013 char fname[PATH_MAX];
3015 const char *cachedir;
3018 snprintf(fname, sizeof(fname), "%s" CACHE_NAME_ROOT,
3019 efreet_cache_home_get());
3022 cachedir = getenv("XDG_CACHE_HOME");
3023 snprintf(fname, sizeof(fname), "%s/%s" CACHE_NAME_ROOT, getenv("HOME"),
3024 cachedir ? : "/.config");
3026 if (!ecore_file_exists(fname)) ecore_file_mkpath(fname);
3028 return strdup(fname);
3032 static Elm_Map_Name *
3033 _name_request(const Evas_Object *obj,
3035 const char *address,
3038 Elm_Map_Name_Cb name_cb,
3043 char *fname, fname2[PATH_MAX];
3045 ELM_MAP_DATA_GET(obj, sd);
3046 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->src_name, NULL);
3048 fname = _prepare_download();
3049 url = sd->src_name->url_cb
3050 (ELM_WIDGET_DATA(sd)->obj, method, address, lon, lat);
3053 ERR("Name URL is NULL");
3058 name = ELM_NEW(Elm_Map_Name);
3060 snprintf(fname2, sizeof(fname2), "%s/%d", fname, rand());
3061 name->fname = strdup(fname2);
3062 name->method = method;
3063 if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
3064 else if (method == ELM_MAP_NAME_METHOD_REVERSE)
3072 if (!ecore_file_download_full(url, name->fname, _name_cb, NULL, name,
3073 &(name->job), sd->ua) || !(name->job))
3075 ERR("Can't request Name from %s to %s", url, name->fname);
3076 if (name->address) free(name->address);
3082 INF("Name requested from %s to %s", url, name->fname);
3086 sd->names = eina_list_append(sd->names, name);
3087 evas_object_smart_callback_call
3088 (ELM_WIDGET_DATA(sd)->obj, SIG_NAME_LOAD, name);
3089 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
3090 "elm,state,busy,start", "elm");
3096 _name_list_request(const Evas_Object *obj,
3098 const char *address,
3101 Elm_Map_Name_List_Cb name_cb,
3105 Elm_Map_Name_List *name_list;
3106 char *fname, fname2[PATH_MAX];
3108 ELM_MAP_DATA_GET(obj, sd);
3109 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->src_name, NULL);
3111 fname = _prepare_download();
3112 url = sd->src_name->url_cb
3113 (ELM_WIDGET_DATA(sd)->obj, method, address, lon, lat);
3116 ERR("Name URL is NULL");
3120 name_list = ELM_NEW(Elm_Map_Name_List);
3121 name_list->wsd = sd;
3122 snprintf(fname2, sizeof(fname2), "%s/%d", fname, rand());
3123 name_list->fname = strdup(fname2);
3124 name_list->cb = name_cb;
3125 name_list->data = data;
3126 if (!ecore_file_download_full(url, name_list->fname, _name_list_cb,
3128 &(name_list->job), sd->ua) || !(name_list->job))
3130 ERR("Can't request Name from %s to %s", url, name_list->fname);
3131 free(name_list->fname);
3136 INF("Name requested from %s to %s", url, name_list->fname);
3140 evas_object_smart_callback_call
3141 (ELM_WIDGET_DATA(sd)->obj, SIG_NAME_LOAD, name_list->names);
3142 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
3143 "elm,state,busy,start", "elm");
3144 return name_list->names;
3148 static Evas_Event_Flags
3149 _pinch_zoom_start_cb(void *data,
3150 void *event_info __UNUSED__)
3152 Elm_Map_Smart_Data *sd = data;
3154 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EVAS_EVENT_FLAG_NONE);
3156 sd->pinch_zoom = sd->zoom_detail;
3158 return EVAS_EVENT_FLAG_NONE;
3161 static Evas_Event_Flags
3162 _pinch_zoom_cb(void *data,
3165 Elm_Map_Smart_Data *sd = data;
3167 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_NONE);
3171 Elm_Gesture_Zoom_Info *ei = event_info;
3173 _zoom(sd, sd->pinch_zoom + ei->zoom - 1, 0);
3176 return EVAS_EVENT_FLAG_NONE;
3179 static Evas_Event_Flags
3180 _pinch_rotate_cb(void *data,
3183 Elm_Map_Smart_Data *sd = data;
3185 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_NONE);
3191 Elm_Gesture_Rotate_Info *ei = event_info;
3192 evas_object_geometry_get(ELM_WIDGET_DATA(sd)->obj, &x, &y, &w, &h);
3193 sd->pinch_rotate.d = sd->pinch_rotate.a + ei->angle - ei->base_angle;
3194 angle = (int)(sd->pinch_rotate.d);
3195 x = x + ((double)w * 0.5);
3196 y = y + ((double)h * 0.5);
3197 sd->engine->rotate(ELM_WIDGET_DATA(sd)->obj, angle, x, y, 0);
3200 return EVAS_EVENT_FLAG_NONE;
3203 static Evas_Event_Flags
3204 _pinch_rotate_end_cb(void *data,
3205 void *event_info __UNUSED__)
3207 Elm_Map_Smart_Data *sd = data;
3209 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_NONE);
3211 sd->pinch_rotate.a = sd->pinch_rotate.d;
3213 return EVAS_EVENT_FLAG_NONE;
3217 static Evas_Event_Flags
3218 _pinch_momentum_start_cb(void *data,
3221 Elm_Map_Smart_Data *sd = data;
3222 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_NONE);
3223 Elm_Gesture_Momentum_Info *mi = ei;
3225 if (strcmp(sd->engine->name, INTERNAL_ENGINE_NAME) &&
3228 sd->pinch_pan.st = mi->tx;
3229 sd->pinch_pan.x = mi->x1;
3230 sd->pinch_pan.y = mi->y1;
3234 return EVAS_EVENT_FLAG_NONE;
3237 static Evas_Event_Flags
3238 _pinch_momentum_move_cb(void *data,
3241 Elm_Map_Smart_Data *sd = data;
3242 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_NONE);
3243 Elm_Gesture_Momentum_Info *mi = ei;
3245 if (strcmp(sd->engine->name, INTERNAL_ENGINE_NAME) &&
3248 sd->engine->pan(ELM_WIDGET_DATA(sd)->obj, sd->pinch_pan.x,
3249 sd->pinch_pan.y, mi->x2, mi->y2);
3250 sd->pinch_pan.x = mi->x2;
3251 sd->pinch_pan.y = mi->y2;
3255 return EVAS_EVENT_FLAG_NONE;
3258 static Evas_Event_Flags
3259 _pinch_momentum_end_cb(void *data,
3262 Elm_Map_Smart_Data *sd = data;
3263 EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EVAS_EVENT_FLAG_NONE);
3264 Elm_Gesture_Momentum_Info *mi = ei;
3266 if (strcmp(sd->engine->name, INTERNAL_ENGINE_NAME) &&
3269 sd->engine->pan(ELM_WIDGET_DATA(sd)->obj, sd->pinch_pan.x,
3271 sd->pinch_pan.x + (mi->mx)/25,
3272 sd->pinch_pan.y + (mi->my)/25);
3276 return EVAS_EVENT_FLAG_NONE;
3280 _elm_map_pan_smart_pos_set(Evas_Object *obj,
3284 ELM_MAP_PAN_DATA_GET(obj, psd);
3286 if ((x == psd->wsd->pan_x) && (y == psd->wsd->pan_y)) return;
3288 psd->wsd->pan_x = x;
3289 psd->wsd->pan_y = y;
3291 evas_object_smart_changed(obj);
3295 _elm_map_pan_smart_pos_get(const Evas_Object *obj,
3299 ELM_MAP_PAN_DATA_GET(obj, psd);
3301 if (x) *x = psd->wsd->pan_x;
3302 if (y) *y = psd->wsd->pan_y;
3306 _elm_map_pan_smart_pos_max_get(const Evas_Object *obj,
3312 ELM_MAP_PAN_DATA_GET(obj, psd);
3314 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
3315 ow = psd->wsd->size.w - ow;
3316 oh = psd->wsd->size.h - oh;
3325 _elm_map_pan_smart_pos_min_get(const Evas_Object *obj __UNUSED__,
3334 _elm_map_pan_smart_content_size_get(const Evas_Object *obj,
3338 ELM_MAP_PAN_DATA_GET(obj, psd);
3340 if (w) *w = psd->wsd->size.w;
3341 if (h) *h = psd->wsd->size.h;
3345 _elm_map_pan_smart_add(Evas_Object *obj)
3347 /* here just to allocate our extended data */
3348 EVAS_SMART_DATA_ALLOC(obj, Elm_Map_Pan_Smart_Data);
3350 ELM_PAN_CLASS(_elm_map_pan_parent_sc)->base.add(obj);
3354 _elm_map_pan_smart_resize(Evas_Object *obj,
3355 Evas_Coord w __UNUSED__,
3356 Evas_Coord h __UNUSED__)
3358 ELM_MAP_PAN_DATA_GET(obj, psd);
3360 _sizing_eval(psd->wsd);
3361 if (!psd->wsd->calc_job.zoom_changed)
3363 psd->wsd->calc_job.zoom_changed = EINA_TRUE;
3364 psd->wsd->calc_job.zoom_anim = EINA_FALSE;
3365 psd->wsd->calc_job.zoom = psd->wsd->zoom;
3367 evas_object_smart_changed(obj);
3370 static Evas_Object *
3371 _map_pan_add(Evas_Object *obj)
3373 Evas_Coord minw, minh;
3374 ELM_MAP_DATA_GET(obj, sd);
3378 sd->layout = edje_object_add(evas_object_evas_get(obj));
3379 elm_widget_theme_object_set
3380 (obj, sd->layout , "map", "base", elm_widget_style_get(obj));
3382 /* common scroller hit rectangle setup */
3383 sd->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
3384 evas_object_smart_member_add(sd->hit_rect, obj);
3385 elm_widget_sub_object_add(obj, sd->hit_rect);
3386 evas_object_color_set(sd->hit_rect, 0, 0, 0, 0);
3387 evas_object_show(sd->hit_rect);
3388 evas_object_repeat_events_set(sd->hit_rect, EINA_TRUE);
3390 /* interface's add() routine issued AFTER the object's smart_add() */
3391 sd->s_iface = evas_object_smart_interface_get
3392 (obj, ELM_SCROLLABLE_IFACE_NAME);
3394 sd->s_iface->objects_set(obj, sd->layout, sd->hit_rect);
3395 edje_object_size_min_calc(sd->layout, &minw, &minh);
3396 evas_object_size_hint_min_set(obj, minw, minh);
3397 sd->s_iface->wheel_disabled_set(obj, EINA_TRUE);
3398 sd->s_iface->bounce_allow_set
3399 (obj, _elm_config->thumbscroll_bounce_enable,
3400 _elm_config->thumbscroll_bounce_enable);
3401 sd->s_iface->extern_pan_set(obj, sd->pan_obj);
3405 evas_object_show(sd->layout);
3406 sd->s_iface->animate_start_cb_set(obj, _scroll_animate_start_cb);
3407 sd->s_iface->animate_stop_cb_set(obj, _scroll_animate_stop_cb);
3408 sd->s_iface->scroll_cb_set(obj, _scroll_cb);
3410 sd->sep_maps_overlays =
3411 evas_object_rectangle_add(evas_object_evas_get(obj));
3412 elm_widget_sub_object_add(obj, sd->sep_maps_overlays);
3413 evas_object_smart_member_add(sd->sep_maps_overlays, sd->pan_obj);
3415 sd->map = evas_map_new(EVAS_MAP_POINT);
3418 sd->id = ((int)getpid() << 16) | id_num;
3420 _grid_all_create(sd);
3422 // FIXME: Tile Provider is better to provide default tile size!
3423 sd->tsize = DEFAULT_TILE_SIZE;
3424 sd->size.w = sd->tsize;
3425 sd->size.h = sd->tsize;
3426 sd->size.tile = sd->tsize;
3428 if (!ecore_file_download_protocol_available("http://"))
3429 ERR("Ecore must be built with curl support for the map widget!");
3434 _map_pan_del(Evas_Object *obj)
3440 Elm_Map_Overlay *overlay;
3441 ELM_MAP_DATA_GET(obj, sd);
3443 EINA_LIST_FOREACH_SAFE(sd->routes, l, ll, r)
3444 elm_map_route_del(r);
3445 eina_list_free(sd->routes);
3448 EINA_LIST_FOREACH_SAFE(sd->names, l, ll, na)
3449 elm_map_name_del(na);
3450 eina_list_free(sd->names);
3453 EINA_LIST_FOREACH_SAFE(sd->overlays, l, ll, overlay)
3454 elm_map_overlay_del(overlay);
3455 eina_list_free(sd->overlays);
3456 sd->overlays = NULL;
3458 eina_list_free(sd->group_overlays);
3459 sd->group_overlays = NULL;
3460 eina_list_free(sd->all_overlays);
3461 sd->all_overlays = NULL;
3463 EINA_LIST_FREE (sd->track, track)
3464 evas_object_del(track);
3469 sd->scr_timer = NULL;
3470 ecore_timer_del(sd->scr_timer);
3472 if (sd->zoom_animator)
3474 ecore_animator_del(sd->zoom_animator);
3475 sd->zoom_animator = NULL;
3477 _grid_all_clear(sd);
3478 if (sd->download_idler) ecore_idler_del(sd->download_idler);
3479 if (sd->download_list) eina_list_free(sd->download_list);
3483 const char *cachedir;
3486 snprintf(buf, sizeof(buf), "%s" CACHE_ROOT, efreet_cache_home_get());
3489 cachedir = getenv("XDG_CACHE_HOME");
3490 snprintf(buf, sizeof(buf), "%s/%s" CACHE_ROOT, getenv("HOME"),
3491 cachedir ? : "/.config");
3493 if (!ecore_file_recursive_rm(buf))
3494 ERR("Deletion of %s failed", buf);
3498 evas_map_free(sd->map);
3502 evas_object_smart_member_del(sd->sep_maps_overlays);
3503 elm_widget_sub_object_del(obj, sd->sep_maps_overlays);
3504 evas_object_del(sd->sep_maps_overlays);
3505 sd->sep_maps_overlays = NULL;
3507 sd->s_iface->scroll_cb_set(obj, NULL);
3508 sd->s_iface->animate_stop_cb_set(obj, NULL);
3509 sd->s_iface->animate_start_cb_set(obj, NULL);
3513 _map_pan_show(Evas_Object *obj, double lon, double lat, int animation)
3516 ELM_MAP_DATA_GET(obj, sd);
3518 _region_to_coord_convert
3519 (sd, lon, lat, sd->size.w, &x, &y);
3520 _viewport_coord_get(sd, NULL, NULL, &w, &h);
3525 sd->s_iface->region_bring_in(ELM_WIDGET_DATA(sd)->obj, x, y, w, h);
3527 sd->s_iface->content_region_show(ELM_WIDGET_DATA(sd)->obj, x, y, w, h);
3531 _map_pan_zoom_do(Elm_Map_Smart_Data *sd,
3534 Evas_Coord vx, vy, vw, vh;
3537 if (zoom > sd->src_tile->zoom_max) zoom = sd->src_tile->zoom_max;
3538 else if (zoom < sd->src_tile->zoom_min)
3539 zoom = sd->src_tile->zoom_min;
3543 sd->size.tile = pow(2.0, (zoom - sd->zoom)) * sd->tsize;
3544 sd->size.w = pow(2.0, sd->zoom) * sd->size.tile;
3545 sd->size.h = sd->size.w;
3547 // Fix to zooming with (viewport center vx, vy) as the center to prevent
3548 // from zooming with (0,0) as the cetner. (scroller default behavior)
3549 _viewport_coord_get(sd, &vx, &vy, &vw, &vh);
3550 if ((vw > 0) && (vh > 0) && (ow > 0) && (oh > 0))
3555 if (vw > ow) sx = 0.5;
3556 else sx = (double)(vx + (double)(vw / 2)) / ow;
3557 if (vh > oh) sy = 0.5;
3558 else sy = (double)(vy + (double)(vh / 2)) / oh;
3560 if (sx > 1.0) sx = 1.0;
3561 if (sy > 1.0) sy = 1.0;
3563 x = ceil((sx * sd->size.w) - (vw / 2));
3564 y = ceil((sy * sd->size.h) - (vh / 2));
3566 else if (x > (sd->size.w - vw))
3567 x = sd->size.w - vw;
3569 else if (y > (sd->size.h - vh))
3570 y = sd->size.h - vh;
3571 sd->s_iface->content_region_show
3572 (ELM_WIDGET_DATA(sd)->obj, x, y, vw, vh);
3575 evas_object_smart_callback_call(sd->pan_obj, "changed", NULL);
3576 evas_object_smart_changed(sd->pan_obj);
3580 _zoom_anim_cb(void *data)
3582 Elm_Map_Smart_Data *sd = data;
3584 if (sd->ani.cnt <= 0)
3586 sd->zoom_animator = NULL;
3587 evas_object_smart_changed(sd->pan_obj);
3589 return ECORE_CALLBACK_CANCEL;
3593 sd->ani.zoom += sd->ani.diff;
3595 sd->zoom_detail = sd->ani.zoom;
3596 sd->zoom = ROUND(sd->zoom_detail);
3597 _map_pan_zoom_do(sd, sd->ani.zoom);
3599 return ECORE_CALLBACK_RENEW;
3604 _map_pan_zoom(Evas_Object *obj, double zoom, int animation)
3606 ELM_MAP_DATA_GET(obj, sd);
3608 if (sd->mode == ELM_MAP_ZOOM_MODE_MANUAL)
3613 sd->ani.zoom = sd->zoom;
3614 sd->ani.diff = (double)(zoom - sd->zoom) / 10;
3615 if (sd->zoom_animator) ecore_animator_del(sd->zoom_animator);
3616 sd->zoom_animator = ecore_animator_add(_zoom_anim_cb, sd);
3620 sd->zoom_detail = zoom;
3621 sd->zoom = ROUND(sd->zoom_detail);
3622 _map_pan_zoom_do(sd, zoom);
3633 _viewport_coord_get(sd, NULL, NULL, &vw, &vh);
3635 if (sd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
3637 if ((w < vw) && (h < vh))
3640 while ((w < vw) && (h < vh))
3643 w = pow(2.0, zoom) * sd->tsize;
3644 h = pow(2.0, zoom) * sd->tsize;
3650 while ((w > vw) || (h > vh))
3653 w = pow(2.0, zoom) * sd->tsize;
3654 h = pow(2.0, zoom) * sd->tsize;
3658 else if (sd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
3660 if ((w < vw) || (h < vh))
3663 while ((w < vw) || (h < vh))
3666 w = pow(2.0, zoom) * sd->tsize;
3667 h = pow(2.0, zoom) * sd->tsize;
3673 while ((w > vw) && (h > vh))
3676 w = pow(2.0, zoom) * sd->tsize;
3677 h = pow(2.0, zoom) * sd->tsize;
3681 sd->zoom_detail = zoom;
3682 sd->zoom = ROUND(sd->zoom_detail);
3683 _map_pan_zoom_do(sd, zoom);
3688 _map_pan_rotate(Evas_Object *obj, double angle, int x, int y, int animation __UNUSED__)
3690 ELM_MAP_DATA_GET(obj, sd);
3691 sd->pan_rotate.d = angle;
3692 sd->pan_rotate.cx = x;
3693 sd->pan_rotate.cy = y;
3694 evas_object_smart_changed(sd->pan_obj);
3698 _map_pan_rotate_get(const Evas_Object *obj, double *angle, int *x, int *y)
3700 ELM_MAP_DATA_GET(obj, sd);
3701 if (angle) *angle = sd->pan_rotate.d;
3702 if (x) *x = sd->pan_rotate.cx;
3703 if (y) *y = sd->pan_rotate.cy;
3707 _map_pan_perspective_set(Evas_Object *obj __UNUSED__, double perpective __UNUSED__, int animate __UNUSED__)
3709 WRN("Not implemented function");
3713 _map_pan_region_get(const Evas_Object *obj, double *lon, double *lat)
3716 Evas_Coord vx, vy, vw, vh;
3717 ELM_MAP_DATA_GET(obj, sd);
3719 _viewport_coord_get(sd, &vx, &vy, &vw, &vh);
3720 _coord_to_region_convert
3721 (sd, vx + vw / 2, vy + vh / 2, sd->size.w, &tlon, &tlat);
3722 if (lon) *lon = tlon;
3723 if (lat) *lat = tlat;
3727 _map_pan_canvas_to_region(const Evas_Object *obj, int x, int y, double *lon, double *lat)
3729 ELM_MAP_DATA_GET(obj, sd);
3730 _canvas_to_coord(sd, x, y, &x, &y);
3731 _coord_to_region_convert(sd, x, y, sd->size.w, lon, lat);
3735 _map_pan_region_to_canvas(const Evas_Object *obj, double lon, double lat, int *x, int *y)
3737 ELM_MAP_DATA_GET(obj, sd);
3738 _region_to_coord_convert(sd, lon, lat, sd->size.w, x, y);
3739 _coord_to_canvas(sd, *x, *y, x, y);
3743 _move_unimplemented(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__)
3745 WRN("move is not implemented");
3749 _resize_unimplemented(Evas_Object *obj __UNUSED__, int w __UNUSED__, int y __UNUSED__)
3751 WRN("resize is not implemented");
3755 _pan_unimplemented(Evas_Object *obj __UNUSED__, int x_1 __UNUSED__, int y_1 __UNUSED__, int x_2 __UNUSED__, int y_2 __UNUSED__)
3757 WRN("pan is not implemented");
3761 _canvas_to_region_unimplemented(const Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, double *lon __UNUSED__, double *lat __UNUSED__)
3763 WRN("canvas to region is not implemented");
3767 _region_to_canvas_unimplemented(const Evas_Object *obj __UNUSED__, double lon __UNUSED__, double lat __UNUSED__, int *x __UNUSED__, int *y __UNUSED__)
3769 WRN("region to canvas is not implemented");
3773 _map_pan_overlays_show(Elm_Map_Smart_Data *sd, Eina_List *overlays)
3775 double max_lon, min_lon, max_lat, min_lat, lon, lat;
3779 EINA_SAFETY_ON_NULL_RETURN(sd);
3780 EINA_SAFETY_ON_NULL_RETURN(overlays);
3782 _region_max_min_get(overlays, &max_lon, &min_lon, &max_lat, &min_lat);
3783 lon = (max_lon + min_lon) / 2;
3784 lat = (max_lat + min_lat) / 2;
3786 zoom = sd->src_tile->zoom_min;
3787 _viewport_coord_get(sd, NULL, NULL, &vw, &vh);
3788 if (sd->src_tile->zoom_max < sd->zoom_max)
3789 zoom_max = sd->src_tile->zoom_max;
3790 else zoom_max = sd->zoom_max;
3791 while (zoom <= zoom_max)
3793 Evas_Coord size, max_x, max_y, min_x, min_y;
3795 size = pow(2.0, zoom) * sd->tsize;
3796 _region_to_coord_convert
3797 (sd, min_lon, max_lat, size, &min_x, &max_y);
3798 _region_to_coord_convert
3799 (sd, max_lon, min_lat, size, &max_x, &min_y);
3800 if ((max_x - min_x) > vw || (max_y - min_y) > vh) break;
3805 sd->engine->zoom(ELM_WIDGET_DATA(sd)->obj, zoom, 0);
3806 sd->engine->show(ELM_WIDGET_DATA(sd)->obj, lon, lat, EINA_FALSE);
3810 _calc_job(Elm_Map_Smart_Data *sd)
3812 if (sd->calc_job.zoom_changed)
3814 _map_pan_zoom(ELM_WIDGET_DATA(sd)->obj, sd->calc_job.zoom, sd->calc_job.zoom_anim);
3815 sd->calc_job.zoom_changed = EINA_FALSE;
3817 if (!sd->zoom_animator && sd->calc_job.show_changed)
3819 _map_pan_show(ELM_WIDGET_DATA(sd)->obj, sd->calc_job.lon, sd->calc_job.lat,
3820 sd->calc_job.show_anim);
3821 sd->calc_job.show_changed = EINA_FALSE;
3823 if (!sd->zoom_animator && sd->calc_job.overlays_changed)
3825 _map_pan_overlays_show(sd, sd->calc_job.overlays);
3826 sd->calc_job.overlays_changed = EINA_FALSE;
3831 _elm_map_pan_smart_calculate(Evas_Object *obj)
3835 ELM_MAP_PAN_DATA_GET(obj, psd);
3837 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
3838 if (w <= 0 || h <= 0) return;
3840 _grid_place(psd->wsd);
3841 _overlay_place(psd->wsd);
3842 _track_place(psd->wsd);
3843 _calc_job(psd->wsd);
3847 _elm_map_pan_smart_move(Evas_Object *obj,
3848 Evas_Coord x __UNUSED__,
3849 Evas_Coord y __UNUSED__)
3851 EINA_SAFETY_ON_NULL_RETURN(obj);
3853 evas_object_smart_changed(obj);
3857 _elm_map_pan_smart_set_user(Elm_Map_Pan_Smart_Class *sc)
3859 ELM_PAN_CLASS(sc)->base.add = _elm_map_pan_smart_add;
3860 ELM_PAN_CLASS(sc)->base.move = _elm_map_pan_smart_move;
3861 ELM_PAN_CLASS(sc)->base.resize = _elm_map_pan_smart_resize;
3862 ELM_PAN_CLASS(sc)->base.calculate = _elm_map_pan_smart_calculate;
3864 ELM_PAN_CLASS(sc)->pos_set = _elm_map_pan_smart_pos_set;
3865 ELM_PAN_CLASS(sc)->pos_get = _elm_map_pan_smart_pos_get;
3866 ELM_PAN_CLASS(sc)->pos_max_get = _elm_map_pan_smart_pos_max_get;
3867 ELM_PAN_CLASS(sc)->pos_min_get = _elm_map_pan_smart_pos_min_get;
3868 ELM_PAN_CLASS(sc)->content_size_get =
3869 _elm_map_pan_smart_content_size_get;
3873 _elm_map_smart_on_focus(Evas_Object *obj)
3875 ELM_MAP_DATA_GET(obj, sd);
3877 if (elm_widget_focus_get(obj))
3879 edje_object_signal_emit
3880 (ELM_WIDGET_DATA(sd)->resize_obj, "elm,action,focus", "elm");
3881 evas_object_focus_set(ELM_WIDGET_DATA(sd)->resize_obj, EINA_TRUE);
3885 edje_object_signal_emit
3886 (ELM_WIDGET_DATA(sd)->resize_obj, "elm,action,unfocus", "elm");
3887 evas_object_focus_set(ELM_WIDGET_DATA(sd)->resize_obj, EINA_FALSE);
3894 _elm_map_smart_theme(Evas_Object *obj)
3896 ELM_MAP_DATA_GET(obj, sd);
3898 if (!ELM_WIDGET_CLASS(_elm_map_parent_sc)->theme(obj))
3907 _elm_map_smart_event(Evas_Object *obj,
3908 Evas_Object *src __UNUSED__,
3909 Evas_Callback_Type type,
3914 Evas_Event_Key_Down *ev = event_info;
3915 Evas_Coord step_x, step_y, page_x, page_y;
3917 ELM_MAP_DATA_GET(obj, sd);
3919 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
3920 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
3921 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
3923 sd->s_iface->content_pos_get(obj, &x, &y);
3924 sd->s_iface->step_size_get(obj, &step_x, &step_y);
3925 sd->s_iface->page_size_get(obj, &page_x, &page_y);
3926 sd->s_iface->content_viewport_size_get(obj, NULL, &vh);
3928 if ((!strcmp(ev->keyname, "Left")) ||
3929 ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string)))
3933 else if ((!strcmp(ev->keyname, "Right")) ||
3934 ((!strcmp(ev->keyname, "KP_Right")) && (!ev->string)))
3938 else if ((!strcmp(ev->keyname, "Up")) ||
3939 ((!strcmp(ev->keyname, "KP_Up")) && (!ev->string)))
3943 else if ((!strcmp(ev->keyname, "Down")) ||
3944 ((!strcmp(ev->keyname, "KP_Down")) && (!ev->string)))
3948 else if ((!strcmp(ev->keyname, "Prior")) ||
3949 ((!strcmp(ev->keyname, "KP_Prior")) && (!ev->string)))
3952 y -= -(page_y * vh) / 100;
3956 else if ((!strcmp(ev->keyname, "Next")) ||
3957 ((!strcmp(ev->keyname, "KP_Next")) && (!ev->string)))
3960 y += -(page_y * vh) / 100;
3964 else if (!strcmp(ev->keyname, "KP_Add"))
3966 _zoom(sd, sd->zoom + 1, 1);
3969 else if (!strcmp(ev->keyname, "KP_Subtract"))
3971 _zoom(sd, sd->zoom - 1, 1);
3974 else return EINA_FALSE;
3976 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
3977 sd->s_iface->content_pos_set(obj, x, y);
3983 _source_tile_set(Elm_Map_Smart_Data *sd,
3984 const char *source_name)
3989 EINA_SAFETY_ON_NULL_RETURN(source_name);
3991 if (sd->src_tile && !strcmp(sd->src_tile->name, source_name))
3994 EINA_LIST_FOREACH(sd->src_tiles, l, s)
3996 if (!strcmp(s->name, source_name))
4004 ERR("source name (%s) is not found", source_name);
4008 if (sd->src_tile->zoom_max < sd->zoom)
4009 sd->zoom = sd->src_tile->zoom_max;
4010 else if (sd->src_tile->zoom_min > sd->zoom)
4011 sd->zoom = sd->src_tile->zoom_min;
4013 if (sd->src_tile->zoom_max < sd->zoom_max)
4014 sd->zoom_max = sd->src_tile->zoom_max;
4015 if (sd->src_tile->zoom_min > sd->zoom_min)
4016 sd->zoom_min = sd->src_tile->zoom_min;
4018 _grid_all_clear(sd);
4019 _grid_all_create(sd);
4020 sd->zoom_detail = sd->zoom;
4021 _map_pan_zoom_do(sd, sd->zoom);
4025 _source_route_set(Elm_Map_Smart_Data *sd,
4026 const char *source_name)
4031 EINA_SAFETY_ON_NULL_RETURN(source_name);
4033 if (sd->src_route && !strcmp(sd->src_route->name, source_name))
4036 EINA_LIST_FOREACH(sd->src_routes, l, s)
4038 if (!strcmp(s->name, source_name))
4046 ERR("source name (%s) is not found", source_name);
4052 _source_name_set(Elm_Map_Smart_Data *sd,
4053 const char *source_name)
4058 EINA_SAFETY_ON_NULL_RETURN(source_name);
4060 if (sd->src_name && !strcmp(sd->src_name->name, source_name))
4063 EINA_LIST_FOREACH(sd->src_names, l, s)
4065 if (!strcmp(s->name, source_name))
4073 ERR("source name (%s) is not found", source_name);
4079 _source_mod_cb(Eina_Module *m,
4083 Elm_Map_Smart_Data *sd = data;
4085 Elm_Map_Module_Source_Name_Func name_cb;
4086 Elm_Map_Module_Add_Func add_cb;
4087 Elm_Map_Module_Del_Func del_cb;
4088 Elm_Map_Module_Move_Func move_cb;
4089 Elm_Map_Module_Resize_Func resize_cb;
4090 Elm_Map_Module_Region_Get_Func region_get_cb;
4091 Elm_Map_Module_Pan_Func pan_cb;
4092 Elm_Map_Module_Show_Func show_cb;
4093 Elm_Map_Module_Zoom_Func zoom_cb;
4094 Elm_Map_Module_Rotate_Func rotate_cb;
4095 Elm_Map_Module_Rotate_Get_Func rotate_get_cb;
4096 Elm_Map_Module_Canvas_to_Region_Func canvas_to_region_cb;
4097 Elm_Map_Module_Region_to_Canvas_Func region_to_canvas_cb;
4098 Elm_Map_Module_Perspective_Set_Func perpective_cb;
4099 Elm_Map_Module_Tile_Url_Func tile_url_cb;
4100 Elm_Map_Module_Tile_Scale_Func scale_cb;
4101 Elm_Map_Module_Tile_Zoom_Min_Func zoom_min;
4102 Elm_Map_Module_Tile_Zoom_Max_Func zoom_max;
4103 Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord;
4104 Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo;
4105 Elm_Map_Module_Route_Url_Func route_url_cb;
4106 Elm_Map_Module_Name_Url_Func name_url_cb;
4108 EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
4110 file = eina_module_file_get(m);
4111 if (!eina_module_load(m))
4113 ERR("Could not load module \"%s\": %s", file,
4114 eina_error_msg_get(eina_error_get()));
4117 name_cb = eina_module_symbol_get(m, "map_module_source_name_get");
4120 name_cb = eina_module_symbol_get(m, "map_module_name_get");
4123 WRN("Could not find map module name from module \"%s\": %s",
4124 file, eina_error_msg_get(eina_error_get()));
4125 eina_module_unload(m);
4131 zoom_min = eina_module_symbol_get(m, "map_module_zoom_min_get");
4132 zoom_max = eina_module_symbol_get(m, "map_module_zoom_max_get");
4133 add_cb = eina_module_symbol_get(m, "map_module_add");
4134 del_cb = eina_module_symbol_get(m, "map_module_del");
4135 move_cb = eina_module_symbol_get(m, "map_module_move");
4136 resize_cb = eina_module_symbol_get(m, "map_module_resize");
4137 region_get_cb = eina_module_symbol_get(m, "map_module_region_get");
4138 pan_cb = eina_module_symbol_get(m, "map_module_pan");
4139 show_cb = eina_module_symbol_get(m, "map_module_show");
4140 zoom_cb = eina_module_symbol_get(m, "map_module_zoom");
4141 rotate_cb = eina_module_symbol_get(m, "map_module_rotate");
4142 rotate_get_cb = eina_module_symbol_get(m, "map_module_rotate_get");
4143 perpective_cb = eina_module_symbol_get(m, "map_module_perpective_set");
4144 canvas_to_region_cb = eina_module_symbol_get(m, "map_module_canvas_to_region");
4145 region_to_canvas_cb = eina_module_symbol_get(m, "map_module_region_to_canvas");
4146 if (zoom_min && zoom_max && add_cb && del_cb && show_cb && zoom_cb && rotate_cb && rotate_get_cb && perpective_cb)
4148 INF("Map ENGINE module is loaded \"%s\"", file);
4150 s = ELM_NEW(Source_Engine);
4151 s->name = name_cb();
4152 s->zoom_min = zoom_min();
4153 s->zoom_max = zoom_max();
4156 if (move_cb) s->move = move_cb;
4157 else s->move = _move_unimplemented;
4158 if (resize_cb) s->resize = resize_cb;
4159 else s->resize = _resize_unimplemented;
4160 s->region_get = region_get_cb;
4161 if (pan_cb) s->pan = pan_cb;
4162 else s->pan = _pan_unimplemented;
4165 s->rotate = rotate_cb;
4166 s->rotate_get = rotate_get_cb;
4167 s->perpective = perpective_cb;
4168 if (canvas_to_region_cb) s->canvas_to_region = canvas_to_region_cb;
4169 else s->canvas_to_region = _canvas_to_region_unimplemented;
4170 if (region_to_canvas_cb) s->region_to_canvas = region_to_canvas_cb;
4171 else s->region_to_canvas = _region_to_canvas_unimplemented;
4173 sd->engines = eina_list_append(sd->engines, s);
4177 tile_url_cb = eina_module_symbol_get(m, "map_module_tile_url_get");
4178 zoom_min = eina_module_symbol_get(m, "map_module_tile_zoom_min_get");
4179 zoom_max = eina_module_symbol_get(m, "map_module_tile_zoom_max_get");
4180 geo_to_coord = eina_module_symbol_get(m, "map_module_tile_geo_to_coord");
4181 coord_to_geo = eina_module_symbol_get(m, "map_module_tile_coord_to_geo");
4182 scale_cb = eina_module_symbol_get(m, "map_module_tile_scale_get");
4183 if (tile_url_cb && zoom_min && zoom_max && geo_to_coord && coord_to_geo && scale_cb)
4185 INF("Map TILE module is loaded \"%s\"", file);
4187 s = ELM_NEW(Source_Tile);
4188 s->name = name_cb();
4189 s->zoom_min = zoom_min();
4190 s->zoom_max = zoom_max();
4191 s->url_cb = tile_url_cb;
4192 s->geo_to_coord = geo_to_coord;
4193 s->coord_to_geo = coord_to_geo;
4194 s->scale_cb = scale_cb;
4195 sd->src_tiles = eina_list_append(sd->src_tiles, s);
4198 // Find ROUTE module
4199 route_url_cb = eina_module_symbol_get(m, "map_module_route_url_get");
4202 INF("Map ROUTE module is loaded \"%s\"", file);
4204 s = ELM_NEW(Source_Tile);
4205 s->name = name_cb();
4206 s->url_cb = route_url_cb;
4207 sd->src_routes = eina_list_append(sd->src_routes, s);
4211 name_url_cb = eina_module_symbol_get(m, "map_module_name_url_get");
4214 INF("Map NAME module is loaded \"%s\"", file);
4216 s = ELM_NEW(Source_Tile);
4217 s->name = name_cb();
4218 s->url_cb = name_url_cb;
4219 sd->src_names = eina_list_append(sd->src_names, s);
4225 _source_all_unload(Elm_Map_Smart_Data *sd)
4230 for (idx = 0; sd->src_tile_names[idx]; idx++)
4231 eina_stringshare_del(sd->src_tile_names[idx]);
4232 for (idx = 0; sd->src_route_names[idx]; idx++)
4233 eina_stringshare_del(sd->src_route_names[idx]);
4234 for (idx = 0; sd->src_name_names[idx]; idx++)
4235 eina_stringshare_del(sd->src_name_names[idx]);
4237 EINA_LIST_FREE(sd->src_tiles, s) free(s);
4238 EINA_LIST_FREE(sd->src_routes, s) free(s);
4239 EINA_LIST_FREE(sd->src_names, s) free(s);
4241 eina_module_list_free(sd->src_mods);
4246 _source_all_load(Elm_Map_Smart_Data *sd)
4248 Source_Engine *engine;
4249 Source_Tile *src_tile;
4250 Source_Route *src_route;
4251 Source_Name *src_name;
4255 // Load hard coded TILE source
4256 for (idx = 0; idx < (sizeof(src_tiles) / sizeof(Source_Tile)); idx++)
4258 src_tile = ELM_NEW(Source_Tile);
4259 src_tile->name = src_tiles[idx].name;
4260 src_tile->zoom_min = src_tiles[idx].zoom_min;
4261 src_tile->zoom_max = src_tiles[idx].zoom_max;
4262 src_tile->url_cb = src_tiles[idx].url_cb;
4263 src_tile->geo_to_coord = src_tiles[idx].geo_to_coord;
4264 src_tile->coord_to_geo = src_tiles[idx].coord_to_geo;
4265 src_tile->scale_cb = src_tiles[idx].scale_cb;
4266 sd->src_tiles = eina_list_append(sd->src_tiles, src_tile);
4268 // Load hard coded ROUTE source
4269 for (idx = 0; idx < (sizeof(src_routes) / sizeof(Source_Route)); idx++)
4271 src_route = ELM_NEW(Source_Route);
4272 src_route->name = src_routes[idx].name;
4273 src_route->url_cb = src_routes[idx].url_cb;
4274 sd->src_routes = eina_list_append(sd->src_routes, src_route);
4276 // Load from hard coded NAME source
4277 for (idx = 0; idx < (sizeof(src_names) / sizeof(Source_Name)); idx++)
4279 src_name = ELM_NEW(Source_Name);
4280 src_name->name = src_names[idx].name;
4281 src_name->url_cb = src_names[idx].url_cb;
4282 sd->src_names = eina_list_append(sd->src_names, src_name);
4284 // Load Internal Default Map Engine
4285 engine = ELM_NEW(Source_Engine);
4286 engine->name = INTERNAL_ENGINE_NAME;
4287 engine->zoom_min = src_tiles[0].zoom_min;
4288 engine->zoom_max = src_tiles[0].zoom_max;
4289 engine->add = _map_pan_add;
4290 engine->del = _map_pan_del;
4291 engine->pan = _pan_unimplemented;
4292 engine->show = _map_pan_show;
4293 engine->zoom = _map_pan_zoom;
4294 engine->rotate = _map_pan_rotate;
4295 engine->rotate_get = _map_pan_rotate_get;
4296 engine->perpective = _map_pan_perspective_set;
4297 engine->region_get = _map_pan_region_get;
4298 engine->canvas_to_region = _map_pan_canvas_to_region;
4299 engine->region_to_canvas = _map_pan_region_to_canvas;
4300 sd->engines = eina_list_append(sd->engines, engine);
4302 // Load from modules
4303 sd->src_mods = eina_module_list_get(sd->src_mods, MODULES_PATH, 1,
4304 &_source_mod_cb, sd);
4306 // Set default source
4307 sd->engine = eina_list_nth(sd->engines, 0);
4308 sd->src_tile = eina_list_nth(sd->src_tiles, 0);
4309 sd->src_route = eina_list_nth(sd->src_routes, 0);
4310 sd->src_name = eina_list_nth(sd->src_names, 0);
4312 // Make name string of sources
4314 sd->engine_names = calloc((eina_list_count(sd->engines) + 1),
4315 sizeof(const char *));
4316 EINA_LIST_FOREACH(sd->engines, l, engine)
4318 eina_stringshare_replace(&sd->engine_names[idx], engine->name);
4319 INF("engine : %s", sd->engine_names[idx]);
4323 sd->src_tile_names = calloc((eina_list_count(sd->src_tiles) + 1),
4324 sizeof(const char *));
4325 EINA_LIST_FOREACH(sd->src_tiles, l, src_tile)
4327 eina_stringshare_replace(&sd->src_tile_names[idx], src_tile->name);
4328 INF("source tile: %s", sd->src_tile_names[idx]);
4332 sd->src_route_names = calloc((eina_list_count(sd->src_routes) + 1),
4333 sizeof(const char *));
4334 EINA_LIST_FOREACH(sd->src_routes, l, src_route)
4336 eina_stringshare_replace(&sd->src_route_names[idx], src_route->name);
4337 INF("source route: %s", sd->src_route_names[idx]);
4341 sd->src_name_names = calloc((eina_list_count(sd->src_names) + 1),
4342 sizeof(const char *));
4343 EINA_LIST_FOREACH(sd->src_names, l, src_name)
4345 eina_stringshare_replace(&sd->src_name_names[idx], src_name->name);
4346 INF("source name: %s", sd->src_name_names[idx]);
4352 _elm_map_smart_add(Evas_Object *obj)
4354 Evas_Object *layout;
4355 Elm_Map_Pan_Smart_Data *pan_data;
4356 EVAS_SMART_DATA_ALLOC(obj, Elm_Map_Smart_Data);
4358 ELM_WIDGET_CLASS(_elm_map_parent_sc)->base.add(obj);
4360 elm_widget_can_focus_set(obj, EINA_TRUE);
4362 priv->pan_obj = evas_object_smart_add
4363 (evas_object_evas_get(obj), _elm_map_pan_smart_class_new());
4364 pan_data = evas_object_smart_data_get(priv->pan_obj);
4365 pan_data->wsd = priv;
4367 _source_all_load(priv);
4368 layout = priv->engine->add(obj);
4369 elm_widget_resize_object_set(obj, layout);
4371 evas_object_event_callback_add
4372 (obj, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, priv);
4373 evas_object_event_callback_add
4374 (obj, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, priv);
4375 evas_object_event_callback_add
4376 (obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, priv);
4377 evas_object_event_callback_add
4378 (obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints_cb, priv);
4380 priv->g_layer = elm_gesture_layer_add(obj);
4381 if (!priv->g_layer) ERR("elm_gesture_layer_add() failed");
4382 elm_gesture_layer_attach(priv->g_layer, obj);
4383 elm_gesture_layer_cb_set
4384 (priv->g_layer, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_START,
4385 _pinch_zoom_start_cb, priv);
4386 elm_gesture_layer_cb_set
4387 (priv->g_layer, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_MOVE,
4388 _pinch_zoom_cb, priv);
4389 elm_gesture_layer_cb_set
4390 (priv->g_layer, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_MOVE,
4391 _pinch_rotate_cb, priv);
4392 elm_gesture_layer_cb_set
4393 (priv->g_layer, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_END,
4394 _pinch_rotate_end_cb, priv);
4395 elm_gesture_layer_cb_set
4396 (priv->g_layer, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_ABORT,
4397 _pinch_rotate_end_cb, priv);
4398 elm_gesture_layer_cb_set
4399 (priv->g_layer, ELM_GESTURE_MOMENTUM, ELM_GESTURE_STATE_START,
4400 _pinch_momentum_start_cb, priv);
4401 elm_gesture_layer_cb_set
4402 (priv->g_layer, ELM_GESTURE_MOMENTUM, ELM_GESTURE_STATE_MOVE,
4403 _pinch_momentum_move_cb, priv);
4404 elm_gesture_layer_cb_set
4405 (priv->g_layer, ELM_GESTURE_MOMENTUM, ELM_GESTURE_STATE_END,
4406 _pinch_momentum_end_cb, priv);
4408 priv->mode = ELM_MAP_ZOOM_MODE_MANUAL;
4409 priv->zoom_min = priv->engine->zoom_min;
4410 priv->zoom_max = priv->engine->zoom_max;
4412 priv->zoom_detail = 0;
4414 priv->engine->zoom(obj, 0, 0);
4418 _elm_map_smart_del(Evas_Object *obj)
4420 ELM_MAP_DATA_GET(obj, sd);
4422 if (sd->zoom_timer) ecore_timer_del(sd->zoom_timer);
4423 if (sd->long_timer) ecore_timer_del(sd->long_timer);
4424 if (sd->loaded_timer) ecore_timer_del(sd->loaded_timer);
4426 if (sd->user_agent) eina_stringshare_del(sd->user_agent);
4427 if (sd->ua) eina_hash_free(sd->ua);
4429 sd->engine->del(obj);
4430 _source_all_unload(sd);
4432 evas_object_del(sd->pan_obj);
4433 ELM_WIDGET_CLASS(_elm_map_parent_sc)->base.del(obj);
4437 _elm_map_smart_move(Evas_Object *obj,
4441 ELM_MAP_DATA_GET(obj, sd);
4443 ELM_WIDGET_CLASS(_elm_map_parent_sc)->base.move(obj, x, y);
4445 if (!strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
4446 evas_object_move(sd->hit_rect, x, y);
4447 else sd->engine->move(obj, x, y);
4451 _elm_map_smart_resize(Evas_Object *obj,
4455 ELM_MAP_DATA_GET(obj, sd);
4457 ELM_WIDGET_CLASS(_elm_map_parent_sc)->base.resize(obj, w, h);
4459 if (!strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
4460 evas_object_resize(sd->hit_rect, w, h);
4461 else sd->engine->resize(obj, w, h);
4465 _elm_map_smart_member_add(Evas_Object *obj,
4466 Evas_Object *member)
4468 ELM_MAP_DATA_GET(obj, sd);
4470 ELM_WIDGET_CLASS(_elm_map_parent_sc)->base.member_add(obj, member);
4473 evas_object_raise(sd->hit_rect);
4477 _elm_map_smart_set_user(Elm_Map_Smart_Class *sc)
4479 ELM_WIDGET_CLASS(sc)->base.add = _elm_map_smart_add;
4480 ELM_WIDGET_CLASS(sc)->base.del = _elm_map_smart_del;
4481 ELM_WIDGET_CLASS(sc)->base.move = _elm_map_smart_move;
4482 ELM_WIDGET_CLASS(sc)->base.resize = _elm_map_smart_resize;
4483 ELM_WIDGET_CLASS(sc)->base.member_add = _elm_map_smart_member_add;
4485 ELM_WIDGET_CLASS(sc)->on_focus = _elm_map_smart_on_focus;
4486 ELM_WIDGET_CLASS(sc)->theme = _elm_map_smart_theme;
4487 ELM_WIDGET_CLASS(sc)->event = _elm_map_smart_event;
4491 EAPI const Elm_Map_Smart_Class *
4492 elm_map_smart_class_get(void)
4494 #ifdef HAVE_ELEMENTARY_ECORE_CON
4495 static Elm_Map_Smart_Class _sc =
4496 ELM_MAP_SMART_CLASS_INIT_NAME_VERSION(ELM_MAP_SMART_NAME);
4497 static const Elm_Map_Smart_Class *class = NULL;
4498 Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
4500 if (class) return class;
4502 _elm_map_smart_set(&_sc);
4503 esc->callbacks = _smart_callbacks;
4513 elm_map_add(Evas_Object *parent)
4515 #ifdef HAVE_ELEMENTARY_ECORE_CON
4518 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
4520 obj = elm_widget_add(_elm_map_smart_class_new(), parent);
4521 if (!obj) return NULL;
4523 if (!elm_widget_sub_object_add(parent, obj))
4524 ERR("could not add %p as sub object of %p", obj, parent);
4534 elm_map_zoom_set(Evas_Object *obj,
4537 #ifdef HAVE_ELEMENTARY_ECORE_CON
4540 ELM_MAP_DATA_GET(obj, sd);
4541 EINA_SAFETY_ON_NULL_RETURN(sd->src_tile);
4543 Eina_Bool animation;
4545 if (sd->mode != ELM_MAP_ZOOM_MODE_MANUAL) return;
4546 if (zoom < 0) zoom = 0;
4547 if (sd->zoom == zoom) return;
4549 if (sd->paused) animation = EINA_FALSE;
4550 else animation = EINA_TRUE;
4552 if (!strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
4554 sd->calc_job.zoom_changed = EINA_TRUE;
4555 sd->calc_job.zoom_anim = animation;
4556 sd->calc_job.zoom = zoom;
4557 evas_object_smart_changed(sd->pan_obj);
4559 else _zoom(sd, zoom, 1);
4568 elm_map_zoom_get(const Evas_Object *obj)
4570 #ifdef HAVE_ELEMENTARY_ECORE_CON
4571 ELM_MAP_CHECK(obj) 0;
4572 ELM_MAP_DATA_GET(obj, sd);
4582 elm_map_zoom_mode_set(Evas_Object *obj,
4583 Elm_Map_Zoom_Mode mode)
4585 #ifdef HAVE_ELEMENTARY_ECORE_CON
4587 ELM_MAP_DATA_GET(obj, sd);
4589 if ((mode == ELM_MAP_ZOOM_MODE_MANUAL) && (sd->mode == !!mode)) return;
4592 if (!strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
4594 sd->calc_job.zoom_changed = EINA_TRUE;
4595 sd->calc_job.zoom_anim = EINA_FALSE;
4596 sd->calc_job.zoom = sd->zoom;
4597 evas_object_smart_changed(sd->pan_obj);
4599 else ERR("Engine(%s) do not support zoom mode", sd->engine->name);
4607 EAPI Elm_Map_Zoom_Mode
4608 elm_map_zoom_mode_get(const Evas_Object *obj)
4610 #ifdef HAVE_ELEMENTARY_ECORE_CON
4611 ELM_MAP_CHECK(obj) ELM_MAP_ZOOM_MODE_MANUAL;
4612 ELM_MAP_DATA_GET(obj, sd);
4617 return ELM_MAP_ZOOM_MODE_MANUAL;
4622 elm_map_zoom_max_set(Evas_Object *obj,
4625 #ifdef HAVE_ELEMENTARY_ECORE_CON
4627 ELM_MAP_DATA_GET(obj, sd);
4628 EINA_SAFETY_ON_NULL_RETURN(sd->src_tile);
4630 sd->zoom_max = zoom;
4638 elm_map_zoom_max_get(const Evas_Object *obj)
4640 #ifdef HAVE_ELEMENTARY_ECORE_CON
4641 ELM_MAP_CHECK(obj) - 1;
4642 ELM_MAP_DATA_GET(obj, sd);
4643 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->src_tile, -1);
4645 return sd->zoom_max;
4653 elm_map_zoom_min_set(Evas_Object *obj,
4656 #ifdef HAVE_ELEMENTARY_ECORE_CON
4658 ELM_MAP_DATA_GET(obj, sd);
4659 EINA_SAFETY_ON_NULL_RETURN(sd->src_tile);
4661 sd->zoom_min = zoom;
4669 elm_map_zoom_min_get(const Evas_Object *obj)
4671 #ifdef HAVE_ELEMENTARY_ECORE_CON
4672 ELM_MAP_CHECK(obj) - 1;
4673 ELM_MAP_DATA_GET(obj, sd);
4674 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->src_tile, -1);
4676 return sd->zoom_min;
4684 elm_map_region_bring_in(Evas_Object *obj,
4688 #ifdef HAVE_ELEMENTARY_ECORE_CON
4690 ELM_MAP_DATA_GET(obj, sd);
4692 if (!strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
4694 sd->calc_job.show_changed = EINA_TRUE;
4695 sd->calc_job.show_anim = EINA_TRUE;
4696 sd->calc_job.lon = lon;
4697 sd->calc_job.lat = lat;
4698 evas_object_smart_changed(sd->pan_obj);
4702 sd->engine->show(obj, lon, lat, 1);
4713 elm_map_region_show(Evas_Object *obj,
4717 #ifdef HAVE_ELEMENTARY_ECORE_CON
4719 ELM_MAP_DATA_GET(obj, sd);
4721 if (!strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
4723 sd->calc_job.show_changed = EINA_TRUE;
4724 sd->calc_job.show_anim = EINA_FALSE;
4725 sd->calc_job.lon = lon;
4726 sd->calc_job.lat = lat;
4727 evas_object_smart_changed(sd->pan_obj);
4731 sd->engine->show(obj, lon, lat, 0);
4743 elm_map_region_get(const Evas_Object *obj,
4747 #ifdef HAVE_ELEMENTARY_ECORE_CON
4750 ELM_MAP_DATA_GET(obj, sd);
4753 sd->engine->region_get(obj, &tlon, &tlat);
4754 if (lon) *lon = tlon;
4755 if (lat) *lat = tlat;
4764 elm_map_paused_set(Evas_Object *obj,
4767 #ifdef HAVE_ELEMENTARY_ECORE_CON
4769 ELM_MAP_DATA_GET(obj, sd);
4771 if (sd->paused == !!paused) return;
4772 sd->paused = !!paused;
4774 if (!strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
4778 if (sd->zoom_animator)
4780 if (sd->zoom_animator) ecore_animator_del(sd->zoom_animator);
4781 sd->zoom_animator = NULL;
4782 sd->zoom_detail = sd->zoom;
4783 _map_pan_zoom_do(sd, sd->zoom);
4785 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
4786 "elm,state,busy,stop", "elm");
4790 if (sd->download_num >= 1)
4791 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
4792 "elm,state,busy,start", "elm");
4803 elm_map_paused_get(const Evas_Object *obj)
4805 #ifdef HAVE_ELEMENTARY_ECORE_CON
4806 ELM_MAP_CHECK(obj) EINA_FALSE;
4807 ELM_MAP_DATA_GET(obj, sd);
4817 elm_map_rotate_set(Evas_Object *obj,
4822 #ifdef HAVE_ELEMENTARY_ECORE_CON
4824 ELM_MAP_DATA_GET(obj, sd);
4826 sd->engine->rotate(obj, degree, cx, cy, degree);
4836 elm_map_rotate_get(const Evas_Object *obj,
4841 #ifdef HAVE_ELEMENTARY_ECORE_CON
4843 ELM_MAP_DATA_GET(obj, sd);
4845 sd->engine->rotate_get(obj, degree, cx, cy);
4855 elm_map_wheel_disabled_set(Evas_Object *obj,
4858 #ifdef HAVE_ELEMENTARY_ECORE_CON
4860 ELM_MAP_DATA_GET(obj, sd);
4862 if ((!sd->wheel_disabled) && (disabled))
4863 evas_object_event_callback_del_full
4864 (obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, sd);
4865 else if ((sd->wheel_disabled) && (!disabled))
4866 evas_object_event_callback_add
4867 (obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, sd);
4868 sd->wheel_disabled = !!disabled;
4876 elm_map_wheel_disabled_get(const Evas_Object *obj)
4878 #ifdef HAVE_ELEMENTARY_ECORE_CON
4879 ELM_MAP_CHECK(obj) EINA_FALSE;
4880 ELM_MAP_DATA_GET(obj, sd);
4882 return sd->wheel_disabled;
4890 elm_map_tile_load_status_get(const Evas_Object *obj,
4894 #ifdef HAVE_ELEMENTARY_ECORE_CON
4896 ELM_MAP_DATA_GET(obj, sd);
4898 if (try_num) *try_num = sd->try_num;
4899 if (finish_num) *finish_num = sd->finish_num;
4908 elm_map_canvas_to_region_convert(const Evas_Object *obj,
4914 #ifdef HAVE_ELEMENTARY_ECORE_CON
4916 ELM_MAP_DATA_GET(obj, sd);
4917 EINA_SAFETY_ON_NULL_RETURN(lon);
4918 EINA_SAFETY_ON_NULL_RETURN(lat);
4920 sd->engine->canvas_to_region(obj, x, y, lon, lat);
4931 elm_map_region_to_canvas_convert(const Evas_Object *obj,
4937 #ifdef HAVE_ELEMENTARY_ECORE_CON
4939 ELM_MAP_DATA_GET(obj, sd);
4940 EINA_SAFETY_ON_NULL_RETURN(x);
4941 EINA_SAFETY_ON_NULL_RETURN(y);
4943 sd->engine->region_to_canvas(obj, lon, lat, x, y);
4954 elm_map_user_agent_set(Evas_Object *obj,
4955 const char *user_agent)
4957 #ifdef HAVE_ELEMENTARY_ECORE_CON
4959 ELM_MAP_DATA_GET(obj, sd);
4960 EINA_SAFETY_ON_NULL_RETURN(user_agent);
4962 eina_stringshare_replace(&sd->user_agent, user_agent);
4964 if (!sd->ua) sd->ua = eina_hash_string_small_new(NULL);
4965 eina_hash_set(sd->ua, "User-Agent", sd->user_agent);
4973 elm_map_user_agent_get(const Evas_Object *obj)
4975 #ifdef HAVE_ELEMENTARY_ECORE_CON
4976 ELM_MAP_CHECK(obj) NULL;
4977 ELM_MAP_DATA_GET(obj, sd);
4979 return sd->user_agent;
4987 elm_map_engine_set(Evas_Object *obj,
4988 const char *engine_name)
4991 ELM_MAP_DATA_GET(obj, sd);
4992 EINA_SAFETY_ON_NULL_RETURN(engine_name);
4994 Source_Engine *engine = NULL;
4997 Evas_Object *layout;
5000 if (sd->engine && !strcmp(sd->engine->name, engine_name))
5003 EINA_LIST_FOREACH(sd->engines, l, e)
5005 if (!strcmp(e->name, engine_name))
5013 ERR("Engine name (%s) is not found", engine_name);
5016 layout = engine->add(obj);
5020 ERR("%s engine can not be added", engine->name);
5023 sd->engine->region_get(obj, &lon, &lat);
5024 sd->engine->del(obj);
5025 sd->engine = engine;
5027 if (sd->engine->zoom_max < sd->zoom)
5028 sd->zoom = sd->engine->zoom_max;
5029 else if (sd->engine->zoom_min > sd->zoom)
5030 sd->zoom = sd->engine->zoom_min;
5032 if (sd->engine->zoom_max < sd->zoom_max)
5033 sd->zoom_max = sd->engine->zoom_max;
5034 if (sd->engine->zoom_min > sd->zoom_min)
5035 sd->zoom_min = sd->engine->zoom_min;
5037 evas_object_hide(ELM_WIDGET_DATA(sd)->resize_obj);
5038 elm_widget_resize_object_set(obj, layout);
5039 sd->engine->zoom(obj, sd->zoom, 0);
5040 sd->engine->show(obj, lon, lat, 0);
5044 elm_map_engine_get(const Evas_Object *obj)
5046 ELM_MAP_CHECK(obj) NULL;
5047 ELM_MAP_DATA_GET(obj, sd);
5049 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->src_tile, NULL);
5051 return sd->engine->name;
5055 elm_map_engines_get(const Evas_Object *obj)
5057 ELM_MAP_CHECK(obj) NULL;
5058 ELM_MAP_DATA_GET(obj, sd);
5060 return sd->engine_names;
5064 elm_map_source_set(Evas_Object *obj,
5065 Elm_Map_Source_Type type,
5066 const char *source_name)
5068 #ifdef HAVE_ELEMENTARY_ECORE_CON
5070 ELM_MAP_DATA_GET(obj, sd);
5071 EINA_SAFETY_ON_NULL_RETURN(source_name);
5073 if (strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
5075 ERR("Current engine is not %s", INTERNAL_ENGINE_NAME);
5079 if (type == ELM_MAP_SOURCE_TYPE_TILE)
5080 _source_tile_set(sd, source_name);
5081 else if (type == ELM_MAP_SOURCE_TYPE_ROUTE)
5082 _source_route_set(sd, source_name);
5083 else if (type == ELM_MAP_SOURCE_TYPE_NAME)
5084 _source_name_set(sd, source_name);
5085 else ERR("Not supported map source type: %d", type);
5095 elm_map_source_get(const Evas_Object *obj,
5096 Elm_Map_Source_Type type)
5098 #ifdef HAVE_ELEMENTARY_ECORE_CON
5099 ELM_MAP_CHECK(obj) NULL;
5100 ELM_MAP_DATA_GET(obj, sd);
5102 if (strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
5104 ERR("Current engine is not %s", INTERNAL_ENGINE_NAME);
5107 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->src_tile, NULL);
5109 if (type == ELM_MAP_SOURCE_TYPE_TILE) return sd->src_tile->name;
5110 else if (type == ELM_MAP_SOURCE_TYPE_ROUTE)
5111 return sd->src_route->name;
5112 else if (type == ELM_MAP_SOURCE_TYPE_NAME)
5113 return sd->src_name->name;
5114 else ERR("Not supported map source type: %d", type);
5125 elm_map_sources_get(const Evas_Object *obj,
5126 Elm_Map_Source_Type type)
5128 #ifdef HAVE_ELEMENTARY_ECORE_CON
5129 ELM_MAP_CHECK(obj) NULL;
5130 ELM_MAP_DATA_GET(obj, sd);
5132 if (type == ELM_MAP_SOURCE_TYPE_TILE) return sd->src_tile_names;
5133 else if (type == ELM_MAP_SOURCE_TYPE_ROUTE)
5134 return sd->src_route_names;
5135 else if (type == ELM_MAP_SOURCE_TYPE_NAME)
5136 return sd->src_name_names;
5137 else ERR("Not supported map source type: %d", type);
5147 EAPI Elm_Map_Route *
5148 elm_map_route_add(Evas_Object *obj,
5149 Elm_Map_Route_Type type,
5150 Elm_Map_Route_Method method,
5155 Elm_Map_Route_Cb route_cb,
5158 #ifdef HAVE_ELEMENTARY_ECORE_CON
5161 Elm_Map_Route *route;
5162 char fname[PATH_MAX], fname2[PATH_MAX];
5164 ELM_MAP_CHECK(obj) NULL;
5165 ELM_MAP_DATA_GET(obj, sd);
5167 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->src_route, NULL);
5170 const char *cachedir;
5173 snprintf(fname, sizeof(fname), "%s" CACHE_ROUTE_ROOT,
5174 efreet_cache_home_get());
5177 cachedir = getenv("XDG_CACHE_HOME");
5178 snprintf(fname, sizeof(fname), "%s/%s" CACHE_ROUTE_ROOT, getenv("HOME"),
5179 cachedir ? : "/.config");
5181 if (!ecore_file_exists(fname)) ecore_file_mkpath(fname);
5184 if (type == ELM_MAP_ROUTE_TYPE_MOTOCAR)
5185 type_name = strdup(ROUTE_TYPE_MOTORCAR);
5186 else if (type == ELM_MAP_ROUTE_TYPE_BICYCLE)
5187 type_name = strdup(ROUTE_TYPE_BICYCLE);
5188 else if (type == ELM_MAP_ROUTE_TYPE_FOOT)
5189 type_name = strdup(ROUTE_TYPE_FOOT);
5190 else type_name = NULL;
5192 url = sd->src_route->url_cb(obj, type_name, method, flon, flat, tlon, tlat);
5195 ERR("Route URL is NULL");
5196 if (type_name) free(type_name);
5199 if (type_name) free(type_name);
5201 route = ELM_NEW(Elm_Map_Route);
5203 snprintf(fname2, sizeof(fname2), "%s/%d", fname, rand());
5204 route->fname = strdup(fname2);
5206 route->method = method;
5211 route->cb = route_cb;
5214 if (!ecore_file_download_full(url, route->fname, _route_cb, NULL, route,
5215 &(route->job), sd->ua) || !(route->job))
5217 ERR("Can't request Route from %s to %s", url, route->fname);
5222 INF("Route requested from %s to %s", url, route->fname);
5225 sd->routes = eina_list_append(sd->routes, route);
5226 evas_object_smart_callback_call
5227 (ELM_WIDGET_DATA(sd)->obj, SIG_ROUTE_LOAD, route);
5228 edje_object_signal_emit(ELM_WIDGET_DATA(sd)->resize_obj,
5229 "elm,state,busy,start", "elm");
5246 elm_map_route_del(Elm_Map_Route *route)
5248 #ifdef HAVE_ELEMENTARY_ECORE_CON
5252 EINA_SAFETY_ON_NULL_RETURN(route);
5253 EINA_SAFETY_ON_NULL_RETURN(route->wsd);
5254 ELM_MAP_CHECK(ELM_WIDGET_DATA(route->wsd)->obj);
5256 if (route->job) ecore_file_download_abort(route->job);
5258 EINA_LIST_FREE (route->waypoint, w)
5260 if (w->point) eina_stringshare_del(w->point);
5264 EINA_LIST_FREE (route->nodes, n)
5266 if (n->pos.address) eina_stringshare_del(n->pos.address);
5272 ecore_file_remove(route->fname);
5276 route->wsd->routes = eina_list_remove(route->wsd->routes, route);
5284 elm_map_route_distance_get(const Elm_Map_Route *route)
5286 #ifdef HAVE_ELEMENTARY_ECORE_CON
5287 EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
5288 return route->info.distance;
5296 elm_map_route_node_get(const Elm_Map_Route *route)
5298 #ifdef HAVE_ELEMENTARY_ECORE_CON
5299 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
5300 return route->info.nodes;
5308 elm_map_route_waypoint_get(const Elm_Map_Route *route)
5310 #ifdef HAVE_ELEMENTARY_ECORE_CON
5311 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
5312 return route->info.waypoints;
5320 elm_map_name_add(const Evas_Object *obj,
5321 const char *address,
5324 Elm_Map_Name_Cb name_cb,
5327 #ifdef HAVE_ELEMENTARY_ECORE_CON
5328 ELM_MAP_CHECK(obj) NULL;
5331 return _name_request(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0, 0,
5334 return _name_request(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat,
5348 elm_map_name_search(const Evas_Object *obj,
5349 const char *address,
5350 Elm_Map_Name_List_Cb name_cb,
5353 #ifdef HAVE_ELEMENTARY_ECORE_CON
5356 _name_list_request(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0, 0,
5367 elm_map_name_del(Elm_Map_Name *name)
5369 #ifdef HAVE_ELEMENTARY_ECORE_CON
5370 EINA_SAFETY_ON_NULL_RETURN(name);
5371 EINA_SAFETY_ON_NULL_RETURN(name->wsd);
5372 ELM_MAP_CHECK(ELM_WIDGET_DATA(name->wsd)->obj);
5374 if (name->job) ecore_file_download_abort(name->job);
5375 if (name->address) free(name->address);
5378 ecore_file_remove(name->fname);
5382 name->wsd->names = eina_list_remove(name->wsd->names, name);
5390 elm_map_name_address_get(const Elm_Map_Name *name)
5392 #ifdef HAVE_ELEMENTARY_ECORE_CON
5393 EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
5394 EINA_SAFETY_ON_NULL_RETURN_VAL(name->wsd, NULL);
5395 ELM_MAP_CHECK(ELM_WIDGET_DATA(name->wsd)->obj) NULL;
5397 return name->address;
5405 elm_map_name_region_get(const Elm_Map_Name *name,
5409 #ifdef HAVE_ELEMENTARY_ECORE_CON
5410 EINA_SAFETY_ON_NULL_RETURN(name);
5411 EINA_SAFETY_ON_NULL_RETURN(name->wsd);
5412 ELM_MAP_CHECK(ELM_WIDGET_DATA(name->wsd)->obj);
5414 if (lon) *lon = name->lon;
5415 if (lat) *lat = name->lat;
5423 EAPI Elm_Map_Overlay *
5424 elm_map_overlay_add(Evas_Object *obj,
5428 #ifdef HAVE_ELEMENTARY_ECORE_CON
5429 Elm_Map_Overlay *overlay;
5431 ELM_MAP_CHECK(obj) NULL;
5432 ELM_MAP_DATA_GET(obj, sd);
5434 overlay = ELM_NEW(Elm_Map_Overlay);
5436 overlay->type = ELM_MAP_OVERLAY_TYPE_DEFAULT;
5437 overlay->c.r = 0x87;
5438 overlay->c.g = 0xce;
5439 overlay->c.b = 0xeb;
5441 overlay->ovl = _overlay_default_new(overlay, lon, lat, overlay->c, 1);
5442 overlay->grp = _overlay_group_new(sd);
5443 sd->overlays = eina_list_append(sd->overlays, overlay);
5445 evas_object_smart_changed(sd->pan_obj);
5457 elm_map_overlays_get(Evas_Object *obj)
5459 #ifdef HAVE_ELEMENTARY_ECORE_CON
5461 Elm_Map_Overlay *ovl;
5463 ELM_MAP_CHECK(obj) NULL;
5464 ELM_MAP_DATA_GET(obj, sd);
5466 eina_list_free(sd->all_overlays);
5467 sd->all_overlays = NULL;
5469 EINA_LIST_FOREACH(sd->overlays, l, ovl)
5470 sd->all_overlays = eina_list_append(sd->all_overlays, ovl);
5471 EINA_LIST_FOREACH(sd->group_overlays, l, ovl)
5472 sd->all_overlays = eina_list_append(sd->all_overlays, ovl);
5474 return sd->all_overlays;
5482 elm_map_overlay_del(Elm_Map_Overlay *overlay)
5484 #ifdef HAVE_ELEMENTARY_ECORE_CON
5485 EINA_SAFETY_ON_NULL_RETURN(overlay);
5486 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5487 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5489 evas_object_smart_callback_call
5490 (ELM_WIDGET_DATA(overlay->wsd)->obj, SIG_OVERLAY_DEL, overlay);
5491 if (overlay->del_cb)
5493 (overlay->del_cb_data, ELM_WIDGET_DATA(overlay->wsd)->obj, overlay);
5497 if (overlay->grp->klass)
5498 elm_map_overlay_class_remove(overlay->grp->klass, overlay);
5499 _overlay_group_free(overlay->grp);
5502 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5503 _overlay_default_free(overlay->ovl);
5504 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
5505 _overlay_bubble_free(overlay->ovl);
5506 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5507 _overlay_class_free(overlay->ovl);
5508 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
5509 _overlay_route_free(overlay->ovl);
5510 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_LINE)
5511 _overlay_line_free(overlay->ovl);
5512 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON)
5513 _overlay_polygon_free(overlay->ovl);
5514 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CIRCLE)
5515 _overlay_circle_free(overlay->ovl);
5516 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_SCALE)
5517 _overlay_scale_free(overlay->ovl);
5518 else ERR("Invalid overlay type: %d", overlay->type);
5520 overlay->wsd->overlays = eina_list_remove(overlay->wsd->overlays, overlay);
5521 evas_object_smart_changed(overlay->wsd->pan_obj);
5529 EAPI Elm_Map_Overlay_Type
5530 elm_map_overlay_type_get(const Elm_Map_Overlay *overlay)
5532 #ifdef HAVE_ELEMENTARY_ECORE_CON
5533 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, ELM_MAP_OVERLAY_TYPE_NONE);
5534 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wsd, ELM_MAP_OVERLAY_TYPE_NONE);
5535 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj) ELM_MAP_OVERLAY_TYPE_NONE;
5537 return overlay->type;
5540 return ELM_MAP_OVERLAY_TYPE_NONE;
5545 elm_map_overlay_data_set(Elm_Map_Overlay *overlay,
5548 #ifdef HAVE_ELEMENTARY_ECORE_CON
5549 EINA_SAFETY_ON_NULL_RETURN(overlay);
5550 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5551 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5553 overlay->data = data;
5561 elm_map_overlay_data_get(const Elm_Map_Overlay *overlay)
5563 #ifdef HAVE_ELEMENTARY_ECORE_CON
5564 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
5565 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wsd, NULL);
5566 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj) NULL;
5568 return overlay->data;
5576 elm_map_overlay_hide_set(Elm_Map_Overlay *overlay,
5579 #ifdef HAVE_ELEMENTARY_ECORE_CON
5580 EINA_SAFETY_ON_NULL_RETURN(overlay);
5581 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5582 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5584 if (overlay->hide == !!hide) return;
5585 overlay->hide = hide;
5587 evas_object_smart_changed(overlay->wsd->pan_obj);
5595 elm_map_overlay_hide_get(const Elm_Map_Overlay *overlay)
5597 #ifdef HAVE_ELEMENTARY_ECORE_CON
5598 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
5599 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wsd, EINA_FALSE);
5600 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj) EINA_FALSE;
5602 return overlay->hide;
5610 elm_map_overlay_displayed_zoom_min_set(Elm_Map_Overlay *overlay,
5613 #ifdef HAVE_ELEMENTARY_ECORE_CON
5614 EINA_SAFETY_ON_NULL_RETURN(overlay);
5615 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5616 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5618 overlay->zoom_min = zoom;
5619 evas_object_smart_changed(overlay->wsd->pan_obj);
5627 elm_map_overlay_displayed_zoom_min_get(const Elm_Map_Overlay *overlay)
5629 #ifdef HAVE_ELEMENTARY_ECORE_CON
5630 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, 0);
5631 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wsd, 0);
5632 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj) 0;
5634 return overlay->zoom_min;
5642 elm_map_overlay_paused_set(Elm_Map_Overlay *overlay,
5645 #ifdef HAVE_ELEMENTARY_ECORE_CON
5646 EINA_SAFETY_ON_NULL_RETURN(overlay);
5647 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5648 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5650 if (overlay->paused == !!paused) return;
5651 overlay->paused = paused;
5653 evas_object_smart_changed(overlay->wsd->pan_obj);
5661 elm_map_overlay_paused_get(const Elm_Map_Overlay *overlay)
5663 #ifdef HAVE_ELEMENTARY_ECORE_CON
5664 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
5665 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wsd, EINA_FALSE);
5666 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj) EINA_FALSE;
5668 return overlay->paused;
5676 elm_map_overlay_visible_get(const Elm_Map_Overlay *overlay)
5678 #ifdef HAVE_ELEMENTARY_ECORE_CON
5679 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
5680 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wsd, EINA_FALSE);
5681 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj) EINA_FALSE;
5683 return overlay->visible;
5691 elm_map_overlay_show(Elm_Map_Overlay *overlay)
5693 #ifdef HAVE_ELEMENTARY_ECORE_CON
5694 EINA_SAFETY_ON_NULL_RETURN(overlay);
5695 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5696 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5698 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5700 Overlay_Default *ovl = overlay->ovl;
5703 (ELM_WIDGET_DATA(overlay->wsd)->obj, ovl->lon, ovl->lat);
5705 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
5707 Overlay_Bubble *ovl = overlay->ovl;
5710 (ELM_WIDGET_DATA(overlay->wsd)->obj, ovl->lon, ovl->lat);
5712 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5714 Overlay_Class *ovl = overlay->ovl;
5715 double lon, lat, max_lo, min_lo, max_la, min_la;
5717 _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la, &min_la);
5718 lon = (max_lo + min_lo) / 2;
5719 lat = (max_la + min_la) / 2;
5720 elm_map_region_show(ELM_WIDGET_DATA(overlay->wsd)->obj, lon, lat);
5722 else ERR("Not supported overlay type: %d", overlay->type);
5724 evas_object_smart_changed(overlay->wsd->pan_obj);
5731 elm_map_overlays_show(Eina_List *overlays)
5733 #ifdef HAVE_ELEMENTARY_ECORE_CON
5734 Elm_Map_Smart_Data *sd;
5735 Elm_Map_Overlay *overlay;
5737 EINA_SAFETY_ON_NULL_RETURN(overlays);
5738 EINA_SAFETY_ON_FALSE_RETURN(eina_list_count(overlays));
5740 overlay = eina_list_data_get(overlays);
5743 if (!strcmp(sd->engine->name, INTERNAL_ENGINE_NAME))
5745 sd->calc_job.overlays_changed = EINA_TRUE;
5746 sd->calc_job.overlays = overlays;
5747 evas_object_smart_changed(sd->pan_obj);
5749 else ERR("Engine(%s) do not support overlays show", sd->engine->name);
5757 elm_map_overlay_region_set(Elm_Map_Overlay *overlay,
5761 #ifdef HAVE_ELEMENTARY_ECORE_CON
5762 EINA_SAFETY_ON_NULL_RETURN(overlay);
5763 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5764 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5766 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5768 Overlay_Default *ovl = overlay->ovl;
5773 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
5775 Overlay_Bubble *ovl = overlay->ovl;
5781 else ERR("Not supported overlay type: %d", overlay->type);
5783 evas_object_smart_changed(overlay->wsd->pan_obj);
5792 elm_map_overlay_region_get(const Elm_Map_Overlay *overlay,
5796 #ifdef HAVE_ELEMENTARY_ECORE_CON
5797 EINA_SAFETY_ON_NULL_RETURN(overlay);
5798 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5799 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5801 if (overlay->type == ELM_MAP_OVERLAY_TYPE_GROUP)
5803 Overlay_Group *ovl = overlay->ovl;
5805 if (lon) *lon = ovl->lon;
5806 if (lat) *lat = ovl->lat;
5808 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5810 const Overlay_Default *ovl = overlay->ovl;
5812 if (lon) *lon = ovl->lon;
5813 if (lat) *lat = ovl->lat;
5815 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
5817 const Overlay_Bubble *ovl = overlay->ovl;
5819 if (lon) *lon = ovl->lon;
5820 if (lat) *lat = ovl->lat;
5822 else ERR("Not supported overlay type: %d", overlay->type);
5831 elm_map_overlay_icon_set(Elm_Map_Overlay *overlay,
5834 #ifdef HAVE_ELEMENTARY_ECORE_CON
5835 EINA_SAFETY_ON_NULL_RETURN(overlay);
5836 EINA_SAFETY_ON_NULL_RETURN(icon);
5837 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5838 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5840 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5841 _overlay_default_icon_update(overlay->ovl, icon);
5842 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5843 _overlay_class_icon_update(overlay->ovl, icon);
5844 else ERR("Not supported overlay type: %d", overlay->type);
5846 evas_object_smart_changed(overlay->wsd->pan_obj);
5853 EAPI const Evas_Object *
5854 elm_map_overlay_icon_get(const Elm_Map_Overlay *overlay)
5856 #ifdef HAVE_ELEMENTARY_ECORE_CON
5857 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
5858 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wsd, NULL);
5859 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj) NULL;
5861 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5863 const Overlay_Default *ovl = overlay->ovl;
5867 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5869 const Overlay_Class *ovl = overlay->ovl;
5875 ERR("Not supported overlay type: %d", overlay->type);
5885 elm_map_overlay_content_set(Elm_Map_Overlay *overlay,
5886 Evas_Object *content)
5888 #ifdef HAVE_ELEMENTARY_ECORE_CON
5889 EINA_SAFETY_ON_NULL_RETURN(overlay);
5890 EINA_SAFETY_ON_NULL_RETURN(content);
5891 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5892 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5894 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5895 _overlay_default_content_update(overlay->ovl, content, overlay);
5896 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5897 _overlay_class_content_update(overlay->ovl, content);
5898 else ERR("Not supported overlay type: %d", overlay->type);
5900 evas_object_smart_changed(overlay->wsd->pan_obj);
5907 EAPI const Evas_Object *
5908 elm_map_overlay_content_get(const Elm_Map_Overlay *overlay)
5910 #ifdef HAVE_ELEMENTARY_ECORE_CON
5911 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
5912 EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wsd, NULL);
5914 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj) NULL;
5916 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5918 const Overlay_Default *ovl = overlay->ovl;
5919 return ovl->content;
5921 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5923 const Overlay_Class *ovl = overlay->ovl;
5924 return ovl->content;
5928 ERR("Not supported overlay type: %d", overlay->type);
5938 elm_map_overlay_color_set(Elm_Map_Overlay *overlay,
5944 #ifdef HAVE_ELEMENTARY_ECORE_CON
5945 EINA_SAFETY_ON_NULL_RETURN(overlay);
5946 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5947 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5954 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
5955 _overlay_class_color_update(overlay->ovl, overlay->c);
5956 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
5957 _overlay_default_color_update(overlay->ovl, overlay->c);
5958 else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
5959 _overlay_route_color_update(overlay->ovl, overlay->c);
5962 ERR("Not supported overlay type: %d", overlay->type);
5975 elm_map_overlay_color_get(const Elm_Map_Overlay *overlay,
5981 #ifdef HAVE_ELEMENTARY_ECORE_CON
5982 EINA_SAFETY_ON_NULL_RETURN(overlay);
5983 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
5984 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
5986 if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
5988 if (r) *r = overlay->c.r;
5989 if (g) *g = overlay->c.g;
5990 if (b) *b = overlay->c.b;
5991 if (a) *a = overlay->c.a;
5993 else ERR("Not supported overlay type: %d", overlay->type);
6004 elm_map_overlay_get_cb_set(Elm_Map_Overlay *overlay,
6005 Elm_Map_Overlay_Get_Cb get_cb,
6008 #ifdef HAVE_ELEMENTARY_ECORE_CON
6009 EINA_SAFETY_ON_NULL_RETURN(overlay);
6010 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
6011 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
6013 overlay->cb = get_cb;
6014 overlay->cb_data = data;
6016 if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
6017 _overlay_class_cb_set(overlay->ovl, get_cb, data);
6026 elm_map_overlay_del_cb_set(Elm_Map_Overlay *overlay,
6027 Elm_Map_Overlay_Del_Cb del_cb,
6030 #ifdef HAVE_ELEMENTARY_ECORE_CON
6031 EINA_SAFETY_ON_NULL_RETURN(overlay);
6032 EINA_SAFETY_ON_NULL_RETURN(overlay->wsd);
6033 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
6035 overlay->del_cb = del_cb;
6036 overlay->del_cb_data = data;
6044 EAPI Elm_Map_Overlay *
6045 elm_map_overlay_class_add(Evas_Object *obj)
6047 #ifdef HAVE_ELEMENTARY_ECORE_CON
6048 Elm_Map_Overlay *overlay;
6050 ELM_MAP_CHECK(obj) NULL;
6051 ELM_MAP_DATA_GET(obj, sd);
6053 overlay = ELM_NEW(Elm_Map_Overlay);
6055 overlay->type = ELM_MAP_OVERLAY_TYPE_CLASS;
6056 overlay->ovl = _overlay_class_new(sd);
6057 overlay->c.r = 0x90;
6058 overlay->c.g = 0xee;
6059 overlay->c.b = 0x90;
6060 overlay->c.a = 0xff;
6061 sd->overlays = eina_list_append(sd->overlays, overlay);
6063 evas_object_smart_changed(sd->pan_obj);
6072 elm_map_overlay_class_append(Elm_Map_Overlay *klass,
6073 Elm_Map_Overlay *overlay)
6075 #ifdef HAVE_ELEMENTARY_ECORE_CON
6076 Overlay_Class *class_ovl;
6078 EINA_SAFETY_ON_NULL_RETURN(klass);
6079 EINA_SAFETY_ON_NULL_RETURN(overlay);
6080 EINA_SAFETY_ON_NULL_RETURN(klass->wsd);
6081 ELM_MAP_CHECK(ELM_WIDGET_DATA(klass->wsd)->obj);
6082 EINA_SAFETY_ON_FALSE_RETURN(klass->type == ELM_MAP_OVERLAY_TYPE_CLASS);
6084 class_ovl = klass->ovl;
6085 if (eina_list_data_find(class_ovl->members, overlay))
6087 ERR("Already added overlay into clas");
6090 class_ovl->members = eina_list_append(class_ovl->members, overlay);
6092 // Update group by class
6093 overlay->grp->klass = klass;
6094 _overlay_group_icon_update(overlay->grp, class_ovl->icon);
6095 _overlay_group_content_update(overlay->grp, class_ovl->content, overlay);
6096 _overlay_group_color_update(overlay->grp, klass->c);
6097 _overlay_group_cb_set(overlay->grp, klass->cb, klass->data);
6098 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
6100 _overlay_default_class_icon_update(overlay->ovl, class_ovl->icon);
6101 _overlay_default_class_content_update
6102 (overlay->ovl, class_ovl->content);
6105 evas_object_smart_changed(klass->wsd->pan_obj);
6113 elm_map_overlay_class_remove(Elm_Map_Overlay *klass,
6114 Elm_Map_Overlay *overlay)
6116 #ifdef HAVE_ELEMENTARY_ECORE_CON
6119 EINA_SAFETY_ON_NULL_RETURN(klass);
6120 EINA_SAFETY_ON_NULL_RETURN(overlay);
6121 EINA_SAFETY_ON_NULL_RETURN(klass->wsd);
6122 ELM_MAP_CHECK(ELM_WIDGET_DATA(klass->wsd)->obj);
6123 EINA_SAFETY_ON_FALSE_RETURN(klass->type == ELM_MAP_OVERLAY_TYPE_CLASS);
6126 ovl->members = eina_list_remove(ovl->members, overlay);
6128 overlay->grp->klass = NULL;
6129 _overlay_group_icon_update(overlay->grp, NULL);
6130 _overlay_group_content_update(overlay->grp, NULL, NULL);
6131 if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
6133 _overlay_default_class_icon_update(overlay->ovl, NULL);
6134 _overlay_default_class_content_update(overlay->ovl, NULL);
6137 evas_object_smart_changed(klass->wsd->pan_obj);
6145 elm_map_overlay_class_zoom_max_set(Elm_Map_Overlay *klass,
6148 #ifdef HAVE_ELEMENTARY_ECORE_CON
6151 EINA_SAFETY_ON_NULL_RETURN(klass);
6152 EINA_SAFETY_ON_NULL_RETURN(klass->wsd);
6153 ELM_MAP_CHECK(ELM_WIDGET_DATA(klass->wsd)->obj);
6154 EINA_SAFETY_ON_FALSE_RETURN(klass->type == ELM_MAP_OVERLAY_TYPE_CLASS);
6157 if (ovl->zoom_max == !!zoom) return;
6158 ovl->zoom_max = zoom;
6160 evas_object_smart_changed(klass->wsd->pan_obj);
6168 elm_map_overlay_class_zoom_max_get(const Elm_Map_Overlay *klass)
6170 #ifdef HAVE_ELEMENTARY_ECORE_CON
6171 const Overlay_Class *ovl;
6173 EINA_SAFETY_ON_NULL_RETURN_VAL(klass, OVERLAY_CLASS_ZOOM_MAX);
6174 EINA_SAFETY_ON_NULL_RETURN_VAL(klass->wsd, OVERLAY_CLASS_ZOOM_MAX);
6175 ELM_MAP_CHECK(ELM_WIDGET_DATA(klass->wsd)->obj) OVERLAY_CLASS_ZOOM_MAX;
6177 EINA_SAFETY_ON_FALSE_RETURN_VAL
6178 (klass->type == ELM_MAP_OVERLAY_TYPE_CLASS, OVERLAY_CLASS_ZOOM_MAX);
6181 return ovl->zoom_max;
6184 return OVERLAY_CLASS_ZOOM_MAX;
6189 elm_map_overlay_group_members_get(const Elm_Map_Overlay *grp)
6191 #ifdef HAVE_ELEMENTARY_ECORE_CON
6194 EINA_SAFETY_ON_NULL_RETURN_VAL(grp, NULL);
6195 EINA_SAFETY_ON_NULL_RETURN_VAL(grp->wsd, NULL);
6196 ELM_MAP_CHECK(ELM_WIDGET_DATA(grp->wsd)->obj) NULL;
6198 EINA_SAFETY_ON_FALSE_RETURN_VAL
6199 (grp->type == ELM_MAP_OVERLAY_TYPE_GROUP, NULL);
6202 return ovl->members;
6209 EAPI Elm_Map_Overlay *
6210 elm_map_overlay_bubble_add(Evas_Object *obj)
6212 #ifdef HAVE_ELEMENTARY_ECORE_CON
6213 Elm_Map_Overlay *overlay;
6215 ELM_MAP_CHECK(obj) NULL;
6216 ELM_MAP_DATA_GET(obj, sd);
6218 overlay = ELM_NEW(Elm_Map_Overlay);
6220 overlay->type = ELM_MAP_OVERLAY_TYPE_BUBBLE;
6225 overlay->ovl = _overlay_bubble_new(overlay);
6226 overlay->grp = _overlay_group_new(sd);
6227 sd->overlays = eina_list_append(sd->overlays, overlay);
6229 evas_object_smart_changed(sd->pan_obj);
6238 elm_map_overlay_bubble_follow(Elm_Map_Overlay *bubble,
6239 const Elm_Map_Overlay *parent)
6241 #ifdef HAVE_ELEMENTARY_ECORE_CON
6242 Overlay_Bubble *ovl;
6245 EINA_SAFETY_ON_NULL_RETURN(bubble);
6246 EINA_SAFETY_ON_NULL_RETURN(parent);
6247 ELM_MAP_CHECK(ELM_WIDGET_DATA(bubble->wsd)->obj);
6248 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
6251 pobj = _overlay_obj_get(parent);
6255 evas_object_smart_changed(bubble->wsd->pan_obj);
6263 elm_map_overlay_bubble_content_append(Elm_Map_Overlay *bubble,
6264 Evas_Object *content)
6266 #ifdef HAVE_ELEMENTARY_ECORE_CON
6269 EINA_SAFETY_ON_NULL_RETURN(bubble);
6270 EINA_SAFETY_ON_NULL_RETURN(content);
6271 ELM_MAP_CHECK(ELM_WIDGET_DATA(bubble->wsd)->obj);
6272 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
6275 elm_box_pack_end(bb->bx, content);
6277 evas_object_smart_changed(bubble->wsd->pan_obj);
6285 elm_map_overlay_bubble_content_clear(Elm_Map_Overlay *bubble)
6287 #ifdef HAVE_ELEMENTARY_ECORE_CON
6290 EINA_SAFETY_ON_NULL_RETURN(bubble);
6291 ELM_MAP_CHECK(ELM_WIDGET_DATA(bubble->wsd)->obj);
6292 EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
6295 elm_box_clear(bb->bx);
6297 evas_object_smart_changed(bubble->wsd->pan_obj);
6303 EAPI Elm_Map_Overlay *
6304 elm_map_overlay_route_add(Evas_Object *obj,
6305 const Elm_Map_Route *route)
6307 #ifdef HAVE_ELEMENTARY_ECORE_CON
6308 Elm_Map_Overlay *overlay;
6310 ELM_MAP_CHECK(obj) NULL;
6311 ELM_MAP_DATA_GET(obj, sd);
6313 EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
6314 EINA_SAFETY_ON_NULL_RETURN_VAL(route->wsd, NULL);
6315 EINA_SAFETY_ON_FALSE_RETURN_VAL
6316 (obj == ELM_WIDGET_DATA(route->wsd)->obj, NULL);
6318 overlay = ELM_NEW(Elm_Map_Overlay);
6320 overlay->type = ELM_MAP_OVERLAY_TYPE_ROUTE;
6321 overlay->c.r = 0xff;
6322 overlay->c.g = 0x00;
6323 overlay->c.b = 0x00;
6324 overlay->c.a = 0xff;
6325 overlay->ovl = _overlay_route_new(sd, route, overlay->c);
6326 overlay->grp = _overlay_group_new(sd);
6327 sd->overlays = eina_list_append(sd->overlays, overlay);
6329 evas_object_smart_changed(sd->pan_obj);
6338 EAPI Elm_Map_Overlay *
6339 elm_map_overlay_line_add(Evas_Object *obj,
6345 #ifdef HAVE_ELEMENTARY_ECORE_CON
6346 Elm_Map_Overlay *overlay;
6348 ELM_MAP_CHECK(obj) NULL;
6349 ELM_MAP_DATA_GET(obj, sd);
6351 overlay = ELM_NEW(Elm_Map_Overlay);
6353 overlay->type = ELM_MAP_OVERLAY_TYPE_LINE;
6354 overlay->c.r = 0xff;
6355 overlay->c.g = 0x00;
6356 overlay->c.b = 0x00;
6357 overlay->c.a = 0xff;
6358 overlay->ovl = _overlay_line_new(sd, flon, flat, tlon, tlat, overlay->c);
6359 overlay->grp = _overlay_group_new(sd);
6360 sd->overlays = eina_list_append(sd->overlays, overlay);
6362 evas_object_smart_changed(sd->pan_obj);
6374 EAPI Elm_Map_Overlay *
6375 elm_map_overlay_polygon_add(Evas_Object *obj)
6377 #ifdef HAVE_ELEMENTARY_ECORE_CON
6378 Elm_Map_Overlay *overlay;
6380 ELM_MAP_CHECK(obj) NULL;
6381 ELM_MAP_DATA_GET(obj, sd);
6383 overlay = ELM_NEW(Elm_Map_Overlay);
6385 overlay->type = ELM_MAP_OVERLAY_TYPE_POLYGON;
6386 overlay->c.r = 0xdc;
6387 overlay->c.g = 0x14;
6388 overlay->c.b = 0x3c;
6390 overlay->ovl = _overlay_polygon_new(sd, overlay->c);
6391 overlay->grp = _overlay_group_new(sd);
6392 sd->overlays = eina_list_append(sd->overlays, overlay);
6393 evas_object_smart_changed(sd->pan_obj);
6402 elm_map_overlay_polygon_region_add(Elm_Map_Overlay *overlay,
6406 #ifdef HAVE_ELEMENTARY_ECORE_CON
6407 Overlay_Polygon *ovl;
6410 EINA_SAFETY_ON_NULL_RETURN(overlay);
6411 ELM_MAP_CHECK(ELM_WIDGET_DATA(overlay->wsd)->obj);
6412 EINA_SAFETY_ON_FALSE_RETURN(overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON);
6415 r = ELM_NEW(Region);
6418 ovl->regions = eina_list_append(ovl->regions, r);
6420 evas_object_smart_changed(ovl->wsd->pan_obj);
6428 EAPI Elm_Map_Overlay *
6429 elm_map_overlay_circle_add(Evas_Object *obj,
6434 #ifdef HAVE_ELEMENTARY_ECORE_CON
6435 Elm_Map_Overlay *overlay;
6437 ELM_MAP_CHECK(obj) NULL;
6438 ELM_MAP_DATA_GET(obj, sd);
6440 overlay = ELM_NEW(Elm_Map_Overlay);
6442 overlay->type = ELM_MAP_OVERLAY_TYPE_CIRCLE;
6443 overlay->c.r = 0xdc;
6444 overlay->c.g = 0x14;
6445 overlay->c.b = 0x3c;
6447 overlay->ovl = _overlay_circle_new(sd, lon, lat, radius, overlay->c);
6448 overlay->grp = _overlay_group_new(sd);
6449 sd->overlays = eina_list_append(sd->overlays, overlay);
6451 evas_object_smart_changed(sd->pan_obj);
6462 EAPI Elm_Map_Overlay *
6463 elm_map_overlay_scale_add(Evas_Object *obj,
6467 #ifdef HAVE_ELEMENTARY_ECORE_CON
6468 Elm_Map_Overlay *overlay;
6470 ELM_MAP_CHECK(obj) NULL;
6471 ELM_MAP_DATA_GET(obj, sd);
6473 overlay = ELM_NEW(Elm_Map_Overlay);
6475 overlay->type = ELM_MAP_OVERLAY_TYPE_SCALE;
6480 overlay->ovl = _overlay_scale_new(sd, x, y, overlay->c);
6481 overlay->grp = _overlay_group_new(sd);
6482 sd->overlays = eina_list_append(sd->overlays, overlay);
6484 evas_object_smart_changed(sd->pan_obj);
6496 elm_map_track_add(Evas_Object *obj,
6499 #ifdef HAVE_ELEMENTARY_ECORE_CON
6500 EMap_Route *emapr = emap;
6503 ELM_MAP_CHECK(obj) NULL;
6504 ELM_MAP_DATA_GET(obj, sd);
6506 route = elm_route_add(obj);
6507 elm_route_emap_set(route, emapr);
6508 sd->track = eina_list_append(sd->track, route);
6519 elm_map_track_remove(Evas_Object *obj,
6522 #ifdef HAVE_ELEMENTARY_ECORE_CON
6524 ELM_MAP_DATA_GET(obj, sd);
6526 sd->track = eina_list_remove(sd->track, route);
6527 evas_object_del(route);
6536 elm_map_track_add(Evas_Object *obj __UNUSED__,
6537 void *emap __UNUSED__)
6543 elm_map_track_remove(Evas_Object *obj __UNUSED__,
6544 Evas_Object *route __UNUSED__)