1 #include <Elementary.h>
3 #include "elm_module_priv.h"
4 #include "els_scroller.h"
10 * This is a widget specifically for displaying the free map OpenStreetMap.
12 * Signals that you can add callbacks for are:
14 * clicked - This is called when a user has clicked the map without dragging
17 * press - This is called when a user has pressed down on the map.
19 * longpressed - This is called when a user has pressed down on the map for
20 * a long time without dragging around.
22 * clicked,double - This is called when a user has double-clicked the photo.
24 * load,details - Map detailed data load begins.
26 * loaded,details - This is called when all parts of the map are loaded.
28 * zoom,start - Zoom animation started.
30 * zoom,stop - Zoom animation stopped.
32 * zoom,change - Zoom changed when using an auto zoom mode.
34 * scroll - the content has been scrolled (moved)
36 * scroll,anim,start - scrolling animation has started
38 * scroll,anim,stop - scrolling animation has stopped
40 * scroll,drag,start - dragging the contents around has started
42 * scroll,drag,stop - dragging the contents around has stopped
48 typedef struct _Widget_Data Widget_Data;
49 typedef struct _Pan Pan;
50 typedef struct _Grid Grid;
51 typedef struct _Grid_Item Grid_Item;
52 typedef struct _Marker_Group Marker_Group;
53 typedef struct _Mod_Api Mod_Api;
55 #define DEST_DIR_ZOOM_PATH "/tmp/elm_map/%d/%d/"
56 #define DEST_DIR_PATH DEST_DIR_ZOOM_PATH"%d/"
57 #define DEST_FILE_PATH "%s%d.png"
60 // Currently the size of a tile must be 256*256
61 // and the size of the map must be pow(2.0, z)*tile_size
62 typedef struct _Map_Sources_Tab
64 Elm_Map_Sources source;
68 ElmMapSourceURLFunc url_cb;
69 Eina_Bool use_module : 1;
73 #define TOUCH_HOLD_RANGE 40
74 //Zemm min is supposed to be 0
75 static char * _mapnik_url_cb(void *data ,int x, int y, int zoom);
76 static char * _osmarender_url_cb(void *data ,int x, int y, int zoom);
77 static char * _cyclemap_url_cb(void *data ,int x, int y, int zoom);
78 static char * _maplint_url_cb(void *data ,int x, int y, int zoom);
79 static char * _decarta_url_cb(void *data ,int x, int y, int zoom);
80 static Map_Sources_Tab map_sources_tab[] =
82 {ELM_MAP_SOURCE_MAPNIK, "Mapnik", 0, 18, _mapnik_url_cb, EINA_FALSE},
83 {ELM_MAP_SOURCE_OSMARENDER, "Osmarender", 0, 17, _osmarender_url_cb, EINA_FALSE},
84 {ELM_MAP_SOURCE_CYCLEMAP, "Cycle Map", 0, 17, _cyclemap_url_cb, EINA_FALSE},
85 {ELM_MAP_SOURCE_MAPLINT, "Maplint", 12, 16, _maplint_url_cb, EINA_FALSE},
86 {ELM_MAP_SOURCE_DECARTA, "Decarta", 1, 20, _decarta_url_cb, EINA_TRUE},
87 {ELM_MAP_SOURCE_CUSTOM_1, "Custom 1", 0, 18, NULL, EINA_FALSE},
88 {ELM_MAP_SOURCE_CUSTOM_2, "Custom 2", 0, 18, NULL, EINA_FALSE},
89 {ELM_MAP_SOURCE_CUSTOM_3, "Custom 3", 0, 18, NULL, EINA_FALSE},
90 {ELM_MAP_SOURCE_CUSTOM_4, "Custom 4", 0, 18, NULL, EINA_FALSE},
91 {ELM_MAP_SOURCE_CUSTOM_5, "Custom 5", 0, 18, NULL, EINA_FALSE},
92 {ELM_MAP_SOURCE_CUSTOM_6, "Custom 6", 0, 18, NULL, EINA_FALSE}
95 struct _Elm_Map_Marker_Class
100 struct _Elm_Map_Marker_Class_Func {
101 ElmMapMarkerGetFunc get;
102 ElmMapMarkerDelFunc del; //if NULL the object will be destroyed with evas_object_del()
103 ElmMapMarkerIconGetFunc icon_get;
106 struct { //this part is private, do not modify these values
108 Evas_Coord edje_w, edje_h;
112 struct _Elm_Map_Marker
115 Elm_Map_Marker_Class *clas;
116 Elm_Map_Group_Class *clas_group;
117 double longitude, latitude;
120 Evas_Coord x[ZOOM_MAX+1], y[ZOOM_MAX+1];
123 Marker_Group *groups[ZOOM_MAX+1];
125 Evas_Object *content;
128 struct _Elm_Map_Group_Class
132 int zoom_displayed; // display the group if the zoom is >= to zoom_display
133 int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
137 ElmMapGroupIconGetFunc icon_get;
140 struct { //this part is private, do not modify these values
142 Evas_Coord edje_w, edje_h;
143 Evas_Coord edje_max_w, edje_max_h;
145 Eina_List *objs_used;
146 Eina_List *objs_notused;
153 Eina_Matrixsparse_Cell *cell;
154 Elm_Map_Group_Class *clas;
157 long long sum_x, sum_y;
161 Evas_Object *obj, *bubble, *sc, *bx, *rect;
163 Eina_Bool bringin : 1;
164 Eina_Bool update_nbelems : 1;
165 Eina_Bool update_resize : 1;
166 Eina_Bool update_raise : 1;
167 Eina_Bool delete_object : 1;
180 Eina_Bool download : 1;
182 Ecore_File_Download_Job *job;
189 int tsize; // size of tile (tsize x tsize pixels)
190 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
191 int iw, ih; // size of image in pixels
192 int w, h; // size of grid image in pixels (represented by grid)
193 int gw, gh; // size of grid in tiles
194 Eina_Matrixsparse *grid;
201 Evas_Object *pan_smart;
203 Evas_Object *sep_maps_markers; //map objects are below this object and marker objects are on top
205 Evas_Coord pan_x, pan_y, minw, minh;
209 Elm_Map_Zoom_Mode mode;
212 Ecore_Timer *scr_timer;
213 Ecore_Timer *long_timer;
214 Ecore_Animator *zoom_animator;
215 double t_start, t_end;
225 Evas_Coord x, y ,w ,h;
231 Eina_Bool resized : 1;
232 Eina_Bool longpressed : 1;
233 Eina_Bool on_hold : 1;
234 Eina_Bool paused : 1;
235 Eina_Bool paused_markers : 1;
236 Eina_Bool pinch_zoom : 1;
243 Ecore_Job *markers_place_job;
244 Eina_Matrixsparse *markers[ZOOM_MAX+1];
245 Eina_List *cells_displayed; // list of Eina_Matrixsparse_Cell
246 Evas_Coord markers_max_num;
247 int marker_max_w, marker_max_h;
249 Eina_List *opened_bubbles; //opened bubbles, list of Map_Group *
251 Eina_List *groups_clas; // list of Elm_Map_Group_Class*
252 Eina_List *markers_clas; // list of Elm_Map_Markers_Class*
254 Elm_Map_Sources source;
260 Evas_Object_Smart_Clipped_Data __clipped_data;
266 Eina_Bool (*obj_hook) (Evas_Object *obj);
267 Eina_Bool (*obj_unhook) (Evas_Object *obj);
268 char * (*obj_url_request) (Evas_Object *obj, int x, int y, int zoom);
269 Eina_Bool (*obj_convert_coord_into_geo) (const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat);
270 Eina_Bool (*obj_convert_geo_into_coord) (const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y);
281 Evas_Coord x, y, w, h;
284 Ecore_Timer *hold_timer;
290 Evas_Object *pinch_obj;
293 static int dis_old = 0;
294 static Eina_List *s_event_list;
296 static const char *widtype = NULL;
298 static const char SIG_CHANGED[] = "changed";
299 static const char SIG_CLICKED[] = "clicked";
300 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
301 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
302 static const char SIG_LOAD_DETAIL[] = "load,detail";
303 static const char SIG_LONGPRESSED[] = "longpressed";
304 static const char SIG_PRESS[] = "press";
305 static const char SIG_SCROLL[] = "scroll";
306 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
307 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
308 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
309 static const char SIG_ZOOM_START[] = "zoom,start";
310 static const char SIG_ZOOM_STOP[] = "zoom,stop";
311 static const Evas_Smart_Cb_Description _signals[] = {
314 {SIG_CLICKED_DOUBLE, ""},
315 {SIG_LOADED_DETAIL, ""},
316 {SIG_LOAD_DETAIL, ""},
317 {SIG_LONGPRESSED, ""},
320 {SIG_SCROLL_DRAG_START, ""},
321 {SIG_SCROLL_DRAG_STOP, ""},
322 {SIG_ZOOM_CHANGE, ""},
323 {SIG_ZOOM_START, ""},
328 static void _pan_calculate(Evas_Object *obj);
330 static void _del_hook(Evas_Object *obj);
331 static void _theme_hook(Evas_Object *obj);
332 static void _sizing_eval(Evas_Object *obj);
333 static void _calc_job(void *data);
334 static void grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
335 static void grid_clear(Evas_Object *obj, Grid *g);
336 static Grid *grid_create(Evas_Object *obj);
337 static void grid_load(Evas_Object *obj, Grid *g);
340 static void _group_object_create(Marker_Group *group);
341 static void _group_object_free(Marker_Group *group);
342 static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
343 static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
344 static void _group_bubble_create(Marker_Group *group);
345 static void _group_bubble_free(Marker_Group *group);
346 static void _group_bubble_place(Marker_Group *group);
348 static int _group_bubble_content_update(Marker_Group *group);
349 static void _group_bubble_content_free(Marker_Group *group);
350 static void marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
351 static void _bubble_sc_hits_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
354 hold_timer_cb(void *data)
356 struct event_t *ev0 = (struct event_t *)data;
357 ev0->hold_timer = NULL;
359 return ECORE_CALLBACK_CANCEL;
363 get_multi_device(void)
366 struct event_t *ev = NULL;
368 EINA_LIST_FOREACH(s_event_list, l, ev) {
369 if(ev->device != 0) return ev->device;
375 get_distance(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
382 dis = (int)sqrt(dx * dx + dy * dy);
386 static struct event_t*
387 get_event_object(int device)
390 struct event_t *ev = NULL;
392 EINA_LIST_FOREACH(s_event_list, l, ev) {
393 if(ev->device == device) break;
399 static struct event_t *
400 create_event_object(Evas_Object *object, int device)
404 ev = calloc(1, sizeof(struct event_t));
405 if(ev == NULL) DBG("Cannot allocate event_t");
410 evas_object_geometry_get(object, &ev->x, &ev->y, &ev->w, &ev->h);
412 s_event_list = eina_list_append(s_event_list, ev);
418 destroy_event_object(struct event_t *ev)
420 if(ev == NULL) return;
421 ev->pinch_obj = NULL;
424 s_event_list = eina_list_remove(s_event_list, ev);
426 if (ev->hold_timer) {
427 ecore_timer_del(ev->hold_timer);
428 ev->hold_timer = NULL;
434 module(Evas_Object *obj __UNUSED__)
436 static Elm_Module *m = NULL;
437 if (m) goto ok; // already found - just use
438 if (!(m = _elm_module_find_as("map/api"))) return NULL;
441 m->api = malloc(sizeof(Mod_Api));
442 if (!m->api) return NULL;
443 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
444 _elm_module_symbol_get(m, "obj_hook");
445 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
446 _elm_module_symbol_get(m, "obj_unhook");
447 ((Mod_Api *)(m->api) )->obj_url_request =
448 _elm_module_symbol_get(m, "obj_url_request");
449 ((Mod_Api *)(m->api) )->obj_convert_coord_into_geo =
450 _elm_module_symbol_get(m, "obj_convert_coord_into_geo");
451 ((Mod_Api *)(m->api) )->obj_convert_geo_into_coord =
452 _elm_module_symbol_get(m, "obj_convert_geo_into_coord");
453 ok: // ok - return api
458 rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
460 Widget_Data *wd = elm_widget_data_get(obj);
461 Evas_Coord ax, ay, gw, gh, hh, ww;
463 evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh);
470 if (ww == gw && hh == gh) return;
472 if (ow > gw) ax = (ow - gw) / 2;
473 if (oh > gh) ay = (oh - gh) / 2;
474 evas_object_move(wd->rect,
477 evas_object_resize(wd->rect, gw, gh);
481 wd->show.show = EINA_FALSE;
482 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
487 marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
489 Widget_Data *wd = elm_widget_data_get(obj);
490 Evas_Coord ax, ay, gw, gh, tx, ty;
491 Eina_List *l, *markers;
492 Eina_Matrixsparse_Cell *cell;
497 int g_xx, g_yy, g_hh, g_ww;
500 if (g != eina_list_data_get(wd->grids)) return;
506 if (ow > gw) ax = (ow - gw) / 2;
507 if (oh > gh) ay = (oh - gh) / 2;
509 if (wd->zoom != wd->marker_zoom)
511 EINA_LIST_FREE(wd->cells_displayed, cell)
513 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
515 if (group->obj) _group_object_free(group);
519 wd->marker_zoom = wd->zoom;
521 if (wd->paused_markers
522 && (wd->size.nw != wd->size.w || wd->size.nh != wd->size.h) )
525 g_xx = wd->pan_x / wd->tsize;
526 if (g_xx < 0) g_xx = 0;
527 g_yy = wd->pan_y / wd->tsize;
528 if (g_yy < 0) g_yy = 0;
529 g_ww = ow / wd->tsize + 1;
530 if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
531 g_hh = oh / wd->tsize + 1;
532 if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
534 //hide groups no more displayed
535 EINA_LIST_FREE(wd->cells_displayed, cell)
537 eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x);
538 if (y < g_yy || y > g_yy + g_hh || x < g_xx || x > g_xx + g_ww)
540 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
542 if (group->obj) _group_object_free(group);
547 for (y = g_yy; y <= g_yy + g_hh; y++)
549 for (x = g_xx; x <= g_xx + g_ww; x++)
551 if (!wd->markers[wd->zoom]) continue;
552 eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell);
554 wd->cells_displayed = eina_list_append(wd->cells_displayed, cell);
555 markers = eina_matrixsparse_cell_data_get(cell);
556 EINA_LIST_FOREACH(markers, l, group)
558 if (!group->markers) continue;
559 if (group->clas->zoom_displayed > wd->zoom) continue;
566 if (eina_list_count(group->markers) == 1)
568 Elm_Map_Marker *m = eina_list_data_get(group->markers);
569 ww = m->clas->priv.edje_w;
570 hh = m->clas->priv.edje_h;
576 if ((gw != g->w) && (g->w > 0))
579 xx = ((long long )gw * xx) / g->w;
580 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
582 if ((gh != g->h) && (g->h > 0))
585 yy = ((long long)gh * yy) / g->h;
586 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
589 if (!group->clas->hide
590 && xx-px+ax+ox >= ox && xx-px+ax+ox<= ox+ow
591 && yy-py+ay+oy >= oy && yy-py+ay+oy<= oy+oh)
593 if (!group->obj) _group_object_create(group);
595 if (group->update_nbelems)
597 group->update_nbelems = EINA_FALSE;
598 if (eina_list_count(group->markers) > 1)
600 snprintf(buf, sizeof(buf), "%d", eina_list_count(group->markers));
601 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
604 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", "");
606 evas_object_move(group->obj,
607 xx - px + ax + ox - ww/2,
608 yy - py + ay + oy - hh/2);
609 if (!wd->paused_markers || group->update_resize)
611 group->update_resize = EINA_FALSE;
612 evas_object_resize(group->obj, ww, hh);
614 if (group->update_raise)
616 group->update_raise = EINA_FALSE;
617 evas_object_raise(group->obj);
618 evas_object_show(group->obj);
620 if (group->bubble) _group_bubble_place(group);
624 _group_object_free(group);
632 grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
634 Widget_Data *wd = elm_widget_data_get(obj);
635 Evas_Coord ax, ay, gw, gh, tx, ty;
644 if (ow > gw) ax = (ow - gw) / 2;
645 if (oh > gh) ay = (oh - gh) / 2;
647 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
648 Eina_Matrixsparse_Cell *cell;
650 EINA_ITERATOR_FOREACH(it, cell)
652 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
658 if ((gw != g->w) && (g->w > 0))
661 xx = ((long long )gw * xx) / g->w;
662 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
664 if ((gh != g->h) && (g->h > 0))
667 yy = ((long long)gh * yy) / g->h;
668 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
670 evas_object_move(gi->img,
674 evas_object_resize(gi->img, ww, hh);
676 /*evas_object_move(gi->txt,
680 evas_object_resize(gi->txt, ww, hh);
683 eina_iterator_free(it);
687 grid_clear(Evas_Object *obj, Grid *g)
689 Widget_Data *wd = elm_widget_data_get(obj);
693 if (!g->grid) return;
695 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
696 Eina_Matrixsparse_Cell *cell;
698 snprintf(buf, sizeof(buf), DEST_DIR_ZOOM_PATH, wd->id, g->zoom);
699 ecore_file_recursive_rm(buf);
701 EINA_ITERATOR_FOREACH(it, cell)
703 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
704 evas_object_del(gi->img);
705 //evas_object_del(gi->txt);
709 gi->want = EINA_FALSE;
711 if (wd->preload_num == 0)
713 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
714 "elm,state,busy,stop", "elm");
715 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
721 DBG("DOWNLOAD abort %s", gi->file);
722 ecore_file_download_abort(gi->job);
723 ecore_file_remove(gi->file);
727 eina_stringshare_del(gi->file);
731 eina_matrixsparse_free(g->grid);
732 eina_iterator_free(it);
739 _tile_update(Grid_Item *gi)
741 gi->want = EINA_FALSE;
742 gi->download = EINA_FALSE;
743 evas_object_image_file_set(gi->img, gi->file, NULL);
744 if (evas_object_image_load_error_get(gi->img) != EVAS_LOAD_ERROR_NONE)
745 ecore_file_remove(gi->file);
747 evas_object_show(gi->img);
749 //evas_object_text_text_set(gi->txt, gi->file);
750 //evas_object_show(gi->txt);
752 gi->have = EINA_TRUE;
753 gi->wd->preload_num--;
754 if (gi->wd->preload_num == 0)
756 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
757 "elm,state,busy,stop", "elm");
758 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
764 _tile_downloaded(void *data, const char *file __UNUSED__, int status)
766 Grid_Item *gi = data;
768 gi->download = EINA_FALSE;
771 DBG("DOWNLOAD done %s", gi->file);
772 if (gi->want && !status) _tile_update(gi);
776 DBG("Download failed %s (%d) ", gi->file, status);
777 ecore_file_remove(gi->file);
782 grid_create(Evas_Object *obj)
784 Widget_Data *wd = elm_widget_data_get(obj);
787 g = calloc(1, sizeof(Grid));
790 g->tsize = wd->tsize;
793 if (g->zoom > map_sources_tab[wd->source].zoom_max) return NULL;
794 if (g->zoom < map_sources_tab[wd->source].zoom_min) return NULL;
796 int size = pow(2.0, wd->zoom);
800 g->w = g->tsize * g->gw;
801 g->h = g->tsize * g->gh;
803 g->grid = eina_matrixsparse_new(g->gh, g->gw, NULL, NULL);
809 grid_load(Evas_Object *obj, Grid *g)
811 Widget_Data *wd = elm_widget_data_get(obj);
814 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
816 Eina_Matrixsparse_Cell *cell;
820 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
821 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
826 if ((gw <= 0) || (gh <= 0)) return;
829 if ((gw != g->w) && (g->w > 0))
830 size = ((long long)gw * size) / g->w;
831 if (size < (g->tsize / 2)) return; // else we will load to much tiles
833 it = eina_matrixsparse_iterator_new(g->grid);
835 EINA_ITERATOR_FOREACH(it, cell)
837 gi = eina_matrixsparse_cell_data_get(cell);
844 if ((gw != g->w) && (g->w > 0))
847 xx = ((long long )gw * xx) / g->w;
848 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
850 if ((gh != g->h) && (g->h > 0))
853 yy = ((long long)gh * yy) / g->h;
854 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
857 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
865 if (wd->preload_num == 0)
867 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
868 "elm,state,busy,stop", "elm");
869 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL,
872 evas_object_hide(gi->img);
873 //evas_object_hide(gi->txt);
874 evas_object_image_file_set(gi->img, NULL, NULL);
875 gi->want = EINA_FALSE;
876 gi->have = EINA_FALSE;
880 DBG("DOWNLOAD abort %s", gi->file);
881 ecore_file_download_abort(gi->job);
882 ecore_file_remove(gi->file);
885 gi->download = EINA_FALSE;
889 evas_object_hide(gi->img);
890 //evas_object_hide(gi->txt);
891 evas_object_image_preload(gi->img, 1);
892 evas_object_image_file_set(gi->img, NULL, NULL);
893 gi->have = EINA_FALSE;
894 gi->want = EINA_FALSE;
898 eina_iterator_free(it);
900 xx = wd->pan_x / size;
903 yy = wd->pan_y / size;
907 if (xx + ww >= g->gw) ww = g->gw - xx - 1;
910 if (yy + hh >= g->gh) hh = g->gh - yy - 1;
912 for (y = yy; y <= yy + hh; y++)
914 for (x = xx; x <= xx + ww; x++)
916 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
918 if ((!gi) && (g != eina_list_data_get(wd->grids)))
923 gi = calloc(1, sizeof(Grid_Item));
924 gi->src.x = x * g->tsize;
925 gi->src.y = y * g->tsize;
926 gi->src.w = g->tsize;
927 gi->src.h = g->tsize;
929 gi->out.x = gi->src.x;
930 gi->out.y = gi->src.y;
931 gi->out.w = gi->src.w;
932 gi->out.h = gi->src.h;
936 gi->img = evas_object_image_add(evas_object_evas_get(obj));
937 evas_object_image_scale_hint_set
938 (gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
939 evas_object_image_filled_set(gi->img, 1);
941 evas_object_smart_member_add(gi->img, wd->pan_smart);
942 elm_widget_sub_object_add(obj, gi->img);
943 evas_object_pass_events_set(gi->img, EINA_TRUE);
944 evas_object_stack_below(gi->img, wd->sep_maps_markers);
946 /*gi->txt = evas_object_text_add(evas_object_evas_get(obj));
947 evas_object_text_font_set(gi->txt, "Vera", 12);
948 evas_object_color_set(gi->txt, 100, 100, 100, 255);
949 evas_object_smart_member_add(gi->txt,
951 elm_widget_sub_object_add(obj, gi->txt);
952 evas_object_pass_events_set(gi->txt, EINA_TRUE);
954 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
957 if (!gi->have && !gi->download)
959 char buf[PATH_MAX], buf2[PATH_MAX];
962 gi->want = EINA_TRUE;
964 snprintf(buf, sizeof(buf), DEST_DIR_PATH, wd->id, g->zoom, x);
965 if (!ecore_file_exists(buf))
966 ecore_file_mkpath(buf);
968 snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y);
970 source = map_sources_tab[wd->source].url_cb(obj, x, y, g->zoom);
971 if(strlen(source)==0) continue;
973 eina_stringshare_replace(&gi->file, buf2);
975 if (ecore_file_exists(buf2) || g == eina_list_data_get(wd->grids))
977 gi->download = EINA_TRUE;
979 if (wd->preload_num == 1)
981 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
982 "elm,state,busy,start", "elm");
983 evas_object_smart_callback_call(obj,
988 if (ecore_file_exists(buf2))
992 DBG("DOWNLOAD %s \t in %s", source, buf2);
993 ecore_file_download(source, buf2, _tile_downloaded, NULL, gi, &(gi->job));
995 DBG("Can't start to download %s", buf);
998 if (source) free(source);
1001 evas_object_show(gi->img);
1007 grid_clearall(Evas_Object *obj)
1009 Widget_Data *wd = elm_widget_data_get(obj);
1013 EINA_LIST_FREE(wd->grids, g)
1021 _smooth_update(Evas_Object *obj)
1023 Widget_Data *wd = elm_widget_data_get(obj);
1028 EINA_LIST_FOREACH(wd->grids, l, g)
1030 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1031 Eina_Matrixsparse_Cell *cell;
1033 EINA_ITERATOR_FOREACH(it, cell)
1035 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1036 evas_object_image_smooth_scale_set(gi->img, (wd->nosmooth == 0));
1038 eina_iterator_free(it);
1043 _grid_raise(Grid *g)
1045 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1046 Eina_Matrixsparse_Cell *cell;
1048 g->wd->size.w = g->w;
1049 g->wd->size.h = g->h;
1051 EINA_ITERATOR_FOREACH(it, cell)
1053 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1054 evas_object_raise(gi->img);
1055 //evas_object_raise(gi->txt);
1057 eina_iterator_free(it);
1061 _scr_timeout(void *data)
1063 Widget_Data *wd = elm_widget_data_get(data);
1064 if (!wd) return ECORE_CALLBACK_CANCEL;
1066 if (wd->nosmooth == 0) _smooth_update(data);
1067 wd->scr_timer = NULL;
1068 return ECORE_CALLBACK_CANCEL;
1072 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1074 Widget_Data *wd = elm_widget_data_get(data);
1079 if (wd->nosmooth == 1) _smooth_update(data);
1081 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1082 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
1086 zoom_do(Evas_Object *obj, double t)
1088 Widget_Data *wd = elm_widget_data_get(obj);
1089 Evas_Coord xx, yy, ow, oh;
1092 if (t > 1.0) t = 1.0;
1094 wd->size.w = (wd->size.ow * (1.0 - t)) + (wd->size.nw * t);
1095 wd->size.h = (wd->size.oh * (1.0 - t)) + (wd->size.nh * t);
1097 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
1099 if (wd->center_on.enabled)
1101 elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy);
1107 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
1108 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
1112 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
1114 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
1116 wd->show.show = EINA_TRUE;
1122 if (wd->calc_job) ecore_job_del(wd->calc_job);
1123 wd->calc_job = ecore_job_add(_calc_job, wd);
1126 return ECORE_CALLBACK_CANCEL;
1128 return ECORE_CALLBACK_RENEW;
1132 _zoom_anim(void *data)
1134 Evas_Object *obj = data;
1135 Widget_Data *wd = elm_widget_data_get(obj);
1139 if (!wd) return ECORE_CALLBACK_CANCEL;
1140 t = ecore_loop_time_get();
1143 else if (wd->t_end > wd->t_start)
1144 t = (t - wd->t_start) / (wd->t_end - wd->t_start);
1149 go = zoom_do(obj, t);
1153 if (wd->nosmooth == 0) _smooth_update(data);
1154 wd->zoom_animator = NULL;
1155 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1161 _long_press(void *data)
1163 Widget_Data *wd = elm_widget_data_get(data);
1164 if (!wd) return ECORE_CALLBACK_CANCEL;
1165 wd->long_timer = NULL;
1166 wd->longpressed = EINA_TRUE;
1167 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1168 return ECORE_CALLBACK_CANCEL;
1172 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1174 Widget_Data *wd = elm_widget_data_get(data);
1175 Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down*)event_info;
1176 struct event_t *ev0;
1178 ev0 = get_event_object(0);
1180 ev0 = create_event_object(obj, 0);
1182 ev0->hold_timer = NULL;
1183 ev0->prev.x = ev->output.x;
1184 ev0->prev.y = ev->output.y;
1189 if (ev->button != 1) return;
1190 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1191 else wd->on_hold = EINA_FALSE;
1192 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1193 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
1195 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
1196 wd->longpressed = EINA_FALSE;
1197 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1198 wd->long_timer = ecore_timer_add(1.0, _long_press, data);
1202 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1204 Evas_Event_Mouse_Move *move = (Evas_Event_Mouse_Move *)event_info;
1205 struct event_t *ev0;
1206 ev0 = get_event_object(0);
1207 if(ev0 == NULL) return;
1209 ev0->prev.x = move->cur.output.x;
1210 ev0->prev.y = move->cur.output.y;
1214 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1216 Widget_Data *wd = elm_widget_data_get(data);
1217 Evas_Event_Mouse_Up *ev = event_info;
1220 struct event_t *ev0;
1221 struct event_t *ev1 = NULL;
1223 ev0 = get_event_object(0);
1225 mdevice = get_multi_device();
1227 if(ev0->hold_timer == NULL){
1229 ecore_timer_del(ev0->hold_timer);
1230 ev0->hold_timer = NULL;
1233 ev1 = get_event_object(mdevice);
1235 ev1->hold_timer = ecore_timer_add(0.35f, hold_timer_cb, ev1);
1238 destroy_event_object(ev0);
1240 DBG("Cannot get event0");
1243 if (ev->button != 1) return;
1244 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1245 else wd->on_hold = EINA_FALSE;
1246 if (wd->long_timer){
1247 ecore_timer_del(wd->long_timer);
1248 wd->long_timer = NULL;
1251 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
1252 wd->on_hold = EINA_FALSE;
1256 _mouse_multi_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1258 Widget_Data *wd = elm_widget_data_get(data);
1260 Evas_Event_Multi_Down *down = event_info;
1262 ev = get_event_object(down->device);
1265 ev = create_event_object(obj, down->device);
1267 DBG("Failed : create_event_object");
1271 elm_smart_scroller_hold_set(wd->scr, 1);
1272 elm_smart_scroller_freeze_set(wd->scr, 1);
1273 elm_smart_scroller_freeze_momentum_animator_set(wd->scr, 1);
1274 elm_smart_scroller_freeze_bounce_animator_set(wd->scr, 1);
1276 wd->pinch_zoom = EINA_FALSE;
1278 ev->hold_timer = NULL;
1279 ev->prev.x = down->output.x;
1280 ev->prev.y = down->output.y;
1284 _mouse_multi_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1286 Widget_Data *wd = elm_widget_data_get(data);
1287 Evas_Event_Multi_Move *move = (Evas_Event_Multi_Move *)event_info;
1289 struct event_t *ev0;
1292 ev = get_event_object(move->device);
1294 DBG("Cannot get multi device");
1298 ev->prev.x = move->cur.output.x;
1299 ev->prev.y = move->cur.output.y;
1301 ev0 = get_event_object(0);
1303 DBG("Cannot get device0");
1307 dis_new = get_distance(ev0->prev.x, ev0->prev.y, ev->prev.x, ev->prev.y);
1308 int zoom = wd->zoom;
1310 if(wd->pinch_zoom) return;
1312 if(dis_old - dis_new > 0 && ev->pinch_dis > TOUCH_HOLD_RANGE){
1313 wd->pinch_zoom = EINA_TRUE;
1315 elm_map_zoom_set(data, zoom);
1317 }else if(dis_old - dis_new < 0 && ev->pinch_dis < -TOUCH_HOLD_RANGE){
1318 wd->pinch_zoom = EINA_TRUE;
1320 elm_map_zoom_set(data, zoom);
1324 ev->pinch_dis += (dis_old - dis_new);
1330 _mouse_multi_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1332 Widget_Data *wd = elm_widget_data_get(data);
1333 Evas_Event_Multi_Up *up = (Evas_Event_Multi_Up *)event_info;
1334 struct event_t *ev0;
1337 elm_smart_scroller_hold_set(wd->scr, 0);
1338 elm_smart_scroller_freeze_set(wd->scr, 0);
1339 elm_smart_scroller_freeze_momentum_animator_set(wd->scr, 0);
1340 elm_smart_scroller_freeze_bounce_animator_set(wd->scr, 0);
1342 ev = get_event_object(up->device);
1344 DBG("Cannot get multi device");
1348 wd->pinch_zoom = EINA_FALSE;
1351 ev0 = get_event_object(0);
1353 ev0->hold_timer = ecore_timer_add(0.35f, hold_timer_cb, ev0);
1355 if(ev->hold_timer == NULL) {
1357 ecore_timer_del(ev->hold_timer);
1358 ev->hold_timer = NULL;
1361 destroy_event_object(ev);
1364 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
1367 _del_hook(Evas_Object *obj)
1369 Elm_Map_Group_Class *group_clas;
1370 Elm_Map_Marker_Class *marker_clas;
1371 Widget_Data *wd = elm_widget_data_get(obj);
1375 EINA_LIST_FREE(wd->groups_clas, group_clas)
1377 if (group_clas->style)
1378 eina_stringshare_del(group_clas->style);
1382 EINA_LIST_FREE(wd->markers_clas, marker_clas)
1384 if (marker_clas->style)
1385 eina_stringshare_del(marker_clas->style);
1389 if (wd->calc_job) ecore_job_del(wd->calc_job);
1390 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1391 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
1392 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1394 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj);
1399 _del_pre_hook(Evas_Object *obj)
1401 Marker_Group *group;
1402 Elm_Map_Marker *marker;
1404 Eina_Bool free_marker = EINA_TRUE;
1406 Widget_Data *wd = elm_widget_data_get(obj);
1410 for (i = 0; i < ZOOM_MAX + 1; i++)
1412 if (!wd->markers[i]) continue;
1413 Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
1414 Eina_Matrixsparse_Cell *cell;
1416 EINA_ITERATOR_FOREACH(it, cell)
1418 l = eina_matrixsparse_cell_data_get(cell);
1419 EINA_LIST_FREE(l, group)
1421 EINA_LIST_FREE(group->markers, marker)
1423 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1424 _bubble_sc_hits_changed_cb, group);
1425 if (free_marker) free(marker);
1429 free_marker = EINA_FALSE;
1431 eina_iterator_free(it);
1432 eina_matrixsparse_free(wd->markers[i]);
1435 evas_object_del(wd->sep_maps_markers);
1436 evas_object_del(wd->pan_smart);
1437 wd->pan_smart = NULL;
1441 _theme_hook(Evas_Object *obj)
1443 Widget_Data *wd = elm_widget_data_get(obj);
1445 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
1446 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
1451 _sizing_eval(Evas_Object *obj)
1453 Widget_Data *wd = elm_widget_data_get(obj);
1454 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
1456 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
1457 evas_object_size_hint_min_set(obj, minw, minh);
1458 evas_object_size_hint_max_set(obj, maxw, maxh);
1462 _calc_job(void *data)
1464 Widget_Data *wd = data;
1465 Evas_Coord minw, minh;
1472 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
1474 double tz = wd->zoom;
1476 elm_map_zoom_set(wd->obj, tz);
1479 if ((minw != wd->minw) || (minh != wd->minh))
1483 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
1484 _sizing_eval(wd->obj);
1486 wd->calc_job = NULL;
1487 evas_object_smart_changed(wd->pan_smart);
1491 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1493 Pan *sd = evas_object_smart_data_get(obj);
1495 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1498 evas_object_smart_changed(obj);
1502 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1504 Pan *sd = evas_object_smart_data_get(obj);
1506 if (x) *x = sd->wd->pan_x;
1507 if (y) *y = sd->wd->pan_y;
1511 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1513 Pan *sd = evas_object_smart_data_get(obj);
1516 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1517 ow = sd->wd->minw - ow;
1519 oh = sd->wd->minh - oh;
1526 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
1528 Pan *sd = evas_object_smart_data_get(obj);
1530 if (w) *w = sd->wd->minw;
1531 if (h) *h = sd->wd->minh;
1535 _pan_add(Evas_Object *obj)
1538 Evas_Object_Smart_Clipped_Data *cd;
1540 cd = evas_object_smart_data_get(obj);
1542 sd = calloc(1, sizeof(Pan));
1544 sd->__clipped_data = *cd;
1546 evas_object_smart_data_set(obj, sd);
1550 _pan_del(Evas_Object *obj)
1552 Pan *sd = evas_object_smart_data_get(obj);
1558 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
1560 Pan *sd = evas_object_smart_data_get(obj);
1563 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1564 if ((ow == w) && (oh == h)) return;
1565 sd->wd->resized = 1;
1566 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1567 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1571 _pan_calculate(Evas_Object *obj)
1573 Pan *sd = evas_object_smart_data_get(obj);
1574 Evas_Coord ox, oy, ow, oh;
1578 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
1579 rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
1580 EINA_LIST_FOREACH(sd->wd->grids, l, g)
1582 grid_load(sd->wd->obj, g);
1583 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
1584 marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
1589 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
1591 Pan *sd = evas_object_smart_data_get(obj);
1593 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1594 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1598 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1600 Widget_Data *wd = elm_widget_data_get(obj);
1602 elm_smart_scroller_hold_set(wd->scr, 1);
1606 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1608 Widget_Data *wd = elm_widget_data_get(obj);
1610 elm_smart_scroller_hold_set(wd->scr, 0);
1614 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1616 Widget_Data *wd = elm_widget_data_get(obj);
1618 elm_smart_scroller_freeze_set(wd->scr, 1);
1622 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1624 Widget_Data *wd = elm_widget_data_get(obj);
1626 elm_smart_scroller_freeze_set(wd->scr, 0);
1630 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1632 evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
1636 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1638 evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
1642 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1644 Widget_Data *wd = elm_widget_data_get(data);
1645 wd->center_on.enabled = EINA_FALSE;
1646 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1650 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1652 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1656 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1658 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1663 _group_object_create(Marker_Group *group)
1665 const char *style = "radio";
1666 Evas_Object *icon = NULL;
1668 if (group->obj) return;
1669 if (!group->clas->priv.objs_notused || eina_list_count(group->markers) == 1)
1671 //set icon and style
1672 if (eina_list_count(group->markers) == 1)
1674 Elm_Map_Marker *m = eina_list_data_get(group->markers);
1676 style = m->clas->style;
1678 if (m->clas->func.icon_get)
1679 icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
1681 group->delete_object = EINA_TRUE;
1685 if (group->clas->style)
1686 style = group->clas->style;
1688 if (group->clas->func.icon_get)
1689 icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
1691 group->delete_object = EINA_FALSE;
1694 group->obj = elm_layout_add(group->wd->obj);
1695 elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
1697 if (icon) elm_layout_content_set(group->obj, "elm.icon", icon);
1699 evas_object_smart_member_add(group->obj, group->wd->pan_smart);
1700 elm_widget_sub_object_add(group->wd->obj, group->obj);
1701 evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
1703 if (!group->delete_object)
1704 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
1708 group->delete_object = EINA_FALSE;
1710 group->obj = eina_list_data_get(group->clas->priv.objs_notused);
1711 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
1712 group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
1713 evas_object_show(group->obj);
1716 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
1717 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
1719 group->update_nbelems = EINA_TRUE;
1720 group->update_resize = EINA_TRUE;
1721 group->update_raise = EINA_TRUE;
1723 if (group->open) _group_bubble_create(group);
1727 _group_object_free(Marker_Group *group)
1729 if (!group->obj) return;
1730 if (!group->delete_object)
1732 group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
1733 group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
1734 evas_object_hide(group->obj);
1736 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
1737 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
1740 evas_object_del(group->obj);
1743 _group_bubble_free(group);
1747 _group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1749 Marker_Group *group = data;
1751 if (!evas_object_above_get(group->rect)) return;
1752 evas_object_raise(group->bubble);
1753 evas_object_raise(group->sc);
1754 evas_object_raise(group->rect);
1758 _group_bubble_create(Marker_Group *group)
1760 if (group->bubble) return;
1762 group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
1763 group->bubble = edje_object_add(evas_object_evas_get(group->obj));
1764 _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
1765 elm_widget_style_get(group->wd->obj));
1766 evas_object_smart_member_add(group->bubble,
1768 elm_widget_sub_object_add(group->wd->obj, group->bubble);
1770 _group_bubble_content_free(group);
1771 if (!_group_bubble_content_update(group))
1773 //no content, we can delete the bubble
1774 _group_bubble_free(group);
1778 group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
1779 evas_object_color_set(group->rect, 0, 0, 0, 0);
1780 evas_object_repeat_events_set(group->rect, EINA_TRUE);
1781 evas_object_smart_member_add(group->rect, group->wd->obj);
1782 elm_widget_sub_object_add(group->wd->obj, group->rect);
1784 evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
1786 _group_bubble_place(group);
1789 static void _bubble_sc_hits_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1791 _group_bubble_place(data);
1795 _group_bubble_content_update(Marker_Group *group)
1798 Elm_Map_Marker *marker;
1801 if (!group->bubble) return 1;
1805 group->sc = elm_scroller_add(group->bubble);
1806 elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
1807 elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
1808 elm_scroller_bounce_set(group->sc, EINA_TRUE, EINA_FALSE);
1809 edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
1810 evas_object_show(group->sc);
1811 evas_object_smart_member_add(group->sc,
1813 elm_widget_sub_object_add(group->wd->obj, group->sc);
1815 group->bx = elm_box_add(group->bubble);
1816 evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1817 evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
1818 elm_box_horizontal_set(group->bx, EINA_TRUE);
1819 evas_object_show(group->bx);
1821 elm_scroller_content_set(group->sc, group->bx);
1823 evas_object_event_callback_add(group->sc, EVAS_CALLBACK_RESIZE,
1824 _bubble_sc_hits_changed_cb, group);
1827 EINA_LIST_FOREACH(group->markers, l, marker)
1829 if (i >= group->wd->markers_max_num) break;
1830 if (!marker->content && marker->clas->func.get)
1831 marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
1832 else if (marker->content)
1833 elm_box_unpack(group->bx, marker->content);
1834 if (marker->content)
1836 elm_box_pack_end(group->bx, marker->content);
1844 _group_bubble_content_free(Marker_Group *group)
1847 Elm_Map_Marker *marker;
1849 if (!group->sc) return;
1850 EINA_LIST_FOREACH(group->markers, l, marker)
1852 if (marker->content && marker->clas->func.del)
1853 marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
1854 else if (marker->content)
1855 evas_object_del(marker->content);
1856 marker->content = NULL;
1858 evas_object_del(group->sc);
1863 _group_bubble_free(Marker_Group *group)
1865 if (!group->bubble) return;
1866 group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
1867 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1868 _bubble_sc_hits_changed_cb, group);
1869 evas_object_del(group->bubble);
1870 evas_object_del(group->rect);
1871 group->bubble = NULL;
1872 _group_bubble_content_free(group);
1876 _group_bubble_place(Marker_Group *group)
1879 Evas_Coord xx, yy, ww, hh;
1882 if (!group->bubble || !group->obj) return;
1884 evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
1885 edje_object_size_min_calc(group->bubble, NULL, &hh);
1887 s = edje_object_data_get(group->bubble, "size_w");
1889 xx = x + w / 2 - ww / 2;
1892 evas_object_move(group->bubble, xx, yy);
1893 evas_object_resize(group->bubble, ww, hh);
1894 evas_object_show(group->bubble);
1896 evas_object_move(group->rect, xx, yy);
1897 evas_object_resize(group->rect, ww, hh);
1898 evas_object_show(group->rect);
1902 _group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
1904 Marker_Group *group = data;
1905 Elm_Map_Marker *marker = eina_list_data_get(group->markers);
1906 if (!marker) return;
1907 group->bringin = EINA_TRUE;
1908 elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
1912 _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
1914 Marker_Group *group = data;
1918 group->bringin = EINA_FALSE;
1924 group->open = EINA_FALSE;
1925 _group_bubble_free(group);
1928 group->open = EINA_TRUE;
1929 _group_bubble_create(group);
1932 static int idnum = 1;
1935 * Add a new Map object
1937 * @param parent The parent object
1938 * @return The new object or NULL if it cannot be created
1943 elm_map_add(Evas_Object *parent)
1947 Evas_Coord minw, minh;
1949 Eina_Bool ret = EINA_FALSE;
1951 static Evas_Smart *smart = NULL;
1953 if (!ecore_file_download_protocol_available("http://"))
1955 ERR("Ecore must be built with the support of HTTP for the widget map !");
1959 wd = ELM_NEW(Widget_Data);
1961 e = evas_object_evas_get(parent);
1962 obj = elm_widget_add(e);
1963 ELM_SET_WIDTYPE(widtype, "map");
1964 elm_widget_type_set(obj, "map");
1965 elm_widget_sub_object_add(parent, obj);
1966 elm_widget_data_set(obj, wd);
1967 elm_widget_del_hook_set(obj, _del_hook);
1968 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1969 elm_widget_theme_hook_set(obj, _theme_hook);
1971 wd->scr = elm_smart_scroller_add(e);
1972 elm_smart_scroller_widget_set(wd->scr, obj);
1973 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
1974 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
1975 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
1976 elm_widget_resize_object_set(obj, wd->scr);
1978 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1979 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1980 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1981 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1982 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1984 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_TRUE, EINA_TRUE);
1988 wd->markers_max_num = 30;
1989 wd->source = ELM_MAP_SOURCE_MAPNIK;
1991 for(idx=ELM_MAP_SOURCE_MAPNIK; idx<=ELM_MAP_SOURCE_CUSTOM_6; idx++)
1992 if(map_sources_tab[idx].use_module == EINA_TRUE){
1994 wd->api = module(obj);
1995 if ((wd->api) && (wd->api->obj_hook)) ret = wd->api->obj_hook(obj);
1996 if (!ret) DBG("Failed : loading module [%s]", elm_map_source_name_get(idx));
2000 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2001 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2002 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2003 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2007 static Evas_Smart_Class sc;
2009 evas_object_smart_clipped_smart_set(&_pan_sc);
2011 sc.name = "elm_map_pan";
2012 sc.version = EVAS_SMART_CLASS_VERSION;
2015 sc.resize = _pan_resize;
2016 sc.move = _pan_move;
2017 sc.calculate = _pan_calculate;
2018 smart = evas_smart_class_new(&sc);
2022 wd->pan_smart = evas_object_smart_add(e, smart);
2023 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2027 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2029 _pan_max_get, _pan_child_size_get);
2031 wd->rect = evas_object_rectangle_add(e);
2032 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
2034 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
2036 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_MOVE,
2038 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_DOWN,
2039 _mouse_multi_down, obj);
2040 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_MOVE,
2041 _mouse_multi_move, obj);
2042 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP,
2043 _mouse_multi_up, obj);
2045 evas_object_smart_member_add(wd->rect, wd->pan_smart);
2046 elm_widget_sub_object_add(obj, wd->rect);
2047 evas_object_show(wd->rect);
2048 evas_object_color_set(wd->rect, 0, 0, 0, 0);
2051 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
2052 wd->id = ((int)getpid() << 16) | idnum;
2057 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2059 evas_object_size_hint_min_set(obj, minw, minh);
2061 wd->paused = EINA_TRUE;
2062 elm_map_zoom_set(obj, 0);
2063 wd->paused = EINA_FALSE;
2067 wd->calc_job = ecore_job_add(_calc_job, wd);
2069 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
2070 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
2072 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2073 // TODO: and save some bytes, making descriptions per-class and not instance!
2074 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2079 * Set the zoom level of the map
2081 * This sets the zoom level. 0 is the world map and 18 is the maximum zoom.
2083 * @param obj The map object
2084 * @param zoom The zoom level to set
2089 elm_map_zoom_set(Evas_Object *obj, int zoom)
2091 ELM_CHECK_WIDTYPE(obj, widtype);
2092 Widget_Data *wd = elm_widget_data_get(obj);
2094 Grid *g, *g_zoom = NULL;
2095 Evas_Coord rx, ry, rw, rh;
2097 int zoom_changed = 0, started = 0;
2100 if (zoom < 0 ) zoom = 0;
2101 if (zoom > map_sources_tab[wd->source].zoom_max)
2102 zoom = map_sources_tab[wd->source].zoom_max;
2103 if (zoom < map_sources_tab[wd->source].zoom_min)
2104 zoom = map_sources_tab[wd->source].zoom_min;
2105 if (zoom == wd->zoom) return;
2106 if (wd->zoom_animator) return;
2109 wd->size.ow = wd->size.w;
2110 wd->size.oh = wd->size.h;
2111 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
2112 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
2114 if (wd->mode == ELM_MAP_ZOOM_MODE_MANUAL)
2116 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
2117 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
2119 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
2126 while (cumulw <= rw)
2135 while (cumulh <= rh)
2148 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
2149 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
2151 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
2158 while (cumulw <= rw)
2167 while (cumulh <= rh)
2180 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
2181 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
2184 EINA_LIST_FOREACH(wd->grids, l, g)
2186 if (g->zoom == wd->zoom)
2188 wd->grids = eina_list_remove(wd->grids, g);
2189 wd->grids = eina_list_prepend(wd->grids, g);
2194 g = grid_create(obj);
2197 if (eina_list_count(wd->grids) > 1)
2199 g_zoom = eina_list_last(wd->grids)->data;
2200 wd->grids = eina_list_remove(wd->grids, g_zoom);
2201 grid_clear(obj, g_zoom);
2204 wd->grids = eina_list_prepend(wd->grids, g);
2208 EINA_LIST_FREE(wd->grids, g)
2216 wd->t_start = ecore_loop_time_get();
2217 wd->t_end = wd->t_start + _elm_config->zoom_friction;
2218 if ((wd->size.w > 0) && (wd->size.h > 0))
2220 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow;
2221 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.oh;
2225 wd->size.spos.x = 0.5;
2226 wd->size.spos.y = 0.5;
2228 if (rw > wd->size.ow) wd->size.spos.x = 0.5;
2229 if (rh > wd->size.oh) wd->size.spos.y = 0.5;
2230 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
2231 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
2238 if (!wd->zoom_animator)
2240 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
2242 if (wd->nosmooth == 1) _smooth_update(obj);
2246 if (wd->zoom_animator)
2248 if (!_zoom_anim(obj))
2250 ecore_animator_del(wd->zoom_animator);
2251 wd->zoom_animator = NULL;
2254 if (wd->calc_job) ecore_job_del(wd->calc_job);
2255 wd->calc_job = ecore_job_add(_calc_job, wd);
2259 evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
2260 if (!wd->zoom_animator)
2261 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
2265 evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
2269 * Get the zoom level of the photo
2271 * This returns the current zoom level of the map object. Note that if
2272 * you set the fill mode to other than ELM_MAP_ZOOM_MODE_MANUAL
2273 * (which is the default), the zoom level may be changed at any time by the
2274 * map object itself to account for map size and map viewpoer size
2276 * @param obj The map object
2277 * @return The current zoom level
2282 elm_map_zoom_get(const Evas_Object *obj)
2284 ELM_CHECK_WIDTYPE(obj, widtype) 1.0;
2285 Widget_Data *wd = elm_widget_data_get(obj);
2286 if (!wd) return 1.0;
2293 * This sets the zoom mode to manual or one of several automatic levels.
2294 * Manual (ELM_MAP_ZOOM_MODE_MANUAL) means that zoom is set manually by
2295 * elm_map_zoom_set() and will stay at that level until changed by code
2296 * or until zoom mode is changed. This is the default mode.
2297 * The Automatic modes will allow the map object to automatically
2298 * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT) will
2299 * adjust zoom so the photo fits inside the scroll frame with no pixels
2300 * outside this area. ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but
2301 * ensure no pixels within the frame are left unfilled. Do not forget that the valid sizes are 2^zoom, consequently the map may be smaller than the scroller view.
2303 * @param obj The map object
2304 * @param mode The desired mode
2309 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
2311 ELM_CHECK_WIDTYPE(obj, widtype);
2312 Widget_Data *wd = elm_widget_data_get(obj);
2314 if (wd->mode == mode) return;
2317 double tz = wd->zoom;
2319 elm_map_zoom_set(wd->obj, tz);
2326 * This gets the current zoom mode of the map object
2328 * @param obj The map object
2329 * @return The current zoom mode
2333 EAPI Elm_Map_Zoom_Mode
2334 elm_map_zoom_mode_get(const Evas_Object *obj)
2336 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
2337 Widget_Data *wd = elm_widget_data_get(obj);
2338 if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
2343 * Centers the map at @p lon @p lat using an animation to scroll.
2345 * @param obj The map object
2346 * @param lon Longitude to center at
2347 * @param lon Latitude to center at
2352 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
2354 ELM_CHECK_WIDTYPE(obj, widtype);
2355 Widget_Data *wd = elm_widget_data_get(obj);
2359 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
2360 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
2365 if (wd->zoom_animator)
2368 if (wd->nosmooth == 0) _smooth_update(obj);
2369 ecore_animator_del(wd->zoom_animator);
2370 wd->zoom_animator = NULL;
2372 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
2374 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
2376 wd->center_on.enabled = EINA_TRUE;
2377 wd->center_on.lon = lon;
2378 wd->center_on.lat = lat;
2382 * Move the map to the current coordinates.
2384 * This move the map to the current coordinates. The map will be centered on these coordinates.
2386 * @param obj The map object
2387 * @param lat The latitude.
2388 * @param lon The longitude.
2393 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
2395 ELM_CHECK_WIDTYPE(obj, widtype);
2396 Widget_Data *wd = elm_widget_data_get(obj);
2400 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
2401 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
2406 if (wd->zoom_animator)
2409 ecore_animator_del(wd->zoom_animator);
2410 wd->zoom_animator = NULL;
2412 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
2414 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
2416 wd->center_on.enabled = EINA_TRUE;
2417 wd->center_on.lon = lon;
2418 wd->center_on.lat = lat;
2422 * Get the current coordinates of the map.
2424 * This gets the current coordinates of the map object.
2426 * @param obj The map object
2427 * @param lat The latitude.
2428 * @param lon The longitude.
2433 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
2435 ELM_CHECK_WIDTYPE(obj, widtype);
2436 Widget_Data *wd = elm_widget_data_get(obj);
2437 Evas_Coord sx, sy, sw, sh;
2440 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
2441 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
2445 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
2449 * Set the paused state for map
2451 * This sets the paused state to on (1) or off (0) for map. The default
2452 * is off. This will stop zooming using animation change zoom levels and
2453 * change instantly. This will stop any existing animations that are running.
2455 * @param obj The map object
2456 * @param paused The pause state to set
2461 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
2463 ELM_CHECK_WIDTYPE(obj, widtype);
2464 Widget_Data *wd = elm_widget_data_get(obj);
2466 if (wd->paused == !!paused) return;
2467 wd->paused = paused;
2470 if (wd->zoom_animator)
2472 ecore_animator_del(wd->zoom_animator);
2473 wd->zoom_animator = NULL;
2475 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
2481 * Set the paused state for the markers
2483 * This sets the paused state to on (1) or off (0) for the markers. The default
2484 * is off. This will stop displaying the markers during change zoom levels. Set
2485 * to on if you have a large number of markers.
2487 * @param obj The map object
2488 * @param paused The pause state to set
2493 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
2495 ELM_CHECK_WIDTYPE(obj, widtype);
2496 Widget_Data *wd = elm_widget_data_get(obj);
2498 if (wd->paused_markers == !!paused) return;
2499 wd->paused_markers = paused;
2503 * Get the paused state for map
2505 * This gets the current paused state for the map object.
2507 * @param obj The map object
2508 * @return The current paused state
2513 elm_map_paused_get(const Evas_Object *obj)
2515 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2516 Widget_Data *wd = elm_widget_data_get(obj);
2517 if (!wd) return EINA_FALSE;
2522 * Get the paused state for the markers
2524 * This gets the current paused state for the markers object.
2526 * @param obj The map object
2527 * @return The current paused state
2532 elm_map_paused_markers_get(const Evas_Object *obj)
2534 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2535 Widget_Data *wd = elm_widget_data_get(obj);
2536 if (!wd) return EINA_FALSE;
2537 return wd->paused_markers;
2541 * Convert a pixel coordinate (x,y) into a geographic coordinate (longitude, latitude).
2543 * @param obj The map object
2544 * @param x the coordinate
2545 * @param y the coordinate
2546 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
2547 * @param lon the longitude correspond to x
2548 * @param lat the latitude correspond to y
2553 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
2555 Widget_Data *wd = elm_widget_data_get(obj);
2556 int zoom = floor(log2(size/256));
2558 if(map_sources_tab[elm_map_source_get(obj)].use_module == EINA_TRUE)
2559 if(wd->api) if ((wd->api) && (wd->api->obj_convert_coord_into_geo)){
2560 if(wd->api->obj_convert_coord_into_geo(obj, zoom, x, y, size, lon, lat)==EINA_TRUE)
2566 *lon = x / (double)size * 360.0 - 180;
2570 double n = ELM_PI - 2.0 * ELM_PI * y / size;
2571 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
2576 * Convert a geographic coordinate (longitude, latitude) into a pixel coordinate (x, y).
2578 * @param obj The map object
2579 * @param lon the longitude
2580 * @param lat the latitude
2581 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
2582 * @param x the coordinate correspond to the longitude
2583 * @param y the coordinate correspond to the latitude
2588 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
2590 Widget_Data *wd = elm_widget_data_get(obj);
2591 int zoom = floor(log2(size/256));
2593 if(map_sources_tab[elm_map_source_get(obj)].use_module == EINA_TRUE)
2594 if(wd->api) if ((wd->api) && (wd->api->obj_convert_geo_into_coord)){
2595 if(wd->api->obj_convert_geo_into_coord(obj, zoom, lon, lat, size, x, y)==EINA_TRUE)
2600 *x = floor((lon + 180.0) / 360.0 * size);
2602 *y = floor((1.0 - log( tan(lat * ELM_PI/180.0) + 1.0 / cos(lat * ELM_PI/180.0)) / ELM_PI) / 2.0 * size);
2608 * Add a marker on the map
2610 * @param obj The map object
2611 * @param lon the longitude
2612 * @param lat the latitude
2613 * @param clas the class to use
2614 * @param data the data passed to the callbacks
2616 * @return The marker object
2620 EAPI Elm_Map_Marker *
2621 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
2625 Marker_Group *group;
2626 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2627 Widget_Data *wd = elm_widget_data_get(obj);
2635 if (!wd) return NULL;
2636 if (!clas_group || !clas) return NULL;
2638 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
2641 marker->clas = clas;
2642 marker->clas_group = clas_group;
2643 marker->longitude = lon;
2644 marker->latitude = lat;
2645 marker->data = data;
2647 tabi[1] = tabi[4] = tabi[6] = -1;
2648 tabi[2] = tabi[0] = tabi[7] = 0;
2649 tabi[3] = tabi[5] = tabi[8] = 1;
2651 tabj[1] = tabj[2] = tabj[3] = -1;
2652 tabj[4] = tabj[0] = tabj[5] = 0;
2653 tabj[6] = tabj[7] = tabj[8] = 1;
2655 if (!clas_group->priv.set)
2658 if (marker->clas_group && marker->clas_group->style)
2659 style = marker->clas_group->style;
2661 o = edje_object_add(evas_object_evas_get(obj));
2662 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
2663 s = edje_object_data_get(o, "size_w");
2664 clas_group->priv.edje_w = atoi(s);
2665 s = edje_object_data_get(o, "size_h");
2666 clas_group->priv.edje_h = atoi(s);
2667 s = edje_object_data_get(o, "size_max_w");
2668 clas_group->priv.edje_max_w = atoi(s);
2669 s = edje_object_data_get(o, "size_max_h");
2670 clas_group->priv.edje_max_h = atoi(s);
2673 clas_group->priv.set = EINA_TRUE;
2676 if (!clas->priv.set)
2679 if (marker->clas && marker->clas->style)
2680 style = marker->clas->style;
2682 o = edje_object_add(evas_object_evas_get(obj));
2683 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
2684 s = edje_object_data_get(o, "size_w");
2685 clas->priv.edje_w = atoi(s);
2686 s = edje_object_data_get(o, "size_h");
2687 clas->priv.edje_h = atoi(s);
2690 clas->priv.set = EINA_TRUE;
2693 for (i = clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
2695 elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
2696 &(marker->x[i]), &(marker->y[i]));
2698 //search in the matrixsparse the region where the marker will be
2699 mpi = marker->x[i] / wd->tsize;
2700 mpj = marker->y[i] / wd->tsize;
2702 if (!wd->markers[i])
2704 int size = pow(2.0, i);
2705 wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
2709 if (i <= clas_group->zoom_grouped)
2711 for (j = 0, group = NULL; j < 9 && !group; j++)
2713 EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
2716 if (group->clas == marker->clas_group
2717 && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
2718 marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
2719 group->x-group->w/4, group->y-group->h/4, group->w, group->h))
2721 group->markers = eina_list_append(group->markers, marker);
2722 group->update_nbelems = EINA_TRUE;
2723 group->update_resize = EINA_TRUE;
2725 group->sum_x += marker->x[i];
2726 group->sum_y += marker->y[i];
2727 group->x = group->sum_x / eina_list_count(group->markers);
2728 group->y = group->sum_y / eina_list_count(group->markers);
2730 group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
2731 * eina_list_count(group->markers);
2732 group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
2733 * eina_list_count(group->markers);
2734 if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
2735 if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
2737 if (group->obj && eina_list_count(group->markers) == 2)
2739 _group_object_free(group);
2740 _group_object_create(group);
2743 _group_bubble_content_update(group);
2752 group = calloc(1, sizeof(Marker_Group));
2754 group->sum_x = marker->x[i];
2755 group->sum_y = marker->y[i];
2756 group->x = marker->x[i];
2757 group->y = marker->y[i];
2758 group->w = clas_group->priv.edje_w;
2759 group->h = clas_group->priv.edje_h;
2760 group->clas = clas_group;
2762 group->markers = eina_list_append(group->markers, marker);
2763 group->update_nbelems = EINA_TRUE;
2764 group->update_resize = EINA_TRUE;
2766 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
2770 l = eina_list_append(NULL, group);
2771 eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
2772 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
2776 l = eina_matrixsparse_cell_data_get(group->cell);
2777 l = eina_list_append(l, group);
2778 eina_matrixsparse_cell_data_set(group->cell, l);
2781 marker->groups[i] = group;
2786 Evas_Coord ox, oy, ow, oh;
2787 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2788 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
2795 * Remove a marker from the map
2797 * @param marker The marker to remove
2802 elm_map_marker_remove(Elm_Map_Marker *marker)
2808 if (!marker) return;
2811 for (i = 0; i <= ZOOM_MAX; i++)
2813 marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
2814 if (eina_list_count(marker->groups[i]->markers) == 0)
2816 groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
2817 groups = eina_list_remove(groups, marker->groups[i]);
2818 eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
2820 _group_object_free(marker->groups[i]);
2821 _group_bubble_free(marker->groups[i]);
2822 free(marker->groups[i]);
2826 marker->groups[i]->sum_x -= marker->x[i];
2827 marker->groups[i]->sum_y -= marker->y[i];
2829 marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
2830 marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
2832 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
2833 + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
2834 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
2835 + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
2836 if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
2837 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
2838 if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
2839 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
2841 if (marker->groups[i]->obj && eina_list_count(marker->groups[i]->markers) == 1)
2843 _group_object_free(marker->groups[i]);
2844 _group_object_create(marker->groups[i]);
2848 if (marker->content && marker->clas->func.del)
2849 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
2850 else if (marker->content)
2851 evas_object_del(marker->content);
2857 Evas_Coord ox, oy, ow, oh;
2858 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
2859 marker_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
2864 * Move the map to the coordinate of the marker.
2866 * @param marker The marker where the map will be center.
2871 elm_map_marker_bring_in(Elm_Map_Marker *marker)
2873 if (!marker) return;
2874 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
2879 * Move the map to the coordinate of the marker.
2881 * @param marker The marker where the map will be center.
2886 elm_map_marker_show(Elm_Map_Marker *marker)
2888 if (!marker) return;
2889 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
2893 * Move and zoom the map to display a list of markers.
2895 * The map will be centered on the center point of the markers in the list. Then
2896 * the map will be zoomed in order to fit the markers using the maximum zoom which
2897 * allows display of all the markers.
2899 * @param markers The list of markers (list of Elm_Map_Marker *)
2904 elm_map_markers_list_show(Eina_List *markers)
2909 Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
2910 Evas_Coord rw, rh, xc, yc;
2913 if (!markers) return;
2915 EINA_LIST_FOREACH(markers, l, marker)
2919 if (!m_min_lon || marker->longitude < m_min_lon->longitude)
2922 if (!m_max_lon || marker->longitude > m_max_lon->longitude)
2925 if (!m_min_lat || marker->latitude > m_min_lat->latitude)
2928 if (!m_max_lat || marker->latitude < m_max_lat->latitude)
2932 lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
2933 lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
2935 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
2936 for (zoom = map_sources_tab[wd->source].zoom_max; zoom>map_sources_tab[wd->source].zoom_min; zoom--)
2938 Evas_Coord size = pow(2.0, zoom)*wd->tsize;
2939 elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
2941 if (m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2
2942 && m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2
2943 && m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2
2944 && m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2)
2948 elm_map_geo_region_show(wd->obj, lon, lat);
2949 elm_map_zoom_set(wd->obj, zoom);
2953 * Set the maximum numbers of markers display in a group.
2955 * A group can have a long list of markers, consequently the creation of the content
2956 * of the bubble can be very slow. In order to avoid this, a maximum number of items
2957 * is displayed in a bubble. By default this number is 30.
2959 * @param obj The map object.
2960 * @param max The maximum numbers of items displayed in a bubble.
2965 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
2967 ELM_CHECK_WIDTYPE(obj, widtype);
2968 Widget_Data *wd = elm_widget_data_get(obj);
2970 wd->markers_max_num = max;
2974 * Return the evas object getting from the ElmMapMarkerGetFunc callback
2976 * @param marker The marker.
2977 * @return Return the evas object if it exists, else NULL.
2982 elm_map_marker_object_get(Elm_Map_Marker *marker)
2984 if (!marker) return NULL;
2985 return marker->content;
2991 * @param marker The marker.
2996 elm_map_marker_update(Elm_Map_Marker *marker)
2998 if (!marker) return;
2999 if (marker->content)
3001 if (marker->clas->func.del)
3002 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
3004 evas_object_del(marker->content);
3005 marker->content = NULL;
3006 _group_bubble_content_update(marker->groups[marker->wd->zoom]);
3011 * Close all opened bubbles
3013 * @param obj The map object
3018 elm_map_bubbles_close(Evas_Object *obj)
3020 ELM_CHECK_WIDTYPE(obj, widtype);
3021 Widget_Data *wd = elm_widget_data_get(obj);
3022 Marker_Group *group;
3023 Eina_List *l, *l_next;
3025 EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
3026 _group_bubble_free(group);
3031 * Create a group class.
3033 * Each marker must be associated to a group class. Marker with the same group are grouped if they are close.
3034 * The group class defines the style of the marker when a marker is grouped to others markers.
3036 * @param obj The map object
3037 * @return Returns the new group class
3041 EAPI Elm_Map_Group_Class *
3042 elm_map_group_class_new(Evas_Object *obj)
3044 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3045 Widget_Data *wd = elm_widget_data_get(obj);
3046 if (!wd) return NULL;
3047 Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
3048 clas->zoom_grouped = ZOOM_MAX;
3049 wd->groups_clas = eina_list_append(wd->groups_clas, clas);
3054 * Set the style of a group class (radio, radio2 or empty)
3056 * @param clas the group class
3057 * @param style the new style
3062 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
3065 eina_stringshare_replace(&clas->style, style);
3069 * Set the icon callback of a group class.
3071 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
3073 * @param clas the group class
3074 * @param icon_get the callback to create the icon
3079 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
3082 clas->func.icon_get = icon_get;
3086 * Set the data associated to the group class (radio, radio2 or empty)
3088 * @param clas the group class
3089 * @param data the new user data
3094 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
3101 * Set the zoom from where the markers are displayed.
3103 * Markers will not be displayed for a zoom less than @ref zoom
3105 * @param clas the group class
3106 * @param zoom the zoom
3111 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
3114 clas->zoom_displayed = zoom;
3118 * Set the zoom from where the markers are no more grouped.
3120 * @param clas the group class
3121 * @param zoom the zoom
3126 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
3129 clas->zoom_grouped = zoom;
3133 * Set if the markers associated to the group class @clas are hidden or not.
3134 * If @ref hide is true the markers will be hidden.
3136 * @param clas the group class
3137 * @param hide if true the markers will be hidden, else they will be displayed.
3142 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
3144 ELM_CHECK_WIDTYPE(obj, widtype);
3145 Widget_Data *wd = elm_widget_data_get(obj);
3148 if (clas->hide == hide) return;
3152 Evas_Coord ox, oy, ow, oh;
3153 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3154 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3160 * Create a marker class.
3162 * Each marker must be associated to a class.
3163 * The class defines the style of the marker when a marker is displayed alone (not grouped).
3165 * @param obj The map object
3166 * @return Returns the new class
3170 EAPI Elm_Map_Marker_Class *
3171 elm_map_marker_class_new(Evas_Object *obj)
3173 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3174 Widget_Data *wd = elm_widget_data_get(obj);
3175 if (!wd) return NULL;
3176 Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
3177 wd->markers_clas = eina_list_append(wd->markers_clas, clas);
3182 * Set the style of a class (radio, radio2 or empty)
3184 * @param clas the group class
3185 * @param style the new style
3190 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
3193 eina_stringshare_replace(&clas->style, style);
3197 * Set the icon callback of a class.
3199 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
3201 * @param clas the group class
3202 * @param icon_get the callback to create the icon
3207 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
3210 clas->func.icon_get = icon_get;
3215 * Set the callback of the content of the bubble.
3217 * When the user click on a marker, a bubble is displayed with a content.
3218 * The callback @ref get musst return this content. It can be NULL.
3220 * @param clas the group class
3221 * @param get the callback to create the content
3226 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
3229 clas->func.get = get;
3233 * Set the callback of the content of delete the object created by the callback "get".
3235 * If this callback is defined the user will have to delete (or not) the object inside.
3236 * If the callback is not defined the object will be destroyed with evas_object_del()
3238 * @param clas the group class
3239 * @param del the callback to delete the content
3244 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
3247 clas->func.del = del;
3251 * Set the source of the map.
3253 * Elm_Map retrieves the image which composed the map from a web service. This web service can
3254 * be set with this method. A different service can return a different maps with different
3255 * information and it can use different zoom value.
3257 * @param clas the group class
3258 * @param source the new source
3263 elm_map_source_set(Evas_Object *obj, Elm_Map_Sources source)
3265 ELM_CHECK_WIDTYPE(obj, widtype);
3266 Widget_Data *wd = elm_widget_data_get(obj);
3270 if (wd->source == source ) return;
3271 if (!map_sources_tab[source].url_cb) return;
3273 EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid);
3275 wd->source = source;
3279 if (map_sources_tab[wd->source].zoom_max < zoom)
3280 zoom = map_sources_tab[wd->source].zoom_max;
3281 if (map_sources_tab[wd->source].zoom_min > zoom)
3282 zoom = map_sources_tab[wd->source].zoom_min;
3284 elm_map_zoom_set(obj, zoom);
3288 * Get the current source
3290 * @param obj the map object
3291 * @return Returns the maximum zoom of the source
3295 EAPI Elm_Map_Sources
3296 elm_map_source_get(const Evas_Object *obj)
3298 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_SOURCE_MAPNIK;
3299 Widget_Data *wd = elm_widget_data_get(obj);
3300 if (!wd) return ELM_MAP_SOURCE_MAPNIK;
3305 * Set the API of a custom source.
3307 * A custom web service can be associated to the source ELM_MAP_SOURCE_CUSTOM_(1..7).
3309 * @param source the source ID (ELM_MAP_SOURCE_CUSTOM_(1..7))
3310 * @param name the name of the source
3311 * @param zoom_min the minimum zoom of the source, must be >= 0
3312 * @param zoom_max the maximum zoom of the source, must be <= ZOOM_MAX
3313 * @param url_cb the callback used to create the url from where a tile (png or jpeg file) is downloaded.
3318 elm_map_source_custom_api_set(Elm_Map_Sources source, const char *name, int zoom_min, int zoom_max, ElmMapSourceURLFunc url_cb)
3320 if (!name || !url_cb) return;
3321 map_sources_tab[source].name = name;
3322 map_sources_tab[source].zoom_min = zoom_min;
3323 map_sources_tab[source].zoom_max = zoom_max;
3324 map_sources_tab[source].url_cb = url_cb;
3328 * Get the maximum zoom of the source.
3330 * @param source the source
3331 * @return Returns the maximum zoom of the source
3336 elm_map_source_zoom_max_get(Elm_Map_Sources source)
3338 return map_sources_tab[source].zoom_max;
3342 * Get the minimum zoom of the source.
3344 * @param source the source
3345 * @return Returns the minimum zoom of the source
3350 elm_map_source_zoom_min_get(Elm_Map_Sources source)
3352 return map_sources_tab[source].zoom_min;
3356 * Get the name of a source.
3358 * @param source the source
3359 * @return Returns the name of the source
3364 elm_map_source_name_get(Elm_Map_Sources source)
3366 return map_sources_tab[source].name;
3371 _mapnik_url_cb(void *data, int x, int y, int zoom)
3374 snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
3380 _osmarender_url_cb(void * data, int x, int y, int zoom)
3383 snprintf(buf, sizeof(buf), "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
3389 _cyclemap_url_cb(void *data, int x, int y, int zoom)
3392 snprintf(buf, sizeof(buf), "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
3398 _maplint_url_cb(void *data, int x, int y, int zoom)
3401 snprintf(buf, sizeof(buf), "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
3407 _decarta_url_cb(void *data, int x, int y, int zoom)
3410 Widget_Data *wd = elm_widget_data_get(data);
3411 if(map_sources_tab[elm_map_source_get(data)].use_module == EINA_TRUE)
3412 if(wd->api) if ((wd->api) && (wd->api->obj_url_request))
3413 url = wd->api->obj_url_request(data, x, y, zoom);
3415 if(!url) url = strdup("");