1 #include <Elementary.h>
3 #include "elm_module_priv.h"
9 * This is a widget specifically for displaying the free map OpenStreetMap.
11 * Signals that you can add callbacks for are:
13 * clicked - This is called when a user has clicked the map without dragging
16 * press - This is called when a user has pressed down on the map.
18 * longpressed - This is called when a user has pressed down on the map for
19 * a long time without dragging around.
21 * clicked,double - This is called when a user has double-clicked the photo.
23 * load,details - Map detailed data load begins.
25 * loaded,details - This is called when all parts of the map are loaded.
27 * zoom,start - Zoom animation started.
29 * zoom,stop - Zoom animation stopped.
31 * zoom,change - Zoom changed when using an auto zoom mode.
33 * scroll - the content has been scrolled (moved)
35 * scroll,anim,start - scrolling animation has started
37 * scroll,anim,stop - scrolling animation has stopped
39 * scroll,drag,start - dragging the contents around has started
41 * scroll,drag,stop - dragging the contents around has stopped
47 typedef struct _Widget_Data Widget_Data;
48 typedef struct _Pan Pan;
49 typedef struct _Grid Grid;
50 typedef struct _Grid_Item Grid_Item;
51 typedef struct _Marker_Group Marker_Group;
52 typedef struct _Mod_Api Mod_Api;
54 #define DEST_DIR_ZOOM_PATH "/tmp/elm_map/%d/%d/"
55 #define DEST_DIR_PATH DEST_DIR_ZOOM_PATH"%d/"
56 #define DEST_FILE_PATH "%s%d.png"
59 // Currently the size of a tile must be 256*256
60 // and the size of the map must be pow(2.0, z)*tile_size
61 typedef struct _Map_Sources_Tab
63 Elm_Map_Sources source;
67 ElmMapSourceURLFunc url_cb;
68 Eina_Bool use_module : 1;
72 #define TOUCH_HOLD_RANGE 40
73 //Zemm min is supposed to be 0
74 static char * _mapnik_url_cb(void *data ,int x, int y, int zoom);
75 static char * _osmarender_url_cb(void *data ,int x, int y, int zoom);
76 static char * _cyclemap_url_cb(void *data ,int x, int y, int zoom);
77 static char * _maplint_url_cb(void *data ,int x, int y, int zoom);
78 static char * _decarta_url_cb(void *data ,int x, int y, int zoom);
79 static Map_Sources_Tab map_sources_tab[] =
81 {ELM_MAP_SOURCE_MAPNIK, "Mapnik", 0, 18, _mapnik_url_cb, EINA_FALSE},
82 {ELM_MAP_SOURCE_OSMARENDER, "Osmarender", 0, 17, _osmarender_url_cb, EINA_FALSE},
83 {ELM_MAP_SOURCE_CYCLEMAP, "Cycle Map", 0, 17, _cyclemap_url_cb, EINA_FALSE},
84 {ELM_MAP_SOURCE_MAPLINT, "Maplint", 12, 16, _maplint_url_cb, EINA_FALSE},
85 {ELM_MAP_SOURCE_DECARTA, "Decarta", 1, 20, _decarta_url_cb, EINA_TRUE},
86 {ELM_MAP_SOURCE_CUSTOM_1, "Custom 1", 0, 18, NULL, EINA_FALSE},
87 {ELM_MAP_SOURCE_CUSTOM_2, "Custom 2", 0, 18, NULL, EINA_FALSE},
88 {ELM_MAP_SOURCE_CUSTOM_3, "Custom 3", 0, 18, NULL, EINA_FALSE},
89 {ELM_MAP_SOURCE_CUSTOM_4, "Custom 4", 0, 18, NULL, EINA_FALSE},
90 {ELM_MAP_SOURCE_CUSTOM_5, "Custom 5", 0, 18, NULL, EINA_FALSE},
91 {ELM_MAP_SOURCE_CUSTOM_6, "Custom 6", 0, 18, NULL, EINA_FALSE}
94 struct _Elm_Map_Marker_Class
99 struct _Elm_Map_Marker_Class_Func {
100 ElmMapMarkerGetFunc get;
101 ElmMapMarkerDelFunc del; //if NULL the object will be destroyed with evas_object_del()
102 ElmMapMarkerIconGetFunc icon_get;
105 struct { //this part is private, do not modify these values
107 Evas_Coord edje_w, edje_h;
111 struct _Elm_Map_Marker
114 Elm_Map_Marker_Class *clas;
115 Elm_Map_Group_Class *clas_group;
116 double longitude, latitude;
119 Evas_Coord x[ZOOM_MAX+1], y[ZOOM_MAX+1];
122 Marker_Group *groups[ZOOM_MAX+1];
124 Evas_Object *content;
127 struct _Elm_Map_Group_Class
131 int zoom_displayed; // display the group if the zoom is >= to zoom_display
132 int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
136 ElmMapGroupIconGetFunc icon_get;
139 struct { //this part is private, do not modify these values
141 Evas_Coord edje_w, edje_h;
142 Evas_Coord edje_max_w, edje_max_h;
144 Eina_List *objs_used;
145 Eina_List *objs_notused;
152 Eina_Matrixsparse_Cell *cell;
153 Elm_Map_Group_Class *clas;
156 long long sum_x, sum_y;
160 Evas_Object *obj, *bubble, *sc, *bx, *rect;
162 Eina_Bool bringin : 1;
163 Eina_Bool update_nbelems : 1;
164 Eina_Bool update_resize : 1;
165 Eina_Bool update_raise : 1;
166 Eina_Bool delete_object : 1;
179 Eina_Bool download : 1;
181 Ecore_File_Download_Job *job;
188 int tsize; // size of tile (tsize x tsize pixels)
189 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
190 int iw, ih; // size of image in pixels
191 int w, h; // size of grid image in pixels (represented by grid)
192 int gw, gh; // size of grid in tiles
193 Eina_Matrixsparse *grid;
200 Evas_Object *pan_smart;
202 Evas_Object *sep_maps_markers; //map objects are below this object and marker objects are on top
204 Evas_Coord pan_x, pan_y, minw, minh;
208 Elm_Map_Zoom_Mode mode;
211 Ecore_Timer *scr_timer;
212 Ecore_Timer *long_timer;
213 Ecore_Animator *zoom_animator;
214 double t_start, t_end;
224 Evas_Coord x, y ,w ,h;
230 Eina_Bool resized : 1;
231 Eina_Bool longpressed : 1;
232 Eina_Bool on_hold : 1;
233 Eina_Bool paused : 1;
234 Eina_Bool paused_markers : 1;
235 Eina_Bool pinch_zoom : 1;
242 Ecore_Job *markers_place_job;
243 Eina_Matrixsparse *markers[ZOOM_MAX+1];
244 Eina_List *cells_displayed; // list of Eina_Matrixsparse_Cell
245 Evas_Coord markers_max_num;
246 int marker_max_w, marker_max_h;
248 Eina_List *opened_bubbles; //opened bubbles, list of Map_Group *
250 Eina_List *groups_clas; // list of Elm_Map_Group_Class*
251 Eina_List *markers_clas; // list of Elm_Map_Markers_Class*
253 Elm_Map_Sources source;
259 Evas_Object_Smart_Clipped_Data __clipped_data;
265 Eina_Bool (*obj_hook) (Evas_Object *obj);
266 Eina_Bool (*obj_unhook) (Evas_Object *obj);
267 char * (*obj_url_request) (Evas_Object *obj, int x, int y, int zoom);
268 Eina_Bool (*obj_convert_coord_into_geo) (const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat);
269 Eina_Bool (*obj_convert_geo_into_coord) (const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y);
280 Evas_Coord x, y, w, h;
283 Ecore_Timer *hold_timer;
289 Evas_Object *pinch_obj;
292 static int dis_old = 0;
293 static Eina_List *s_event_list;
295 static const char *widtype = NULL;
297 static const char SIG_CHANGED[] = "changed";
298 static const char SIG_CLICKED[] = "clicked";
299 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
300 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
301 static const char SIG_LOAD_DETAIL[] = "load,detail";
302 static const char SIG_LONGPRESSED[] = "longpressed";
303 static const char SIG_PRESS[] = "press";
304 static const char SIG_SCROLL[] = "scroll";
305 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
306 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
307 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
308 static const char SIG_ZOOM_START[] = "zoom,start";
309 static const char SIG_ZOOM_STOP[] = "zoom,stop";
310 static const Evas_Smart_Cb_Description _signals[] = {
313 {SIG_CLICKED_DOUBLE, ""},
314 {SIG_LOADED_DETAIL, ""},
315 {SIG_LOAD_DETAIL, ""},
316 {SIG_LONGPRESSED, ""},
319 {SIG_SCROLL_DRAG_START, ""},
320 {SIG_SCROLL_DRAG_STOP, ""},
321 {SIG_ZOOM_CHANGE, ""},
322 {SIG_ZOOM_START, ""},
327 static void _pan_calculate(Evas_Object *obj);
329 static void _del_hook(Evas_Object *obj);
330 static void _theme_hook(Evas_Object *obj);
331 static void _sizing_eval(Evas_Object *obj);
332 static void _calc_job(void *data);
333 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);
334 static void grid_clear(Evas_Object *obj, Grid *g);
335 static Grid *grid_create(Evas_Object *obj);
336 static void grid_load(Evas_Object *obj, Grid *g);
339 static void _group_object_create(Marker_Group *group);
340 static void _group_object_free(Marker_Group *group);
341 static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
342 static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
343 static void _group_bubble_create(Marker_Group *group);
344 static void _group_bubble_free(Marker_Group *group);
345 static void _group_bubble_place(Marker_Group *group);
347 static int _group_bubble_content_update(Marker_Group *group);
348 static void _group_bubble_content_free(Marker_Group *group);
349 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);
350 static void _bubble_sc_hits_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
352 static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
353 static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
354 static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
356 static void _mouse_multi_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
357 static void _mouse_multi_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
358 static void _mouse_multi_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
361 hold_timer_cb(void *data)
363 struct event_t *ev0 = (struct event_t *)data;
364 ev0->hold_timer = NULL;
366 return ECORE_CALLBACK_CANCEL;
370 _rect_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
372 Widget_Data *wd = elm_widget_data_get(data);
375 evas_object_geometry_get(wd->rect,&x,&y,&w,&h);
376 evas_object_geometry_get(wd->pan_smart,&x,&y,&w,&h);
377 evas_object_resize(wd->rect,w,h);
378 evas_object_move(wd->rect,x,y);
382 get_multi_device(void)
385 struct event_t *ev = NULL;
387 EINA_LIST_FOREACH(s_event_list, l, ev) {
388 if(ev->device != 0) return ev->device;
394 get_distance(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
401 dis = (int)sqrt(dx * dx + dy * dy);
405 static struct event_t*
406 get_event_object(int device)
409 struct event_t *ev = NULL;
411 EINA_LIST_FOREACH(s_event_list, l, ev) {
412 if(ev->device == device) break;
418 static struct event_t *
419 create_event_object(Evas_Object *object, int device)
423 ev = calloc(1, sizeof(struct event_t));
424 if(ev == NULL) DBG("Cannot allocate event_t");
429 evas_object_geometry_get(object, &ev->x, &ev->y, &ev->w, &ev->h);
431 s_event_list = eina_list_append(s_event_list, ev);
437 destroy_event_object(struct event_t *ev)
439 if(ev == NULL) return;
440 ev->pinch_obj = NULL;
443 s_event_list = eina_list_remove(s_event_list, ev);
445 if (ev->hold_timer) {
446 ecore_timer_del(ev->hold_timer);
447 ev->hold_timer = NULL;
453 module(Evas_Object *obj __UNUSED__)
455 static Elm_Module *m = NULL;
456 if (m) goto ok; // already found - just use
457 if (!(m = _elm_module_find_as("map/api"))) return NULL;
460 m->api = malloc(sizeof(Mod_Api));
461 if (!m->api) return NULL;
462 ((Mod_Api *)(m->api) )->obj_hook = // called on creation
463 _elm_module_symbol_get(m, "obj_hook");
464 ((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
465 _elm_module_symbol_get(m, "obj_unhook");
466 ((Mod_Api *)(m->api) )->obj_url_request =
467 _elm_module_symbol_get(m, "obj_url_request");
468 ((Mod_Api *)(m->api) )->obj_convert_coord_into_geo =
469 _elm_module_symbol_get(m, "obj_convert_coord_into_geo");
470 ((Mod_Api *)(m->api) )->obj_convert_geo_into_coord =
471 _elm_module_symbol_get(m, "obj_convert_geo_into_coord");
472 ok: // ok - return api
477 rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
479 Widget_Data *wd = elm_widget_data_get(obj);
480 Evas_Coord ax, ay, gw, gh, hh, ww;
482 evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh);
489 if (ww == gw && hh == gh) return;
491 if (ow > gw) ax = (ow - gw) / 2;
492 if (oh > gh) ay = (oh - gh) / 2;
493 evas_object_move(wd->rect,
496 evas_object_resize(wd->rect, gw, gh);
500 wd->show.show = EINA_FALSE;
501 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
506 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)
508 Widget_Data *wd = elm_widget_data_get(obj);
509 Evas_Coord ax, ay, gw, gh, tx, ty;
510 Eina_List *l, *markers;
511 Eina_Matrixsparse_Cell *cell;
516 int g_xx, g_yy, g_hh, g_ww;
519 if (g != eina_list_data_get(wd->grids)) return;
525 if (ow > gw) ax = (ow - gw) / 2;
526 if (oh > gh) ay = (oh - gh) / 2;
528 if (wd->zoom != wd->marker_zoom)
530 EINA_LIST_FREE(wd->cells_displayed, cell)
532 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
534 if (group->obj) _group_object_free(group);
538 wd->marker_zoom = wd->zoom;
540 if (wd->paused_markers
541 && (wd->size.nw != wd->size.w || wd->size.nh != wd->size.h) )
544 g_xx = wd->pan_x / wd->tsize;
545 if (g_xx < 0) g_xx = 0;
546 g_yy = wd->pan_y / wd->tsize;
547 if (g_yy < 0) g_yy = 0;
548 g_ww = ow / wd->tsize + 1;
549 if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
550 g_hh = oh / wd->tsize + 1;
551 if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
553 //hide groups no more displayed
554 EINA_LIST_FREE(wd->cells_displayed, cell)
556 eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x);
557 if (y < g_yy || y > g_yy + g_hh || x < g_xx || x > g_xx + g_ww)
559 EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
561 if (group->obj) _group_object_free(group);
566 for (y = g_yy; y <= g_yy + g_hh; y++)
568 for (x = g_xx; x <= g_xx + g_ww; x++)
570 if (!wd->markers[wd->zoom]) continue;
571 eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell);
573 wd->cells_displayed = eina_list_append(wd->cells_displayed, cell);
574 markers = eina_matrixsparse_cell_data_get(cell);
575 EINA_LIST_FOREACH(markers, l, group)
577 if (!group->markers) continue;
578 if (group->clas->zoom_displayed > wd->zoom) continue;
585 if (eina_list_count(group->markers) == 1)
587 Elm_Map_Marker *m = eina_list_data_get(group->markers);
588 ww = m->clas->priv.edje_w;
589 hh = m->clas->priv.edje_h;
595 if ((gw != g->w) && (g->w > 0))
598 xx = ((long long )gw * xx) / g->w;
599 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
601 if ((gh != g->h) && (g->h > 0))
604 yy = ((long long)gh * yy) / g->h;
605 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
608 if (!group->clas->hide
609 && xx-px+ax+ox >= ox && xx-px+ax+ox<= ox+ow
610 && yy-py+ay+oy >= oy && yy-py+ay+oy<= oy+oh)
612 if (!group->obj) _group_object_create(group);
614 if (group->update_nbelems)
616 group->update_nbelems = EINA_FALSE;
617 if (eina_list_count(group->markers) > 1)
619 snprintf(buf, sizeof(buf), "%d", eina_list_count(group->markers));
620 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
623 edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", "");
625 evas_object_move(group->obj,
626 xx - px + ax + ox - ww/2,
627 yy - py + ay + oy - hh/2);
628 if (!wd->paused_markers || group->update_resize)
630 group->update_resize = EINA_FALSE;
631 evas_object_resize(group->obj, ww, hh);
633 if (group->update_raise)
635 group->update_raise = EINA_FALSE;
636 evas_object_raise(group->obj);
637 evas_object_show(group->obj);
639 if (group->bubble) _group_bubble_place(group);
643 _group_object_free(group);
651 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)
653 Widget_Data *wd = elm_widget_data_get(obj);
654 Evas_Coord ax, ay, gw, gh, tx, ty;
663 if (ow > gw) ax = (ow - gw) / 2;
664 if (oh > gh) ay = (oh - gh) / 2;
666 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
667 Eina_Matrixsparse_Cell *cell;
669 EINA_ITERATOR_FOREACH(it, cell)
671 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
677 if ((gw != g->w) && (g->w > 0))
680 xx = ((long long )gw * xx) / g->w;
681 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
683 if ((gh != g->h) && (g->h > 0))
686 yy = ((long long)gh * yy) / g->h;
687 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
689 evas_object_move(gi->img,
693 evas_object_resize(gi->img, ww, hh);
695 /*evas_object_move(gi->txt,
699 evas_object_resize(gi->txt, ww, hh);
702 eina_iterator_free(it);
706 grid_clear(Evas_Object *obj, Grid *g)
708 Widget_Data *wd = elm_widget_data_get(obj);
712 if (!g->grid) return;
714 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
715 Eina_Matrixsparse_Cell *cell;
717 snprintf(buf, sizeof(buf), DEST_DIR_ZOOM_PATH, wd->id, g->zoom);
718 ecore_file_recursive_rm(buf);
720 EINA_ITERATOR_FOREACH(it, cell)
722 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
723 evas_object_del(gi->img);
724 //evas_object_del(gi->txt);
728 gi->want = EINA_FALSE;
730 if (wd->preload_num == 0)
732 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
733 "elm,state,busy,stop", "elm");
734 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
740 DBG("DOWNLOAD abort %s", gi->file);
741 ecore_file_download_abort(gi->job);
742 ecore_file_remove(gi->file);
746 eina_stringshare_del(gi->file);
750 eina_matrixsparse_free(g->grid);
751 eina_iterator_free(it);
758 _tile_update(Grid_Item *gi)
760 gi->want = EINA_FALSE;
761 gi->download = EINA_FALSE;
762 evas_object_image_file_set(gi->img, gi->file, NULL);
763 if (evas_object_image_load_error_get(gi->img) != EVAS_LOAD_ERROR_NONE)
764 ecore_file_remove(gi->file);
766 evas_object_show(gi->img);
768 //evas_object_text_text_set(gi->txt, gi->file);
769 //evas_object_show(gi->txt);
771 gi->have = EINA_TRUE;
772 gi->wd->preload_num--;
773 if (gi->wd->preload_num == 0)
775 edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
776 "elm,state,busy,stop", "elm");
777 evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
783 _tile_downloaded(void *data, const char *file __UNUSED__, int status)
785 Grid_Item *gi = data;
787 gi->download = EINA_FALSE;
790 DBG("DOWNLOAD done %s", gi->file);
791 if (gi->want && !status) _tile_update(gi);
795 DBG("Download failed %s (%d) ", gi->file, status);
796 ecore_file_remove(gi->file);
801 grid_create(Evas_Object *obj)
803 Widget_Data *wd = elm_widget_data_get(obj);
806 g = calloc(1, sizeof(Grid));
809 g->tsize = wd->tsize;
812 if (g->zoom > map_sources_tab[wd->source].zoom_max) return NULL;
813 if (g->zoom < map_sources_tab[wd->source].zoom_min) return NULL;
815 int size = pow(2.0, wd->zoom);
819 g->w = g->tsize * g->gw;
820 g->h = g->tsize * g->gh;
822 g->grid = eina_matrixsparse_new(g->gh, g->gw, NULL, NULL);
828 grid_load(Evas_Object *obj, Grid *g)
830 Widget_Data *wd = elm_widget_data_get(obj);
833 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
835 Eina_Matrixsparse_Cell *cell;
839 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
840 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
845 if ((gw <= 0) || (gh <= 0)) return;
848 if ((gw != g->w) && (g->w > 0))
849 size = ((long long)gw * size) / g->w;
850 if (size < (g->tsize / 2)) return; // else we will load to much tiles
852 it = eina_matrixsparse_iterator_new(g->grid);
854 EINA_ITERATOR_FOREACH(it, cell)
856 gi = eina_matrixsparse_cell_data_get(cell);
863 if ((gw != g->w) && (g->w > 0))
866 xx = ((long long )gw * xx) / g->w;
867 ww = (((long long)gw * (tx + ww)) / g->w) - xx;
869 if ((gh != g->h) && (g->h > 0))
872 yy = ((long long)gh * yy) / g->h;
873 hh = (((long long)gh * (ty + hh)) / g->h) - yy;
876 if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
884 if (wd->preload_num == 0)
886 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
887 "elm,state,busy,stop", "elm");
888 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL,
891 evas_object_hide(gi->img);
892 //evas_object_hide(gi->txt);
893 evas_object_image_file_set(gi->img, NULL, NULL);
894 gi->want = EINA_FALSE;
895 gi->have = EINA_FALSE;
899 DBG("DOWNLOAD abort %s", gi->file);
900 ecore_file_download_abort(gi->job);
901 ecore_file_remove(gi->file);
904 gi->download = EINA_FALSE;
908 evas_object_hide(gi->img);
909 //evas_object_hide(gi->txt);
910 evas_object_image_preload(gi->img, 1);
911 evas_object_image_file_set(gi->img, NULL, NULL);
912 gi->have = EINA_FALSE;
913 gi->want = EINA_FALSE;
917 eina_iterator_free(it);
919 xx = wd->pan_x / size;
922 yy = wd->pan_y / size;
926 if (xx + ww >= g->gw) ww = g->gw - xx - 1;
929 if (yy + hh >= g->gh) hh = g->gh - yy - 1;
931 for (y = yy; y <= yy + hh; y++)
933 for (x = xx; x <= xx + ww; x++)
935 gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
937 if ((!gi) && (g != eina_list_data_get(wd->grids)))
942 gi = calloc(1, sizeof(Grid_Item));
943 gi->src.x = x * g->tsize;
944 gi->src.y = y * g->tsize;
945 gi->src.w = g->tsize;
946 gi->src.h = g->tsize;
948 gi->out.x = gi->src.x;
949 gi->out.y = gi->src.y;
950 gi->out.w = gi->src.w;
951 gi->out.h = gi->src.h;
955 gi->img = evas_object_image_add(evas_object_evas_get(obj));
956 evas_object_image_scale_hint_set
957 (gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
958 evas_object_image_filled_set(gi->img, 1);
960 evas_object_smart_member_add(gi->img, wd->pan_smart);
961 elm_widget_sub_object_add(obj, gi->img);
962 evas_object_pass_events_set(gi->img, EINA_TRUE);
963 evas_object_stack_below(gi->img, wd->sep_maps_markers);
965 /*gi->txt = evas_object_text_add(evas_object_evas_get(obj));
966 evas_object_text_font_set(gi->txt, "Vera", 12);
967 evas_object_color_set(gi->txt, 100, 100, 100, 255);
968 evas_object_smart_member_add(gi->txt,
970 elm_widget_sub_object_add(obj, gi->txt);
971 evas_object_pass_events_set(gi->txt, EINA_TRUE);
973 eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
976 if (!gi->have && !gi->download)
978 char buf[PATH_MAX], buf2[PATH_MAX];
981 gi->want = EINA_TRUE;
983 snprintf(buf, sizeof(buf), DEST_DIR_PATH, wd->id, g->zoom, x);
984 if (!ecore_file_exists(buf))
985 ecore_file_mkpath(buf);
987 snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y);
989 source = map_sources_tab[wd->source].url_cb(obj, x, y, g->zoom);
990 if(strlen(source)==0) continue;
992 eina_stringshare_replace(&gi->file, buf2);
994 if (ecore_file_exists(buf2) || g == eina_list_data_get(wd->grids))
996 gi->download = EINA_TRUE;
998 if (wd->preload_num == 1)
1000 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1001 "elm,state,busy,start", "elm");
1002 evas_object_smart_callback_call(obj,
1007 if (ecore_file_exists(buf2))
1011 DBG("DOWNLOAD %s \t in %s", source, buf2);
1012 ecore_file_download(source, buf2, _tile_downloaded, NULL, gi, &(gi->job));
1014 DBG("Can't start to download %s", buf);
1017 if (source) free(source);
1020 evas_object_show(gi->img);
1026 grid_clearall(Evas_Object *obj)
1028 Widget_Data *wd = elm_widget_data_get(obj);
1032 EINA_LIST_FREE(wd->grids, g)
1040 _smooth_update(Evas_Object *obj)
1042 Widget_Data *wd = elm_widget_data_get(obj);
1047 EINA_LIST_FOREACH(wd->grids, l, g)
1049 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1050 Eina_Matrixsparse_Cell *cell;
1052 EINA_ITERATOR_FOREACH(it, cell)
1054 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1055 evas_object_image_smooth_scale_set(gi->img, (wd->nosmooth == 0));
1057 eina_iterator_free(it);
1062 _grid_raise(Grid *g)
1064 Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
1065 Eina_Matrixsparse_Cell *cell;
1067 g->wd->size.w = g->w;
1068 g->wd->size.h = g->h;
1070 EINA_ITERATOR_FOREACH(it, cell)
1072 Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
1073 evas_object_raise(gi->img);
1074 //evas_object_raise(gi->txt);
1076 eina_iterator_free(it);
1080 _scr_timeout(void *data)
1082 Widget_Data *wd = elm_widget_data_get(data);
1083 if (!wd) return ECORE_CALLBACK_CANCEL;
1085 if (wd->nosmooth == 0) _smooth_update(data);
1086 wd->scr_timer = NULL;
1087 return ECORE_CALLBACK_CANCEL;
1091 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1093 Widget_Data *wd = elm_widget_data_get(data);
1098 if (wd->nosmooth == 1) _smooth_update(data);
1100 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1101 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
1105 zoom_do(Evas_Object *obj, double t)
1107 Widget_Data *wd = elm_widget_data_get(obj);
1108 Evas_Coord xx, yy, ow, oh;
1111 if (t > 1.0) t = 1.0;
1113 wd->size.w = (wd->size.ow * (1.0 - t)) + (wd->size.nw * t);
1114 wd->size.h = (wd->size.oh * (1.0 - t)) + (wd->size.nh * t);
1116 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
1118 if (wd->center_on.enabled)
1120 elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy);
1126 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
1127 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
1131 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
1133 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
1135 wd->show.show = EINA_TRUE;
1141 if (wd->calc_job) ecore_job_del(wd->calc_job);
1142 wd->calc_job = ecore_job_add(_calc_job, wd);
1145 return ECORE_CALLBACK_CANCEL;
1147 return ECORE_CALLBACK_RENEW;
1151 _zoom_anim(void *data)
1153 Evas_Object *obj = data;
1154 Widget_Data *wd = elm_widget_data_get(obj);
1158 if (!wd) return ECORE_CALLBACK_CANCEL;
1159 t = ecore_loop_time_get();
1162 else if (wd->t_end > wd->t_start)
1163 t = (t - wd->t_start) / (wd->t_end - wd->t_start);
1168 go = zoom_do(obj, t);
1172 if (wd->nosmooth == 0) _smooth_update(data);
1173 wd->zoom_animator = NULL;
1174 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1180 _long_press(void *data)
1182 Widget_Data *wd = elm_widget_data_get(data);
1183 if (!wd) return ECORE_CALLBACK_CANCEL;
1184 wd->long_timer = NULL;
1185 wd->longpressed = EINA_TRUE;
1186 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
1187 return ECORE_CALLBACK_CANCEL;
1191 _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1193 Widget_Data *wd = elm_widget_data_get(data);
1194 Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down*)event_info;
1195 struct event_t *ev0;
1197 ev0 = get_event_object(0);
1199 ev0 = create_event_object(obj, 0);
1201 ev0->hold_timer = NULL;
1202 ev0->prev.x = ev->output.x;
1203 ev0->prev.y = ev->output.y;
1208 if (ev->button != 1) return;
1209 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1210 else wd->on_hold = EINA_FALSE;
1211 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1212 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, ev);
1214 evas_object_smart_callback_call(data, SIG_PRESS, ev);
1215 wd->longpressed = EINA_FALSE;
1216 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1217 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
1221 _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1223 Widget_Data *wd = elm_widget_data_get(data);
1224 Evas_Event_Mouse_Move *move = (Evas_Event_Mouse_Move *)event_info;
1225 struct event_t *ev0;
1226 if(wd->pinch_zoom) return;
1227 ev0 = get_event_object(0);
1228 if(ev0 == NULL) return;
1230 ev0->prev.x = move->cur.output.x;
1231 ev0->prev.y = move->cur.output.y;
1235 _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1237 Widget_Data *wd = elm_widget_data_get(data);
1238 Evas_Event_Mouse_Up *ev = event_info;
1241 struct event_t *ev0;
1242 struct event_t *ev1 = NULL;
1244 ev0 = get_event_object(0);
1246 mdevice = get_multi_device();
1248 if(ev0->hold_timer == NULL){
1250 ecore_timer_del(ev0->hold_timer);
1251 ev0->hold_timer = NULL;
1253 elm_smart_scroller_hold_set(wd->scr, 0);
1254 elm_smart_scroller_freeze_set(wd->scr, 0);
1255 elm_smart_scroller_freeze_momentum_animator_set(wd->scr, 0);
1256 elm_smart_scroller_freeze_bounce_animator_set(wd->scr, 0);
1257 wd->pinch_zoom = EINA_FALSE;
1259 ev1 = get_event_object(mdevice);
1261 ev1->hold_timer = ecore_timer_add(0.35f, hold_timer_cb, ev1);
1264 destroy_event_object(ev0);
1266 DBG("Cannot get event0");
1269 if (ev->button != 1) return;
1270 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
1271 else wd->on_hold = EINA_FALSE;
1272 if (wd->long_timer){
1273 ecore_timer_del(wd->long_timer);
1274 wd->long_timer = NULL;
1277 evas_object_smart_callback_call(data, SIG_CLICKED, ev);
1278 wd->on_hold = EINA_FALSE;
1282 _mouse_multi_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1284 Widget_Data *wd = elm_widget_data_get(data);
1286 Evas_Event_Multi_Down *down = event_info;
1288 elm_smart_scroller_hold_set(wd->scr, 1);
1289 elm_smart_scroller_freeze_set(wd->scr, 1);
1290 elm_smart_scroller_freeze_momentum_animator_set(wd->scr, 1);
1291 elm_smart_scroller_freeze_bounce_animator_set(wd->scr, 1);
1293 ev = get_event_object(down->device);
1296 ev = create_event_object(obj, down->device);
1298 DBG("Failed : create_event_object");
1302 wd->pinch_zoom = EINA_FALSE;
1304 ev->hold_timer = NULL;
1305 ev->prev.x = down->output.x;
1306 ev->prev.y = down->output.y;
1311 elm_smart_scroller_hold_set(wd->scr, 0);
1312 elm_smart_scroller_freeze_set(wd->scr, 0);
1313 elm_smart_scroller_freeze_momentum_animator_set(wd->scr, 0);
1314 elm_smart_scroller_freeze_bounce_animator_set(wd->scr, 0);
1319 _mouse_multi_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1321 Widget_Data *wd = elm_widget_data_get(data);
1322 Evas_Event_Multi_Move *move = (Evas_Event_Multi_Move *)event_info;
1324 struct event_t *ev0;
1327 if(wd->pinch_zoom) return;
1328 ev = get_event_object(move->device);
1330 DBG("Cannot get multi device");
1334 ev->prev.x = move->cur.output.x;
1335 ev->prev.y = move->cur.output.y;
1337 ev0 = get_event_object(0);
1339 DBG("Cannot get device0");
1343 dis_new = get_distance(ev0->prev.x, ev0->prev.y, ev->prev.x, ev->prev.y);
1344 int zoom = wd->zoom;
1347 if(dis_old - dis_new > 0 && ev->pinch_dis > TOUCH_HOLD_RANGE){
1348 wd->pinch_zoom = EINA_TRUE;
1350 elm_map_zoom_set(data, zoom);
1352 }else if(dis_old - dis_new < 0 && ev->pinch_dis < -TOUCH_HOLD_RANGE){
1353 wd->pinch_zoom = EINA_TRUE;
1355 elm_map_zoom_set(data, zoom);
1359 ev->pinch_dis += (dis_old - dis_new);
1365 _mouse_multi_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1367 Evas_Event_Multi_Up *up = (Evas_Event_Multi_Up *)event_info;
1368 struct event_t *ev0;
1371 ev = get_event_object(up->device);
1373 DBG("Cannot get multi device");
1378 ev0 = get_event_object(0);
1380 ev0->hold_timer = ecore_timer_add(0.35f, hold_timer_cb, ev0);
1382 if(ev->hold_timer == NULL) {
1384 ecore_timer_del(ev->hold_timer);
1385 ev->hold_timer = NULL;
1388 destroy_event_object(ev);
1391 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
1394 _del_hook(Evas_Object *obj)
1396 Elm_Map_Group_Class *group_clas;
1397 Elm_Map_Marker_Class *marker_clas;
1398 Widget_Data *wd = elm_widget_data_get(obj);
1402 EINA_LIST_FREE(wd->groups_clas, group_clas)
1404 if (group_clas->style)
1405 eina_stringshare_del(group_clas->style);
1409 EINA_LIST_FREE(wd->markers_clas, marker_clas)
1411 if (marker_clas->style)
1412 eina_stringshare_del(marker_clas->style);
1416 if (wd->calc_job) ecore_job_del(wd->calc_job);
1417 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
1418 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
1419 if (wd->long_timer) ecore_timer_del(wd->long_timer);
1421 if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj);
1426 _del_pre_hook(Evas_Object *obj)
1428 Marker_Group *group;
1429 Elm_Map_Marker *marker;
1431 Eina_Bool free_marker = EINA_TRUE;
1433 Widget_Data *wd = elm_widget_data_get(obj);
1437 for (i = 0; i < ZOOM_MAX + 1; i++)
1439 if (!wd->markers[i]) continue;
1440 Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
1441 Eina_Matrixsparse_Cell *cell;
1443 EINA_ITERATOR_FOREACH(it, cell)
1445 l = eina_matrixsparse_cell_data_get(cell);
1446 EINA_LIST_FREE(l, group)
1448 EINA_LIST_FREE(group->markers, marker)
1450 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1451 _bubble_sc_hits_changed_cb, group);
1452 if (free_marker) free(marker);
1456 free_marker = EINA_FALSE;
1458 eina_iterator_free(it);
1459 eina_matrixsparse_free(wd->markers[i]);
1462 evas_object_del(wd->sep_maps_markers);
1463 evas_object_del(wd->pan_smart);
1464 wd->pan_smart = NULL;
1468 _theme_hook(Evas_Object *obj)
1470 Widget_Data *wd = elm_widget_data_get(obj);
1472 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
1473 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
1478 _sizing_eval(Evas_Object *obj)
1480 Widget_Data *wd = elm_widget_data_get(obj);
1481 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
1483 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
1484 evas_object_size_hint_min_set(obj, minw, minh);
1485 evas_object_size_hint_max_set(obj, maxw, maxh);
1489 _calc_job(void *data)
1491 Widget_Data *wd = data;
1492 Evas_Coord minw, minh;
1499 if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
1501 double tz = wd->zoom;
1503 elm_map_zoom_set(wd->obj, tz);
1506 if ((minw != wd->minw) || (minh != wd->minh))
1510 evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
1511 _sizing_eval(wd->obj);
1513 wd->calc_job = NULL;
1514 evas_object_smart_changed(wd->pan_smart);
1518 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
1520 Pan *sd = evas_object_smart_data_get(obj);
1522 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
1525 evas_object_smart_changed(obj);
1529 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1531 Pan *sd = evas_object_smart_data_get(obj);
1533 if (x) *x = sd->wd->pan_x;
1534 if (y) *y = sd->wd->pan_y;
1538 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
1540 Pan *sd = evas_object_smart_data_get(obj);
1543 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1544 ow = sd->wd->minw - ow;
1546 oh = sd->wd->minh - oh;
1553 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
1555 Pan *sd = evas_object_smart_data_get(obj);
1557 if (w) *w = sd->wd->minw;
1558 if (h) *h = sd->wd->minh;
1562 _pan_add(Evas_Object *obj)
1565 Evas_Object_Smart_Clipped_Data *cd;
1567 cd = evas_object_smart_data_get(obj);
1569 sd = calloc(1, sizeof(Pan));
1571 sd->__clipped_data = *cd;
1573 evas_object_smart_data_set(obj, sd);
1577 _pan_del(Evas_Object *obj)
1579 Pan *sd = evas_object_smart_data_get(obj);
1585 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
1587 Pan *sd = evas_object_smart_data_get(obj);
1590 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1591 if ((ow == w) && (oh == h)) return;
1592 sd->wd->resized = 1;
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 _pan_calculate(Evas_Object *obj)
1600 Pan *sd = evas_object_smart_data_get(obj);
1601 Evas_Coord ox, oy, ow, oh;
1605 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
1606 rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
1607 EINA_LIST_FOREACH(sd->wd->grids, l, g)
1609 grid_load(sd->wd->obj, g);
1610 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
1611 marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
1616 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
1618 Pan *sd = evas_object_smart_data_get(obj);
1620 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
1621 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
1625 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1627 Widget_Data *wd = elm_widget_data_get(obj);
1629 elm_smart_scroller_hold_set(wd->scr, 1);
1633 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1635 Widget_Data *wd = elm_widget_data_get(obj);
1637 elm_smart_scroller_hold_set(wd->scr, 0);
1641 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1643 Widget_Data *wd = elm_widget_data_get(obj);
1645 elm_smart_scroller_freeze_set(wd->scr, 1);
1649 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1651 Widget_Data *wd = elm_widget_data_get(obj);
1653 elm_smart_scroller_freeze_set(wd->scr, 0);
1657 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1659 evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
1663 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1665 evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
1669 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1671 Widget_Data *wd = elm_widget_data_get(data);
1672 wd->center_on.enabled = EINA_FALSE;
1673 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1677 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1679 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1683 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1685 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1690 _group_object_create(Marker_Group *group)
1692 const char *style = "radio";
1693 Evas_Object *icon = NULL;
1695 if (group->obj) return;
1696 if (!group->clas->priv.objs_notused || eina_list_count(group->markers) == 1)
1698 //set icon and style
1699 if (eina_list_count(group->markers) == 1)
1701 Elm_Map_Marker *m = eina_list_data_get(group->markers);
1703 style = m->clas->style;
1705 if (m->clas->func.icon_get)
1706 icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
1708 group->delete_object = EINA_TRUE;
1712 if (group->clas->style)
1713 style = group->clas->style;
1715 if (group->clas->func.icon_get)
1716 icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
1718 group->delete_object = EINA_FALSE;
1721 group->obj = elm_layout_add(group->wd->obj);
1722 elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
1724 if (icon) elm_layout_content_set(group->obj, "elm.icon", icon);
1726 evas_object_smart_member_add(group->obj, group->wd->pan_smart);
1727 elm_widget_sub_object_add(group->wd->obj, group->obj);
1728 evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
1730 if (!group->delete_object)
1731 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
1735 group->delete_object = EINA_FALSE;
1737 group->obj = eina_list_data_get(group->clas->priv.objs_notused);
1738 group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
1739 group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
1740 evas_object_show(group->obj);
1743 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
1744 edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
1746 group->update_nbelems = EINA_TRUE;
1747 group->update_resize = EINA_TRUE;
1748 group->update_raise = EINA_TRUE;
1750 if (group->open) _group_bubble_create(group);
1754 _group_object_free(Marker_Group *group)
1756 if (!group->obj) return;
1757 if (!group->delete_object)
1759 group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
1760 group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
1761 evas_object_hide(group->obj);
1763 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
1764 edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
1767 evas_object_del(group->obj);
1770 _group_bubble_free(group);
1774 _group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1776 Marker_Group *group = data;
1778 if (!evas_object_above_get(group->rect)) return;
1779 evas_object_raise(group->bubble);
1780 evas_object_raise(group->sc);
1781 evas_object_raise(group->rect);
1785 _group_bubble_create(Marker_Group *group)
1787 if (group->bubble) return;
1789 group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
1790 group->bubble = edje_object_add(evas_object_evas_get(group->obj));
1791 _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
1792 elm_widget_style_get(group->wd->obj));
1793 evas_object_smart_member_add(group->bubble,
1795 elm_widget_sub_object_add(group->wd->obj, group->bubble);
1797 _group_bubble_content_free(group);
1798 if (!_group_bubble_content_update(group))
1800 //no content, we can delete the bubble
1801 _group_bubble_free(group);
1805 group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
1806 evas_object_color_set(group->rect, 0, 0, 0, 0);
1807 evas_object_repeat_events_set(group->rect, EINA_TRUE);
1808 evas_object_smart_member_add(group->rect, group->wd->obj);
1809 elm_widget_sub_object_add(group->wd->obj, group->rect);
1811 evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
1813 _group_bubble_place(group);
1816 static void _bubble_sc_hits_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1818 _group_bubble_place(data);
1822 _group_bubble_content_update(Marker_Group *group)
1825 Elm_Map_Marker *marker;
1828 if (!group->bubble) return 1;
1832 group->sc = elm_scroller_add(group->bubble);
1833 elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
1834 elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
1835 elm_scroller_bounce_set(group->sc, EINA_TRUE, EINA_FALSE);
1836 edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
1837 evas_object_show(group->sc);
1838 evas_object_smart_member_add(group->sc,
1840 elm_widget_sub_object_add(group->wd->obj, group->sc);
1842 group->bx = elm_box_add(group->bubble);
1843 evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1844 evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
1845 elm_box_horizontal_set(group->bx, EINA_TRUE);
1846 evas_object_show(group->bx);
1848 elm_scroller_content_set(group->sc, group->bx);
1850 evas_object_event_callback_add(group->sc, EVAS_CALLBACK_RESIZE,
1851 _bubble_sc_hits_changed_cb, group);
1854 EINA_LIST_FOREACH(group->markers, l, marker)
1856 if (i >= group->wd->markers_max_num) break;
1857 if (!marker->content && marker->clas->func.get)
1858 marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
1859 else if (marker->content)
1860 elm_box_unpack(group->bx, marker->content);
1861 if (marker->content)
1863 elm_box_pack_end(group->bx, marker->content);
1871 _group_bubble_content_free(Marker_Group *group)
1874 Elm_Map_Marker *marker;
1876 if (!group->sc) return;
1877 EINA_LIST_FOREACH(group->markers, l, marker)
1879 if (marker->content && marker->clas->func.del)
1880 marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
1881 else if (marker->content)
1882 evas_object_del(marker->content);
1883 marker->content = NULL;
1885 evas_object_del(group->sc);
1890 _group_bubble_free(Marker_Group *group)
1892 if (!group->bubble) return;
1893 group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
1894 evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1895 _bubble_sc_hits_changed_cb, group);
1896 evas_object_del(group->bubble);
1897 evas_object_del(group->rect);
1898 group->bubble = NULL;
1899 _group_bubble_content_free(group);
1903 _group_bubble_place(Marker_Group *group)
1906 Evas_Coord xx, yy, ww, hh;
1909 if (!group->bubble || !group->obj) return;
1911 evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
1912 edje_object_size_min_calc(group->bubble, NULL, &hh);
1914 s = edje_object_data_get(group->bubble, "size_w");
1916 xx = x + w / 2 - ww / 2;
1919 evas_object_move(group->bubble, xx, yy);
1920 evas_object_resize(group->bubble, ww, hh);
1921 evas_object_show(group->bubble);
1923 evas_object_move(group->rect, xx, yy);
1924 evas_object_resize(group->rect, ww, hh);
1925 evas_object_show(group->rect);
1929 _group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
1931 Marker_Group *group = data;
1932 Elm_Map_Marker *marker = eina_list_data_get(group->markers);
1933 if (!marker) return;
1934 group->bringin = EINA_TRUE;
1935 elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
1939 _group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
1941 Marker_Group *group = data;
1945 group->bringin = EINA_FALSE;
1951 group->open = EINA_FALSE;
1952 _group_bubble_free(group);
1955 group->open = EINA_TRUE;
1956 _group_bubble_create(group);
1959 static int idnum = 1;
1962 * Add a new Map object
1964 * @param parent The parent object
1965 * @return The new object or NULL if it cannot be created
1970 elm_map_add(Evas_Object *parent)
1974 Evas_Coord minw, minh;
1976 Eina_Bool ret = EINA_FALSE;
1978 static Evas_Smart *smart = NULL;
1980 if (!ecore_file_download_protocol_available("http://"))
1982 ERR("Ecore must be built with the support of HTTP for the widget map !");
1986 wd = ELM_NEW(Widget_Data);
1988 e = evas_object_evas_get(parent);
1989 obj = elm_widget_add(e);
1990 ELM_SET_WIDTYPE(widtype, "map");
1991 elm_widget_type_set(obj, "map");
1992 elm_widget_sub_object_add(parent, obj);
1993 elm_widget_data_set(obj, wd);
1994 elm_widget_del_hook_set(obj, _del_hook);
1995 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1996 elm_widget_theme_hook_set(obj, _theme_hook);
1998 wd->scr = elm_smart_scroller_add(e);
1999 elm_smart_scroller_widget_set(wd->scr, obj);
2000 elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
2001 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
2002 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
2003 elm_widget_resize_object_set(obj, wd->scr);
2005 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
2006 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
2007 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
2008 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
2009 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
2011 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_TRUE, EINA_TRUE);
2015 wd->markers_max_num = 30;
2016 wd->source = ELM_MAP_SOURCE_MAPNIK;
2018 for(idx=ELM_MAP_SOURCE_MAPNIK; idx<=ELM_MAP_SOURCE_CUSTOM_6; idx++)
2019 if(map_sources_tab[idx].use_module == EINA_TRUE){
2021 wd->api = module(obj);
2022 if ((wd->api) && (wd->api->obj_hook)) ret = wd->api->obj_hook(obj);
2023 if (!ret) DBG("Failed : loading module [%s]", elm_map_source_name_get(idx));
2027 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2028 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2029 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2030 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2034 static Evas_Smart_Class sc;
2036 evas_object_smart_clipped_smart_set(&_pan_sc);
2038 sc.name = "elm_map_pan";
2039 sc.version = EVAS_SMART_CLASS_VERSION;
2042 sc.resize = _pan_resize;
2043 sc.move = _pan_move;
2044 sc.calculate = _pan_calculate;
2045 smart = evas_smart_class_new(&sc);
2049 wd->pan_smart = evas_object_smart_add(e, smart);
2050 wd->pan = evas_object_smart_data_get(wd->pan_smart);
2054 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
2056 _pan_max_get, _pan_child_size_get);
2058 wd->rect = evas_object_rectangle_add(e);
2059 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_RESIZE, _rect_resize_cb, obj);
2060 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
2062 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
2064 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_MOVE,
2066 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_DOWN,
2067 _mouse_multi_down, obj);
2068 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_MOVE,
2069 _mouse_multi_move, obj);
2070 evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP,
2071 _mouse_multi_up, obj);
2073 evas_object_smart_member_add(wd->rect, wd->pan_smart);
2074 elm_widget_sub_object_add(obj, wd->rect);
2075 evas_object_show(wd->rect);
2076 evas_object_color_set(wd->rect, 0, 0, 0, 0);
2079 wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
2080 wd->id = ((int)getpid() << 16) | idnum;
2085 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
2087 evas_object_size_hint_min_set(obj, minw, minh);
2089 wd->paused = EINA_TRUE;
2090 elm_map_zoom_set(obj, 0);
2091 wd->paused = EINA_FALSE;
2095 wd->calc_job = ecore_job_add(_calc_job, wd);
2097 wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
2098 evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
2100 // TODO: convert Elementary to subclassing of Evas_Smart_Class
2101 // TODO: and save some bytes, making descriptions per-class and not instance!
2102 evas_object_smart_callbacks_descriptions_set(obj, _signals);
2107 * Set the zoom level of the map
2109 * This sets the zoom level. 0 is the world map and 18 is the maximum zoom.
2111 * @param obj The map object
2112 * @param zoom The zoom level to set
2117 elm_map_zoom_set(Evas_Object *obj, int zoom)
2119 ELM_CHECK_WIDTYPE(obj, widtype);
2120 Widget_Data *wd = elm_widget_data_get(obj);
2122 Grid *g, *g_zoom = NULL;
2123 Evas_Coord rx, ry, rw, rh;
2125 int zoom_changed = 0, started = 0;
2128 if (zoom < 0 ) zoom = 0;
2129 if (zoom > map_sources_tab[wd->source].zoom_max)
2130 zoom = map_sources_tab[wd->source].zoom_max;
2131 if (zoom < map_sources_tab[wd->source].zoom_min)
2132 zoom = map_sources_tab[wd->source].zoom_min;
2133 if (zoom == wd->zoom) return;
2134 if (wd->zoom_animator) return;
2137 wd->size.ow = wd->size.w;
2138 wd->size.oh = wd->size.h;
2139 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
2140 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
2142 if (wd->mode == ELM_MAP_ZOOM_MODE_MANUAL)
2144 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
2145 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
2147 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
2154 while (cumulw <= rw)
2163 while (cumulh <= rh)
2176 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
2177 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
2179 else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
2186 while (cumulw <= rw)
2195 while (cumulh <= rh)
2208 wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
2209 wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
2212 EINA_LIST_FOREACH(wd->grids, l, g)
2214 if (g->zoom == wd->zoom)
2216 wd->grids = eina_list_remove(wd->grids, g);
2217 wd->grids = eina_list_prepend(wd->grids, g);
2222 g = grid_create(obj);
2225 if (eina_list_count(wd->grids) > 1)
2227 g_zoom = eina_list_last(wd->grids)->data;
2228 wd->grids = eina_list_remove(wd->grids, g_zoom);
2229 grid_clear(obj, g_zoom);
2232 wd->grids = eina_list_prepend(wd->grids, g);
2236 EINA_LIST_FREE(wd->grids, g)
2244 wd->t_start = ecore_loop_time_get();
2245 wd->t_end = wd->t_start + _elm_config->zoom_friction;
2246 if ((wd->size.w > 0) && (wd->size.h > 0))
2248 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow;
2249 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.oh;
2253 wd->size.spos.x = 0.5;
2254 wd->size.spos.y = 0.5;
2256 if (rw > wd->size.ow) wd->size.spos.x = 0.5;
2257 if (rh > wd->size.oh) wd->size.spos.y = 0.5;
2258 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
2259 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
2266 if (!wd->zoom_animator)
2268 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
2270 if (wd->nosmooth == 1) _smooth_update(obj);
2274 if (wd->zoom_animator)
2276 if (!_zoom_anim(obj))
2278 ecore_animator_del(wd->zoom_animator);
2279 wd->zoom_animator = NULL;
2282 if (wd->calc_job) ecore_job_del(wd->calc_job);
2283 wd->calc_job = ecore_job_add(_calc_job, wd);
2287 evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
2288 if (!wd->zoom_animator)
2289 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
2293 evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
2297 * Get the zoom level of the photo
2299 * This returns the current zoom level of the map object. Note that if
2300 * you set the fill mode to other than ELM_MAP_ZOOM_MODE_MANUAL
2301 * (which is the default), the zoom level may be changed at any time by the
2302 * map object itself to account for map size and map viewpoer size
2304 * @param obj The map object
2305 * @return The current zoom level
2310 elm_map_zoom_get(const Evas_Object *obj)
2312 ELM_CHECK_WIDTYPE(obj, widtype) 1.0;
2313 Widget_Data *wd = elm_widget_data_get(obj);
2314 if (!wd) return 1.0;
2321 * This sets the zoom mode to manual or one of several automatic levels.
2322 * Manual (ELM_MAP_ZOOM_MODE_MANUAL) means that zoom is set manually by
2323 * elm_map_zoom_set() and will stay at that level until changed by code
2324 * or until zoom mode is changed. This is the default mode.
2325 * The Automatic modes will allow the map object to automatically
2326 * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT) will
2327 * adjust zoom so the photo fits inside the scroll frame with no pixels
2328 * outside this area. ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but
2329 * 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.
2331 * @param obj The map object
2332 * @param mode The desired mode
2337 elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
2339 ELM_CHECK_WIDTYPE(obj, widtype);
2340 Widget_Data *wd = elm_widget_data_get(obj);
2342 if (wd->mode == mode) return;
2345 double tz = wd->zoom;
2347 elm_map_zoom_set(wd->obj, tz);
2354 * This gets the current zoom mode of the map object
2356 * @param obj The map object
2357 * @return The current zoom mode
2361 EAPI Elm_Map_Zoom_Mode
2362 elm_map_zoom_mode_get(const Evas_Object *obj)
2364 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
2365 Widget_Data *wd = elm_widget_data_get(obj);
2366 if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
2371 * Centers the map at @p lon @p lat using an animation to scroll.
2373 * @param obj The map object
2374 * @param lon Longitude to center at
2375 * @param lon Latitude to center at
2380 elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
2382 ELM_CHECK_WIDTYPE(obj, widtype);
2383 Widget_Data *wd = elm_widget_data_get(obj);
2387 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
2388 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
2393 if (wd->zoom_animator)
2396 if (wd->nosmooth == 0) _smooth_update(obj);
2397 ecore_animator_del(wd->zoom_animator);
2398 wd->zoom_animator = NULL;
2400 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
2402 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
2404 wd->center_on.enabled = EINA_TRUE;
2405 wd->center_on.lon = lon;
2406 wd->center_on.lat = lat;
2410 * Move the map to the current coordinates.
2412 * This move the map to the current coordinates. The map will be centered on these coordinates.
2414 * @param obj The map object
2415 * @param lat The latitude.
2416 * @param lon The longitude.
2421 elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
2423 ELM_CHECK_WIDTYPE(obj, widtype);
2424 Widget_Data *wd = elm_widget_data_get(obj);
2428 elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
2429 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
2434 if (wd->zoom_animator)
2437 ecore_animator_del(wd->zoom_animator);
2438 wd->zoom_animator = NULL;
2440 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
2442 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
2444 wd->center_on.enabled = EINA_TRUE;
2445 wd->center_on.lon = lon;
2446 wd->center_on.lat = lat;
2450 * Get the current coordinates of the map.
2452 * This gets the current coordinates of the map object.
2454 * @param obj The map object
2455 * @param lat The latitude.
2456 * @param lon The longitude.
2461 elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
2463 ELM_CHECK_WIDTYPE(obj, widtype);
2464 Widget_Data *wd = elm_widget_data_get(obj);
2465 Evas_Coord sx, sy, sw, sh;
2468 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
2469 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
2473 elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
2477 * Set the paused state for map
2479 * This sets the paused state to on (1) or off (0) for map. The default
2480 * is off. This will stop zooming using animation change zoom levels and
2481 * change instantly. This will stop any existing animations that are running.
2483 * @param obj The map object
2484 * @param paused The pause state to set
2489 elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
2491 ELM_CHECK_WIDTYPE(obj, widtype);
2492 Widget_Data *wd = elm_widget_data_get(obj);
2494 if (wd->paused == !!paused) return;
2495 wd->paused = paused;
2498 if (wd->zoom_animator)
2500 ecore_animator_del(wd->zoom_animator);
2501 wd->zoom_animator = NULL;
2503 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
2509 * Set the paused state for the markers
2511 * This sets the paused state to on (1) or off (0) for the markers. The default
2512 * is off. This will stop displaying the markers during change zoom levels. Set
2513 * to on if you have a large number of markers.
2515 * @param obj The map object
2516 * @param paused The pause state to set
2521 elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
2523 ELM_CHECK_WIDTYPE(obj, widtype);
2524 Widget_Data *wd = elm_widget_data_get(obj);
2526 if (wd->paused_markers == !!paused) return;
2527 wd->paused_markers = paused;
2531 * Get the paused state for map
2533 * This gets the current paused state for the map object.
2535 * @param obj The map object
2536 * @return The current paused state
2541 elm_map_paused_get(const Evas_Object *obj)
2543 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2544 Widget_Data *wd = elm_widget_data_get(obj);
2545 if (!wd) return EINA_FALSE;
2550 * Get the paused state for the markers
2552 * This gets the current paused state for the markers object.
2554 * @param obj The map object
2555 * @return The current paused state
2560 elm_map_paused_markers_get(const Evas_Object *obj)
2562 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2563 Widget_Data *wd = elm_widget_data_get(obj);
2564 if (!wd) return EINA_FALSE;
2565 return wd->paused_markers;
2569 * Convert a pixel coordinate (x,y) into a geographic coordinate (longitude, latitude).
2571 * @param obj The map object
2572 * @param x the coordinate
2573 * @param y the coordinate
2574 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
2575 * @param lon the longitude correspond to x
2576 * @param lat the latitude correspond to y
2581 elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
2583 Widget_Data *wd = elm_widget_data_get(obj);
2584 int zoom = floor(log2(size/256));
2586 if(map_sources_tab[elm_map_source_get(obj)].use_module == EINA_TRUE)
2587 if(wd->api) if ((wd->api) && (wd->api->obj_convert_coord_into_geo)){
2588 if(wd->api->obj_convert_coord_into_geo(obj, zoom, x, y, size, lon, lat)==EINA_TRUE)
2594 *lon = x / (double)size * 360.0 - 180;
2598 double n = ELM_PI - 2.0 * ELM_PI * y / size;
2599 *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
2604 * Convert a geographic coordinate (longitude, latitude) into a pixel coordinate (x, y).
2606 * @param obj The map object
2607 * @param lon the longitude
2608 * @param lat the latitude
2609 * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
2610 * @param x the coordinate correspond to the longitude
2611 * @param y the coordinate correspond to the latitude
2616 elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
2618 Widget_Data *wd = elm_widget_data_get(obj);
2619 int zoom = floor(log2(size/256));
2621 if(map_sources_tab[elm_map_source_get(obj)].use_module == EINA_TRUE)
2622 if(wd->api) if ((wd->api) && (wd->api->obj_convert_geo_into_coord)){
2623 if(wd->api->obj_convert_geo_into_coord(obj, zoom, lon, lat, size, x, y)==EINA_TRUE)
2628 *x = floor((lon + 180.0) / 360.0 * size);
2630 *y = floor((1.0 - log( tan(lat * ELM_PI/180.0) + 1.0 / cos(lat * ELM_PI/180.0)) / ELM_PI) / 2.0 * size);
2636 * Add a marker on the map
2638 * @param obj The map object
2639 * @param lon the longitude
2640 * @param lat the latitude
2641 * @param clas the class to use
2642 * @param data the data passed to the callbacks
2644 * @return The marker object
2648 EAPI Elm_Map_Marker *
2649 elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
2653 Marker_Group *group;
2654 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2655 Widget_Data *wd = elm_widget_data_get(obj);
2663 if (!wd) return NULL;
2664 if (!clas_group || !clas) return NULL;
2666 Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
2669 marker->clas = clas;
2670 marker->clas_group = clas_group;
2671 marker->longitude = lon;
2672 marker->latitude = lat;
2673 marker->data = data;
2675 tabi[1] = tabi[4] = tabi[6] = -1;
2676 tabi[2] = tabi[0] = tabi[7] = 0;
2677 tabi[3] = tabi[5] = tabi[8] = 1;
2679 tabj[1] = tabj[2] = tabj[3] = -1;
2680 tabj[4] = tabj[0] = tabj[5] = 0;
2681 tabj[6] = tabj[7] = tabj[8] = 1;
2683 if (!clas_group->priv.set)
2686 if (marker->clas_group && marker->clas_group->style)
2687 style = marker->clas_group->style;
2689 o = edje_object_add(evas_object_evas_get(obj));
2690 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
2691 s = edje_object_data_get(o, "size_w");
2692 clas_group->priv.edje_w = atoi(s);
2693 s = edje_object_data_get(o, "size_h");
2694 clas_group->priv.edje_h = atoi(s);
2695 s = edje_object_data_get(o, "size_max_w");
2696 clas_group->priv.edje_max_w = atoi(s);
2697 s = edje_object_data_get(o, "size_max_h");
2698 clas_group->priv.edje_max_h = atoi(s);
2701 clas_group->priv.set = EINA_TRUE;
2704 if (!clas->priv.set)
2707 if (marker->clas && marker->clas->style)
2708 style = marker->clas->style;
2710 o = edje_object_add(evas_object_evas_get(obj));
2711 _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
2712 s = edje_object_data_get(o, "size_w");
2713 clas->priv.edje_w = atoi(s);
2714 s = edje_object_data_get(o, "size_h");
2715 clas->priv.edje_h = atoi(s);
2718 clas->priv.set = EINA_TRUE;
2721 for (i = clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
2723 elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
2724 &(marker->x[i]), &(marker->y[i]));
2726 //search in the matrixsparse the region where the marker will be
2727 mpi = marker->x[i] / wd->tsize;
2728 mpj = marker->y[i] / wd->tsize;
2730 if (!wd->markers[i])
2732 int size = pow(2.0, i);
2733 wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
2737 if (i <= clas_group->zoom_grouped)
2739 for (j = 0, group = NULL; j < 9 && !group; j++)
2741 EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
2744 if (group->clas == marker->clas_group
2745 && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
2746 marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
2747 group->x-group->w/4, group->y-group->h/4, group->w, group->h))
2749 group->markers = eina_list_append(group->markers, marker);
2750 group->update_nbelems = EINA_TRUE;
2751 group->update_resize = EINA_TRUE;
2753 group->sum_x += marker->x[i];
2754 group->sum_y += marker->y[i];
2755 group->x = group->sum_x / eina_list_count(group->markers);
2756 group->y = group->sum_y / eina_list_count(group->markers);
2758 group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
2759 * eina_list_count(group->markers);
2760 group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
2761 * eina_list_count(group->markers);
2762 if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
2763 if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
2765 if (group->obj && eina_list_count(group->markers) == 2)
2767 _group_object_free(group);
2768 _group_object_create(group);
2771 _group_bubble_content_update(group);
2780 group = calloc(1, sizeof(Marker_Group));
2782 group->sum_x = marker->x[i];
2783 group->sum_y = marker->y[i];
2784 group->x = marker->x[i];
2785 group->y = marker->y[i];
2786 group->w = clas_group->priv.edje_w;
2787 group->h = clas_group->priv.edje_h;
2788 group->clas = clas_group;
2790 group->markers = eina_list_append(group->markers, marker);
2791 group->update_nbelems = EINA_TRUE;
2792 group->update_resize = EINA_TRUE;
2794 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
2798 l = eina_list_append(NULL, group);
2799 eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
2800 eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
2804 l = eina_matrixsparse_cell_data_get(group->cell);
2805 l = eina_list_append(l, group);
2806 eina_matrixsparse_cell_data_set(group->cell, l);
2809 marker->groups[i] = group;
2814 Evas_Coord ox, oy, ow, oh;
2815 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2816 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
2823 * Remove a marker from the map
2825 * @param marker The marker to remove
2830 elm_map_marker_remove(Elm_Map_Marker *marker)
2836 if (!marker) return;
2839 for (i = 0; i <= ZOOM_MAX; i++)
2841 marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
2842 if (eina_list_count(marker->groups[i]->markers) == 0)
2844 groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
2845 groups = eina_list_remove(groups, marker->groups[i]);
2846 eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
2848 _group_object_free(marker->groups[i]);
2849 _group_bubble_free(marker->groups[i]);
2850 free(marker->groups[i]);
2854 marker->groups[i]->sum_x -= marker->x[i];
2855 marker->groups[i]->sum_y -= marker->y[i];
2857 marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
2858 marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
2860 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
2861 + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
2862 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
2863 + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
2864 if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
2865 marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
2866 if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
2867 marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
2869 if (marker->groups[i]->obj && eina_list_count(marker->groups[i]->markers) == 1)
2871 _group_object_free(marker->groups[i]);
2872 _group_object_create(marker->groups[i]);
2876 if (marker->content && marker->clas->func.del)
2877 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
2878 else if (marker->content)
2879 evas_object_del(marker->content);
2885 Evas_Coord ox, oy, ow, oh;
2886 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
2887 marker_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
2892 * Move the map to the coordinate of the marker.
2894 * @param marker The marker where the map will be center.
2899 elm_map_marker_bring_in(Elm_Map_Marker *marker)
2901 if (!marker) return;
2902 elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
2907 * Move the map to the coordinate of the marker.
2909 * @param marker The marker where the map will be center.
2914 elm_map_marker_show(Elm_Map_Marker *marker)
2916 if (!marker) return;
2917 elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
2921 * Move and zoom the map to display a list of markers.
2923 * The map will be centered on the center point of the markers in the list. Then
2924 * the map will be zoomed in order to fit the markers using the maximum zoom which
2925 * allows display of all the markers.
2927 * @param markers The list of markers (list of Elm_Map_Marker *)
2932 elm_map_markers_list_show(Eina_List *markers)
2937 Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
2938 Evas_Coord rw, rh, xc, yc;
2941 if (!markers) return;
2943 EINA_LIST_FOREACH(markers, l, marker)
2947 if (!m_min_lon || marker->longitude < m_min_lon->longitude)
2950 if (!m_max_lon || marker->longitude > m_max_lon->longitude)
2953 if (!m_min_lat || marker->latitude > m_min_lat->latitude)
2956 if (!m_max_lat || marker->latitude < m_max_lat->latitude)
2960 lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
2961 lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
2963 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
2964 for (zoom = map_sources_tab[wd->source].zoom_max; zoom>map_sources_tab[wd->source].zoom_min; zoom--)
2966 Evas_Coord size = pow(2.0, zoom)*wd->tsize;
2967 elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
2969 if (m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2
2970 && m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2
2971 && m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2
2972 && m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2)
2976 elm_map_geo_region_show(wd->obj, lon, lat);
2977 elm_map_zoom_set(wd->obj, zoom);
2981 * Set the maximum numbers of markers display in a group.
2983 * A group can have a long list of markers, consequently the creation of the content
2984 * of the bubble can be very slow. In order to avoid this, a maximum number of items
2985 * is displayed in a bubble. By default this number is 30.
2987 * @param obj The map object.
2988 * @param max The maximum numbers of items displayed in a bubble.
2993 elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
2995 ELM_CHECK_WIDTYPE(obj, widtype);
2996 Widget_Data *wd = elm_widget_data_get(obj);
2998 wd->markers_max_num = max;
3002 * Return the evas object getting from the ElmMapMarkerGetFunc callback
3004 * @param marker The marker.
3005 * @return Return the evas object if it exists, else NULL.
3010 elm_map_marker_object_get(Elm_Map_Marker *marker)
3012 if (!marker) return NULL;
3013 return marker->content;
3019 * @param marker The marker.
3024 elm_map_marker_update(Elm_Map_Marker *marker)
3026 if (!marker) return;
3027 if (marker->content)
3029 if (marker->clas->func.del)
3030 marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
3032 evas_object_del(marker->content);
3033 marker->content = NULL;
3034 _group_bubble_content_update(marker->groups[marker->wd->zoom]);
3039 * Close all opened bubbles
3041 * @param obj The map object
3046 elm_map_bubbles_close(Evas_Object *obj)
3048 ELM_CHECK_WIDTYPE(obj, widtype);
3049 Widget_Data *wd = elm_widget_data_get(obj);
3050 Marker_Group *group;
3051 Eina_List *l, *l_next;
3053 EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
3054 _group_bubble_free(group);
3059 * Create a group class.
3061 * Each marker must be associated to a group class. Marker with the same group are grouped if they are close.
3062 * The group class defines the style of the marker when a marker is grouped to others markers.
3064 * @param obj The map object
3065 * @return Returns the new group class
3069 EAPI Elm_Map_Group_Class *
3070 elm_map_group_class_new(Evas_Object *obj)
3072 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3073 Widget_Data *wd = elm_widget_data_get(obj);
3074 if (!wd) return NULL;
3075 Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
3076 clas->zoom_grouped = ZOOM_MAX;
3077 wd->groups_clas = eina_list_append(wd->groups_clas, clas);
3082 * Set the style of a group class (radio, radio2 or empty)
3084 * @param clas the group class
3085 * @param style the new style
3090 elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
3093 eina_stringshare_replace(&clas->style, style);
3097 * Set the icon callback of a group class.
3099 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
3101 * @param clas the group class
3102 * @param icon_get the callback to create the icon
3107 elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
3110 clas->func.icon_get = icon_get;
3114 * Set the data associated to the group class (radio, radio2 or empty)
3116 * @param clas the group class
3117 * @param data the new user data
3122 elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
3129 * Set the zoom from where the markers are displayed.
3131 * Markers will not be displayed for a zoom less than @ref zoom
3133 * @param clas the group class
3134 * @param zoom the zoom
3139 elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
3142 clas->zoom_displayed = zoom;
3146 * Set the zoom from where the markers are no more grouped.
3148 * @param clas the group class
3149 * @param zoom the zoom
3154 elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
3157 clas->zoom_grouped = zoom;
3161 * Set if the markers associated to the group class @clas are hidden or not.
3162 * If @ref hide is true the markers will be hidden.
3164 * @param clas the group class
3165 * @param hide if true the markers will be hidden, else they will be displayed.
3170 elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
3172 ELM_CHECK_WIDTYPE(obj, widtype);
3173 Widget_Data *wd = elm_widget_data_get(obj);
3176 if (clas->hide == hide) return;
3180 Evas_Coord ox, oy, ow, oh;
3181 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3182 marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
3188 * Create a marker class.
3190 * Each marker must be associated to a class.
3191 * The class defines the style of the marker when a marker is displayed alone (not grouped).
3193 * @param obj The map object
3194 * @return Returns the new class
3198 EAPI Elm_Map_Marker_Class *
3199 elm_map_marker_class_new(Evas_Object *obj)
3201 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3202 Widget_Data *wd = elm_widget_data_get(obj);
3203 if (!wd) return NULL;
3204 Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
3205 wd->markers_clas = eina_list_append(wd->markers_clas, clas);
3210 * Set the style of a class (radio, radio2 or empty)
3212 * @param clas the group class
3213 * @param style the new style
3218 elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
3221 eina_stringshare_replace(&clas->style, style);
3225 * Set the icon callback of a class.
3227 * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
3229 * @param clas the group class
3230 * @param icon_get the callback to create the icon
3235 elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
3238 clas->func.icon_get = icon_get;
3243 * Set the callback of the content of the bubble.
3245 * When the user click on a marker, a bubble is displayed with a content.
3246 * The callback @ref get musst return this content. It can be NULL.
3248 * @param clas the group class
3249 * @param get the callback to create the content
3254 elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
3257 clas->func.get = get;
3261 * Set the callback of the content of delete the object created by the callback "get".
3263 * If this callback is defined the user will have to delete (or not) the object inside.
3264 * If the callback is not defined the object will be destroyed with evas_object_del()
3266 * @param clas the group class
3267 * @param del the callback to delete the content
3272 elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
3275 clas->func.del = del;
3279 * Set the source of the map.
3281 * Elm_Map retrieves the image which composed the map from a web service. This web service can
3282 * be set with this method. A different service can return a different maps with different
3283 * information and it can use different zoom value.
3285 * @param clas the group class
3286 * @param source the new source
3291 elm_map_source_set(Evas_Object *obj, Elm_Map_Sources source)
3293 ELM_CHECK_WIDTYPE(obj, widtype);
3294 Widget_Data *wd = elm_widget_data_get(obj);
3298 if (wd->source == source ) return;
3299 if (!map_sources_tab[source].url_cb) return;
3301 EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid);
3303 wd->source = source;
3307 if (map_sources_tab[wd->source].zoom_max < zoom)
3308 zoom = map_sources_tab[wd->source].zoom_max;
3309 if (map_sources_tab[wd->source].zoom_min > zoom)
3310 zoom = map_sources_tab[wd->source].zoom_min;
3312 elm_map_zoom_set(obj, zoom);
3316 * Get the current source
3318 * @param obj the map object
3319 * @return Returns the maximum zoom of the source
3323 EAPI Elm_Map_Sources
3324 elm_map_source_get(const Evas_Object *obj)
3326 ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_SOURCE_MAPNIK;
3327 Widget_Data *wd = elm_widget_data_get(obj);
3328 if (!wd) return ELM_MAP_SOURCE_MAPNIK;
3333 * Set the API of a custom source.
3335 * A custom web service can be associated to the source ELM_MAP_SOURCE_CUSTOM_(1..7).
3337 * @param source the source ID (ELM_MAP_SOURCE_CUSTOM_(1..7))
3338 * @param name the name of the source
3339 * @param zoom_min the minimum zoom of the source, must be >= 0
3340 * @param zoom_max the maximum zoom of the source, must be <= ZOOM_MAX
3341 * @param url_cb the callback used to create the url from where a tile (png or jpeg file) is downloaded.
3346 elm_map_source_custom_api_set(Elm_Map_Sources source, const char *name, int zoom_min, int zoom_max, ElmMapSourceURLFunc url_cb)
3348 if (!name || !url_cb) return;
3349 map_sources_tab[source].name = name;
3350 map_sources_tab[source].zoom_min = zoom_min;
3351 map_sources_tab[source].zoom_max = zoom_max;
3352 map_sources_tab[source].url_cb = url_cb;
3356 * Get the maximum zoom of the source.
3358 * @param source the source
3359 * @return Returns the maximum zoom of the source
3364 elm_map_source_zoom_max_get(Elm_Map_Sources source)
3366 return map_sources_tab[source].zoom_max;
3370 * Get the minimum zoom of the source.
3372 * @param source the source
3373 * @return Returns the minimum zoom of the source
3378 elm_map_source_zoom_min_get(Elm_Map_Sources source)
3380 return map_sources_tab[source].zoom_min;
3384 * Get the name of a source.
3386 * @param source the source
3387 * @return Returns the name of the source
3392 elm_map_source_name_get(Elm_Map_Sources source)
3394 return map_sources_tab[source].name;
3399 _mapnik_url_cb(void *data, int x, int y, int zoom)
3402 snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
3408 _osmarender_url_cb(void * data, int x, int y, int zoom)
3411 snprintf(buf, sizeof(buf), "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
3417 _cyclemap_url_cb(void *data, int x, int y, int zoom)
3420 snprintf(buf, sizeof(buf), "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
3426 _maplint_url_cb(void *data, int x, int y, int zoom)
3429 snprintf(buf, sizeof(buf), "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
3435 _decarta_url_cb(void *data, int x, int y, int zoom)
3438 Widget_Data *wd = elm_widget_data_get(data);
3439 if(map_sources_tab[elm_map_source_get(data)].use_module == EINA_TRUE)
3440 if(wd->api) if ((wd->api) && (wd->api->obj_url_request))
3441 url = wd->api->obj_url_request(data, x, y, zoom);
3443 if(!url) url = strdup("");