diff --git a/legacy/elementary/src/bin/test_map.c b/legacy/elementary/src/bin/test_map.c index 11b47e46a9..d51b9d8a37 100644 --- a/legacy/elementary/src/bin/test_map.c +++ b/legacy/elementary/src/bin/test_map.c @@ -19,19 +19,6 @@ typedef struct Map_Source char *source_name; } Map_Source; -static Elm_Map_Overlay *route_start, *route_end, *route_clas; -static Elm_Map_Overlay *bubble_img; -static Elm_Map_Overlay *bubble_parking; - -static Evas_Object *menu, *fs_win; -static Elm_Map_Route *route; -static Elm_Map_Name *name; -static Evas_Object *track; -static const char **source_names = NULL; -static Evas_Coord old_x, old_y; -static Evas_Coord old_d; -static Map_Source ms[SOURCE_MAX]; - Overlay_Data data1 = {PACKAGE_DATA_DIR"/images/logo.png"}; Overlay_Data data2 = {PACKAGE_DATA_DIR"/images/logo_small.png"}; Overlay_Data data3 = {PACKAGE_DATA_DIR"/images/panel_01.jpg"}; @@ -46,6 +33,20 @@ Overlay_Data data11= {PACKAGE_DATA_DIR"/images/wood_01.jpg"}; Overlay_Data parking= {PACKAGE_DATA_DIR"/images/parking.png"}; Overlay_Data icon_data = {PACKAGE_DATA_DIR"/images/icon_14.png"}; +static Elm_Map_Overlay *route_start, *route_end, *route_clas; +static Elm_Map_Overlay *bubble_img; +static Elm_Map_Overlay *bubble_parking; +static Elm_Map_Overlay *route_ovl; + +static Evas_Object *menu, *fs_win; +static Elm_Map_Route *route; +static Elm_Map_Name *name; +static Evas_Object *track; +static const char **source_names = NULL; +static Evas_Coord old_x, old_y; +static Evas_Coord old_d; +static Map_Source ms[SOURCE_MAX]; + static void #ifdef ELM_EMAP my_map_gpx_fileselector_done(void *data, Evas_Object *obj __UNUSED__, void *event_info) @@ -68,32 +69,6 @@ my_map_gpx_fileselector_done(void *data __UNUSED__, Evas_Object *obj __UNUSED__, evas_object_del(fs_win); } -static void -my_map_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - printf("clicked\n"); -} - -static void -my_map_press(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - printf("press\n"); -} - -static void -my_map_longpressed(void *data __UNUSED__, Evas_Object *obj, void *event_info) -{ - if (!event_info) return; - double lon, lat; - Evas_Event_Mouse_Down *down = (Evas_Event_Mouse_Down *)event_info; - elm_map_canvas_to_geo_convert(obj, down->canvas.x, down->canvas.y, &lon, &lat); - printf("longpressed, x:%d, y:%d, lon:%lf, lat:%lf\n", down->canvas.x, down->canvas.y, lon, lat); - - if (elm_map_zoom_get(obj) < 5) return; - if (name) elm_map_name_remove(name); - name = elm_map_utils_convert_coord_into_name(obj, lon, lat); -} - static Evas_Object * _route_icon_get(Evas_Object *obj) { @@ -105,7 +80,13 @@ _route_icon_get(Evas_Object *obj) } static void -my_map_clicked_double(void *data __UNUSED__, Evas_Object *obj, void *event_info) +_map_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + printf("clicked\n"); +} + +static void +_map_clicked_double(void *data __UNUSED__, Evas_Object *obj, void *event_info) { printf("clicked,double\n"); double lon, lat; @@ -113,10 +94,9 @@ my_map_clicked_double(void *data __UNUSED__, Evas_Object *obj, void *event_info) if (!down) return; if (elm_map_zoom_get(obj) < 5) return; - elm_map_canvas_to_geo_convert(obj, down->canvas.x, down->canvas.y, &lon, &lat); + elm_map_canvas_to_region_convert(obj, down->canvas.x, down->canvas.y, &lon, &lat); printf("x:%d, y:%d, lon:%lf, lat:%lf\n", down->canvas.x, down->canvas.y, lon, lat); - if (!route_clas) { route_clas = elm_map_overlay_class_add(obj); @@ -126,13 +106,13 @@ my_map_clicked_double(void *data __UNUSED__, Evas_Object *obj, void *event_info) if (route_start && route_end) { - printf("11\n"); elm_map_overlay_del(route_start); elm_map_overlay_del(route_end); - elm_map_route_remove(route); +// FIXME: deprecated +// elm_map_route_remove(route); route_start = NULL; route_end = NULL; - //route = NULL; + route = NULL; } if (!route_start) route_start = elm_map_overlay_add(obj, lon, lat); @@ -143,99 +123,123 @@ my_map_clicked_double(void *data __UNUSED__, Evas_Object *obj, void *event_info) double start_lon, start_lat, end_lon, end_lat; elm_map_overlay_class_append(route_clas, route_start); elm_map_overlay_class_append(route_clas, route_end); - elm_map_overlay_geo_get(route_start, &start_lon, &start_lat); - elm_map_overlay_geo_get(route_end, &end_lon, &end_lat); + elm_map_overlay_region_get(route_start, &start_lon, &start_lat); + elm_map_overlay_region_get(route_end, &end_lon, &end_lat); route = elm_map_route_add(obj, ELM_MAP_ROUTE_TYPE_MOTOCAR, - ELM_MAP_ROUTE_METHOD_FASTEST, - start_lon, start_lat, end_lon, end_lat); - elm_map_route_color_set(route, 255, 0, 0, 255); + ELM_MAP_ROUTE_METHOD_FASTEST, + start_lon, start_lat, end_lon, end_lat, + NULL, NULL); } } static void -my_map_load_detail(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_press(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - printf("load,detail\n"); + printf("press\n"); } static void -my_map_loaded_detail(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_longpressed(void *data __UNUSED__, Evas_Object *obj, void *event_info) { - printf("loaded,detail\n"); + if (!event_info) return; + double lon, lat; + Evas_Event_Mouse_Down *down = (Evas_Event_Mouse_Down *)event_info; + elm_map_canvas_to_region_convert(obj, down->canvas.x, down->canvas.y, &lon, &lat); + printf("longpressed, x:%d, y:%d, lon:%lf, lat:%lf\n", down->canvas.x, down->canvas.y, lon, lat); + + if (elm_map_zoom_get(obj) < 8) return; +// FIXME: deprecated +// if (name) elm_map_name_remove(name); + name = elm_map_name_add(obj, NULL, lon, lat, NULL, NULL); } static void -my_map_zoom_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_scroll(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { - printf("zoom,start\n"); + double lon, lat; + elm_map_region_get(obj, &lon, &lat); + printf("scroll, longitude: %f latitude: %f\n", lon, lat); } static void -my_map_zoom_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - printf("zoom,stop\n"); + printf("scroll,drag,start\n"); + evas_object_smart_callback_del(data, "longpressed", _map_longpressed); } static void -my_map_zoom_change(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - printf("zoom,change\n"); + printf("scroll,drag,stop\n"); + evas_object_smart_callback_add(data, "longpressed", _map_longpressed, data); } static void -my_map_anim_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_anim_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { printf("scroll,anim,start\n"); } static void -my_map_anim_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_anim_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { printf("scroll,anim,stop\n"); } static void -my_map_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_zoom_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - printf("scroll,drag,start\n"); - evas_object_smart_callback_del(data, "longpressed", my_map_longpressed); + printf("zoom,start\n"); } static void -my_map_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_zoom_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - printf("scroll,drag,stop\n"); - evas_object_smart_callback_add(data, "longpressed", my_map_longpressed, data); + printf("zoom,stop\n"); } static void -my_map_scroll(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +_map_zoom_change(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - double lon, lat; - elm_map_geo_region_get(obj, &lon, &lat); - printf("scroll, longitude: %f latitude: %f\n", lon, lat); + printf("zoom,change\n"); } static void -my_map_downloaded(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_tile_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + printf("tile,load\n"); +} + +static void +_map_tile_loaded(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { int try_num, finish_num; - elm_map_utils_downloading_status_get(data, &try_num, &finish_num); - printf("downloaded : %d / %d\n", finish_num, try_num); + elm_map_tile_load_status_get(data, &try_num, &finish_num); + printf("tile,loaded: %d / %d\n", finish_num, try_num); } static void -my_map_route_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_tile_loaded_fail(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + int try_num, finish_num; + elm_map_tile_load_status_get(data, &try_num, &finish_num); + printf("tile,loaded,fail: %d / %d\n", finish_num, try_num); +} + +static void +_map_route_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { printf("route,load\n"); } static void -my_map_route_loaded(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_route_loaded(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) { printf("route,loaded\n"); double d; const char *w, *n; + d = elm_map_route_distance_get(route); printf("route distance = %lf km\n", d); @@ -244,16 +248,26 @@ my_map_route_loaded(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *ev n = elm_map_route_node_get(route); if (n) printf("[nodes]\n%s\n", n); + + if (route_ovl) elm_map_overlay_del(route_ovl); + route_ovl = elm_map_overlay_route_add(obj, route); + elm_map_overlay_color_set(route_ovl, 255, 0, 0, 255); } static void -my_map_name_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_route_loaded_fail(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + printf("route,loaded,fail\n"); +} + +static void +_map_name_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { printf("name,load\n"); } static void -my_map_name_loaded(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_map_name_loaded(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { printf("name,loaded\n"); if (!name) return; @@ -268,12 +282,20 @@ my_map_name_loaded(void *data, Evas_Object *obj __UNUSED__, void *event_info __U Eina_Bool b = elm_map_paused_get(data); elm_map_paused_set(data, EINA_TRUE); elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL); - elm_map_geo_region_show(data, lon, lat); - elm_map_zoom_set(data, elm_map_source_zoom_max_get(data)); + elm_map_region_show(data, lon, lat); + elm_map_zoom_set(data, elm_map_zoom_max_get(data)); elm_map_paused_set(data, b); } } - elm_map_name_remove(name); +// FIXME: deprecated +// elm_map_name_remove(name); + name = NULL; +} + +static void +_map_name_loaded_fail(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + printf("name,loaded,fail\n"); } static void @@ -282,7 +304,7 @@ map_show_urmatt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUS Eina_Bool b = elm_map_paused_get(data); elm_map_paused_set(data, EINA_TRUE); elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL); - elm_map_geo_region_show(data,7.325201, 48.526813); + elm_map_region_show(data,7.325201, 48.526813); elm_map_zoom_set(data, 12); elm_map_paused_set(data, b); } @@ -290,7 +312,7 @@ map_show_urmatt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUS static void map_bring_seoul(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - elm_map_geo_region_bring_in(data, 126.977969, 37.566535); + elm_map_region_bring_in(data, 126.977969, 37.566535); } static void @@ -438,13 +460,13 @@ map_rotate_reset(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNU static void map_zoom_min_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - elm_map_source_zoom_min_set(data, 1); + elm_map_zoom_min_set(data, 1); } static void map_zoom_max_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - elm_map_source_zoom_max_set(data, 10); + elm_map_zoom_max_set(data, 10); } static void @@ -453,7 +475,7 @@ map_source(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) Map_Source *s = data; if (!s) return; - elm_map_source_name_set(s->map, s->source_name); + elm_map_source_set(s->map, ELM_MAP_SOURCE_TYPE_TILE, s->source_name); } /* @@ -694,13 +716,13 @@ _overlay_cb(void *data __UNUSED__, Evas_Object *map, void *ev) } static void -_parking_cb(void *data __UNUSED__, Evas_Object *map, Elm_Map_Overlay *ovl) +_parking_cb(void *data __UNUSED__, Evas_Object *map, const Elm_Map_Overlay *ovl) { printf("Parking clicked\n"); if (elm_map_overlay_type_get(ovl) != ELM_MAP_OVERLAY_TYPE_DEFAULT) return; double lon, lat; - elm_map_overlay_geo_get(ovl, &lon, &lat); + elm_map_overlay_region_get(ovl, &lon, &lat); if (!bubble_parking) { Evas_Object *bubble, *label; @@ -720,7 +742,31 @@ _parking_cb(void *data __UNUSED__, Evas_Object *map, Elm_Map_Overlay *ovl) bubble_parking = elm_map_overlay_add(map, lon + 0.0006, lat + 0.0006); elm_map_overlay_content_set(bubble_parking, bubble); } - elm_map_overlay_geo_set(bubble_parking, lon + 0.0006, lat + 0.0006); + elm_map_overlay_region_set(bubble_parking, lon + 0.0006, lat + 0.0006); +} + +static void +_del_map(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ei __UNUSED__) +{ + if (route_start) elm_map_overlay_del(route_start); + if (route_end) elm_map_overlay_del(route_end); + if (route_clas) elm_map_overlay_del(route_clas); + if (bubble_img) elm_map_overlay_del(bubble_img); + if (bubble_parking) elm_map_overlay_del(bubble_parking); + if (route_ovl) elm_map_overlay_del(route_ovl); + route_start = NULL; + route_end = NULL; + route_clas = NULL; + bubble_img = NULL; + bubble_parking = NULL; + route_ovl = NULL; + +// FIXME: deprecated +// if (route) elm_map_route_remove(route); +// FIXME: deprecated +// if (name) elm_map_name_remove(name); + route = NULL; + name = NULL; } void @@ -746,13 +792,15 @@ test_map(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __ Elm_Map_Overlay *parking1, *parking2, *parking3, *parking4, *parking5; Elm_Map_Overlay *grp1, *grp2, *grp_parking; + evas_object_event_callback_add(map, EVAS_CALLBACK_DEL, _del_map, NULL); + srand(time(NULL)); - source_names = elm_map_source_names_get(map); + source_names = elm_map_sources_get(map, ELM_MAP_SOURCE_TYPE_TILE); if (!source_names) return; printf("map sources [ "); - for (idx = 0; source_names[idx] ; idx++) printf("%s ", source_names[idx]); + for (idx = 0; source_names[idx] ; idx++) printf("%s, ", source_names[idx]); printf("]\n"); evas_object_size_hint_weight_set(map, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -766,25 +814,27 @@ test_map(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __ evas_object_event_callback_add(map, EVAS_CALLBACK_MOUSE_UP, _map_mouse_up, map); - evas_object_smart_callback_add(map, "clicked", my_map_clicked, map); - evas_object_smart_callback_add(map, "press", my_map_press, map); - evas_object_smart_callback_add(map, "longpressed", my_map_longpressed, map); - evas_object_smart_callback_add(map, "clicked,double", my_map_clicked_double, map); - evas_object_smart_callback_add(map, "load,detail", my_map_load_detail, map); - evas_object_smart_callback_add(map, "loaded,detail", my_map_loaded_detail, map); - evas_object_smart_callback_add(map, "zoom,start", my_map_zoom_start, map); - evas_object_smart_callback_add(map, "zoom,stop", my_map_zoom_stop, map); - evas_object_smart_callback_add(map, "zoom,change", my_map_zoom_change, map); - evas_object_smart_callback_add(map, "scroll,anim,start", my_map_anim_start, map); - evas_object_smart_callback_add(map, "scroll,anim,stop", my_map_anim_stop, map); - evas_object_smart_callback_add(map, "scroll,drag,start", my_map_drag_start, map); - evas_object_smart_callback_add(map, "scroll,drag,stop", my_map_drag_stop, map); - evas_object_smart_callback_add(map, "scroll", my_map_scroll, map); - evas_object_smart_callback_add(map, "downloaded", my_map_downloaded, map); - evas_object_smart_callback_add(map, "route,load", my_map_route_load, map); - evas_object_smart_callback_add(map, "route,loaded", my_map_route_loaded, map); - evas_object_smart_callback_add(map, "name,load", my_map_name_load, map); - evas_object_smart_callback_add(map, "name,loaded", my_map_name_loaded, map); + evas_object_smart_callback_add(map, "clicked", _map_clicked, map); + evas_object_smart_callback_add(map, "clicked,double", _map_clicked_double, map); + evas_object_smart_callback_add(map, "press", _map_press, map); + evas_object_smart_callback_add(map, "longpressed", _map_longpressed, map); + evas_object_smart_callback_add(map, "scroll", _map_scroll, map); + evas_object_smart_callback_add(map, "scroll,drag,start", _map_drag_start, map); + evas_object_smart_callback_add(map, "scroll,drag,stop", _map_drag_stop, map); + evas_object_smart_callback_add(map, "scroll,anim,start", _map_anim_start, map); + evas_object_smart_callback_add(map, "scroll,anim,stop", _map_anim_stop, map); + evas_object_smart_callback_add(map, "zoom,start", _map_zoom_start, map); + evas_object_smart_callback_add(map, "zoom,stop", _map_zoom_stop, map); + evas_object_smart_callback_add(map, "zoom,change", _map_zoom_change, map); + evas_object_smart_callback_add(map, "tile,load", _map_tile_load, map); + evas_object_smart_callback_add(map, "tile,loaded", _map_tile_loaded, map); + evas_object_smart_callback_add(map, "tile,loaded,fail", _map_tile_loaded_fail, map); + evas_object_smart_callback_add(map, "route,load", _map_route_load, map); + evas_object_smart_callback_add(map, "route,loaded", _map_route_loaded, map); + evas_object_smart_callback_add(map, "route,loaded,fail", _map_route_loaded_fail, map); + evas_object_smart_callback_add(map, "name,load", _map_name_load, map); + evas_object_smart_callback_add(map, "name,loaded", _map_name_loaded, map); + evas_object_smart_callback_add(map, "name,loaded,fail", _map_name_loaded_fail, map); evas_object_smart_callback_add(map, "overlay,clicked", _overlay_cb, map); // Create Overlays @@ -820,6 +870,7 @@ test_map(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __ elm_map_overlay_class_append(grp1, ovl_4); elm_map_overlay_class_append(grp1, ovl_5); elm_map_overlay_class_append(grp1, ovl6); + evas_object_smart_callback_add(map, "overlay,clicked", _overlay_cb, map); // Append overlays to groups grp2 = elm_map_overlay_class_add(map); diff --git a/legacy/elementary/src/edje_externals/elm_map.c b/legacy/elementary/src/edje_externals/elm_map.c index d6ad0e0527..11c0ece7fb 100644 --- a/legacy/elementary/src/edje_externals/elm_map.c +++ b/legacy/elementary/src/edje_externals/elm_map.c @@ -41,13 +41,13 @@ external_map_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from if (p->map_source) { - elm_map_source_name_set(obj, p->map_source); + elm_map_source_set(obj, ELM_MAP_SOURCE_TYPE_TILE, p->map_source); } if (p->zoom_mode) { - Elm_Map_Zoom_Mode set = _zoom_mode_get(p->zoom_mode); - if (set == ELM_MAP_ZOOM_MODE_LAST) return; - elm_map_zoom_mode_set(obj, set); + Elm_Map_Zoom_Mode set = _zoom_mode_get(p->zoom_mode); + if (set == ELM_MAP_ZOOM_MODE_LAST) return; + elm_map_zoom_mode_set(obj, set); } if (p->zoom_set) elm_map_zoom_set(obj, p->zoom); } @@ -59,7 +59,7 @@ external_map_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_Exter { if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE) { - elm_map_source_name_set(obj, param->s); + elm_map_source_set(obj, ELM_MAP_SOURCE_TYPE_TILE, param->s); return EINA_TRUE; } } @@ -95,7 +95,7 @@ external_map_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_Exter { if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE) { - const char *set = elm_map_source_name_get(obj); + const char *set = elm_map_source_get(obj, ELM_MAP_SOURCE_TYPE_TILE); param->s = set; return EINA_TRUE; } diff --git a/legacy/elementary/src/examples/map_example_01.c b/legacy/elementary/src/examples/map_example_01.c index 3572498413..6339745468 100644 --- a/legacy/elementary/src/examples/map_example_01.c +++ b/legacy/elementary/src/examples/map_example_01.c @@ -112,8 +112,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) evas_object_smart_callback_add(bt, "clicked", _bt_zoom_fill, map); elm_map_zoom_set(map, 12); - elm_map_geo_region_show(map, -43.2, -22.9); - + elm_map_region_show(map, -43.2, -22.9); evas_object_resize(win, 512, 512); evas_object_show(win); diff --git a/legacy/elementary/src/examples/map_example_03.c b/legacy/elementary/src/examples/map_example_03.c index 6a49b4511c..c033e1414f 100644 --- a/legacy/elementary/src/examples/map_example_03.c +++ b/legacy/elementary/src/examples/map_example_03.c @@ -22,10 +22,20 @@ typedef struct _Example_Data Elm_Map_Route *route; double start_lon, start_lat, dest_lon, dest_lat; Elm_Map_Name *name; + Elm_Map_Overlay *route_ovl; } Example_Data; static Example_Data example_data; +static void +_route_loaded(void *data, Evas_Object *obj, void *ev __UNUSED__) +{ + Example_Data *example_data = data; + + example_data->route_ovl = elm_map_overlay_route_add(obj, example_data->route); + elm_map_overlay_color_set(example_data->route_ovl, 0, 255, 0, 255); +} + static void _name_loaded(void *data, Evas_Object *obj, void *ev __UNUSED__) { @@ -41,8 +51,8 @@ _name_loaded(void *data, Evas_Object *obj, void *ev __UNUSED__) example_data->route = elm_map_route_add(map, ELM_MAP_ROUTE_TYPE_FOOT, ELM_MAP_ROUTE_METHOD_SHORTEST, example_data->start_lon, example_data->start_lat, - example_data->dest_lon, example_data->dest_lat); - elm_map_route_color_set(example_data->route, 0, 255, 0, 255); + example_data->dest_lon, example_data->dest_lat, + NULL, NULL); } static void @@ -55,9 +65,10 @@ _bt_route(void *data, Evas_Object *obj __UNUSED__, void *ev __UNUSED__) map = example_data->map; address = (char *)elm_object_text_get(example_data->entry); - example_data->name = elm_map_utils_convert_name_into_coord(map, address); + example_data->name = elm_map_name_add(map, address, 0, 0, NULL, NULL); evas_object_smart_callback_add(map, "name,loaded", _name_loaded, data); + evas_object_smart_callback_add(map, "route,loaded", _route_loaded, data); } static void @@ -187,7 +198,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) example_data.start_lat = -22.97; elm_map_zoom_set(map, 12); - elm_map_geo_region_show(map, example_data.start_lon, example_data.start_lat); + elm_map_region_show(map, example_data.start_lon, example_data.start_lat); evas_object_resize(win, 512, 512); evas_object_show(win); diff --git a/legacy/elementary/src/lib/elm_deprecated.h b/legacy/elementary/src/lib/elm_deprecated.h index dfb01c0d65..77966f2406 100644 --- a/legacy/elementary/src/lib/elm_deprecated.h +++ b/legacy/elementary/src/lib/elm_deprecated.h @@ -1299,6 +1299,7 @@ EINA_DEPRECATED EAPI const char *elm_diskselector_item_cursor_style_g * between cursors provided by the engine or searched on widget's * theme as well. * + * @see elm_object_cursor_engine_only_set() for more details. * @deprecated Use elm_object_item_cursor_engine_only_set() instead * * @ingroup Diskselector @@ -1313,6 +1314,7 @@ EINA_DEPRECATED EAPI void elm_diskselector_item_cursor_engine_ * between the provided by the engine or searched on widget's theme as well. * If the item does not have a cursor set, then @c EINA_FALSE is returned. * + * @see elm_object_cursor_engine_only_get() for more details. * @see elm_diskselector_item_cursor_engine_only_set() * @deprecated Use elm_object_item_cursor_engine_only_get() instead * @@ -2949,7 +2951,7 @@ EINA_DEPRECATED EAPI Eina_Bool elm_toolbar_orientation_get(const Evas_Object * * This way, a data associated to a toolbar item could be properly freed. * - * @deprecated Use elm_object_item_del_cb_set() instead + * @deprecated Use elm_object_item_del_cb_set() instead * @ingroup Toolbar */ EINA_DEPRECATED EAPI void elm_toolbar_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func); @@ -3288,7 +3290,7 @@ EINA_DEPRECATED EAPI void elm_segment_control_item_del(Elm_Object_I * @param obj The multibuttonentry object * @return The label, or NULL if none * - * @deprecated Use elm_object_text_get() instead + * @deprecated Use elm_object_text_get() instead * */ EINA_DEPRECATED EAPI const char *elm_multibuttonentry_label_get(const Evas_Object *obj); @@ -3329,8 +3331,8 @@ EINA_DEPRECATED EAPI void elm_multibuttonentry_item_label_ * Delete a given item * * @param it The item - * - * @deprecated Use elm_object_item_del() instead + * + * @deprecated Use elm_object_item_del() instead * */ EINA_DEPRECATED EAPI void elm_multibuttonentry_item_del(Elm_Object_Item *it); @@ -3363,7 +3365,7 @@ EINA_DEPRECATED EAPI void elm_naviframe_item_del(Elm_Object_Item *it * enabled). * * @deprecated Use elm_object_item_disabled_set() instead - * + * * @ingroup List */ EINA_DEPRECATED EAPI void elm_list_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled); @@ -3377,7 +3379,7 @@ EINA_DEPRECATED EAPI void elm_list_item_disabled_set(Elm * @see elm_list_item_disabled_set() for more details. * * @deprecated Use elm_object_item_disabled_get() instead - * + * * @ingroup List */ EINA_DEPRECATED EAPI Eina_Bool elm_list_item_disabled_get(const Elm_Object_Item *it); @@ -3395,7 +3397,7 @@ EINA_DEPRECATED EAPI Eina_Bool elm_list_item_disabled_get(con * @li item itself; * * This way, a data associated to a list item could be properly freed. - * + * * @deprecated Please use elm_object_item_del_cb_set() instead. * * @ingroup List @@ -3415,7 +3417,7 @@ EINA_DEPRECATED EAPI void elm_list_item_del_cb_set(Elm_O * @see elm_list_item_append() * * @deprecated Please use elm_object_item_data_get() instead. - * + * * @ingroup List */ EINA_DEPRECATED EAPI void *elm_list_item_data_get(const Elm_Object_Item *it); @@ -3940,6 +3942,23 @@ EAPI Evas_Object *elm_entry_end_get(const Evas_Object *obj); */ EINA_DEPRECATED EAPI Evas_Object *elm_entry_end_unset(Evas_Object *obj); +/** + * Set route service to be used. By default used source is + * #ELM_MAP_ROUTE_SOURCE_YOURS. + * + * @see elm_map_route_source_set() + * @see elm_map_route_source_get() + * + * @ingroup Map + */ +typedef enum +{ + ELM_MAP_ROUTE_SOURCE_YOURS, /**< Routing service http://www.yournavigation.org/ . Set by default.*/ + ELM_MAP_ROUTE_SOURCE_MONAV, /**< MoNav offers exact routing without heuristic assumptions. Its routing core is based on Contraction Hierarchies. It's not working with Map yet. */ + ELM_MAP_ROUTE_SOURCE_ORS, /**< Open Route Service: http://www.openrouteservice.org/ . It's not working with Map yet. */ + ELM_MAP_ROUTE_SOURCE_LAST +} Elm_Map_Route_Sources; + /** * Convert a pixel coordinate into a rotated pixel coordinate. * @@ -3953,10 +3972,944 @@ EINA_DEPRECATED EAPI Evas_Object *elm_entry_end_unset(Evas_Object *obj); * @param yy Pointer where to store rotated y. * * @ingroup Map - * @deprecated Rotation is not needed to know. Use elm_map_canvas_to_geo_convert() instead + * @deprecated Use elm_map_canvas_to_geo_convert() instead */ EINA_DEPRECATED EAPI void elm_map_utils_rotate_coord(const Evas_Object *obj, const Evas_Coord x, const Evas_Coord y, const Evas_Coord cx, const Evas_Coord cy, const double degree, Evas_Coord *xx, Evas_Coord *yy); +/** + * Convert a pixel coordinate (x,y) into a geographic coordinate + * (longitude, latitude). + * + * @param obj The map object. + * @param x the coordinate. + * @param y the coordinate. + * @param size the size in pixels of the map. + * The map is a square and generally his size is : pow(2.0, zoom)*256. + * @param lon Pointer to store the longitude that correspond to x. + * @param lat Pointer to store the latitude that correspond to y. + * + * @note Origin pixel point is the top left corner of the viewport. + * Map zoom and size are taken on account. + * + * @see elm_map_utils_convert_geo_into_coord() if you need the inverse. + * + * @ingroup Map + * @deprecated Use elm_map_canvas_to_geo_convert() instead + */ +EINA_DEPRECATED EAPI void elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat); + +/** + * Convert a geographic coordinate (longitude, latitude) into a pixel + * coordinate (x, y). + * + * @param obj The map object. + * @param lon the longitude. + * @param lat the latitude. + * @param size the size in pixels of the map. The map is a square + * and generally his size is : pow(2.0, zoom)*256. + * @param x Pointer to store the horizontal pixel coordinate that + * correspond to the longitude. + * @param y Pointer to store the vertical pixel coordinate that + * correspond to the latitude. + * + * @note Origin pixel point is the top left corner of the viewport. + * Map zoom and size are taken on account. + * + * @see elm_map_utils_convert_coord_into_geo() if you need the inverse. + * + * @ingroup Map + * @deprecatedUse Use elm_map_canvas_to_geo_convert() instead + */ +EINA_DEPRECATED EAPI void elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y); + +/** + * Get the information of downloading status. + * + * @param obj The map object. + * @param try_num Pointer to store number of tiles being downloaded. + * @param finish_num Pointer to store number of tiles successfully + * downloaded. + * + * This gets the current downloading status for the map object, the number + * of tiles being downloaded and the number of tiles already downloaded. + * + * @ingroup Map + * @deprecatedUse Use elm_map_tile_load_status_get() instead + */ +EINA_DEPRECATED EAPI void elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num); + +/** + * Convert a geographic coordinate (longitude, latitude) into a name + * (address). + * + * @param obj The map object. + * @param lon the longitude. + * @param lat the latitude. + * @return name A #Elm_Map_Name handle for this coordinate. + * + * To get the string for this address, elm_map_name_address_get() + * should be used. + * + * @see elm_map_utils_convert_name_into_coord() if you need the inverse. + * @deprecatedUse Use elm_map_name_add() instead + * + * @ingroup Map + */ +EINA_DEPRECATED EAPI Elm_Map_Name *elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat); + +/** + * Convert a name (address) into a geographic coordinate + * (longitude, latitude). + * + * @param obj The map object. + * @param address The address. + * @return name A #Elm_Map_Name handle for this address. + * + * To get the longitude and latitude, elm_map_name_region_get() + * should be used. + * + * @see elm_map_utils_convert_coord_into_name() if you need the inverse. + * @deprecatedUse Use elm_map_name_geo_request() instead + * + * @ingroup Map + */ +EINA_DEPRECATED EAPI Elm_Map_Name *elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address); + +/** + * Convert canvas coordinates into a geographic coordinate + * (longitude, latitude). + * + * @param obj The map object. + * @param x horizontal coordinate of the point to convert. + * @param y vertical coordinate of the point to convert. + * @param lon A pointer to the longitude. + * @param lat A pointer to the latitude. + * + * This gets longitude and latitude from canvas x, y coordinates. The canvas + * coordinates mean x, y coordinate from current viewport. + * + * see elm_map_rotate_get() + * @deprecatedUse Use elm_map_canvas_to_region_convert() instead + * + * @ingroup Map + */ +EAPI void elm_map_canvas_to_geo_convert(const Evas_Object *obj, const Evas_Coord x, const Evas_Coord y, double *lon, double *lat); + +/** + * Get the current geographic coordinates of the map. + * + * @param obj The map object. + * @param lon Pointer to store longitude. + * @param lat Pointer to store latitude. + * + * This gets the current center coordinates of the map object. It can be + * set by elm_map_region_bring_in() and elm_map_region_show(). + * + * @see elm_map_region_bring_in() + * @see elm_map_region_show() + * + * @ingroup Map + * @deprecated Use elm_map_region_get() instead + */ +EINA_DEPRECATED EAPI void elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat); + +/** + * Animatedly bring in given coordinates to the center of the map. + * + * @param obj The map object. + * @param lon Longitude to center at. + * @param lat Latitude to center at. + * + * This causes map to jump to the given @p lat and @p lon coordinates + * and show it (by scrolling) in the center of the viewport, if it is not + * already centered. This will use animation to do so and take a period + * of time to complete. + * + * @see elm_map_region_show() for a function to avoid animation. + * @see elm_map_region_get() + * + * @ingroup Map + * @deprecated Use elm_map_region_bring_in() instead + */ +EINA_DEPRECATED EAPI void elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat); + +/** + * Show the given coordinates at the center of the map, @b immediately. + * + * @param obj The map object. + * @param lon Longitude to center at. + * @param lat Latitude to center at. + * + * This causes map to @b redraw its viewport's contents to the + * region containing the given @p lat and @p lon, that will be moved to the + * center of the map. + * + * @see elm_map_region_bring_in() for a function to move with animation. + * @see elm_map_region_get() + * + * @ingroup Map + * @deprecated Use elm_map_region_show() instead + */ +EINA_DEPRECATED EAPI void elm_map_geo_region_show(Evas_Object *obj, double lon, double lat); + +/** + * Set the minimum zoom of the source. + * + * @param obj The map object. + * @param zoom New minimum zoom value to be used. + * + * By default, it's 0. + * + * @ingroup Map + * @deprecated Use elm_map_zoom_min_set() instead + */ +EINA_DEPRECATED EAPI void elm_map_source_zoom_min_set(Evas_Object *obj, int zoom); + +/** + * Get the minimum zoom of the source. + * + * @param obj The map object. + * @return Returns the minimum zoom of the source. + * + * @see elm_map_zoom_min_set() for details. + * + * @ingroup Map + * @deprecated Use elm_map_zoom_min_get() instead + */ +EINA_DEPRECATED EAPI int elm_map_source_zoom_min_get(const Evas_Object *obj); + +/** + * Set the maximum zoom of the source. + * + * @param obj The map object. + * @param zoom New maximum zoom value to be used. + * + * By default, it's 18. + * + * @ingroup Map + * @deprecated Use elm_map_zoom_max_set() instead + */ +EINA_DEPRECATED EAPI void elm_map_source_zoom_max_set(Evas_Object *obj, int zoom); + +/** + * Get the maximum zoom of the source. + * + * @param obj The map object. + * @return Returns the maximum zoom of the source. + * + * @see elm_map_zoom_min_set() for details. + * + * @ingroup Map + * @deprecated Use elm_map_zoom_max_get() instead + */ +EINA_DEPRECATED EAPI int elm_map_source_zoom_max_get(const Evas_Object *obj); + + +/** + * Get the list of available sources. + * + * @param obj The map object. + * @return The source names list. + * + * It will provide a list with all available sources, that can be set as + * current source with elm_map_source_name_set(), or get with + * elm_map_source_name_get(). + * + * Available sources: + * @li "Mapnik" + * @li "Osmarender" + * @li "CycleMap" + * @li "Maplint" + * + * @see elm_map_source_name_set() for more details. + * @see elm_map_source_name_get() + * @deprecated Use elm_map_sources_get() instead + * + * @ingroup Map + */ +EINA_DEPRECATED EAPI const char **elm_map_source_names_get(const Evas_Object *obj); + +/** + * Set the source of the map. + * + * @param obj The map object. + * @param source_name The source to be used. + * + * Map widget retrieves images that composes the map from a web service. + * This web service can be set with this method. + * + * A different service can return a different maps with different + * information and it can use different zoom values. + * + * The @p source_name need to match one of the names provided by + * elm_map_source_names_get(). + * + * The current source can be get using elm_map_source_name_get(). + * + * @see elm_map_source_names_get() + * @see elm_map_source_name_get() + * @deprecated Use elm_map_source_set() instead + * + * @ingroup Map + */ +EINA_DEPRECATED EAPI void elm_map_source_name_set(Evas_Object *obj, const char *source_name); + +/** + * Get the name of currently used source. + * + * @param obj The map object. + * @return Returns the name of the source in use. + * + * @see elm_map_source_name_set() for more details. + * @deprecated Use elm_map_source_get() instead + * + * @ingroup Map + */ +EINA_DEPRECATED EAPI const char *elm_map_source_name_get(const Evas_Object *obj); + +/** + * Set the source of the route service to be used by the map. + * + * @param obj The map object. + * @param source The route service to be used, being it one of + * #ELM_MAP_ROUTE_SOURCE_YOURS (default), #ELM_MAP_ROUTE_SOURCE_MONAV, + * and #ELM_MAP_ROUTE_SOURCE_ORS. + * + * Each one has its own algorithm, so the route retrieved may + * differ depending on the source route. Now, only the default is working. + * + * #ELM_MAP_ROUTE_SOURCE_YOURS is the routing service provided at + * http://www.yournavigation.org/. + * + * #ELM_MAP_ROUTE_SOURCE_MONAV, offers exact routing without heuristic + * assumptions. Its routing core is based on Contraction Hierarchies. + * + * #ELM_MAP_ROUTE_SOURCE_ORS, is provided at http://www.openrouteservice.org/ + * + * @see elm_map_route_source_get(). + * @deprecated Use elm_map_source_set() instead + * + * @ingroup Map + */ +EAPI void elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source); + +/** + * Get the current route source. + * + * @param obj The map object. + * @return The source of the route service used by the map. + * + * @see elm_map_route_source_set() for details. + * @deprecated Use elm_map_source_get() instead + * + * @ingroup Map + */ +EAPI Elm_Map_Route_Sources elm_map_route_source_get(const Evas_Object *obj); + +/** + * Add a new marker to the map object. + * + * @param obj The map object. + * @param lon The longitude of the marker. + * @param lat The latitude of the marker. + * @param clas The class, to use when marker @b isn't grouped to others. + * @param clas_group The class group, to use when marker is grouped to others + * @param data The data passed to the callbacks. + * + * @return The created marker or @c NULL upon failure. + * + * A marker will be created and shown in a specific point of the map, defined + * by @p lon and @p lat. + * + * It will be displayed using style defined by @p class when this marker + * is displayed alone (not grouped). A new class can be created with + * elm_map_marker_class_new(). + * + * If the marker is grouped to other markers, it will be displayed with + * style defined by @p class_group. Markers with the same group are grouped + * if they are close. A new group class can be created with + * elm_map_marker_group_class_new(). + * + * Markers created with this method can be deleted with + * elm_map_marker_remove(). + * + * A marker can have associated content to be displayed by a bubble, + * when a user click over it, as well as an icon. These objects will + * be fetch using class' callback functions. + * + * @see elm_map_marker_class_new() + * @see elm_map_marker_group_class_new() + * @see elm_map_marker_remove() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI Elm_Map_Marker *elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data); + +/** + * Set the maximum numbers of markers' content to be displayed in a group. + * + * @param obj The map object. + * @param max The maximum numbers of items displayed in a bubble. + * + * A bubble will be displayed when the user clicks over the group, + * and will place the content of markers that belong to this group + * inside it. + * + * A group can have a long list of markers, consequently the creation + * of the content of the bubble can be very slow. + * + * In order to avoid this, a maximum number of items is displayed + * in a bubble. + * + * By default this number is 30. + * + * Marker with the same group class are grouped if they are close. + * + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_max_marker_per_group_set(Evas_Object *obj, int max); + +/** + * Remove a marker from the map. + * + * @param marker The marker to remove. + * + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_marker_remove(Elm_Map_Marker *marker); + +/** + * Get the current coordinates of the marker. + * + * @param marker marker. + * @param lat Pointer to store the marker's latitude. + * @param lon Pointer to store the marker's longitude. + * + * These values are set when adding markers, with function + * elm_map_marker_add(). + * + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat); + +/** + * Animatedly bring in given marker to the center of the map. + * + * @param marker The marker to center at. + * + * This causes map to jump to the given @p marker's coordinates + * and show it (by scrolling) in the center of the viewport, if it is not + * already centered. This will use animation to do so and take a period + * of time to complete. + * + * @see elm_map_marker_show() for a function to avoid animation. + * @see elm_map_marker_region_get() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_marker_bring_in(Elm_Map_Marker *marker); + +/** + * Show the given marker at the center of the map, @b immediately. + * + * @param marker The marker to center at. + * + * This causes map to @b redraw its viewport's contents to the + * region containing the given @p marker's coordinates, that will be + * moved to the center of the map. + * + * @see elm_map_marker_bring_in() for a function to move with animation. + * @see elm_map_markers_list_show() if more than one marker need to be + * displayed. + * @see elm_map_marker_region_get() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_marker_show(Elm_Map_Marker *marker); + +/** + * Move and zoom the map to display a list of markers. + * + * @param markers A list of #Elm_Map_Marker handles. + * + * The map will be centered on the center point of the markers in the list. + * Then the map will be zoomed in order to fit the markers using the maximum + * zoom which allows display of all the markers. + * + * @warning All the markers should belong to the same map object. + * + * @see elm_map_marker_show() to show a single marker. + * @see elm_map_marker_bring_in() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_markers_list_show(Eina_List *markers); + +/** + * Set to show markers during zoom level changes or not. + * + * @param obj The map object. + * @param paused Use @c EINA_TRUE to @b not show markers or @c EINA_FALSE + * to show them. + * + * This sets the paused state to on (@c EINA_TRUE) or off (@c EINA_FALSE) + * for map. + * + * The default is off. + * + * This will stop zooming using animation, changing zoom levels will + * change instantly. This will stop any existing animations that are running. + * + * This sets the paused state to on (@c EINA_TRUE) or off (@c EINA_FALSE) + * for the markers. + * + * The default is off. + * + * Enabling it will force the map to stop displaying the markers during + * zoom level changes. Set to on if you have a large number of markers. + * + * @see elm_map_paused_markers_get() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused); + +/** + * Get a value whether markers will be displayed on zoom level changes or not + * + * @param obj The map object. + * @return @c EINA_TRUE means map @b won't display markers or @c EINA_FALSE + * indicates it will. + * + * This gets the current markers paused state for the map object. + * + * @see elm_map_paused_markers_set() for details. + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI Eina_Bool elm_map_paused_markers_get(const Evas_Object *obj); + +/** + * Get the Evas object returned by the Elm_Map_Marker_Get_Func callback + * + * @param marker The marker which content should be returned. + * @return Return the evas object if it exists, else @c NULL. + * + * To set callback function #Elm_Map_Marker_Get_Func for the marker class, + * elm_map_marker_class_get_cb_set() should be used. + * + * This content is what will be inside the bubble that will be displayed + * when an user clicks over the marker. + * + * This returns the actual Evas object used to be placed inside + * the bubble. This may be @c NULL, as it may + * not have been created or may have been deleted, at any time, by + * the map. Do not modify this object (move, resize, + * show, hide, etc.), as the map is controlling it. This + * function is for querying, emitting custom signals or hooking + * lower level callbacks for events on that object. Do not delete + * this object under any circumstances. + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI Evas_Object *elm_map_marker_object_get(const Elm_Map_Marker *marker); + +/** + * Update the marker + * + * @param marker The marker to be updated. + * + * If a content is set to this marker, it will call function to delete it, + * #Elm_Map_Marker_Del_Func, and then will fetch the content again with + * #Elm_Map_Marker_Get_Func. + * + * These functions are set for the marker class with + * elm_map_marker_class_get_cb_set() and elm_map_marker_class_del_cb_set(). + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_marker_update(Elm_Map_Marker *marker); + +/** + * Close all the bubbles opened by the user. + * + * @param obj The map object. + * + * A bubble is displayed with a content fetched with #Elm_Map_Marker_Get_Func + * when the user clicks on a marker. + * + * This functions is set for the marker class with + * elm_map_marker_class_get_cb_set(). + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_bubbles_close(Evas_Object *obj); + +/** + * Create a new group class. + * + * @param obj The map object. + * @return Returns the new group class. + * + * Each marker must be associated to a group class. Markers in the same + * group are grouped if they are close. + * + * The group class defines the style of the marker when a marker is grouped + * to others markers. When it is alone, another class will be used. + * + * A group class will need to be provided when creating a marker with + * elm_map_marker_add(). + * + * Some properties and functions can be set by class, as: + * - style, with elm_map_group_class_style_set() + * - data - to be associated to the group class. It can be set using + * elm_map_group_class_data_set(). + * - min zoom to display markers, set with + * elm_map_group_class_zoom_displayed_set(). + * - max zoom to group markers, set using + * elm_map_group_class_zoom_grouped_set(). + * - visibility - set if markers will be visible or not, set with + * elm_map_group_class_hide_set(). + * - #Elm_Map_Group_Icon_Get_Func - used to fetch icon for markers group classes. + * It can be set using elm_map_group_class_icon_cb_set(). + * + * @see elm_map_marker_add() + * @see elm_map_group_class_style_set() + * @see elm_map_group_class_data_set() + * @see elm_map_group_class_zoom_displayed_set() + * @see elm_map_group_class_zoom_grouped_set() + * @see elm_map_group_class_hide_set() + * @see elm_map_group_class_icon_cb_set() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI Elm_Map_Group_Class *elm_map_group_class_new(Evas_Object *obj); + +/** + * Set the marker's style of a group class. + * + * @param clas The group class. + * @param style The style to be used by markers. + * + * Each marker must be associated to a group class, and will use the style + * defined by such class when grouped to other markers. + * + * The following styles are provided by default theme: + * @li @c radio - blue circle + * @li @c radio2 - green circle + * @li @c empty + * + * @see elm_map_group_class_new() for more details. + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style); + +/** + * Set the icon callback function of a group class. + * + * @param clas The group class. + * @param icon_get The callback function that will return the icon. + * + * Each marker must be associated to a group class, and it can display a + * custom icon. The function @p icon_get must return this icon. + * + * @see elm_map_group_class_new() for more details. + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, Elm_Map_Group_Icon_Get_Func icon_get); + +/** + * Set the data associated to the group class. + * + * @param clas The group class. + * @param data The new user data. + * + * This data will be passed for callback functions, like icon get callback, + * that can be set with elm_map_group_class_icon_cb_set(). + * + * If a data was previously set, the object will lose the pointer for it, + * so if needs to be freed, you must do it yourself. + * + * @see elm_map_group_class_new() for more details. + * @see elm_map_group_class_icon_cb_set() + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data); + +/** + * Set the minimum zoom from where the markers are displayed. + * + * @param clas The group class. + * @param zoom The minimum zoom. + * + * Markers only will be displayed when the map is displayed at @p zoom + * or bigger. + * + * @see elm_map_group_class_new() for more details. + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom); + +/** + * Set the zoom from where the markers are no more grouped. + * + * @param clas The group class. + * @param zoom The maximum zoom. + * + * Markers only will be grouped when the map is displayed at + * less than @p zoom. + * + * @see elm_map_group_class_new() for more details. + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom); + +/** + * Set if the markers associated to the group class @p clas are hidden or not. + * + * @param clas The group class. + * @param hide Use @c EINA_TRUE to hide markers or @c EINA_FALSE + * to show them. + * + * @param obj The map object. + * If @p hide is @c EINA_TRUE the markers will be hidden, but default + * is to show them. + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide); + +/** + * Create a new marker class. + * + * @param obj The map object. + * @return Returns the new group class. + * + * Each marker must be associated to a class. + * + * The marker class defines the style of the marker when a marker is + * displayed alone, i.e., not grouped to to others markers. When grouped + * it will use group class style. + * + * A marker class will need to be provided when creating a marker with + * elm_map_marker_add(). + * + * Some properties and functions can be set by class, as: + * - style, with elm_map_marker_class_style_set() + * - #Elm_Map_Marker_Icon_Get_Func - used to fetch icon for markers classes. + * It can be set using elm_map_marker_class_icon_cb_set(). + * - #Elm_Map_Marker_Get_Func - used to fetch bubble content for marker classes. + * Set using elm_map_marker_class_get_cb_set(). + * - #Elm_Map_Marker_Del_Func - used to delete bubble content for marker classes. + * Set using elm_map_marker_class_del_cb_set(). + * + * @see elm_map_marker_add() + * @see elm_map_marker_class_style_set() + * @see elm_map_marker_class_icon_cb_set() + * @see elm_map_marker_class_get_cb_set() + * @see elm_map_marker_class_del_cb_set() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI Elm_Map_Marker_Class *elm_map_marker_class_new(Evas_Object *obj); + +/** + * Set the marker's style of a marker class. + * + * @param clas The marker class. + * @param style The style to be used by markers. + * + * Each marker must be associated to a marker class, and will use the style + * defined by such class when alone, i.e., @b not grouped to other markers. + * + * The following styles are provided by default theme: + * @li @c radio + * @li @c radio2 + * @li @c empty + * + * @see elm_map_marker_class_new() for more details. + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style); + +/** + * Set the icon callback function of a marker class. + * + * @param clas The marker class. + * @param icon_get The callback function that will return the icon. + * + * Each marker must be associated to a marker class, and it can display a + * custom icon. The function @p icon_get must return this icon. + * + * @see elm_map_marker_class_new() for more details. + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, Elm_Map_Marker_Icon_Get_Func icon_get); + +/** + * Set the bubble content callback function of a marker class. + * + * @param clas The marker class. + * @param get The callback function that will return the content. + * + * Each marker must be associated to a marker class, and it can display a + * a content on a bubble that opens when the user click over the marker. + * The function @p get must return this content object. + * + * If this content will need to be deleted, elm_map_marker_class_del_cb_set() + * can be used. + * + * @see elm_map_marker_class_new() for more details. + * @see elm_map_marker_class_del_cb_set() + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, Elm_Map_Marker_Get_Func get); + +/** + * Set the callback function used to delete bubble content of a marker class. + * + * @param clas The marker class. + * @param del The callback function that will delete the content. + * + * Each marker must be associated to a marker class, and it can display a + * a content on a bubble that opens when the user click over the marker. + * The function to return such content can be set with + * elm_map_marker_class_get_cb_set(). + * + * If this content must be freed, a callback function need to be + * set for that task with this function. + * + * If this callback is defined it will have to delete (or not) the + * object inside, but if the callback is not defined the object will be + * destroyed with evas_object_del(). + * + * @see elm_map_marker_class_new() for more details. + * @see elm_map_marker_class_get_cb_set() + * @see elm_map_marker_add() + * + * @ingroup Map + * @deprecated Use Elm_Map_Overlay instead + */ +EINA_DEPRECATED EAPI void elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, Elm_Map_Marker_Del_Func del); + +/** + * Set the route color. + * + * @param route The route object. + * @param r Red channel value, from 0 to 255. + * @param g Green channel value, from 0 to 255. + * @param b Blue channel value, from 0 to 255. + * @param a Alpha channel value, from 0 to 255. + * + * It uses an additive color model, so each color channel represents + * how much of each primary colors must to be used. 0 represents + * absence of this color, so if all of the three are set to 0, + * the color will be black. + * + * These component values should be integers in the range 0 to 255, + * (single 8-bit byte). + * + * This sets the color used for the route. By default, it is set to + * solid red (r = 255, g = 0, b = 0, a = 255). + * + * For alpha channel, 0 represents completely transparent, and 255, opaque. + * + * @see elm_map_route_color_get() + * @deprecated Use elm_map_overlay_color_set() instead + * + * @ingroup Map + */ +EINA_DEPRECATED EAPI void elm_map_route_color_set(Elm_Map_Route *route, int r, int g, int b, int a); + +/** + * Get the route color. + * + * @param route The route object. + * @param r Pointer to store the red channel value. + * @param g Pointer to store the green channel value. + * @param b Pointer to store the blue channel value. + * @param a Pointer to store the alpha channel value. + * + * @see elm_map_route_color_set() for details. + * @deprecated Use elm_map_overlay_color_get() instead + * + * @ingroup Map + */ +EINA_DEPRECATED EAPI void elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g, int *b, int *a); + +/** + * Remove a route from the map. + * + * @param route The route to remove. + * + * @see elm_map_route_add() + * @deprecated Use elm_map_route_del() instead + * + * @ingroup Map + */ +EINA_DEPRECATED EAPI void elm_map_route_remove(Elm_Map_Route *route); + +/** + * Remove a name from the map. + * + * @param name The name to remove. + * + * Basically the struct handled by @p name will be freed, so conversions + * between address and coordinates will be lost. + * + * @see elm_map_utils_convert_name_into_coord() + * @see elm_map_utils_convert_coord_into_name() + * @deprecated Use elm_map_name_del() instead + * + * @ingroup Map + */ +EINA_DEPRECATED EAPI void elm_map_name_remove(Elm_Map_Name *name); + /** * Get the gengrid object's handle which contains a given gengrid item * @@ -4045,34 +4998,12 @@ EINA_DEPRECATED EAPI Eina_Bool elm_gengrid_item_disabled_get * * @see elm_gengrid_clear(), to remove all items in a gengrid at * once. - * @deprecated use elm_object_item_del() instead + * @deprecated use elm_object_item_de() instead * * @ingroup Gengrid */ EINA_DEPRECATED EAPI void elm_gengrid_item_del(Elm_Object_Item *it); -/** - * Get the real Evas object created to implement the view of a - * given gengrid item - * - * @param it The gengrid item. - * @return the Evas object implementing this item's view. - * - * This returns the actual Evas object used to implement the - * specified gengrid item's view. This may be @c NULL, as it may - * not have been created or may have been deleted, at any time, by - * the gengrid. Do not modify this object (move, resize, - * show, hide, etc.), as the gengrid is controlling it. This - * function is for querying, emitting custom signals or hooking - * lower level callbacks for events on that object. Do not delete - * this object under any circumstances. - * - * @see elm_object_item_data_get() - * - * @ingroup Gengrid - */ -EINA_DEPRECATED EAPI const Evas_Object *elm_gengrid_item_object_get(const Elm_Object_Item *it); - /** * Update the item class of a gengrid item. * @@ -4128,7 +5059,7 @@ EINA_DEPRECATED EAPI Elm_Object_Item *elm_gengrid_item_direct_sorted * @param func The function to use as text filter * @param data User data to pass to @p func * @deprecated use elm_entry_markup_filter_append() instead - * @ingroup Entry + * @ingroup Entry */ EINA_DEPRECATED EAPI void elm_entry_text_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data); @@ -4367,7 +5298,7 @@ EINA_DEPRECATED EAPI void elm_label_fontsize_set(Evas_Obj * * @warning NEVER use this. It is for hyper-special cases only. use styles * instead. e.g. "default", "marker", "slide_long" etc. - * @deprecated Use tag instead. about tag - Text color in one of the following formats: "#RRGGBB", "#RRGGBBAA", "#RGB", and "#RGBA" + * @deprecated Use tag instead. about tag - Text color in one of the following formats: "#RRGGBB", "#RRGGBBAA", "#RGB", and "#RGBA" */ EINA_DEPRECATED EAPI void elm_label_text_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a); @@ -4394,7 +5325,7 @@ EINA_DEPRECATED EAPI void elm_label_text_align_set(Evas_O * * @warning NEVER use this. It is for hyper-special cases only. use styles * instead. e.g. "default", "marker", "slide_long" etc. - * @deprecated Just make colored background by yourself. + * @deprecated Just make colored background by yourself. */ EINA_DEPRECATED EAPI void elm_label_background_color_set(Evas_Object *obj, unsigned int r, unsigned int g, unsigned int b, unsigned int a); @@ -4407,7 +5338,7 @@ EINA_DEPRECATED EAPI void elm_label_background_color_set( * This function sets the maximum height size hint of the label. * * @warning This is only relevant if the label is inside a container. - * @deprecated This function should not be used because of wrong concept. + * @deprecated This function should not be used because of wrong concept. */ EAPI void elm_label_wrap_height_set(Evas_Object *obj, Evas_Coord h); @@ -4416,7 +5347,7 @@ EAPI void elm_label_wrap_height_set(Evas_Object *obj, Eva * * @param obj The label object * @return The wrap height in pixels at a minimum where words need to wrap - * @deprecated This function should not be used because of wrong concept. + * @deprecated This function should not be used because of wrong concept. */ EAPI Evas_Coord elm_label_wrap_height_get(const Evas_Object *obj); @@ -4440,17 +5371,17 @@ EINA_DEPRECATED EAPI void elm_all_flush(void); /** * @brief Define the uri that will be the video source. - * + * * @param video The video object to define the file for. * @param uri The uri to target. - * + * * This function will define an uri as a source for the video of the * Elm_Video object. URI could be remote source of video, like http:// or local * like for example WebCam who are most of the time v4l2:// (but that depend an - * you should use Emotion API to request and list the available Webcam on your - * + * you should use Emotion API to request and list the available Webcam on your + * * @deprecated Use elm_video_file_set() instead. - * + * */ EINA_DEPRECATED EAPI void elm_video_uri_set(Evas_Object *video, const char *uri); @@ -4479,33 +5410,6 @@ EINA_DEPRECATED EAPI double elm_route_lon_max_get(Evas_Object *obj); EINA_DEPRECATED EAPI double elm_route_lat_max_get(Evas_Object *obj); -/** - * Control pasting of text and images for the widget. - * - * Normally the entry allows both text and images to be pasted. By setting - * textonly to be true, this prevents images from being pasted. - * - * Note this only changes the behaviour of text. - * - * @param obj The entry object - * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is - * text+image+other. - * @deprecated Use elm_entry_cnp_mode_set() instead. - */ -EINA_DEPRECATED EAPI void elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly); - -/** - * Getting elm_entry text paste/drop mode. - * - * In textonly mode, only text may be pasted or dropped into the widget. - * - * @param obj The entry object - * @return If the widget only accepts text from pastes. - * @deprecated Use elm_entry_cnp_mode_get() instead. - */ -EINA_DEPRECATED EAPI Eina_Bool elm_entry_cnp_textonly_get(const Evas_Object *obj); - - /** * Get the duration after which tooltip will be shown. * @@ -4517,7 +5421,7 @@ EINA_DEPRECATED EAPI double elm_tooltip_delay_get(void); /** * Set the duration after which tooltip will be shown. * - * @return EINA_TRUE if value is set. + * @return EINA_TRUE if value is set. * @deprecated Use elm_config_tooltip_delay_set(double delay); */ EINA_DEPRECATED EAPI Eina_Bool elm_tooltip_delay_set(double delay); diff --git a/legacy/elementary/src/lib/elm_map.c b/legacy/elementary/src/lib/elm_map.c index 85fa44db92..ac7c3b74e4 100644 --- a/legacy/elementary/src/lib/elm_map.c +++ b/legacy/elementary/src/lib/elm_map.c @@ -16,6 +16,7 @@ typedef struct _Overlay_Default Overlay_Default; typedef struct _Overlay_Group Overlay_Group; typedef struct _Overlay_Class Overlay_Class; typedef struct _Overlay_Bubble Overlay_Bubble; +typedef struct _Overlay_Route Overlay_Route; typedef struct _Marker_Group Marker_Group; typedef struct _Marker_Bubble Marker_Bubble; typedef struct _Path_Node Path_Node; @@ -24,38 +25,38 @@ typedef struct _Url_Data Url_Data; typedef struct _Route_Dump Route_Dump; typedef struct _Name_Dump Name_Dump; typedef struct _Delayed_Data Delayed_Data; -typedef struct _Map_Sources_Tab Map_Sources_Tab; +typedef struct _Source_Tile Source_Tile; +typedef struct _Source_Route Source_Route; +typedef struct _Source_Name Source_Name; -#define ROUND(z) (((z) < 0) ? (int)ceil((z) - 0.005) : (int)floor((z) + 0.005)) -#define EVAS_MAP_POINT 4 -#define DEFAULT_TILE_SIZE 256 +#define ROUND(z) (((z) < 0) ? (int)ceil((z) - 0.005) : (int)floor((z) + 0.005)) +#define EVAS_MAP_POINT 4 +#define DEFAULT_TILE_SIZE 256 #define MAX_CONCURRENT_DOWNLOAD 10 - -#define MARER_MAX_NUMBER 30 - -#define CACHE_ROOT_PATH "/tmp/elm_map" -#define CACHE_PATH CACHE_ROOT_PATH"/%d/%d/%d" -#define CACHE_FILE_PATH "%s/%d.png" -#define DEST_ROUTE_XML_FILE "/tmp/elm_map-route-XXXXXX" -#define DEST_NAME_XML_FILE "/tmp/elm_map-name-XXXXXX" - -#define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php" -#define ROUTE_TYPE_MOTORCAR "motocar" -#define ROUTE_TYPE_BICYCLE "bicycle" -#define ROUTE_TYPE_FOOT "foot" -#define YOURS_DISTANCE "distance" -#define YOURS_DESCRIPTION "description" -#define YOURS_COORDINATES "coordinates" - -#define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org" -#define NOMINATIM_RESULT "result" -#define NOMINATIM_PLACE "place" -#define NOMINATIM_ATTR_LON "lon" -#define NOMINATIM_ATTR_LAT "lat" - +#define MARER_MAX_NUMBER 30 #define OVERLAY_CLASS_ZOOM_MAX 255 #define OVERLAY_GROUPING_SCALE 2 +#define CACHE_ROOT "/tmp/elm_map" +#define CACHE_TILE_ROOT CACHE_ROOT"/%d/%d/%d" +#define CACHE_TILE_PATH "%s/%d.png" +#define CACHE_ROUTE_ROOT CACHE_ROOT"/route" +#define CACHE_NAME_ROOT CACHE_ROOT"/name" + +#define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php" +#define ROUTE_TYPE_MOTORCAR "motocar" +#define ROUTE_TYPE_BICYCLE "bicycle" +#define ROUTE_TYPE_FOOT "foot" +#define YOURS_DISTANCE "distance" +#define YOURS_DESCRIPTION "description" +#define YOURS_COORDINATES "coordinates" + +#define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org" +#define NOMINATIM_RESULT "result" +#define NOMINATIM_PLACE "place" +#define NOMINATIM_ATTR_LON "lon" +#define NOMINATIM_ATTR_LAT "lat" + enum _Route_Xml_Attribute { ROUTE_XML_NONE, @@ -92,20 +93,31 @@ struct _Delayed_Data Eina_List *overlays; }; -// Map sources -// Currently the size of a tile must be 256*256 -// and the size of the map must be pow(2.0, z)*tile_size -struct _Map_Sources_Tab +// Map Tile source +// FIXME: Currently tile size must be 256*256 +// and the map size is pow(2.0, z) * (tile size) +struct _Source_Tile { const char *name; int zoom_min; int zoom_max; - Elm_Map_Module_Url_Func url_cb; - Elm_Map_Route_Sources route_source; - Elm_Map_Module_Route_Url_Func route_url_cb; - Elm_Map_Module_Name_Url_Func name_url_cb; - Elm_Map_Module_Geo_Into_Coord_Func geo_into_coord; - Elm_Map_Module_Coord_Into_Geo_Func coord_into_geo; + Elm_Map_Module_Tile_Url_Func url_cb; + Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord; + Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo; +}; + +// Map Route Source +struct _Source_Route +{ + const char *name; + Elm_Map_Module_Route_Url_Func url_cb; +}; + +// Map Name Source +struct _Source_Name +{ + const char *name; + Elm_Map_Module_Name_Url_Func url_cb; }; struct _Url_Data @@ -163,6 +175,24 @@ struct _Overlay_Bubble Evas_Coord x, y, w, h; }; +struct _Overlay_Route +{ + Widget_Data *wd; + + Eina_Bool inbound : 1; + struct + { + int r; + int g; + int b; + int a; + } color; + + Eina_List *paths; + Eina_List *nodes; + int x, y; +}; + struct _Elm_Map_Overlay { Widget_Data *wd; @@ -256,18 +286,17 @@ struct _Elm_Map_Route { Widget_Data *wd; - Path_Node *n; - Path_Waypoint *w; - Ecore_Con_Url *con_url; - - int type; - int method; - int x, y; + char *fname; + Elm_Map_Route_Type type; + Elm_Map_Route_Method method; double flon, flat, tlon, tlat; + Elm_Map_Route_Cb cb; + void *data; + Ecore_File_Download_Job *job; - Eina_List *nodes, *path; + + Eina_List *nodes; Eina_List *waypoint; - struct { int node_count; @@ -277,18 +306,9 @@ struct _Elm_Map_Route double distance; /* unit : km */ } info; - Eina_List *handlers; - Url_Data ud; + Path_Node *n; + Path_Waypoint *w; - struct - { - int r; - int g; - int b; - int a; - } color; - - Eina_Bool inbound : 1; }; struct _Path_Node @@ -314,12 +334,14 @@ struct _Elm_Map_Name { Widget_Data *wd; - Ecore_Con_Url *con_url; int method; char *address; double lon, lat; - Url_Data ud; - Ecore_Event_Handler *handler; + + char *fname; + Ecore_File_Download_Job *job; + Elm_Map_Name_Cb cb; + void *data; }; struct _Route_Dump @@ -346,7 +368,7 @@ struct _Grid_Item Widget_Data *wd; Evas_Object *img; const char *file; - const char *source; + const char *url; int x, y; // Tile coordinate Eina_Bool file_have : 1; @@ -376,9 +398,18 @@ struct _Widget_Data Evas_Object *sep_maps_markers; // Tiles are below this and overlays are on top Evas_Map *map; - Map_Sources_Tab *src; - Eina_List *srcs; - const char **src_names; + Source_Tile *src_tile; + Eina_List *src_tiles; + const char **src_tile_names; + + Source_Route *src_route; + Eina_List *src_routes; + const char **src_route_names; + + Source_Name *src_name; + Eina_List *src_names; + const char **src_name_names; + int zoom_min, zoom_max; int tsize; @@ -436,8 +467,7 @@ struct _Widget_Data Eina_List *marker_classes; Eina_List *markers; - Elm_Map_Route_Sources route_source; - Eina_List *route; + Eina_List *routes; Eina_List *track; Eina_List *names; @@ -449,20 +479,34 @@ static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int z static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); static char *_mapquest_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); static char *_mapquest_aerial_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom); -static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); -static char *_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat); +static char *_yours_url_cb(Evas_Object *obj __UNUSED__, const char *type_name, int method, double flon, double flat, double tlon, double tlat); +static char *_nominatim_url_cb(Evas_Object *obj, int method, const char *name, double lon, double lat); /* static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat) static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat); */ -static Map_Sources_Tab default_map_sources_tab[] = +const Source_Tile src_tiles[] = { - {"Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL}, - {"Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL}, - {"CycleMap", 0, 16, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL}, - {"MapQuest", 0, 18, _mapquest_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL}, - {"MapQuest Open Aerial", 0, 11, _mapquest_aerial_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL}, + {"Mapnik", 0, 18, _mapnik_url_cb, NULL, NULL}, + {"Osmarender", 0, 17, _osmarender_url_cb, NULL, NULL}, + {"CycleMap", 0, 16, _cyclemap_url_cb, NULL, NULL}, + {"MapQuest", 0, 18, _mapquest_url_cb, NULL, NULL}, + {"MapQuest Open Aerial", 0, 11, _mapquest_aerial_url_cb, NULL, NULL}, +}; + +// FIXME: Fix more open sources +const Source_Route src_routes[] = +{ + {"Yours", _yours_url_cb} // http://www.yournavigation.org/ + //{"Monav", _monav_url_cb}, + //{"ORS", _ors_url_cb}, // http://www.openrouteservice.org +}; + +// FIXME: Add more open sources +const Source_Name src_names[] = +{ + {"Nominatim", _nominatim_url_cb} }; static const char *widtype = NULL; @@ -471,154 +515,54 @@ static Evas_Smart_Class sc; static Evas_Smart *smart; static int idnum = 1; -static const char SIG_CHANGED[] = "changed"; -static const char SIG_CLICKED[] = "clicked"; -static const char SIG_CLICKED_DOUBLE[] = "clicked,double"; -static const char SIG_LOADED_DETAIL[] = "loaded,detail"; -static const char SIG_LOAD_DETAIL[] = "load,detail"; -static const char SIG_LONGPRESSED[] = "longpressed"; -static const char SIG_PRESS[] = "press"; -static const char SIG_SCROLL[] = "scroll"; -static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start"; -static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop"; -static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start"; -static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop"; -static const char SIG_ZOOM_CHANGE[] = "zoom,change"; -static const char SIG_ZOOM_START[] = "zoom,start"; -static const char SIG_ZOOM_STOP[] = "zoom,stop"; -static const char SIG_DOWNLOADED[] = "downloaded"; -static const char SIG_ROUTE_LOAD[] = "route,load"; -static const char SIG_ROUTE_LOADED[] = "route,loaded"; -static const char SIG_NAME_LOAD[] = "name,load"; -static const char SIG_NAME_LOADED[] = "name,loaded"; -static const char SIG_OVERLAY_CLICKED[] = "overlay,clicked"; +static const char SIG_CLICKED[] = "clicked"; +static const char SIG_CLICKED_DOUBLE[] = "clicked,double"; +static const char SIG_PRESS[] = "press"; +static const char SIG_LONGPRESSED[] = "longpressed"; +static const char SIG_SCROLL[] = "scroll"; +static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start"; +static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop"; +static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start"; +static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop"; +static const char SIG_ZOOM_START[] = "zoom,start"; +static const char SIG_ZOOM_STOP[] = "zoom,stop"; +static const char SIG_ZOOM_CHANGE[] = "zoom,change"; +static const char SIG_TILE_LOAD[] = "tile,load"; +static const char SIG_TILE_LOADED[] = "tile,loaded"; +static const char SIG_TILE_LOADED_FAIL[] = "tile,loaded,fail"; +static const char SIG_ROUTE_LOAD[] = "route,load"; +static const char SIG_ROUTE_LOADED[] = "route,loaded"; +static const char SIG_ROUTE_LOADED_FAIL[] = "route,loaded,fail"; +static const char SIG_NAME_LOAD[] = "name,load"; +static const char SIG_NAME_LOADED[] = "name,loaded"; +static const char SIG_NAME_LOADED_FAIL[] = "name,loaded,fail"; +static const char SIG_OVERLAY_CLICKED[] = "overlay,clicked"; static const Evas_Smart_Cb_Description _signals[] = { - {SIG_CHANGED, ""}, {SIG_CLICKED, ""}, {SIG_CLICKED_DOUBLE, ""}, - {SIG_LOADED_DETAIL, ""}, - {SIG_LOAD_DETAIL, ""}, - {SIG_LONGPRESSED, ""}, {SIG_PRESS, ""}, + {SIG_LONGPRESSED, ""}, {SIG_SCROLL, ""}, {SIG_SCROLL_DRAG_START, ""}, {SIG_SCROLL_DRAG_STOP, ""}, {SIG_SCROLL_ANIM_START, ""}, {SIG_SCROLL_ANIM_STOP, ""}, - {SIG_ZOOM_CHANGE, ""}, {SIG_ZOOM_START, ""}, {SIG_ZOOM_STOP, ""}, - {SIG_DOWNLOADED, ""}, + {SIG_ZOOM_CHANGE, ""}, + {SIG_TILE_LOAD, ""}, + {SIG_TILE_LOADED, ""}, + {SIG_TILE_LOADED_FAIL, ""}, {SIG_ROUTE_LOAD, ""}, {SIG_ROUTE_LOADED, ""}, + {SIG_ROUTE_LOADED_FAIL, ""}, {SIG_NAME_LOAD, ""}, {SIG_NAME_LOADED, ""}, + {SIG_NAME_LOADED_FAIL, ""}, {SIG_OVERLAY_CLICKED, ""}, {NULL, NULL} }; -static Eina_Bool -module_list_cb(Eina_Module *m, void *data) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(data,EINA_FALSE); - Widget_Data *wd = data; - - Map_Sources_Tab *s; - Elm_Map_Module_Source_Func source; - Elm_Map_Module_Zoom_Min_Func zoom_min; - Elm_Map_Module_Zoom_Max_Func zoom_max; - Elm_Map_Module_Url_Func url; - Elm_Map_Module_Route_Source_Func route_source; - Elm_Map_Module_Route_Url_Func route_url; - Elm_Map_Module_Name_Url_Func name_url; - Elm_Map_Module_Geo_Into_Coord_Func geo_into_coord; - Elm_Map_Module_Coord_Into_Geo_Func coord_into_geo; - const char *file; - - file = eina_module_file_get(m); - if (!eina_module_load(m)) - { - ERR("could not load module \"%s\": %s", file, - eina_error_msg_get(eina_error_get())); - return EINA_FALSE; - } - - source = eina_module_symbol_get(m, "map_module_source_get"); - zoom_min = eina_module_symbol_get(m, "map_module_zoom_min_get"); - zoom_max = eina_module_symbol_get(m, "map_module_zoom_max_get"); - url = eina_module_symbol_get(m, "map_module_url_get"); - route_source = eina_module_symbol_get(m, "map_module_route_source_get"); - route_url = eina_module_symbol_get(m, "map_module_route_url_get"); - name_url = eina_module_symbol_get(m, "map_module_name_url_get"); - geo_into_coord = eina_module_symbol_get(m, "map_module_geo_into_coord"); - coord_into_geo = eina_module_symbol_get(m, "map_module_coord_into_geo"); - if ((!source) || (!zoom_min) || (!zoom_max) || (!url) || (!route_source) || - (!route_url) || (!name_url) || (!geo_into_coord) || (!coord_into_geo)) - { - WRN("could not find map_module_source_get() in module \"%s\": %s", - file, eina_error_msg_get(eina_error_get())); - eina_module_unload(m); - return EINA_FALSE; - } - s = ELM_NEW(Map_Sources_Tab); - s->name = source(); - s->zoom_min = zoom_min(); - s->zoom_max = zoom_max(); - s->url_cb = url; - s->route_source = route_source(); - s->route_url_cb = route_url; - s->name_url_cb = name_url; - s->geo_into_coord = geo_into_coord; - s->coord_into_geo = coord_into_geo; - wd->srcs = eina_list_append(wd->srcs, s); - - eina_module_unload(m); - return EINA_TRUE; -} - -static void -source_init(Widget_Data *wd) -{ - EINA_SAFETY_ON_NULL_RETURN(wd); - - Map_Sources_Tab *s; - unsigned int idx; - Eina_Array *modules = NULL; - Eina_List *l; - - for (idx = 0; idx < (sizeof(default_map_sources_tab) / sizeof(Map_Sources_Tab)); idx++) - { - s = ELM_NEW(Map_Sources_Tab); - s->name = default_map_sources_tab[idx].name; - s->zoom_min = default_map_sources_tab[idx].zoom_min; - s->zoom_max = default_map_sources_tab[idx].zoom_max; - s->url_cb = default_map_sources_tab[idx].url_cb; - s->route_source = default_map_sources_tab[idx].route_source; - s->route_url_cb = default_map_sources_tab[idx].route_url_cb; - s->name_url_cb = default_map_sources_tab[idx].name_url_cb; - s->geo_into_coord = default_map_sources_tab[idx].geo_into_coord; - s->coord_into_geo = default_map_sources_tab[idx].coord_into_geo; - wd->srcs = eina_list_append(wd->srcs, s); - if (!idx) - { - wd->src = s; - wd->zoom_min = s->zoom_min; - wd->zoom_max = s->zoom_max; - } - } - modules = eina_module_list_get(modules, MODULES_PATH, 1, &module_list_cb, wd); - eina_array_free(modules); - - wd->src_names = calloc((eina_list_count(wd->srcs) + 1), sizeof(char *)); - idx = 0; - EINA_LIST_FOREACH(wd->srcs, l, s) - { - eina_stringshare_replace(&wd->src_names[idx], s->name); - INF("source : %s", wd->src_names[idx]); - idx++; - } -} - static void _edj_marker_size_get(Widget_Data *wd, Evas_Coord *w, Evas_Coord *h) { @@ -642,55 +586,17 @@ _edj_marker_size_get(Widget_Data *wd, Evas_Coord *w, Evas_Coord *h) } static void -_coord_rotate(const Evas_Coord x, const Evas_Coord y, const Evas_Coord cx, const Evas_Coord cy, const double degree, Evas_Coord *xx, Evas_Coord *yy) +_coord_rotate(Evas_Coord x, Evas_Coord y, Evas_Coord cx, Evas_Coord cy, double degree, Evas_Coord *xx, Evas_Coord *yy) { EINA_SAFETY_ON_NULL_RETURN(xx); EINA_SAFETY_ON_NULL_RETURN(yy); double r = (degree * M_PI) / 180.0; - double tx, ty, ttx, tty; - tx = x - cx; - ty = y - cy; - - ttx = tx * cos(r); - tty = tx * sin(r); - tx = ttx + (ty * cos(r + M_PI_2)); - ty = tty + (ty * sin(r + M_PI_2)); - - *xx = tx + cx; - *yy = ty + cy; + if (xx) *xx = ((x - cx) * cos(r)) + ((y - cy) * cos(r + M_PI_2)) + cx; + if (yy) *yy = ((x - cx) * sin(r)) + ((y - cy) * sin(r + M_PI_2)) + cy; } -static void -_viewport_size_get(Widget_Data *wd, Evas_Coord *vw, Evas_Coord *vh) -{ - EINA_SAFETY_ON_NULL_RETURN(wd); - - Evas_Coord x, y, w, h; - evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h); - if (vw) *vw = (x * 2) + w; - if (vh) *vh = (y * 2) + h; -} - -static void -_pan_geometry_get(Widget_Data *wd, Evas_Coord *px, Evas_Coord *py) -{ - EINA_SAFETY_ON_NULL_RETURN(wd); - - Evas_Coord x, y, vx, vy, vw, vh; - elm_smart_scroller_child_pos_get(wd->scr, &x, &y); - evas_object_geometry_get(wd->pan_smart, &vx, &vy, &vw, &vh); - x = -x; - y = -y; - if (vw > wd->size.w) x += (((vw - wd->size.w) / 2) + vx); - else x -= vx; - if (vh > wd->size.h) y += (((vh - wd->size.h) / 2) + vy); - else y -= vy; - if (px) *px = x; - if (py) *py = y; - } - static void _obj_rotate(Widget_Data *wd, Evas_Object *obj) { @@ -722,6 +628,73 @@ _obj_place(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coor evas_object_show(obj); } +static void +_coord_to_region_convert(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord size, double *lon, double *lat) +{ + EINA_SAFETY_ON_NULL_RETURN(wd); + + int zoom = floor(log(size / wd->size.tile) / log(2)); + if ((wd->src_tile) && (wd->src_tile->coord_to_geo)) + { + if (wd->src_tile->coord_to_geo(wd->obj, zoom, x, y, size, lon, lat)) + return; + } + + if (lon) *lon = (x / (double)size * 360.0) - 180; + if (lat) + { + double n = ELM_PI - (2.0 * ELM_PI * y / size); + *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n))); + } +} + +static void +_geo_to_coord_convert(Widget_Data *wd, double lon, double lat, Evas_Coord size, Evas_Coord *x, Evas_Coord *y) +{ + EINA_SAFETY_ON_NULL_RETURN(wd); + + int zoom = floor(log(size / 256) / log(2)); + if ((wd->src_tile) && (wd->src_tile->geo_to_coord)) + { + if (wd->src_tile->geo_to_coord(wd->obj, zoom, lon, lat, size, x, y)) return; + } + + if (x) *x = floor((lon + 180.0) / 360.0 * size); + if (y) + *y = floor((1.0 - log(tan(lat * ELM_PI / 180.0) + (1.0 / cos(lat * ELM_PI / 180.0))) + / ELM_PI) / 2.0 * size); +} + + +static void +_viewport_size_get(Widget_Data *wd, Evas_Coord *vw, Evas_Coord *vh) +{ + EINA_SAFETY_ON_NULL_RETURN(wd); + + Evas_Coord x, y, w, h; + evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h); + if (vw) *vw = (x * 2) + w; + if (vh) *vh = (y * 2) + h; +} + +static void +_pan_geometry_get(Widget_Data *wd, Evas_Coord *px, Evas_Coord *py) +{ + EINA_SAFETY_ON_NULL_RETURN(wd); + + Evas_Coord x, y, vx, vy, vw, vh; + elm_smart_scroller_child_pos_get(wd->scr, &x, &y); + evas_object_geometry_get(wd->pan_smart, &vx, &vy, &vw, &vh); + x = -x; + y = -y; + if (vw > wd->size.w) x += (((vw - wd->size.w) / 2) + vx); + else x -= vx; + if (vh > wd->size.h) y += (((vh - wd->size.h) / 2) + vy); + else y -= vy; + if (px) *px = x; + if (py) *py = y; + } + static void _region_show(void *data) { @@ -729,8 +702,7 @@ _region_show(void *data) Delayed_Data *dd = data; int x, y, w, h; - elm_map_utils_convert_geo_into_coord(dd->wd->obj, dd->lon, dd->lat, - dd->wd->size.w, &x, &y); + _geo_to_coord_convert(dd->wd, dd->lon, dd->lat, dd->wd->size.w, &x, &y); _viewport_size_get(dd->wd, &w, &h); x = x - (w / 2); y = y - (h / 2); @@ -968,9 +940,9 @@ _marker_group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *em double lon, lat; Marker_Group *group = data; - elm_map_utils_convert_coord_into_geo(group->wd->obj, group->x, group->y, - group->wd->size.w, &lon, &lat); - elm_map_geo_region_bring_in(group->wd->obj, lon, lat); + _coord_to_region_convert(group->wd, group->x, group->y, group->wd->size.w, + &lon, &lat); + elm_map_region_bring_in(group->wd->obj, lon, lat); } static void @@ -1013,7 +985,7 @@ _marker_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission { Elm_Map_Marker *marker = data; EINA_SAFETY_ON_NULL_RETURN(marker); - elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude); + elm_map_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude); } static void @@ -1048,10 +1020,8 @@ _marker_update(Elm_Map_Marker *marker) icon = clas->func.icon_get(marker->wd->obj, marker, marker->data); elm_object_part_content_set(marker->obj, "elm.icon", icon); } - - elm_map_utils_convert_geo_into_coord(marker->wd->obj, marker->longitude, - marker->latitude, marker->wd->size.w, - &(marker->x), &(marker->y)); + _geo_to_coord_convert(marker->wd, marker->longitude, marker->latitude, + marker->wd->size.w, &(marker->x), &(marker->y)); if (marker->bubble) { @@ -1269,7 +1239,7 @@ _grid_item_create(Grid *g, Evas_Coord x, Evas_Coord y) EINA_SAFETY_ON_NULL_RETURN_VAL(g, NULL); char buf[PATH_MAX]; char buf2[PATH_MAX]; - char *source; + char *url; Grid_Item *gi; gi = ELM_NEW(Grid_Item); @@ -1289,19 +1259,19 @@ _grid_item_create(Grid *g, Evas_Coord x, Evas_Coord y) evas_object_pass_events_set(gi->img, EINA_TRUE); evas_object_stack_below(gi->img, g->wd->sep_maps_markers); - snprintf(buf, sizeof(buf), CACHE_PATH, g->wd->id, g->zoom, x); - snprintf(buf2, sizeof(buf2), CACHE_FILE_PATH, buf, y); + snprintf(buf, sizeof(buf), CACHE_TILE_ROOT, g->wd->id, g->zoom, x); + snprintf(buf2, sizeof(buf2), CACHE_TILE_PATH, buf, y); if (!ecore_file_exists(buf)) ecore_file_mkpath(buf); eina_stringshare_replace(&gi->file, buf2); - source = g->wd->src->url_cb(g->wd->obj, x, y, g->zoom); - if ((!source) || (!strlen(source))) + url = g->wd->src_tile->url_cb(g->wd->obj, x, y, g->zoom); + if ((!url) || (!strlen(url))) { - eina_stringshare_replace(&gi->source, NULL); + eina_stringshare_replace(&gi->url, NULL); ERR("Getting source url failed: %s", gi->file); } - else eina_stringshare_replace(&gi->source, source); - if (source) free(source); + else eina_stringshare_replace(&gi->url, url); + if (url) free(url); eina_matrixsparse_data_idx_set(g->grid, y, x, gi); return gi; } @@ -1310,11 +1280,10 @@ static void _grid_item_free(Grid_Item *gi) { EINA_SAFETY_ON_NULL_RETURN(gi); - _grid_item_unload(gi); if (gi->g && gi->g->grid) eina_matrixsparse_data_idx_set(gi->g->grid, gi->y, gi->x, NULL); - if (gi->source) eina_stringshare_del(gi->source); + if (gi->url) eina_stringshare_del(gi->url); if (gi->file) eina_stringshare_del(gi->file); if (gi->img) evas_object_del(gi->img); if (gi->file_have) ecore_file_remove(gi->file); @@ -1328,27 +1297,24 @@ _downloaded_cb(void *data, const char *file __UNUSED__, int status) if (status == 200) { - DBG("Download success from %s to %s", gi->source, gi->file); + DBG("Download success from %s to %s", gi->url, gi->file); _grid_item_update(gi); gi->wd->finish_num++; + evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOADED, NULL); } else { - WRN("Download failed from %s to %s (%d) ", gi->source, gi->file, status); + WRN("Download failed from %s to %s (%d) ", gi->url, gi->file, status); ecore_file_remove(gi->file); gi->file_have = EINA_FALSE; + evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOADED_FAIL, NULL); } gi->job = NULL; gi->wd->download_num--; - evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL); - if (!gi->wd->download_num) - { - edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr), - "elm,state,busy,stop", "elm"); - evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL); - } + edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr), + "elm,state,busy,stop", "elm"); } static Eina_Bool @@ -1376,20 +1342,22 @@ _download_job(void *data) if (wd->download_num >= MAX_CONCURRENT_DOWNLOAD) return ECORE_CALLBACK_RENEW; - Eina_Bool ret = ecore_file_download_full(gi->source, gi->file, + Eina_Bool ret = ecore_file_download_full(gi->url, gi->file, _downloaded_cb, NULL, gi, &(gi->job), wd->ua); if ((!ret) || (!gi->job)) - ERR("Can't start to download from %s to %s", gi->source, gi->file); + ERR("Can't start to download from %s to %s", gi->url, gi->file); else { wd->download_list = eina_list_remove(wd->download_list, gi); - wd->try_num++; wd->download_num++; + evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOAD, + NULL); if (wd->download_num == 1) - edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), - "elm,state,busy,start", "elm"); + edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), + "elm,state,busy,start", "elm"); + } } return ECORE_CALLBACK_RENEW; @@ -1490,10 +1458,10 @@ static void _grid_all_create(Widget_Data *wd) { EINA_SAFETY_ON_NULL_RETURN(wd); - EINA_SAFETY_ON_NULL_RETURN(wd->src); + EINA_SAFETY_ON_NULL_RETURN(wd->src_tile); int zoom; - for (zoom = wd->src->zoom_min; zoom <= wd->src->zoom_max; zoom++) + for (zoom = wd->src_tile->zoom_min; zoom <= wd->src_tile->zoom_max; zoom++) { Grid *g; int tnum; @@ -1516,11 +1484,11 @@ _grid_all_clear(Widget_Data *wd) Grid *g; EINA_LIST_FREE(wd->grids, g) { - Grid_Item *gi; - Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid); Eina_Matrixsparse_Cell *cell; + Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid); EINA_ITERATOR_FOREACH(it, cell) { + Grid_Item *gi; gi = eina_matrixsparse_cell_data_get(cell); if (gi) _grid_item_free(gi); } @@ -1529,8 +1497,6 @@ _grid_all_clear(Widget_Data *wd) eina_matrixsparse_free(g->grid); free(g); } - if (!ecore_file_recursive_rm(CACHE_ROOT_PATH)) - ERR("Deletion of %s failed", CACHE_ROOT_PATH); } static void @@ -1555,8 +1521,8 @@ _track_place(Widget_Data *wd) double lat_min, lat_max; elm_route_longitude_min_max_get(route, &lon_min, &lon_max); elm_route_latitude_min_max_get(route, &lat_min, &lat_max); - elm_map_utils_convert_geo_into_coord(wd->obj, lon_min, lat_max, size, &xmin, &ymin); - elm_map_utils_convert_geo_into_coord(wd->obj, lon_max, lat_min, size, &xmax, &ymax); + _geo_to_coord_convert(wd, lon_min, lat_max, size, &xmin, &ymin); + _geo_to_coord_convert(wd, lon_max, lat_min, size, &xmax, &ymax); if( !(xmin < px && xmax < px) && !(xmin > px+ow && xmax > px+ow)) { @@ -1580,90 +1546,6 @@ _track_place(Widget_Data *wd) (void) wd; #endif } -static void -_route_place(Widget_Data *wd) -{ - EINA_SAFETY_ON_NULL_RETURN(wd); - Eina_List *lr, *lp, *ln; - Path_Node *n; - Evas_Object *p; - Elm_Map_Route *r; - int nodes; - int x, y; - double a; - Evas_Coord ow, oh; - Evas_Coord px, py; - - px = wd->pan_x; - py = wd->pan_y; - _viewport_size_get(wd, &ow, &oh); - - Evas_Coord size = wd->size.w; - - EINA_LIST_FOREACH(wd->route, lr, r) - { - EINA_LIST_FOREACH(r->path, lp, p) - { - evas_object_polygon_points_clear(p); - } - - nodes = eina_list_count(r->nodes); - - EINA_LIST_FOREACH(r->nodes, ln, n) - { - if ((!wd->zoom) || ((n->idx) && - ((n->idx % (int)ceil((double)nodes/(double)size*100.0))))) continue; - if (r->inbound) - { - elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y); - if ((x >= px - ow) && (x <= (px + ow*2)) && - (y >= py - oh) && (y <= (py + oh*2))) - { - x = x - px; - y = y - py; - - p = eina_list_nth(r->path, n->idx); - a = (double)(y - r->y) / (double)(x - r->x); - if ((abs(a) >= 1) || (r->x == x)) - { - evas_object_polygon_point_add(p, r->x - 3, r->y); - evas_object_polygon_point_add(p, r->x + 3, r->y); - evas_object_polygon_point_add(p, x + 3, y); - evas_object_polygon_point_add(p, x - 3, y); - } - else - { - evas_object_polygon_point_add(p, r->x, r->y - 3); - evas_object_polygon_point_add(p, r->x, r->y + 3); - evas_object_polygon_point_add(p, x, y + 3); - evas_object_polygon_point_add(p, x, y - 3); - } - - evas_object_color_set(p, r->color.r, r->color.g, r->color.b, r->color.a); - evas_object_raise(p); - _obj_rotate(wd, p); - evas_object_show(p); - r->x = x; - r->y = y; - } - else r->inbound = EINA_FALSE; - } - else - { - elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y); - if ((x >= px - ow) && (x <= (px + ow*2)) && - (y >= py - oh) && (y <= (py + oh*2))) - { - r->x = x - px; - r->y = y - py; - r->inbound = EINA_TRUE; - } - else r->inbound = EINA_FALSE; - } - } - r->inbound = EINA_FALSE; - } -} static void _delayed_do(Widget_Data *wd) @@ -1753,13 +1635,12 @@ zoom_do(Widget_Data *wd, double zoom) else if (yy > (wd->size.h - vh)) yy = wd->size.h - vh; elm_smart_scroller_child_region_show(wd->scr, xx, yy, vw, vh); } - if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer); else evas_object_smart_callback_call(wd->obj, SIG_ZOOM_START, NULL); wd->zoom_timer = ecore_timer_add(0.25, _zoom_timeout, wd); evas_object_smart_callback_call(wd->obj, SIG_ZOOM_CHANGE, NULL); - evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL); + evas_object_smart_callback_call(wd->pan_smart, "changed", NULL); evas_object_smart_changed(wd->pan_smart); } @@ -2095,8 +1976,7 @@ _overlay_default_update(Widget_Data *wd, Overlay_Default *ovl, Evas_Object *obj, EINA_SAFETY_ON_NULL_RETURN(wd); EINA_SAFETY_ON_NULL_RETURN(ovl); - elm_map_utils_convert_geo_into_coord(wd->obj, ovl->lon, ovl->lat, - wd->size.w, &ovl->x, &ovl->y); + _geo_to_coord_convert(wd, ovl->lon, ovl->lat, wd->size.w, &ovl->x, &ovl->y); if (obj) { @@ -2323,9 +2203,8 @@ _overlay_bubble_update(Overlay_Bubble *bubble) EINA_SAFETY_ON_NULL_RETURN(bubble); if ((!bubble->pobj) && (bubble->lon >= 0) && (bubble->lat >= 0)) { - elm_map_utils_convert_geo_into_coord(bubble->wd->obj, bubble->lon, - bubble->lat, bubble->wd->size.w, - &bubble->x, &bubble->y); + _geo_to_coord_convert(bubble->wd, bubble->lon, bubble->lat, + bubble->wd->size.w, &bubble->x, &bubble->y); } } @@ -2443,6 +2322,150 @@ _overlay_bubble_new(Widget_Data *wd) return bubble; } +static void +_overlay_route_hide(Overlay_Route *r) +{ + EINA_SAFETY_ON_NULL_RETURN(r); + Eina_List *l; + Evas_Object *p; + EINA_LIST_FOREACH(r->paths, l, p) evas_object_hide(p); +} + +static void +_overlay_route_show(Overlay_Route *r) +{ + EINA_SAFETY_ON_NULL_RETURN(r); + EINA_SAFETY_ON_NULL_RETURN(r->wd); + + Widget_Data *wd; + Eina_List *l; + Evas_Object *p; + Path_Node *n; + int cnt; + int x, y; + double a; + Evas_Coord ow, oh, px, py, size; + + wd = r->wd; + _viewport_size_get(wd, &ow, &oh); + px = wd->pan_x; + py = wd->pan_y; + size = wd->size.w; + + EINA_LIST_FOREACH(r->paths, l, p) evas_object_polygon_points_clear(p); + + cnt = eina_list_count(r->nodes); + EINA_LIST_FOREACH(r->nodes, l, n) + { + if ((!wd->zoom) || ((n->idx) && + ((n->idx % (int)ceil((double)cnt/(double)size*100.0))))) continue; + if (r->inbound) + { + _geo_to_coord_convert(wd, n->pos.lon, n->pos.lat, size, + &x, &y); + if ((x >= px - ow) && (x <= (px + ow*2)) && + (y >= py - oh) && (y <= (py + oh*2))) + { + x = x - px; + y = y - py; + + p = eina_list_nth(r->paths, n->idx); + a = (double)(y - r->y) / (double)(x - r->x); + if ((abs(a) >= 1) || (r->x == x)) + { + evas_object_polygon_point_add(p, r->x - 3, r->y); + evas_object_polygon_point_add(p, r->x + 3, r->y); + evas_object_polygon_point_add(p, x + 3, y); + evas_object_polygon_point_add(p, x - 3, y); + } + else + { + evas_object_polygon_point_add(p, r->x, r->y - 3); + evas_object_polygon_point_add(p, r->x, r->y + 3); + evas_object_polygon_point_add(p, x, y + 3); + evas_object_polygon_point_add(p, x, y - 3); + } + + evas_object_color_set(p, r->color.r, r->color.g, r->color.b, + r->color.a); + evas_object_raise(p); + _obj_rotate(wd, p); + evas_object_show(p); + r->x = x; + r->y = y; + } + + else r->inbound = EINA_FALSE; + } + else + { + _geo_to_coord_convert(wd, n->pos.lon, n->pos.lat, size, + &x, &y); + if ((x >= px - ow) && (x <= (px + ow*2)) && + (y >= py - oh) && (y <= (py + oh*2))) + { + r->x = x - px; + r->y = y - py; + r->inbound = EINA_TRUE; + } + else r->inbound = EINA_FALSE; + } + } + r->inbound = EINA_FALSE; +} + +static void +_overlay_route_free(Overlay_Route* route) +{ + EINA_SAFETY_ON_NULL_RETURN(route); + Evas_Object *p; + Path_Node *n; + + EINA_LIST_FREE(route->paths, p) evas_object_del(p); + EINA_LIST_FREE(route->nodes, n) + { + if (n->pos.address) eina_stringshare_del(n->pos.address); + free(n); + } + free(route); +} + +static Overlay_Route * +_overlay_route_new(Widget_Data *wd, const Elm_Map_Route *route) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL); + + Eina_List *l; + Path_Node *n; + + Overlay_Route *ovl = ELM_NEW(Overlay_Route); + ovl->wd = wd; + ovl->inbound = EINA_FALSE; + ovl->color.r = 255; + ovl->color.g = 0; + ovl->color.b = 0; + ovl->color.a = 255; + + EINA_LIST_FOREACH(route->nodes, l, n) + { + Evas_Object *path; + Path_Node *node; + + node = ELM_NEW(Path_Node); + node->idx = n->idx; + node->pos.lon = n->pos.lon; + node->pos.lat = n->pos.lat; + if (n->pos.address) node->pos.address = strdup(n->pos.address); + ovl->nodes = eina_list_append(ovl->nodes, node); + + path = evas_object_polygon_add(evas_object_evas_get(wd->obj)); + evas_object_smart_member_add(path, wd->pan_smart); + ovl->paths = eina_list_append(ovl->paths, path); + } + return ovl; +} + static void _overlay_grouping(Eina_List *members, Elm_Map_Overlay *overlay) { @@ -2510,6 +2533,11 @@ _overlay_display(Widget_Data *wd, Elm_Map_Overlay *overlay) if (hide) _overlay_bubble_hide(overlay->ovl); else _overlay_bubble_show(overlay->ovl); } + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE) + { + if (hide) _overlay_route_hide(overlay->ovl); + else _overlay_route_show(overlay->ovl); + } } static void @@ -2534,8 +2562,8 @@ _overlay_place(Widget_Data *wd) { Overlay_Class *ovl_grp = NULL; if (overlay->grp->clas) ovl_grp = overlay->grp->clas->ovl; - _overlay_default_update(wd, overlay->ovl, NULL, NULL, ovl_grp, NULL, - NULL); + _overlay_default_update(wd, overlay->ovl, NULL, NULL, ovl_grp, + NULL, NULL); } else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE) _overlay_bubble_update(overlay->ovl); @@ -2604,16 +2632,14 @@ _overlays_show(void *data) dd->lon = (max_lon + min_lon) / 2; dd->lat = (max_lat + min_lat) / 2; - zoom = dd->wd->src->zoom_min; + zoom = dd->wd->src_tile->zoom_min; _viewport_size_get(dd->wd, &vw, &vh); - while (zoom <= dd->wd->src->zoom_max) + while (zoom <= dd->wd->src_tile->zoom_max) { Evas_Coord size, max_x, max_y, min_x, min_y; size = pow(2.0, zoom) * dd->wd->tsize; - elm_map_utils_convert_geo_into_coord(dd->wd->obj, min_lon, max_lat, - size, &min_x, &max_y); - elm_map_utils_convert_geo_into_coord(dd->wd->obj, max_lon, min_lat, - size, &max_x, &min_y); + _geo_to_coord_convert(dd->wd, min_lon, max_lat, size, &min_x, &max_y); + _geo_to_coord_convert(dd->wd, max_lon, min_lat, size, &max_x, &min_y); if ((max_x - min_x) > vw || (max_y - min_y) > vh) break; zoom++; } @@ -2714,7 +2740,6 @@ _pan_calculate(Evas_Object *obj) _grid_place(sd->wd); _marker_place(sd->wd); _overlay_place(sd->wd); - _route_place(sd->wd); _track_place(sd->wd); _delayed_do(sd->wd); } @@ -2758,6 +2783,33 @@ _freeze_off(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__ elm_smart_scroller_freeze_set(wd->scr, 0); } +static void +_elm_map_marker_remove(Elm_Map_Marker *marker) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(marker); + Widget_Data *wd = marker->wd; + EINA_SAFETY_ON_NULL_RETURN(wd); + + if ((marker->content) && (marker->clas->func.del)) + marker->clas->func.del(wd->obj, marker, marker->data, marker->content); + + if (marker->bubble) _bubble_free(marker->bubble); + if (marker->group) _marker_group_free(marker->group); + + if (marker->group_clas) + marker->group_clas->markers = eina_list_remove(marker->group_clas->markers, marker); + wd->markers = eina_list_remove(wd->markers, marker); + + evas_object_del(marker->obj); + free(marker); + + evas_object_smart_changed(wd->pan_smart); +#else + (void) marker; +#endif +} + static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj) { @@ -2784,110 +2836,7 @@ _del_hook(Evas_Object *obj) Widget_Data *wd = elm_widget_data_get(obj); EINA_SAFETY_ON_NULL_RETURN(wd); - Eina_List *l, *ll; - Evas_Object *p; - Path_Node *n; - Path_Waypoint *w; - Ecore_Event_Handler *h; - Elm_Map_Route *r; - Elm_Map_Name *na; - Evas_Object *route; - Elm_Map_Marker *marker; - Elm_Map_Group_Class *group_clas; - Elm_Map_Marker_Class *clas; - Elm_Map_Overlay *overlay; - Delayed_Data *dd; - int idx = 0; - Map_Sources_Tab *s; - - EINA_LIST_FOREACH(wd->route, l, r) - { - EINA_LIST_FREE(r->path, p) - { - evas_object_del(p); - } - - EINA_LIST_FREE(r->waypoint, w) - { - if (w->point) eina_stringshare_del(w->point); - free(w); - } - - EINA_LIST_FREE(r->nodes, n) - { - if (n->pos.address) eina_stringshare_del(n->pos.address); - free(n); - } - - EINA_LIST_FREE(r->handlers, h) - { - ecore_event_handler_del(h); - } - - if (r->con_url) ecore_con_url_free(r->con_url); - if (r->info.nodes) eina_stringshare_del(r->info.nodes); - if (r->info.waypoints) eina_stringshare_del(r->info.waypoints); - } - - EINA_LIST_FREE(wd->names, na) - { - if (na->address) free(na->address); - if (na->handler) ecore_event_handler_del(na->handler); - if (na->ud.fname) - { - ecore_file_remove(na->ud.fname); - free(na->ud.fname); - na->ud.fname = NULL; - } - } - - EINA_LIST_FREE(wd->track, route) - { - evas_object_del(route); - } - - - EINA_LIST_FOREACH_SAFE(wd->markers, l, ll, marker) - elm_map_marker_remove(marker); - eina_list_free(wd->markers); - - EINA_LIST_FREE(wd->group_classes, group_clas) - { - eina_list_free(group_clas->markers); - if (group_clas->style) eina_stringshare_del(group_clas->style); - free(group_clas); - } - - EINA_LIST_FREE(wd->marker_classes, clas) - { - if (clas->style) eina_stringshare_del(clas->style); - free(clas); - } - - EINA_LIST_FREE(wd->overlays, overlay) elm_map_overlay_del(overlay); - - if (wd->scr_timer) ecore_timer_del(wd->scr_timer); - if (wd->long_timer) ecore_timer_del(wd->long_timer); - - if (wd->delayed_jobs) EINA_LIST_FREE(wd->delayed_jobs, dd) free(dd); - - if (wd->user_agent) eina_stringshare_del(wd->user_agent); - if (wd->ua) eina_hash_free(wd->ua); - if (wd->download_idler) ecore_idler_del(wd->download_idler); - eina_list_free(wd->download_list); - - if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer); - if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator); - - _grid_all_clear(wd); - - for (idx = 0; wd->src_names[idx]; idx++) - eina_stringshare_del(wd->src_names[idx]); - - EINA_LIST_FREE(wd->srcs, s) free(s); - if (wd->map) evas_map_free(wd->map); - free(wd); } @@ -2897,6 +2846,79 @@ _del_pre_hook(Evas_Object *obj) ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); EINA_SAFETY_ON_NULL_RETURN(wd); + + Eina_List *l, *ll; + Elm_Map_Route *r; + Elm_Map_Name *na; + Evas_Object *track; + Elm_Map_Marker *marker; + Elm_Map_Group_Class *group_clas; + Elm_Map_Marker_Class *clas; + Elm_Map_Overlay *overlay; + Delayed_Data *dd; + int idx = 0; + Source_Tile *ts; + Source_Route *rs; + Source_Name *ns; + + EINA_LIST_FOREACH_SAFE(wd->routes, l, ll, r) elm_map_route_del(r); + eina_list_free(wd->routes); + + EINA_LIST_FOREACH_SAFE(wd->names, l, ll, na) elm_map_name_del(na); + eina_list_free(wd->names); + + EINA_LIST_FOREACH_SAFE(wd->overlays, l, ll, overlay) + elm_map_overlay_del(overlay); + eina_list_free(wd->overlays); + + EINA_LIST_FREE(wd->track, track) evas_object_del(track); + + EINA_LIST_FOREACH_SAFE(wd->markers, l, ll, marker) + _elm_map_marker_remove(marker); + eina_list_free(wd->markers); + + EINA_LIST_FREE(wd->group_classes, group_clas) + { + eina_list_free(group_clas->markers); + if (group_clas->style) eina_stringshare_del(group_clas->style); + free(group_clas); + } + EINA_LIST_FREE(wd->marker_classes, clas) + { + if (clas->style) eina_stringshare_del(clas->style); + free(clas); + } + + if (wd->scr_timer) ecore_timer_del(wd->scr_timer); + if (wd->long_timer) ecore_timer_del(wd->long_timer); + + if (wd->delayed_jobs) EINA_LIST_FREE(wd->delayed_jobs, dd) free(dd); + + if (wd->user_agent) eina_stringshare_del(wd->user_agent); + if (wd->ua) eina_hash_free(wd->ua); + + if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer); + if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator); + + _grid_all_clear(wd); + // Removal of download list should be after grid clear. + if (wd->download_idler) ecore_idler_del(wd->download_idler); + eina_list_free(wd->download_list); + + for (idx = 0; wd->src_tile_names[idx]; idx++) + eina_stringshare_del(wd->src_tile_names[idx]); + EINA_LIST_FREE(wd->src_tiles, ts) free(ts); + + for (idx = 0; wd->src_route_names[idx]; idx++) + eina_stringshare_del(wd->src_route_names[idx]); + EINA_LIST_FREE(wd->src_routes, rs) free(rs); + + for (idx = 0; wd->src_name_names[idx]; idx++) + eina_stringshare_del(wd->src_name_names[idx]); + EINA_LIST_FREE(wd->src_names, ns) free(ns); + + if (!ecore_file_recursive_rm(CACHE_ROOT)) + ERR("Deletion of %s failed", CACHE_ROOT); } static void @@ -3071,20 +3093,19 @@ cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned } static void -_parse_kml(void *data) +_kml_parse(Elm_Map_Route *r) { - Elm_Map_Route *r = (Elm_Map_Route*)data; - if (!r || !r->ud.fname) return; + EINA_SAFETY_ON_NULL_RETURN(r); + EINA_SAFETY_ON_NULL_RETURN(r->fname); FILE *f; char **str; unsigned int ele, idx; double lon, lat; - Evas_Object *path; - Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL}; + Route_Dump dump = {0, r->fname, 0.0, NULL, NULL}; - f = fopen(r->ud.fname, "rb"); + f = fopen(r->fname, "rb"); if (f) { long sz; @@ -3101,7 +3122,8 @@ _parse_kml(void *data) { if (fread(buf, 1, sz, f)) { - eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump); + eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, + &dump); free(buf); } } @@ -3151,10 +3173,6 @@ _parse_kml(void *data) DBG("%lf:%lf", lon, lat); n->pos.address = NULL; r->nodes = eina_list_append(r->nodes, n); - - path = evas_object_polygon_add(evas_object_evas_get(r->wd->obj)); - evas_object_smart_member_add(path, r->wd->pan_smart); - r->path = eina_list_append(r->path, path); } } if (str && str[0]) @@ -3167,16 +3185,16 @@ _parse_kml(void *data) } static void -_parse_name(void *data) +_name_parse(Elm_Map_Name *n) { - Elm_Map_Name *n = (Elm_Map_Name*)data; - if (!n || !n->ud.fname) return; + EINA_SAFETY_ON_NULL_RETURN(n); + EINA_SAFETY_ON_NULL_RETURN(n->fname); FILE *f; Name_Dump dump = {0, NULL, 0.0, 0.0}; - f = fopen(n->ud.fname, "rb"); + f = fopen(n->fname, "rb"); if (f) { long sz; @@ -3226,106 +3244,119 @@ Grid *_get_current_grid(Widget_Data *wd) return ret; } -static Eina_Bool -_route_complete_cb(void *data, int ev_type __UNUSED__, void *event) +static void +_route_cb(void *data, const char *file, int status) { - Ecore_Con_Event_Url_Complete *ev = event; - Elm_Map_Route *r = (Elm_Map_Route*)data; - Widget_Data *wd = r->wd; + EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(file); - if ((!r) || (!ev)) return EINA_TRUE; - Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url); - ecore_con_url_data_set(r->con_url, NULL); - if (r!=rr) return EINA_TRUE; + Elm_Map_Route *route = data; + Widget_Data *wd = route->wd; + EINA_SAFETY_ON_NULL_RETURN(wd); - if (r->ud.fd) fclose(r->ud.fd); - _parse_kml(r); - - _route_place(wd); + route->job = NULL; + if (status == 200) + { + _kml_parse(route); + INF("Route request success from (%lf, %lf) to (%lf, %lf)", + route->flon, route->flat, route->tlon, route->tlat); + if (route->cb) route->cb(route->data, wd->obj, route); + evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL); + } + else + { + ERR("Route request failed: %d", status); + if (route->cb) route->cb(route->data, wd->obj, NULL); + evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED_FAIL, NULL); + } edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,state,busy,stop", "elm"); - evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL); - return EINA_TRUE; } -static Eina_Bool -_name_complete_cb(void *data, int ev_type __UNUSED__, void *event) +static void +_name_cb(void *data, const char *file, int status) { - Ecore_Con_Event_Url_Complete *ev = event; - Elm_Map_Name *n = (Elm_Map_Name*)data; - Widget_Data *wd = n->wd; + EINA_SAFETY_ON_NULL_RETURN(data); + EINA_SAFETY_ON_NULL_RETURN(file); - if ((!n) || (!ev)) return EINA_TRUE; - Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url); - ecore_con_url_data_set(n->con_url, NULL); - if (n!=nn) return EINA_TRUE; - - if (n->ud.fd) fclose(n->ud.fd); - _parse_name(n); + Elm_Map_Name *name = data; + Widget_Data *wd = name->wd; + EINA_SAFETY_ON_NULL_RETURN(wd); + name->job = NULL; + if (status == 200) + { + _name_parse(name); + INF("Name request success address:%s, lon:%lf, lat:%lf", + name->address, name->lon, name->lat); + if (name->cb) name->cb(name->data, wd->obj, name); + evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL); + } + else + { + ERR("Name request failed: %d", status); + if (name->cb) name->cb(name->data, wd->obj, NULL); + evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED_FAIL, NULL); + } edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,state,busy,stop", "elm"); - evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL); - return EINA_TRUE; } + + static Elm_Map_Name * -_utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat) +_name_request(const Evas_Object *obj, int method, const char *address, double lon, double lat, Elm_Map_Name_Cb name_cb, void *data) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); - char buf[PATH_MAX]; - char *source; - int fd; + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_name, NULL); + + + char *url; + char fname[PATH_MAX]; + + if (!ecore_file_exists(CACHE_NAME_ROOT)) ecore_file_mkpath(CACHE_NAME_ROOT); + + url = wd->src_name->url_cb(wd->obj, method, address, lon, lat); + if (!url) + { + ERR("Name URL is NULL"); + return NULL; + } - if ((!wd) || (!wd->src)) return NULL; Elm_Map_Name *name = ELM_NEW(Elm_Map_Name); - - snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE); - fd = mkstemp(buf); - if (fd < 0) - { - free(name); - return NULL; - } - - name->con_url = ecore_con_url_new(NULL); - name->ud.fname = strdup(buf); - INF("xml file : %s", name->ud.fname); - - name->ud.fd = fdopen(fd, "w+"); - if ((!name->con_url) || (!name->ud.fd)) - { - ecore_con_url_free(name->con_url); - free(name); - return NULL; - } - name->wd = wd; - name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name); + snprintf(fname, sizeof(fname), CACHE_NAME_ROOT"/%d", rand()); + name->fname = strdup(fname); name->method = method; if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address); - else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL; - name->lon = lon; - name->lat = lat; + else if (method == ELM_MAP_NAME_METHOD_REVERSE) + { + name->lon = lon; + name->lat = lat; + } + name->cb = name_cb; + name->data = data; - source = wd->src->name_url_cb(wd->obj, method, address, lon, lat); - INF("name url = %s", source); + if (!ecore_file_download_full(url, name->fname, _name_cb, NULL, name, + &(name->job), wd->ua) || !(name->job)) + { + ERR("Can't request Name from %s to %s", url, name->fname); + if (name->address) free(name->address); + free(name->fname); + free(name); + return NULL; + } + INF("Name requested from %s to %s", url, name->fname); + free(url); wd->names = eina_list_append(wd->names, name); - ecore_con_url_url_set(name->con_url, source); - ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd)); - ecore_con_url_data_set(name->con_url, name); - + evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, name); edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,state,busy,start", "elm"); - evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL); - ecore_con_url_get(name->con_url); - if (source) free(source); - return name; - } static Evas_Event_Flags @@ -3384,6 +3415,344 @@ _pinch_rotate_end_cb(void *data, void *event_info __UNUSED__) return EVAS_EVENT_FLAG_NONE; } +static Eina_Bool +_source_tile_mod_cb(Eina_Module *m, void *data) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE); + + Widget_Data *wd = data; + Source_Tile *s; + Elm_Map_Module_Source_Name_Func name_cb; + Elm_Map_Module_Tile_Zoom_Min_Func zoom_min; + Elm_Map_Module_Tile_Zoom_Max_Func zoom_max; + Elm_Map_Module_Tile_Url_Func url_cb; + Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord; + Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo; + const char *file; + + file = eina_module_file_get(m); + if (!eina_module_load(m)) + { + ERR("Could not load module \"%s\": %s", file, + eina_error_msg_get(eina_error_get())); + return EINA_FALSE; + } + + name_cb = eina_module_symbol_get(m, "map_module_source_name_get"); + zoom_min = eina_module_symbol_get(m, "map_module_tile_zoom_min_get"); + zoom_max = eina_module_symbol_get(m, "map_module_tile_zoom_max_get"); + url_cb = eina_module_symbol_get(m, "map_module_tile_url_get"); + geo_to_coord = eina_module_symbol_get(m, "map_module_tile_geo_to_coord"); + coord_to_geo = eina_module_symbol_get(m, "map_module_tile_coord_to_geo"); + + if ((!name_cb) || (!zoom_min) || (!zoom_max) || (!url_cb) || + (!geo_to_coord) || (!coord_to_geo)) + { + WRN("Could not find map module functions from module \"%s\": %s", + file, eina_error_msg_get(eina_error_get())); + eina_module_unload(m); + return EINA_FALSE; + } + s = ELM_NEW(Source_Tile); + s->name = name_cb(); + s->zoom_min = zoom_min(); + s->zoom_max = zoom_max(); + s->url_cb = url_cb; + s->geo_to_coord = geo_to_coord; + s->coord_to_geo = coord_to_geo; + wd->src_tiles = eina_list_append(wd->src_tiles, s); + + eina_module_unload(m); + return EINA_TRUE; +} + +static void +_source_tile_load(Widget_Data *wd) +{ + unsigned int idx; + Eina_List *l; + Source_Tile *s; + Eina_Array *modules = NULL; + + // Load from hard coded data + for (idx = 0; idx < (sizeof(src_tiles) / sizeof(Source_Tile)); idx++) + { + s= ELM_NEW(Source_Tile); + s->name = src_tiles[idx].name; + s->zoom_min = src_tiles[idx].zoom_min; + s->zoom_max = src_tiles[idx].zoom_max; + s->url_cb = src_tiles[idx].url_cb; + s->geo_to_coord = src_tiles[idx].geo_to_coord; + s->coord_to_geo = src_tiles[idx].coord_to_geo; + wd->src_tiles = eina_list_append(wd->src_tiles, s); + } + + // Load from modules + modules = eina_module_list_get(modules, MODULES_PATH, 1, &_source_tile_mod_cb, wd); + eina_array_free(modules); + + // Set default source + wd->src_tile = eina_list_nth(wd->src_tiles, 0); + + // Make name strings + idx = 0; + wd->src_tile_names = calloc((eina_list_count(wd->src_tiles) + 1), + sizeof(char *)); + EINA_LIST_FOREACH(wd->src_tiles, l, s) + { + eina_stringshare_replace(&wd->src_tile_names[idx], s->name); + INF("source : %s", wd->src_tile_names[idx]); + idx++; + } +} + +static void +_source_tile_set(Widget_Data *wd, const char *source_name) +{ + EINA_SAFETY_ON_NULL_RETURN(wd); + EINA_SAFETY_ON_NULL_RETURN(source_name); + Source_Tile *s; + Eina_List *l; + + if (wd->src_tile && !strcmp(wd->src_tile->name, source_name)) return; + + EINA_LIST_FOREACH(wd->src_tiles, l, s) + { + if (!strcmp(s->name, source_name)) + { + wd->src_tile = s; + break; + } + } + if (!wd->src_tile) + { + ERR("source name (%s) is not found", source_name); + return; + } + + if (wd->src_tile->zoom_max < wd->zoom) + wd->zoom = wd->src_tile->zoom_max; + else if (wd->src_tile->zoom_min > wd->zoom) + wd->zoom = wd->src_tile->zoom_min; + + if (wd->src_tile->zoom_max < wd->zoom_max) + wd->zoom_max = wd->src_tile->zoom_max; + if (wd->src_tile->zoom_min > wd->zoom_min) + wd->zoom_min = wd->src_tile->zoom_min; + + _grid_all_clear(wd); + _grid_all_create(wd); + zoom_do(wd, wd->zoom); +} + +static Eina_Bool +_source_route_mod_cb(Eina_Module *m, void *data) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE); + + Widget_Data *wd = data; + Source_Route *s; + Elm_Map_Module_Source_Name_Func name_cb; + Elm_Map_Module_Route_Url_Func url_cb; + const char *file; + + file = eina_module_file_get(m); + if (!eina_module_load(m)) + { + ERR("Could not load module \"%s\": %s", file, + eina_error_msg_get(eina_error_get())); + return EINA_FALSE; + } + + name_cb = eina_module_symbol_get(m, "map_module_source_name_get"); + url_cb = eina_module_symbol_get(m, "map_module_route_url_get"); + + if ((!name_cb) || (!url_cb)) + { + WRN("Could not find map module functions from module \"%s\": %s", + file, eina_error_msg_get(eina_error_get())); + eina_module_unload(m); + return EINA_FALSE; + } + s = ELM_NEW(Source_Tile); + s->name = name_cb(); + s->url_cb = url_cb; + wd->src_routes = eina_list_append(wd->src_routes, s); + + eina_module_unload(m); + return EINA_TRUE; +} + +static void +_source_route_load(Widget_Data *wd) +{ + unsigned int idx; + Eina_List *l; + Source_Route *s; + Eina_Array *modules = NULL; + + // Load from hard coded data + for (idx = 0; idx < (sizeof(src_routes) / sizeof(Source_Route)); idx++) + { + s= ELM_NEW(Source_Route); + s->name = src_routes[idx].name; + s->url_cb = src_routes[idx].url_cb; + wd->src_routes = eina_list_append(wd->src_routes, s); + } + + // Load from modules + modules = eina_module_list_get(modules, MODULES_PATH, 1, &_source_route_mod_cb, wd); + eina_array_free(modules); + + // Set default source + wd->src_route = eina_list_nth(wd->src_routes, 0); + + // Make name strings + idx = 0; + wd->src_route_names = calloc((eina_list_count(wd->src_routes) + 1), + sizeof(char *)); + EINA_LIST_FOREACH(wd->src_routes, l, s) + { + eina_stringshare_replace(&wd->src_route_names[idx], s->name); + INF("source : %s", wd->src_route_names[idx]); + idx++; + } +} + +static void +_source_route_set(Widget_Data *wd, const char *source_name) +{ + EINA_SAFETY_ON_NULL_RETURN(wd); + EINA_SAFETY_ON_NULL_RETURN(source_name); + Source_Route *s; + Eina_List *l; + + if (wd->src_route && !strcmp(wd->src_route->name, source_name)) return; + + EINA_LIST_FOREACH(wd->src_routes, l, s) + { + if (!strcmp(s->name, source_name)) + { + wd->src_route = s; + break; + } + } + if (!wd->src_route) + { + ERR("source name (%s) is not found", source_name); + return; + } +} + +static Eina_Bool +_source_name_mod_cb(Eina_Module *m, void *data) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE); + + Widget_Data *wd = data; + Source_Name *s; + Elm_Map_Module_Source_Name_Func name_cb; + Elm_Map_Module_Name_Url_Func url_cb; + const char *file; + + file = eina_module_file_get(m); + if (!eina_module_load(m)) + { + ERR("Could not load module \"%s\": %s", file, + eina_error_msg_get(eina_error_get())); + return EINA_FALSE; + } + + name_cb = eina_module_symbol_get(m, "map_module_source_name_get"); + url_cb = eina_module_symbol_get(m, "map_module_name_url_get"); + + if ((!name_cb) || (!url_cb)) + { + WRN("Could not find map module functions from module \"%s\": %s", + file, eina_error_msg_get(eina_error_get())); + eina_module_unload(m); + return EINA_FALSE; + } + s = ELM_NEW(Source_Tile); + s->name = name_cb(); + s->url_cb = url_cb; + wd->src_names = eina_list_append(wd->src_names, s); + + eina_module_unload(m); + return EINA_TRUE; +} + +static void +_source_name_load(Widget_Data *wd) +{ + unsigned int idx; + Eina_List *l; + Source_Name *s; + Eina_Array *modules = NULL; + + // Load from hard coded data + for (idx = 0; idx < (sizeof(src_names) / sizeof(Source_Name)); idx++) + { + s= ELM_NEW(Source_Name); + s->name = src_names[idx].name; + s->url_cb = src_names[idx].url_cb; + wd->src_names = eina_list_append(wd->src_names, s); + } + + // Load from modules + modules = eina_module_list_get(modules, MODULES_PATH, 1, &_source_name_mod_cb, wd); + eina_array_free(modules); + + // Set default source + wd->src_name = eina_list_nth(wd->src_names, 0); + + // Make name strings + idx = 0; + wd->src_name_names = calloc((eina_list_count(wd->src_names) + 1), + sizeof(char *)); + EINA_LIST_FOREACH(wd->src_names, l, s) + { + eina_stringshare_replace(&wd->src_name_names[idx], s->name); + INF("source : %s", wd->src_name_names[idx]); + idx++; + } +} + +static void +_source_name_set(Widget_Data *wd, const char *source_name) +{ + EINA_SAFETY_ON_NULL_RETURN(wd); + EINA_SAFETY_ON_NULL_RETURN(source_name); + + Source_Name *s; + Eina_List *l; + + if (wd->src_name && !strcmp(wd->src_name->name, source_name)) return; + + EINA_LIST_FOREACH(wd->src_names, l, s) + { + if (!strcmp(s->name, source_name)) + { + wd->src_name = s; + break; + } + } + if (!wd->src_name) + { + ERR("source name (%s) is not found", source_name); + return; + } +} + +static void +_source_all_load(Widget_Data *wd) +{ + EINA_SAFETY_ON_NULL_RETURN(wd); + _source_tile_load(wd); + _source_route_load(wd); + _source_name_load(wd); +} + static void _zoom_mode_set(void *data) { @@ -3473,8 +3842,7 @@ _region_bring_in(void *data) Delayed_Data *dd = data; int x, y, w, h; - elm_map_utils_convert_geo_into_coord(dd->wd->obj, dd->lon, dd->lat, - dd->wd->size.w, &x, &y); + _geo_to_coord_convert(dd->wd, dd->lon, dd->lat, dd->wd->size.w, &x, &y); _viewport_size_get(dd->wd, &w, &h); x = x - (w / 2); y = y - (h / 2); @@ -3503,14 +3871,14 @@ _marker_list_show(void *data) dd->lon = (max_lon + min_lon) / 2; dd->lat = (max_lat + min_lat) / 2; - zoom = dd->wd->src->zoom_min; + zoom = dd->wd->src_tile->zoom_min; _viewport_size_get(dd->wd, &vw, &vh); - while (zoom <= dd->wd->src->zoom_max) + while (zoom <= dd->wd->src_tile->zoom_max) { Evas_Coord size, max_x, max_y, min_x, min_y; size = pow(2.0, zoom) * dd->wd->tsize; - elm_map_utils_convert_geo_into_coord(dd->wd->obj, min_lon, max_lat, size, &min_x, &max_y); - elm_map_utils_convert_geo_into_coord(dd->wd->obj, max_lon, min_lat, size, &max_x, &min_y); + _geo_to_coord_convert(dd->wd, min_lon, max_lat, size, &min_x, &max_y); + _geo_to_coord_convert(dd->wd, max_lon, min_lat, size, &max_x, &min_y); if ((max_x - min_x) > vw || (max_y - min_y) > vh) break; zoom++; } @@ -3570,7 +3938,7 @@ _mapquest_aerial_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom) return strdup(buf); } -static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat) +static char *_yours_url_cb(Evas_Object *obj __UNUSED__, const char *type_name, int method, double flon, double flat, double tlon, double tlat) { char buf[PATH_MAX]; snprintf(buf, sizeof(buf), @@ -3607,7 +3975,7 @@ static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int metho */ static char * -_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat) +_nominatim_url_cb(Evas_Object *obj, int method, const char *name, double lon, double lat) { ELM_CHECK_WIDTYPE(obj, widtype) strdup(""); Widget_Data *wd = elm_widget_data_get(obj); @@ -3647,6 +4015,8 @@ _nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double l return strdup(buf); } + + #endif EAPI Evas_Object * @@ -3745,8 +4115,13 @@ elm_map_add(Evas_Object *parent) wd->map = evas_map_new(EVAS_MAP_POINT); - source_init(wd); - wd->tsize = DEFAULT_TILE_SIZE; // FIXME: It should be hard-coded ? or can get from provider? + _source_all_load(wd); + wd->zoom_min = wd->src_tile->zoom_min; + wd->zoom_max = wd->src_tile->zoom_max; + // FIXME: Tile Provider is better to provide tile size! + wd->tsize = DEFAULT_TILE_SIZE; + + srand(time(NULL)); wd->id = ((int)getpid() << 16) | idnum; idnum++; @@ -3778,13 +4153,13 @@ elm_map_zoom_set(Evas_Object *obj, int zoom) ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); EINA_SAFETY_ON_NULL_RETURN(wd); - EINA_SAFETY_ON_NULL_RETURN(wd->src); + EINA_SAFETY_ON_NULL_RETURN(wd->src_tile); if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL) return; if (zoom < 0) zoom = 0; if (wd->zoom == zoom) return; - if (zoom > wd->src->zoom_max) zoom = wd->src->zoom_max; - if (zoom < wd->src->zoom_min) zoom = wd->src->zoom_min; + if (zoom > wd->src_tile->zoom_max) zoom = wd->src_tile->zoom_max; + if (zoom < wd->src_tile->zoom_min) zoom = wd->src_tile->zoom_min; Delayed_Data *data = ELM_NEW(Delayed_Data); data->func = _zoom_set; @@ -3851,7 +4226,76 @@ elm_map_zoom_mode_get(const Evas_Object *obj) } EAPI void -elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat) +elm_map_zoom_max_set(Evas_Object *obj, int zoom) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + EINA_SAFETY_ON_NULL_RETURN(wd->src_tile); + + if ((zoom > wd->src_tile->zoom_max) || (zoom < wd->src_tile->zoom_min)) + return; + wd->zoom_max = zoom; +#else + (void) obj; + (void) zoom; +#endif +} + +EAPI int +elm_map_zoom_max_get(const Evas_Object *obj) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) 18; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, -1); + + return wd->zoom_max; +#else + (void) obj; + return 18; +#endif +} + +EAPI void +elm_map_zoom_min_set(Evas_Object *obj, int zoom) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + EINA_SAFETY_ON_NULL_RETURN(wd->src_tile); + + if ((zoom > wd->src_tile->zoom_max) || (zoom < wd->src_tile->zoom_min)) + return; + wd->zoom_min = zoom; +#else + (void) obj; + (void) zoom; +#endif +} + +EAPI int +elm_map_zoom_min_get(const Evas_Object *obj) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) 0; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, -1); + + return wd->zoom_min; +#else + (void) obj; + return 0; +#endif +} + + +EAPI void +elm_map_region_bring_in(Evas_Object *obj, double lon, double lat) { #ifdef HAVE_ELEMENTARY_ECORE_CON ELM_CHECK_WIDTYPE(obj, widtype); @@ -3872,7 +4316,7 @@ elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat) } EAPI void -elm_map_geo_region_show(Evas_Object *obj, double lon, double lat) +elm_map_region_show(Evas_Object *obj, double lon, double lat) { #ifdef HAVE_ELEMENTARY_ECORE_CON ELM_CHECK_WIDTYPE(obj, widtype); @@ -3893,7 +4337,7 @@ elm_map_geo_region_show(Evas_Object *obj, double lon, double lat) } EAPI void -elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat) +elm_map_region_get(const Evas_Object *obj, double *lon, double *lat) { #ifdef HAVE_ELEMENTARY_ECORE_CON ELM_CHECK_WIDTYPE(obj, widtype); @@ -3905,8 +4349,7 @@ elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat) _pan_geometry_get(wd, &px, &py); _viewport_size_get(wd, &vw, &vh); - elm_map_utils_convert_coord_into_geo(obj, vw/2 - px, vh/2 -py, wd->size.w, - &tlon, &tlat); + _coord_to_region_convert(wd, vw/2 - px, vh/2 -py, wd->size.w, &tlon, &tlat); if (lon) *lon = tlon; if (lat) *lat = tlat; #else @@ -3949,22 +4392,6 @@ elm_map_paused_set(Evas_Object *obj, Eina_Bool paused) #endif } -EAPI void -elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); - - if (wd->paused_markers == !!paused) return; - wd->paused_markers = paused; -#else - (void) obj; - (void) paused; -#endif -} - EAPI Eina_Bool elm_map_paused_get(const Evas_Object *obj) { @@ -3980,15 +4407,74 @@ elm_map_paused_get(const Evas_Object *obj) #endif } +EAPI void +elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + + wd->rotate.d = degree; + wd->rotate.cx = cx; + wd->rotate.cy = cy; + + evas_object_smart_changed(wd->pan_smart); +#else + (void) obj; + (void) degree; + (void) cx; + (void) cy; +#endif +} + +EAPI void +elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + + if (degree) *degree = wd->rotate.d; + if (cx) *cx = wd->rotate.cx; + if (cy) *cy = wd->rotate.cy; +#else + (void) obj; + (void) degree; + (void) cx; + (void) cy; +#endif +} + +EAPI void +elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + + if ((!wd->wheel_disabled) && (disabled)) + evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj); + else if ((wd->wheel_disabled) && (!disabled)) + evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj); + wd->wheel_disabled = !!disabled; +#else + (void) obj; + (void) disabled; +#endif +} + EAPI Eina_Bool -elm_map_paused_markers_get(const Evas_Object *obj) +elm_map_wheel_disabled_get(const Evas_Object *obj) { #ifdef HAVE_ELEMENTARY_ECORE_CON ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; Widget_Data *wd = elm_widget_data_get(obj); EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE); - return wd->paused_markers; + return wd->wheel_disabled; #else (void) obj; return EINA_FALSE; @@ -3996,7 +4482,7 @@ elm_map_paused_markers_get(const Evas_Object *obj) } EAPI void -elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num) +elm_map_tile_load_status_get(const Evas_Object *obj, int *try_num, int *finish_num) { #ifdef HAVE_ELEMENTARY_ECORE_CON ELM_CHECK_WIDTYPE(obj, widtype); @@ -4012,6 +4498,1199 @@ elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int * #endif } +EAPI void +elm_map_canvas_to_region_convert(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, double *lon, double *lat) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + EINA_SAFETY_ON_NULL_RETURN(lon); + EINA_SAFETY_ON_NULL_RETURN(lat); + + Evas_Coord px, py, vw, vh; + _pan_geometry_get(wd, &px, &py); + _viewport_size_get(wd, &vw, &vh); + _coord_rotate(x - px, y - py, (vw / 2) - px, (vh / 2) - py, -wd->rotate.d, + &x, &y); + _coord_to_region_convert(wd, x, y, wd->size.w, lon, lat); +#else + (void) obj; + (void) x; + (void) y; + (void) lon; + (void) lat; +#endif +} + +// FIXME: Make it! +/* +EAPI void +elm_map_region_to_canvas_convert(const Evas_Object *obj, double lon, double lat, Evas_Coord *x, Evas_Coord *y) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + EINA_SAFETY_ON_NULL_RETURN(x); + EINA_SAFETY_ON_NULL_RETURN(y); + +#else + (void) obj; + (void) lon; + (void) lat; + (void) x; + (void) y; +#endif +}*/ + +EAPI void +elm_map_user_agent_set(Evas_Object *obj, const char *user_agent) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + EINA_SAFETY_ON_NULL_RETURN(user_agent); + + eina_stringshare_replace(&wd->user_agent, user_agent); + + if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL); + eina_hash_set(wd->ua, "User-Agent", wd->user_agent); +#else + (void) obj; + (void) user_agent; +#endif +} + +EAPI const char * +elm_map_user_agent_get(const Evas_Object *obj) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); + + return wd->user_agent; +#else + (void) obj; + return NULL; +#endif +} + +EAPI void +elm_map_source_set(Evas_Object *obj, Elm_Map_Source_Type type, const char *source_name) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + EINA_SAFETY_ON_NULL_RETURN(source_name); + + if (type == ELM_MAP_SOURCE_TYPE_TILE) _source_tile_set(wd, source_name); + else if (type == ELM_MAP_SOURCE_TYPE_ROUTE) + _source_route_set(wd, source_name); + else if (type == ELM_MAP_SOURCE_TYPE_NAME) _source_name_set(wd, source_name); + else ERR("Not supported map source type: %d", type); + +#else + (void) obj; + (void) source_name; +#endif +} + +EAPI const char * +elm_map_source_get(const Evas_Object *obj, Elm_Map_Source_Type type) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, NULL); + + if (type == ELM_MAP_SOURCE_TYPE_TILE) return wd->src_tile->name; + else if (type == ELM_MAP_SOURCE_TYPE_ROUTE) return wd->src_route->name; + else if (type == ELM_MAP_SOURCE_TYPE_NAME) return wd->src_name->name; + else ERR("Not supported map source type: %d", type); + return NULL; +#else + (void) obj; + return NULL; +#endif +} + +EAPI const char ** +elm_map_sources_get(const Evas_Object *obj, Elm_Map_Source_Type type) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); + + if (type == ELM_MAP_SOURCE_TYPE_TILE) return wd->src_tile_names; + else if (type == ELM_MAP_SOURCE_TYPE_ROUTE) return wd->src_route_names; + else if (type == ELM_MAP_SOURCE_TYPE_NAME) return wd->src_tile_names; + else ERR("Not supported map source type: %d", type); + return NULL; +#else + (void) obj; + return NULL; +#endif +} + +EAPI Elm_Map_Route * +elm_map_route_add(Evas_Object *obj, Elm_Map_Route_Type type, Elm_Map_Route_Method method, double flon, double flat, double tlon, double tlat, Elm_Map_Route_Cb route_cb, void *data) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_route, NULL); + + char *type_name; + char *url; + char fname[PATH_MAX]; + + if (!ecore_file_exists(CACHE_ROUTE_ROOT)) + ecore_file_mkpath(CACHE_ROUTE_ROOT); + + if (type == ELM_MAP_ROUTE_TYPE_MOTOCAR) + type_name = strdup(ROUTE_TYPE_MOTORCAR); + else if (type == ELM_MAP_ROUTE_TYPE_BICYCLE) + type_name = strdup(ROUTE_TYPE_BICYCLE); + else if (type == ELM_MAP_ROUTE_TYPE_FOOT) + type_name = strdup(ROUTE_TYPE_FOOT); + else type_name = NULL; + + url = wd->src_route->url_cb(obj, type_name, method, flon, flat, tlon, tlat); + if (!url) + { + ERR("Route URL is NULL"); + if (type_name) free(type_name); + return NULL; + } + if (type_name) free(type_name); + + Elm_Map_Route *route = ELM_NEW(Elm_Map_Route); + route->wd = wd; + snprintf(fname, sizeof(fname), CACHE_ROUTE_ROOT"/%d", rand()); + route->fname = strdup(fname); + route->type = type; + route->method = method; + route->flon = flon; + route->flat = flat; + route->tlon = tlon; + route->tlat = tlat; + route->cb = route_cb; + route->data = data; + + if (!ecore_file_download_full(url, route->fname, _route_cb, NULL, route, + &(route->job), wd->ua) || !(route->job)) + { + ERR("Can't request Route from %s to %s", url, route->fname); + free(route->fname); + free(route); + return NULL; + } + INF("Route requested from %s to %s", url, route->fname); + free(url); + + wd->routes = eina_list_append(wd->routes, route); + evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, route); + edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), + "elm,state,busy,start", "elm"); + return route; +#else + (void) obj; + (void) type; + (void) method; + (void) flon; + (void) flat; + (void) tlon; + (void) tlat; + (void) route_cb; + (void) data; + return NULL; +#endif +} + + +EAPI void +elm_map_route_del(Elm_Map_Route *route) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(route); + EINA_SAFETY_ON_NULL_RETURN(route->wd); + ELM_CHECK_WIDTYPE(route->wd->obj, widtype); + + Path_Waypoint *w; + Path_Node *n; + + if (route->job) ecore_file_download_abort(route->job); + + EINA_LIST_FREE(route->waypoint, w) + { + if (w->point) eina_stringshare_del(w->point); + free(w); + } + + EINA_LIST_FREE(route->nodes, n) + { + if (n->pos.address) eina_stringshare_del(n->pos.address); + free(n); + } + + if (route->fname) + { + ecore_file_remove(route->fname); + free(route->fname); + } + + route->wd->routes = eina_list_remove(route->wd->routes, route); + free(route); +#else + (void) route; +#endif +} + +EAPI double +elm_map_route_distance_get(const Elm_Map_Route *route) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0); + return route->info.distance; +#else + (void) route; + return 0.0; +#endif +} + +EAPI const char* +elm_map_route_node_get(const Elm_Map_Route *route) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL); + return route->info.nodes; +#else + (void) route; + return NULL; +#endif +} + +EAPI const char* +elm_map_route_waypoint_get(const Elm_Map_Route *route) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL); + return route->info.waypoints; +#else + (void) route; + return NULL; +#endif +} + +EAPI Elm_Map_Name * +elm_map_name_add(const Evas_Object *obj, const char *address, double lon, double lat, Elm_Map_Name_Cb name_cb, void *data) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + + if (address) + return _name_request(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0, 0, + name_cb, data); + else + return _name_request(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat, + name_cb, data); +#else + (void) obj; + (void) address; + (void) lon; + (void) lat; + (void) name_cb; + (void) data; + return NULL; +#endif +} + +EAPI void +elm_map_name_del(Elm_Map_Name *name) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(name); + EINA_SAFETY_ON_NULL_RETURN(name->wd); + ELM_CHECK_WIDTYPE(name->wd->obj, widtype); + + if (name->job) ecore_file_download_abort(name->job); + if (name->address) free(name->address); + if (name->fname) + { + ecore_file_remove(name->fname); + free(name->fname); + } + + name->wd->names = eina_list_remove(name->wd->names, name); + free(name); +#else + (void) name; +#endif +} + +EAPI const char * +elm_map_name_address_get(const Elm_Map_Name *name) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(name->wd, NULL); + ELM_CHECK_WIDTYPE(name->wd->obj, widtype) NULL; + + return name->address; +#else + (void) name; + return NULL; +#endif +} + +EAPI void +elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(name); + EINA_SAFETY_ON_NULL_RETURN(name->wd); + ELM_CHECK_WIDTYPE(name->wd->obj, widtype); + + if (lon) *lon = name->lon; + if (lat) *lat = name->lat; +#else + (void) name; + (void) lon; + (void) lat; +#endif +} + +EAPI Elm_Map_Overlay * +elm_map_overlay_add(Evas_Object *obj, double lon, double lat) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); + + Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay); + overlay->wd = wd; + overlay->type = ELM_MAP_OVERLAY_TYPE_DEFAULT; + overlay->ovl = _overlay_default_new(wd, lon, lat, "radio"); + _overlay_default_cb_add(overlay->ovl, _overlay_clicked_cb, overlay); + overlay->grp = _overlay_group_new(wd); + wd->overlays = eina_list_append(wd->overlays, overlay); + + evas_object_smart_changed(wd->pan_smart); + return overlay; +#else + (void) obj; + (void) lon; + (void) lat; + return NULL; +#endif +} + +EAPI void +elm_map_overlay_del(Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) + { + _overlay_default_cb_del(overlay->ovl, _overlay_clicked_cb); + _overlay_default_free(overlay->ovl); + } + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE) + { + _overlay_bubble_cb_del(overlay->ovl); + _overlay_bubble_free(overlay->ovl); + } + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) + _overlay_class_free(overlay->ovl); + + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE) + _overlay_route_free(overlay->ovl); + + if (overlay->grp) + { + _overlay_group_cb_del(overlay->grp); + _overlay_group_free(overlay->grp, overlay); + } + + overlay->wd->overlays = eina_list_remove(overlay->wd->overlays, overlay); + evas_object_smart_changed(overlay->wd->pan_smart); + + free(overlay); +#else + (void) overlay; +#endif +} + +EAPI Elm_Map_Overlay_Type +elm_map_overlay_type_get(const Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, ELM_MAP_OVERLAY_TYPE_NONE); + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, ELM_MAP_OVERLAY_TYPE_NONE); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) ELM_MAP_OVERLAY_TYPE_NONE; + + return overlay->type; +#else + (void) overlay; + return OVERLAY_TYPE_NONE; +#endif +} + +EAPI void +elm_map_overlay_data_set(Elm_Map_Overlay *overlay, void *data) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + overlay->data = data; +#else + (void) overlay; + (void) data; +#endif +} + +EAPI void * +elm_map_overlay_data_get(const Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL; + + return overlay->data; +#else + (void) overlay; + return NULL; +#endif +} + +EAPI void +elm_map_overlay_hide_set(Elm_Map_Overlay *overlay, Eina_Bool hide) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + if (overlay->hide == !!hide) return; + overlay->hide = hide; + + evas_object_smart_changed(overlay->wd->pan_smart); +#else + (void) overlay; + (void) hide; +#endif +} + +EAPI Eina_Bool +elm_map_overlay_hide_get(const Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE; + + return overlay->hide; +#else + (void) overlay; + return EINA_FALSE; +#endif +} + +EAPI void +elm_map_overlay_displayed_zoom_min_set(Elm_Map_Overlay *overlay, int zoom) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + overlay->zoom_min = zoom; + evas_object_smart_changed(overlay->wd->pan_smart); +#else + (void) overlay; + (void) zoom; +#endif +} + +EAPI int +elm_map_overlay_displayed_zoom_min_get(const Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, 0); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) 0; + + return overlay->zoom_min; +#else + (void) overlay; + return 0; +#endif +} + +EAPI void +elm_map_overlay_paused_set(Elm_Map_Overlay *overlay, Eina_Bool paused) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + if (overlay->paused == !!paused) return; + overlay->paused = paused; + + evas_object_smart_changed(overlay->wd->pan_smart); +#else + (void) overlay; + (void) paused; +#endif +} + +EAPI Eina_Bool +elm_map_overlay_paused_get(const Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE; + + return overlay->paused; +#else + (void) overlay; + return EINA_FALSE; +#endif +} + +EAPI void +elm_map_overlay_show(Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) + { + Overlay_Default *ovl = overlay->ovl; + elm_map_region_show(overlay->wd->obj, ovl->lon, ovl->lat); + } + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE) + { + Overlay_Bubble *ovl = overlay->ovl; + elm_map_region_show(overlay->wd->obj, ovl->lon, ovl->lat); + } + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) + { + Overlay_Class *ovl = overlay->ovl; + double lon, lat, max_lo, min_lo, max_la, min_la; + _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la, &min_la); + lon = (max_lo + min_lo) / 2; + lat = (max_la + min_la) / 2; + elm_map_region_show(overlay->wd->obj, lon, lat); + } + else ERR("Not supported overlay type: %d", overlay->type); + + evas_object_smart_changed(overlay->wd->pan_smart); +#else + (void) overlay; +#endif +} + +EAPI void +elm_map_overlays_show(Eina_List *overlays) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlays); + EINA_SAFETY_ON_FALSE_RETURN(eina_list_count(overlays)); + + Elm_Map_Overlay *overlay; + overlay = eina_list_data_get(overlays); + + Delayed_Data *data = ELM_NEW(Delayed_Data); + data->func = _overlays_show; + data->wd = overlay->wd; + data->overlays = eina_list_clone(overlays); + data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data); + evas_object_smart_changed(data->wd->pan_smart); +#else + (void) overlays; +#endif +} + +EAPI void +elm_map_overlay_region_set(Elm_Map_Overlay *overlay, double lon, double lat) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) + { + Overlay_Default *ovl = overlay->ovl; + ovl->lon = lon; + ovl->lat = lat; + } + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE) + { + Overlay_Bubble *ovl = overlay->ovl; + ovl->lon = lon; + ovl->lat = lat; + } + else ERR("Not supported overlay type: %d", overlay->type); + + evas_object_smart_changed(overlay->wd->pan_smart); +#else + (void) overlay; + (void) lon; + (void) lat; +#endif +} + +EAPI void +elm_map_overlay_region_get(const Elm_Map_Overlay *overlay, double *lon, double *lat) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) + { + const Overlay_Default *ovl = overlay->ovl; + if (lon) *lon = ovl->lon; + if (lat) *lat = ovl->lat; + } + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE) + { + const Overlay_Bubble *ovl = overlay->ovl; + if (lon) *lon = ovl->lon; + if (lat) *lat = ovl->lat; + } + else ERR("Not supported overlay type: %d", overlay->type); +#else + (void) overlay; + (void) lon; + (void) lat; +#endif +} + +EAPI void +elm_map_overlay_icon_set(Elm_Map_Overlay *overlay, Evas_Object *icon) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(icon); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) + _overlay_default_update(overlay->wd, overlay->ovl, NULL, icon, + NULL, NULL, NULL); + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) + _overlay_class_update(overlay->wd, overlay->ovl, NULL, icon); + else ERR("Not supported overlay type: %d", overlay->type); + + evas_object_smart_changed(overlay->wd->pan_smart); +#else + (void) overlay; + (void) icon; +#endif +} + +EAPI const Evas_Object * +elm_map_overlay_icon_get(const Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL; + + if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) + { + const Overlay_Default *ovl = overlay->ovl; + return elm_object_part_content_get(ovl->layout, "elm.icon"); + } + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) + { + const Overlay_Class *ovl = overlay->ovl; + return ovl->icon; + } + else + { + ERR("Not supported overlay type: %d", overlay->type); + return NULL; + } +#else + (void) overlay; + return NULL; +#endif +} + +EAPI void +elm_map_overlay_content_set(Elm_Map_Overlay *overlay, Evas_Object *obj) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(obj); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) + _overlay_default_update(overlay->wd, overlay->ovl, obj, NULL, NULL, + NULL, NULL); + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) + _overlay_class_update(overlay->wd, overlay->ovl, obj, NULL); + else ERR("Not supported overlay type: %d", overlay->type); + + evas_object_smart_changed(overlay->wd->pan_smart); +#else + (void) overlay; + (void) obj; +#endif +} + +EAPI const Evas_Object * +elm_map_overlay_content_get(const Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL; + + if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) + { + const Overlay_Default *ovl = overlay->ovl; + return elm_object_part_content_get(ovl->layout, "elm.icon"); + } + else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) + { + const Overlay_Class *ovl = overlay->ovl; + return ovl->icon; + } + else + { + ERR("Not supported overlay type: %d", overlay->type); + return NULL; + } +#else + (void) overlay; + return NULL; +#endif +} + +EAPI void +elm_map_overlay_color_set(Elm_Map_Overlay *overlay, int r, int g , int b, int a) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE) + { + Overlay_Route *route = overlay->ovl; + route->color.r = r; + route->color.g = g; + route->color.b = b; + route->color.a = a; + } + else ERR("Not supported overlay type: %d", overlay->type); +#else + (void) overlay; + (void) r; + (void) g; + (void) b; + (void) a; +#endif +} + +EAPI void +elm_map_overlay_color_get(const Elm_Map_Overlay *overlay, int *r, int *g , int *b, int *a) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + int rr, gg, bb, aa; + + if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE) + { + Overlay_Route *route = overlay->ovl; + rr = route->color.r; + gg = route->color.g; + bb = route->color.b; + aa = route->color.a; + } + else + { + ERR("Not supported overlay type: %d", overlay->type); + return; + } + if (r) *r = rr; + if (g) *g = gg; + if (b) *b = bb; + if (a) *a = aa; +#else + (void) overlay; + (void) r; + (void) g; + (void) b; + (void) a; +#endif +} + +EAPI void +elm_map_overlay_get_cb_set(Elm_Map_Overlay *overlay, Elm_Map_Overlay_Get_Cb get_cb, void *data) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(overlay->wd); + ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); + + overlay->cb = get_cb; + overlay->cb_data = data; +#else + (void) overlay; + (void) get_cb; + (void) data; +#endif +} + +EAPI Elm_Map_Overlay * +elm_map_overlay_class_add(Evas_Object *obj) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); + + Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay); + overlay->wd = wd; + overlay->type = ELM_MAP_OVERLAY_TYPE_CLASS; + overlay->ovl = _overlay_class_new(wd, overlay); + overlay->grp = NULL; + wd->overlays = eina_list_append(wd->overlays, overlay); + + evas_object_smart_changed(wd->pan_smart); + return overlay; +#else + (void) obj; + return NULL; +#endif +} + +EAPI void +elm_map_overlay_class_append(Elm_Map_Overlay *group, Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(group); + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(group->wd); + ELM_CHECK_WIDTYPE(group->wd->obj, widtype); + EINA_SAFETY_ON_FALSE_RETURN(group->type == ELM_MAP_OVERLAY_TYPE_CLASS); + + if (overlay->type != ELM_MAP_OVERLAY_TYPE_DEFAULT) + { + ERR("Currently group supports only default overlays"); + return; + } + + Overlay_Class *ovl = group->ovl; + if (eina_list_data_find(ovl->members, overlay)) + { + ERR("Already added overlay into group"); + return; + } + ovl->members = eina_list_append(ovl->members, overlay); + overlay->grp->clas = group; + + evas_object_smart_changed(group->wd->pan_smart); +#else + (void) group; + (void) overlay; +#endif +} + +EAPI void +elm_map_overlay_class_remove(Elm_Map_Overlay *group, Elm_Map_Overlay *overlay) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(group); + EINA_SAFETY_ON_NULL_RETURN(overlay); + EINA_SAFETY_ON_NULL_RETURN(group->wd); + ELM_CHECK_WIDTYPE(group->wd->obj, widtype); + EINA_SAFETY_ON_FALSE_RETURN(group->type == ELM_MAP_OVERLAY_TYPE_CLASS); + + if (overlay->type != ELM_MAP_OVERLAY_TYPE_DEFAULT) + { + ERR("Currently group supports only default overlays"); + return; + } + Overlay_Class *ovl = group->ovl; + ovl->members = eina_list_remove(ovl->members, overlay); + overlay->grp->clas = NULL; + _overlay_group_update(group->wd, overlay->grp, NULL); + + evas_object_smart_changed(group->wd->pan_smart); +#else + (void) group; + (void) overlay; +#endif +} + +EAPI void +elm_map_overlay_class_zoom_max_set(Elm_Map_Overlay *group, int zoom) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(group); + EINA_SAFETY_ON_NULL_RETURN(group->wd); + ELM_CHECK_WIDTYPE(group->wd->obj, widtype); + EINA_SAFETY_ON_FALSE_RETURN(group->type == ELM_MAP_OVERLAY_TYPE_CLASS); + + Overlay_Class *ovl = group->ovl; + if (ovl->zoom_max == !!zoom) return; + ovl->zoom_max = zoom; + + evas_object_smart_changed(group->wd->pan_smart); +#else + (void) group; + (void) zoom; +#endif +} + +EAPI int +elm_map_overlay_class_zoom_max_get(const Elm_Map_Overlay *group) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN_VAL(group, OVERLAY_CLASS_ZOOM_MAX); + EINA_SAFETY_ON_NULL_RETURN_VAL(group->wd, OVERLAY_CLASS_ZOOM_MAX); + ELM_CHECK_WIDTYPE(group->wd->obj, widtype) OVERLAY_CLASS_ZOOM_MAX; + EINA_SAFETY_ON_FALSE_RETURN_VAL(group->type == ELM_MAP_OVERLAY_TYPE_CLASS, OVERLAY_CLASS_ZOOM_MAX); + + const Overlay_Class *ovl = group->ovl; + return ovl->zoom_max; +#else + (void) group; + return OVERLAY_CLASS_ZOOM_MAX; +#endif +} + +EAPI Elm_Map_Overlay * +elm_map_overlay_bubble_add(Evas_Object *obj) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); + + Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay); + overlay->wd = wd; + overlay->type = ELM_MAP_OVERLAY_TYPE_BUBBLE; + overlay->ovl = _overlay_bubble_new(wd); + _overlay_bubble_cb_add(overlay->ovl, overlay); + overlay->grp = _overlay_group_new(wd); + wd->overlays = eina_list_append(wd->overlays, overlay); + + evas_object_smart_changed(wd->pan_smart); + return overlay; +#else + (void) obj; + return NULL; +#endif +} + +EAPI void +elm_map_overlay_bubble_follow(Elm_Map_Overlay *bubble, Elm_Map_Overlay *parent) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(bubble); + EINA_SAFETY_ON_NULL_RETURN(parent); + ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype); + EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE); + + Overlay_Bubble *ovl = bubble->ovl; + Evas_Object *pobj = _overlay_obj_get(parent); + if (!pobj) return; + + if (ovl->pobj) + { + evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_HIDE, + _overlay_bubble_hide_cb, ovl); + evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_SHOW, + _overlay_bubble_chase_cb, ovl); + evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_MOVE, + _overlay_bubble_chase_cb, ovl); + } + + ovl->pobj = pobj; + evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_HIDE, + _overlay_bubble_hide_cb, ovl); + evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_SHOW, + _overlay_bubble_chase_cb, ovl); + evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_MOVE, + _overlay_bubble_chase_cb, ovl); + + _overlay_bubble_chase(ovl); + evas_object_smart_changed(bubble->wd->pan_smart); +#else + (void) bubble; + (void) parent; +#endif +} + +EAPI void +elm_map_overlay_bubble_content_append(Elm_Map_Overlay *bubble, Evas_Object *content) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(bubble); + EINA_SAFETY_ON_NULL_RETURN(content); + ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype); + EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE); + + Overlay_Bubble *bb = bubble->ovl; + elm_box_pack_end(bb->bx, content); + + evas_object_smart_changed(bubble->wd->pan_smart); +#else + (void) bubble; + (void) content; +#endif +} + +EAPI void +elm_map_overlay_bubble_content_clear(Elm_Map_Overlay *bubble) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EINA_SAFETY_ON_NULL_RETURN(bubble); + ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype); + EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE); + + Overlay_Bubble *bb = bubble->ovl; + elm_box_clear(bb->bx); + + evas_object_smart_changed(bubble->wd->pan_smart); +#else + (void) bubble; +#endif +} + +EAPI Elm_Map_Overlay * +elm_map_overlay_route_add(Evas_Object *obj, const Elm_Map_Route *route) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(route->wd, NULL); + EINA_SAFETY_ON_FALSE_RETURN_VAL(obj == route->wd->obj, NULL); + + Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay); + overlay->wd = wd; + overlay->type = ELM_MAP_OVERLAY_TYPE_ROUTE; + overlay->ovl = _overlay_route_new(wd, route); + overlay->grp = _overlay_group_new(wd); + wd->overlays = eina_list_append(wd->overlays, overlay); + + evas_object_smart_changed(wd->pan_smart); + return overlay; +#else + (void) obj; + (void) route; + return NULL; +#endif +} + +#ifdef ELM_EMAP +EAPI Evas_Object * +elm_map_track_add(Evas_Object *obj, void *emap) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + EMap_Route *emapr = emap; + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE); + + Evas_Object *route = elm_route_add(obj); + elm_route_emap_set(route, emapr); + wd->track = eina_list_append(wd->track, route); + + return route; +#else + (void) obj; + (void) emap; + return NULL; +#endif +} + +EAPI void +elm_map_track_remove(Evas_Object *obj, Evas_Object *route) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) ; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + + wd->track = eina_list_remove(wd->track, route); + evas_object_del(route); +#else + (void) obj; + (void) route; +#endif +} +#else +EAPI Evas_Object * +elm_map_track_add(Evas_Object *obj __UNUSED__, void *emap __UNUSED__) +{ + return NULL; +} + +EAPI void +elm_map_track_remove(Evas_Object *obj __UNUSED__, Evas_Object *route __UNUSED__) +{ +} +#endif + +/************************* Belows are deprecated APIs *************************/ +EAPI void +elm_map_source_zoom_max_set(Evas_Object *obj, int zoom) +{ + elm_map_zoom_max_set(obj, zoom); +} + +EAPI int +elm_map_source_zoom_max_get(const Evas_Object *obj) +{ + return elm_map_zoom_max_get(obj); +} + +EAPI void +elm_map_source_zoom_min_set(Evas_Object *obj, int zoom) +{ + elm_map_zoom_min_set(obj, zoom); +} + +EAPI int +elm_map_source_zoom_min_get(const Evas_Object *obj) +{ + return elm_map_zoom_min_get(obj); +} + EAPI void elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat) { @@ -4020,18 +5699,7 @@ elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int s Widget_Data *wd = elm_widget_data_get(obj); EINA_SAFETY_ON_NULL_RETURN(wd); - int zoom = floor(log(size / 256) / log(2)); - if ((wd->src) && (wd->src->coord_into_geo)) - { - if (wd->src->coord_into_geo(obj, zoom, x, y, size, lon, lat)) return; - } - - if (lon) *lon = (x / (double)size * 360.0) - 180; - if (lat) - { - double n = ELM_PI - (2.0 * ELM_PI * y / size); - *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n))); - } + _coord_to_region_convert(wd, x, y, size, lon, lat); #else (void) obj; (void) x; @@ -4050,16 +5718,7 @@ elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double Widget_Data *wd = elm_widget_data_get(obj); EINA_SAFETY_ON_NULL_RETURN(wd); - int zoom = floor(log(size / 256) / log(2)); - if ((wd->src) && (wd->src->geo_into_coord)) - { - if (wd->src->geo_into_coord(obj, zoom, lon, lat, size, x, y)) return; - } - - if (x) *x = floor((lon + 180.0) / 360.0 * size); - if (y) - *y = floor((1.0 - log(tan(lat * ELM_PI / 180.0) + (1.0 / cos(lat * ELM_PI / 180.0))) - / ELM_PI) / 2.0 * size); + _geo_to_coord_convert(wd, lon, lat, size, x, y); #else (void) obj; (void) lon; @@ -4070,36 +5729,8 @@ elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double #endif } -EAPI Elm_Map_Name * -elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat); -#else - (void) obj; - (void) lon; - (void) lat; - return NULL; -#endif -} - -EAPI Elm_Map_Name * -elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - if (!address) return NULL; - return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0); -#else - (void) obj; - (void) address; - return NULL; -#endif -} - -EINA_DEPRECATED EAPI void -elm_map_utils_rotate_coord(const Evas_Object *obj, const Evas_Coord x, const Evas_Coord y, const Evas_Coord cx, const Evas_Coord cy, const double degree, Evas_Coord *xx, Evas_Coord *yy) +EAPI void +elm_map_utils_rotate_coord(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord cx, const Evas_Coord cy, double degree, Evas_Coord *xx, Evas_Coord *yy) { #ifdef HAVE_ELEMENTARY_ECORE_CON ELM_CHECK_WIDTYPE(obj, widtype); @@ -4115,29 +5746,46 @@ elm_map_utils_rotate_coord(const Evas_Object *obj, const Evas_Coord x, const Eva #endif } +EAPI void +elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num) +{ + elm_map_tile_load_status_get(obj, try_num, finish_num); +} + +EAPI void +elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat) +{ + elm_map_region_bring_in(obj, lon, lat); +} + +EAPI void +elm_map_geo_region_show(Evas_Object *obj, double lon, double lat) +{ + elm_map_region_show(obj, lon, lat); +} + +EAPI void +elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat) +{ + elm_map_region_get(obj, lon, lat); +} + +EAPI Elm_Map_Name * +elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat) +{ + return elm_map_name_add(obj, NULL, lon, lat, NULL, NULL); +} + +EAPI Elm_Map_Name * +elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address) +{ + return elm_map_name_add(obj, address, 0, 0, NULL, NULL); +} + EAPI void elm_map_canvas_to_geo_convert(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, double *lon, double *lat) { -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(lon); - EINA_SAFETY_ON_NULL_RETURN(lat); - EINA_SAFETY_ON_NULL_RETURN(wd); - - Evas_Coord px, py, vw, vh; - _pan_geometry_get(wd, &px, &py); - _viewport_size_get(wd, &vw, &vh); - _coord_rotate(x - px, y - py, (vw / 2) - px, (vh / 2) - py, -wd->rotate.d, - &x, &y); - elm_map_utils_convert_coord_into_geo(obj, x, y, wd->size.w, lon, lat); -#else - (void) obj; - (void) x; - (void) y; - (void) lon; - (void) lat; -#endif + elm_map_canvas_to_region_convert(obj, x, y, lon, lat); } EAPI Elm_Map_Marker * @@ -4191,28 +5839,7 @@ elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Clas EAPI void elm_map_marker_remove(Elm_Map_Marker *marker) { -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(marker); - Widget_Data *wd = marker->wd; - EINA_SAFETY_ON_NULL_RETURN(wd); - - if ((marker->content) && (marker->clas->func.del)) - marker->clas->func.del(wd->obj, marker, marker->data, marker->content); - - if (marker->bubble) _bubble_free(marker->bubble); - if (marker->group) _marker_group_free(marker->group); - - if (marker->group_clas) - marker->group_clas->markers = eina_list_remove(marker->group_clas->markers, marker); - wd->markers = eina_list_remove(wd->markers, marker); - - evas_object_del(marker->obj); - free(marker); - - evas_object_smart_changed(wd->pan_smart); -#else - (void) marker; -#endif + _elm_map_marker_remove(marker); } EAPI void @@ -4234,7 +5861,7 @@ elm_map_marker_bring_in(Elm_Map_Marker *marker) { #ifdef HAVE_ELEMENTARY_ECORE_CON EINA_SAFETY_ON_NULL_RETURN(marker); - elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude); + elm_map_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude); #else (void) marker; #endif @@ -4245,7 +5872,7 @@ elm_map_marker_show(Elm_Map_Marker *marker) { #ifdef HAVE_ELEMENTARY_ECORE_CON EINA_SAFETY_ON_NULL_RETURN(marker); - elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude); + elm_map_region_show(marker->wd->obj, marker->longitude, marker->latitude); #else (void) marker; #endif @@ -4272,6 +5899,37 @@ elm_map_markers_list_show(Eina_List *markers) #endif } +EAPI void +elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN(wd); + + if (wd->paused_markers == !!paused) return; + wd->paused_markers = paused; +#else + (void) obj; + (void) paused; +#endif +} + +EAPI Eina_Bool +elm_map_paused_markers_get(const Evas_Object *obj) +{ +#ifdef HAVE_ELEMENTARY_ECORE_CON + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + Widget_Data *wd = elm_widget_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE); + + return wd->paused_markers; +#else + (void) obj; + return EINA_FALSE; +#endif +} + EAPI void elm_map_max_marker_per_group_set(Evas_Object *obj, int max) { @@ -4507,1242 +6165,27 @@ elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, Elm_Map_Marker_Del_F #endif } -EAPI const char ** -elm_map_source_names_get(const Evas_Object *obj) +EAPI void +elm_map_route_color_set(Elm_Map_Route *route __UNUSED__, int r __UNUSED__, int g __UNUSED__, int b __UNUSED__, int a __UNUSED__) { -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); - - return wd->src_names; -#else - (void) obj; - return NULL; -#endif + return; } EAPI void -elm_map_source_name_set(Evas_Object *obj, const char *source_name) +elm_map_route_color_get(const Elm_Map_Route *route __UNUSED__, int *r __UNUSED__, int *g __UNUSED__, int *b __UNUSED__, int *a __UNUSED__) { -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); - - Map_Sources_Tab *s; - Eina_List *l; - int zoom; - - if (wd->src) - { - if (!strcmp(wd->src->name, source_name)) return; - if (!wd->src->url_cb) return; - } - - _grid_all_clear(wd); - EINA_LIST_FOREACH(wd->srcs, l, s) - { - if (!strcmp(s->name, source_name)) - { - wd->src = s; - break; - } - } - zoom = wd->zoom; - wd->zoom = -1; - - if (wd->src) - { - if (wd->src->zoom_max < zoom) - zoom = wd->src->zoom_max; - if (wd->src->zoom_min > zoom) - zoom = wd->src->zoom_min; - if (wd->src->zoom_max < wd->zoom_max) wd->zoom_max = wd->src->zoom_max; - if (wd->src->zoom_min > wd->zoom_min) wd->zoom_min = wd->src->zoom_min; - } - _grid_all_create(wd); - zoom_do(wd, zoom); -#else - (void) obj; - (void) source_name; -#endif -} - -EAPI const char * -elm_map_source_name_get(const Evas_Object *obj) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - - if ((!wd) || (!wd->src)) return NULL; - return wd->src->name; -#else - (void) obj; - return NULL; -#endif -} - -EAPI void -elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); - - wd->route_source = source; -#else - (void) obj; - (void) source; -#endif -} - -EAPI Elm_Map_Route_Sources -elm_map_route_source_get(const Evas_Object *obj) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, ELM_MAP_ROUTE_SOURCE_YOURS); - - return wd->route_source; -#else - (void) obj; - return ELM_MAP_ROUTE_SOURCE_YOURS; -#endif -} - -EAPI void -elm_map_source_zoom_max_set(Evas_Object *obj, int zoom) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); - EINA_SAFETY_ON_NULL_RETURN(wd->src); - - if ((zoom > wd->src->zoom_max) || (zoom < wd->src->zoom_min)) return; - wd->zoom_max = zoom; -#else - (void) obj; - (void) zoom; -#endif -} - -EAPI int -elm_map_source_zoom_max_get(const Evas_Object *obj) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) 18; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src, -1); - - return wd->zoom_max; -#else - (void) obj; - return 18; -#endif -} - -EAPI void -elm_map_source_zoom_min_set(Evas_Object *obj, int zoom) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); - EINA_SAFETY_ON_NULL_RETURN(wd->src); - - if ((zoom > wd->src->zoom_max) || (zoom < wd->src->zoom_min)) return; - wd->zoom_min = zoom; -#else - (void) obj; - (void) zoom; -#endif -} - -EAPI int -elm_map_source_zoom_min_get(const Evas_Object *obj) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) 0; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src, -1); - - return wd->zoom_min; -#else - (void) obj; - return 0; -#endif -} - -EAPI void -elm_map_user_agent_set(Evas_Object *obj, const char *user_agent) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); - EINA_SAFETY_ON_NULL_RETURN(user_agent); - - eina_stringshare_replace(&wd->user_agent, user_agent); - - if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL); - eina_hash_set(wd->ua, "User-Agent", wd->user_agent); -#else - (void) obj; - (void) user_agent; -#endif -} - -EAPI const char * -elm_map_user_agent_get(const Evas_Object *obj) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); - - return wd->user_agent; -#else - (void) obj; - return NULL; -#endif -} - -EAPI Elm_Map_Route * -elm_map_route_add(Evas_Object *obj, Elm_Map_Route_Type type, Elm_Map_Route_Method method, double flon, double flat, double tlon, double tlat) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - char buf[PATH_MAX]; - char *source; - char *type_name = NULL; - int fd; - - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src, NULL); - - Elm_Map_Route *route = ELM_NEW(Elm_Map_Route); - - snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE); - fd = mkstemp(buf); - if (fd < 0) - { - free(route); - return NULL; - } - - route->con_url = ecore_con_url_new(NULL); - route->ud.fname = strdup(buf); - INF("xml file : %s", route->ud.fname); - - route->ud.fd = fdopen(fd, "w+"); - if ((!route->con_url) || (!route->ud.fd)) - { - ecore_con_url_free(route->con_url); - free(route); - return NULL; - } - - route->wd = wd; - route->color.r = 255; - route->color.g = 0; - route->color.b = 0; - route->color.a = 255; - route->handlers = eina_list_append - (route->handlers, (void *)ecore_event_handler_add - (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route)); - - route->inbound = EINA_FALSE; - route->type = type; - route->method = method; - route->flon = flon; - route->flat = flat; - route->tlon = tlon; - route->tlat = tlat; - - switch (type) - { - case ELM_MAP_ROUTE_TYPE_MOTOCAR: - type_name = strdup(ROUTE_TYPE_MOTORCAR); - break; - case ELM_MAP_ROUTE_TYPE_BICYCLE: - type_name = strdup(ROUTE_TYPE_BICYCLE); - break; - case ELM_MAP_ROUTE_TYPE_FOOT: - type_name = strdup(ROUTE_TYPE_FOOT); - break; - default: - break; - } - - source = wd->src->route_url_cb(obj, type_name, method, flon, flat, tlon, tlat); - INF("route url = %s", source); - - wd->route = eina_list_append(wd->route, route); - - ecore_con_url_url_set(route->con_url, source); - ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd)); - ecore_con_url_data_set(route->con_url, route); - ecore_con_url_get(route->con_url); - if (type_name) free(type_name); - if (source) free(source); - - edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), - "elm,state,busy,start", "elm"); - evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL); - return route; -#else - (void) obj; - (void) type; - (void) method; - (void) flon; - (void) flat; - (void) tlon; - (void) tlat; - return NULL; -#endif + return; } EAPI void elm_map_route_remove(Elm_Map_Route *route) { -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(route); - - Path_Waypoint *w; - Path_Node *n; - Evas_Object *p; - Ecore_Event_Handler *h; - - EINA_LIST_FREE(route->path, p) - { - evas_object_del(p); - } - - EINA_LIST_FREE(route->waypoint, w) - { - if (w->point) eina_stringshare_del(w->point); - free(w); - } - - EINA_LIST_FREE(route->nodes, n) - { - if (n->pos.address) eina_stringshare_del(n->pos.address); - free(n); - } - - EINA_LIST_FREE(route->handlers, h) - { - ecore_event_handler_del(h); - } - - if (route->ud.fname) - { - ecore_file_remove(route->ud.fname); - free(route->ud.fname); - route->ud.fname = NULL; - } -#else - (void) route; -#endif -} - -EAPI void -elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(route); - route->color.r = r; - route->color.g = g; - route->color.b = b; - route->color.a = a; -#else - (void) route; - (void) r; - (void) g; - (void) b; - (void) a; -#endif -} - -EAPI void -elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(route); - if (r) *r = route->color.r; - if (g) *g = route->color.g; - if (b) *b = route->color.b; - if (a) *a = route->color.a; -#else - (void) route; - (void) r; - (void) g; - (void) b; - (void) a; -#endif -} - -EAPI double -elm_map_route_distance_get(const Elm_Map_Route *route) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0); - return route->info.distance; -#else - (void) route; - return 0.0; -#endif -} - -EAPI const char* -elm_map_route_node_get(const Elm_Map_Route *route) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL); - return route->info.nodes; -#else - (void) route; - return NULL; -#endif -} - -EAPI const char* -elm_map_route_waypoint_get(const Elm_Map_Route *route) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL); - return route->info.waypoints; -#else - (void) route; - return NULL; -#endif -} - -EAPI const char * -elm_map_name_address_get(const Elm_Map_Name *name) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); - return name->address; -#else - (void) name; - return NULL; -#endif -} - -EAPI void -elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(name); - if (lon) *lon = name->lon; - if (lat) *lat = name->lat; -#else - (void) name; - (void) lon; - (void) lat; -#endif + elm_map_route_del(route); } EAPI void elm_map_name_remove(Elm_Map_Name *name) { -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(name); - if (name->address) - { - free(name->address); - name->address = NULL; - } - if (name->handler) - { - ecore_event_handler_del(name->handler); - name->handler = NULL; - } - if (name->ud.fname) - { - ecore_file_remove(name->ud.fname); - free(name->ud.fname); - name->ud.fname = NULL; - } -#else - (void) name; -#endif + elm_map_name_del(name); } -EAPI void -elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); - - wd->rotate.d = degree; - wd->rotate.cx = cx; - wd->rotate.cy = cy; - - evas_object_smart_changed(wd->pan_smart); -#else - (void) obj; - (void) degree; - (void) cx; - (void) cy; -#endif -} - -EAPI void -elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); - - if (degree) *degree = wd->rotate.d; - if (cx) *cx = wd->rotate.cx; - if (cy) *cy = wd->rotate.cy; -#else - (void) obj; - (void) degree; - (void) cx; - (void) cy; -#endif -} - -EAPI void -elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); - - if ((!wd->wheel_disabled) && (disabled)) - evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj); - else if ((wd->wheel_disabled) && (!disabled)) - evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj); - wd->wheel_disabled = !!disabled; -#else - (void) obj; - (void) disabled; -#endif -} - -EAPI Eina_Bool -elm_map_wheel_disabled_get(const Evas_Object *obj) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE); - - return wd->wheel_disabled; -#else - (void) obj; - return EINA_FALSE; -#endif -} - -#ifdef ELM_EMAP -EAPI Evas_Object * -elm_map_track_add(Evas_Object *obj, EMap_Route *emap) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE); - - Evas_Object *route = elm_route_add(obj); - elm_route_emap_set(route, emap); - wd->track = eina_list_append(wd->track, route); - - return route; -#else - (void) obj; - (void) emap; - return NULL; -#endif -} -#endif - -EAPI void -elm_map_track_remove(Evas_Object *obj, Evas_Object *route) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) ; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN(wd); - - wd->track = eina_list_remove(wd->track, route); - evas_object_del(route); -#else - (void) obj; - (void) route; -#endif -} - -EAPI Elm_Map_Overlay * -elm_map_overlay_add(Evas_Object *obj, double lon, double lat) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); - - Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay); - overlay->wd = wd; - overlay->type = ELM_MAP_OVERLAY_TYPE_DEFAULT; - overlay->ovl = _overlay_default_new(wd, lon, lat, "radio"); - _overlay_default_cb_add(overlay->ovl, _overlay_clicked_cb, overlay); - overlay->grp = _overlay_group_new(wd); - wd->overlays = eina_list_append(wd->overlays, overlay); - - evas_object_smart_changed(wd->pan_smart); - return overlay; -#else - (void) obj; - (void) lon; - (void) lat; - return NULL; -#endif -} - -EAPI void -elm_map_overlay_del(Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) - { - _overlay_default_cb_del(overlay->ovl, _overlay_clicked_cb); - _overlay_default_free(overlay->ovl); - } - else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE) - { - _overlay_bubble_cb_del(overlay->ovl); - _overlay_bubble_free(overlay->ovl); - } - else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) - _overlay_class_free(overlay->ovl); - - if (overlay->grp) - { - _overlay_group_cb_del(overlay->grp); - _overlay_group_free(overlay->grp, overlay); - } - - overlay->wd->overlays = eina_list_remove(overlay->wd->overlays, overlay); - evas_object_smart_changed(overlay->wd->pan_smart); - - free(overlay); -#else - (void) overlay; -#endif -} - -EAPI Elm_Map_Overlay_Type -elm_map_overlay_type_get(Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, ELM_MAP_OVERLAY_TYPE_NONE); - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, ELM_MAP_OVERLAY_TYPE_NONE); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) ELM_MAP_OVERLAY_TYPE_NONE; - - return overlay->type; -#else - (void) overlay; - return OVERLAY_TYPE_NONE; -#endif -} - -EAPI void -elm_map_overlay_data_set(Elm_Map_Overlay *overlay, void *data) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - overlay->data = data; -#else - (void) overlay; - (void) data; -#endif -} - -EAPI void * -elm_map_overlay_data_get(const Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL); - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL; - - return overlay->data; -#else - (void) overlay; - return NULL; -#endif -} - -EAPI void -elm_map_overlay_hide_set(Elm_Map_Overlay *overlay, Eina_Bool hide) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - if (overlay->hide == !!hide) return; - overlay->hide = hide; - - evas_object_smart_changed(overlay->wd->pan_smart); -#else - (void) overlay; - (void) hide; -#endif -} - -EAPI Eina_Bool -elm_map_overlay_hide_get(const Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE; - - return overlay->hide; -#else - (void) overlay; - return EINA_FALSE; -#endif -} - -EAPI void -elm_map_overlay_displayed_zoom_min_set(Elm_Map_Overlay *overlay, int zoom) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - overlay->zoom_min = zoom; - evas_object_smart_changed(overlay->wd->pan_smart); -#else - (void) overlay; - (void) zoom; -#endif -} - -EAPI int -elm_map_overlay_displayed_zoom_min_get(const Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, 0); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) 0; - - return overlay->zoom_min; -#else - (void) overlay; - return 0; -#endif -} - -EAPI void -elm_map_overlay_paused_set(Elm_Map_Overlay *overlay, Eina_Bool paused) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - if (overlay->paused == !!paused) return; - overlay->paused = paused; - - evas_object_smart_changed(overlay->wd->pan_smart); -#else - (void) overlay; - (void) paused; -#endif -} - -EAPI Eina_Bool -elm_map_overlay_paused_get(const Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE); - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE; - - return overlay->paused; -#else - (void) overlay; - return EINA_FALSE; -#endif -} - -EAPI void -elm_map_overlay_show(Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) - { - Overlay_Default *ovl = overlay->ovl; - elm_map_geo_region_show(overlay->wd->obj, ovl->lon, ovl->lat); - } - else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE) - { - Overlay_Bubble *ovl = overlay->ovl; - elm_map_geo_region_show(overlay->wd->obj, ovl->lon, ovl->lat); - } - else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) - { - Overlay_Class *ovl = overlay->ovl; - double lon, lat, max_lo, min_lo, max_la, min_la; - _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la, &min_la); - lon = (max_lo + min_lo) / 2; - lat = (max_la + min_la) / 2; - elm_map_geo_region_show(overlay->wd->obj, lon, lat); - } - else ERR("Not supported overlay type: %d", overlay->type); - - evas_object_smart_changed(overlay->wd->pan_smart); -#else - (void) overlay; -#endif -} - -EAPI void -elm_map_overlays_show(Eina_List *overlays) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlays); - EINA_SAFETY_ON_FALSE_RETURN(eina_list_count(overlays)); - - Elm_Map_Overlay *overlay; - overlay = eina_list_data_get(overlays); - - Delayed_Data *data = ELM_NEW(Delayed_Data); - data->func = _overlays_show; - data->wd = overlay->wd; - data->overlays = eina_list_clone(overlays); - data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data); - evas_object_smart_changed(data->wd->pan_smart); -#else - (void) overlays; -#endif -} - -EAPI void -elm_map_overlay_geo_set(Elm_Map_Overlay *overlay, double lon, double lat) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) - { - Overlay_Default *ovl = overlay->ovl; - ovl->lon = lon; - ovl->lat = lat; - } - else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE) - { - Overlay_Bubble *ovl = overlay->ovl; - ovl->lon = lon; - ovl->lat = lat; - } - else ERR("Not supported overlay type: %d", overlay->type); - - evas_object_smart_changed(overlay->wd->pan_smart); -#else - (void) overlay; - (void) lon; - (void) lat; -#endif -} - -EAPI void -elm_map_overlay_geo_get(const Elm_Map_Overlay *overlay, double *lon, double *lat) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) - { - const Overlay_Default *ovl = overlay->ovl; - if (lon) *lon = ovl->lon; - if (lat) *lat = ovl->lat; - } - else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE) - { - const Overlay_Bubble *ovl = overlay->ovl; - if (lon) *lon = ovl->lon; - if (lat) *lat = ovl->lat; - } - else ERR("Not supported overlay type: %d", overlay->type); -#else - (void) overlay; - (void) lon; - (void) lat; -#endif -} - -EAPI void -elm_map_overlay_icon_set(Elm_Map_Overlay *overlay, Evas_Object *icon) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(icon); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) - _overlay_default_update(overlay->wd, overlay->ovl, NULL, icon, - NULL, NULL, NULL); - else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) - _overlay_class_update(overlay->wd, overlay->ovl, NULL, icon); - else ERR("Not supported overlay type: %d", overlay->type); - - evas_object_smart_changed(overlay->wd->pan_smart); -#else - (void) overlay; - (void) icon; -#endif -} - -EAPI const Evas_Object * -elm_map_overlay_icon_get(const Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL); - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL; - - if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) - { - const Overlay_Default *ovl = overlay->ovl; - return elm_object_part_content_get(ovl->layout, "elm.icon"); - } - else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) - { - const Overlay_Class *ovl = overlay->ovl; - return ovl->icon; - } - else - { - ERR("Not supported overlay type: %d", overlay->type); - return NULL; - } -#else - (void) overlay; - return NULL; -#endif -} - -EAPI void -elm_map_overlay_content_set(Elm_Map_Overlay *overlay, Evas_Object *obj) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(obj); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) - _overlay_default_update(overlay->wd, overlay->ovl, obj, NULL, NULL, - NULL, NULL); - else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) - _overlay_class_update(overlay->wd, overlay->ovl, obj, NULL); - else ERR("Not supported overlay type: %d", overlay->type); - - evas_object_smart_changed(overlay->wd->pan_smart); -#else - (void) overlay; - (void) obj; -#endif -} - -EAPI const Evas_Object * -elm_map_overlay_content_get(const Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL); - EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL; - - if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT) - { - const Overlay_Default *ovl = overlay->ovl; - return elm_object_part_content_get(ovl->layout, "elm.icon"); - } - else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) - { - const Overlay_Class *ovl = overlay->ovl; - return ovl->icon; - } - else - { - ERR("Not supported overlay type: %d", overlay->type); - return NULL; - } -#else - (void) overlay; - return NULL; -#endif -} - -EAPI void -elm_map_overlay_get_cb_set(Elm_Map_Overlay *overlay, Elm_Map_Overlay_Get_Cb get_cb, void *data) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(overlay->wd); - ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype); - - overlay->cb = get_cb; - overlay->cb_data = data; -#else - (void) overlay; - (void) get_cb; - (void) data; -#endif -} - -EAPI Elm_Map_Overlay * -elm_map_overlay_class_add(Evas_Object *obj) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); - - Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay); - overlay->wd = wd; - overlay->type = ELM_MAP_OVERLAY_TYPE_CLASS; - overlay->ovl = _overlay_class_new(wd, overlay); - overlay->grp = NULL; - wd->overlays = eina_list_append(wd->overlays, overlay); - - evas_object_smart_changed(wd->pan_smart); - return overlay; -#else - (void) obj; - return NULL; -#endif -} - -EAPI void -elm_map_overlay_class_append(Elm_Map_Overlay *group, Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(group); - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(group->wd); - ELM_CHECK_WIDTYPE(group->wd->obj, widtype); - EINA_SAFETY_ON_FALSE_RETURN(group->type == ELM_MAP_OVERLAY_TYPE_CLASS); - - if (overlay->type != ELM_MAP_OVERLAY_TYPE_DEFAULT) - { - ERR("Currently group supports only default overlays"); - return; - } - - Overlay_Class *ovl = group->ovl; - if (eina_list_data_find(ovl->members, overlay)) - { - ERR("Already added overlay into group"); - return; - } - ovl->members = eina_list_append(ovl->members, overlay); - overlay->grp->clas = group; - - evas_object_smart_changed(group->wd->pan_smart); -#else - (void) group; - (void) overlay; -#endif -} - -EAPI void -elm_map_overlay_class_remove(Elm_Map_Overlay *group, Elm_Map_Overlay *overlay) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(group); - EINA_SAFETY_ON_NULL_RETURN(overlay); - EINA_SAFETY_ON_NULL_RETURN(group->wd); - ELM_CHECK_WIDTYPE(group->wd->obj, widtype); - EINA_SAFETY_ON_FALSE_RETURN(group->type == ELM_MAP_OVERLAY_TYPE_CLASS); - - if (overlay->type != ELM_MAP_OVERLAY_TYPE_DEFAULT) - { - ERR("Currently group supports only default overlays"); - return; - } - Overlay_Class *ovl = group->ovl; - ovl->members = eina_list_remove(ovl->members, overlay); - overlay->grp->clas = NULL; - _overlay_group_update(group->wd, overlay->grp, NULL); - - evas_object_smart_changed(group->wd->pan_smart); -#else - (void) group; - (void) overlay; -#endif -} - -EAPI void -elm_map_overlay_class_zoom_max_set(Elm_Map_Overlay *group, int zoom) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(group); - EINA_SAFETY_ON_NULL_RETURN(group->wd); - ELM_CHECK_WIDTYPE(group->wd->obj, widtype); - EINA_SAFETY_ON_FALSE_RETURN(group->type == ELM_MAP_OVERLAY_TYPE_CLASS); - - Overlay_Class *ovl = group->ovl; - if (ovl->zoom_max == !!zoom) return; - ovl->zoom_max = zoom; - - evas_object_smart_changed(group->wd->pan_smart); -#else - (void) group; - (void) zoom; -#endif -} - -EAPI int -elm_map_overlay_class_zoom_max_get(const Elm_Map_Overlay *group) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN_VAL(group, OVERLAY_CLASS_ZOOM_MAX); - EINA_SAFETY_ON_NULL_RETURN_VAL(group->wd, OVERLAY_CLASS_ZOOM_MAX); - ELM_CHECK_WIDTYPE(group->wd->obj, widtype) OVERLAY_CLASS_ZOOM_MAX; - EINA_SAFETY_ON_FALSE_RETURN_VAL(group->type == ELM_MAP_OVERLAY_TYPE_CLASS, OVERLAY_CLASS_ZOOM_MAX); - - const Overlay_Class *ovl = group->ovl; - return ovl->zoom_max; -#else - (void) group; - return OVERLAY_CLASS_ZOOM_MAX; -#endif -} - -EAPI Elm_Map_Overlay * -elm_map_overlay_bubble_add(Evas_Object *obj) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL); - - Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay); - overlay->wd = wd; - overlay->type = ELM_MAP_OVERLAY_TYPE_BUBBLE; - overlay->ovl = _overlay_bubble_new(wd); - _overlay_bubble_cb_add(overlay->ovl, overlay); - overlay->grp = _overlay_group_new(wd); - wd->overlays = eina_list_append(wd->overlays, overlay); - - evas_object_smart_changed(wd->pan_smart); - return overlay; -#else - (void) obj; - return NULL; -#endif -} - -EAPI void -elm_map_overlay_bubble_follow(Elm_Map_Overlay *bubble, Elm_Map_Overlay *parent) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(bubble); - EINA_SAFETY_ON_NULL_RETURN(parent); - ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype); - EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE); - - Overlay_Bubble *ovl = bubble->ovl; - Evas_Object *pobj = _overlay_obj_get(parent); - if (!pobj) return; - - if (ovl->pobj) - { - evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_HIDE, - _overlay_bubble_hide_cb, ovl); - evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_SHOW, - _overlay_bubble_chase_cb, ovl); - evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_MOVE, - _overlay_bubble_chase_cb, ovl); - } - - ovl->pobj = pobj; - evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_HIDE, - _overlay_bubble_hide_cb, ovl); - evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_SHOW, - _overlay_bubble_chase_cb, ovl); - evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_MOVE, - _overlay_bubble_chase_cb, ovl); - - _overlay_bubble_chase(ovl); - evas_object_smart_changed(bubble->wd->pan_smart); -#else - (void) bubble; - (void) parent; -#endif -} - -EAPI void -elm_map_overlay_bubble_content_append(Elm_Map_Overlay *bubble, Evas_Object *content) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(bubble); - EINA_SAFETY_ON_NULL_RETURN(content); - ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype); - EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE); - - Overlay_Bubble *bb = bubble->ovl; - elm_box_pack_end(bb->bx, content); - - evas_object_smart_changed(bubble->wd->pan_smart); -#else - (void) bubble; - (void) content; -#endif -} - -EAPI void -elm_map_overlay_bubble_content_clear(Elm_Map_Overlay *bubble) -{ -#ifdef HAVE_ELEMENTARY_ECORE_CON - EINA_SAFETY_ON_NULL_RETURN(bubble); - ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype); - EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE); - - Overlay_Bubble *bb = bubble->ovl; - elm_box_clear(bb->bx); - - evas_object_smart_changed(bubble->wd->pan_smart); -#else - (void) bubble; -#endif -} diff --git a/legacy/elementary/src/lib/elm_map.h b/legacy/elementary/src/lib/elm_map.h index c2cc6127ab..26992d27e0 100644 --- a/legacy/elementary/src/lib/elm_map.h +++ b/legacy/elementary/src/lib/elm_map.h @@ -19,28 +19,29 @@ * * - "clicked" - This is called when a user has clicked the map without * dragging around. + * - "clicked,double" - This is called when a user has double-clicked + * the map. * - "press" - This is called when a user has pressed down on the map. * - "longpressed" - This is called when a user has pressed down on the map * for a long time without dragging around. - * - "clicked,double" - This is called when a user has double-clicked - * the map. - * - "load,detail" - Map detailed data load begins. - * - "loaded,detail" - This is called when all currently visible parts of - * the map are loaded. + * - "scroll" - the content has been scrolled (moved). + * - "scroll,drag,start" - dragging the contents around has started. + * - "scroll,drag,stop" - dragging the contents around has stopped. + * - "scroll,anim,start" - scrolling animation has started. + * - "scroll,anim,stop" - scrolling animation has stopped. * - "zoom,start" - Zoom animation started. * - "zoom,stop" - Zoom animation stopped. * - "zoom,change" - Zoom changed when using an auto zoom mode. - * - "scroll" - the content has been scrolled (moved). - * - "scroll,anim,start" - scrolling animation has started. - * - "scroll,anim,stop" - scrolling animation has stopped. - * - "scroll,drag,start" - dragging the contents around has started. - * - "scroll,drag,stop" - dragging the contents around has stopped. - * - "downloaded" - This is called when all currently required map images - * are downloaded. - * - "route,load" - This is called when route request begins. - * - "route,loaded" - This is called when route request ends. - * - "name,load" - This is called when name request begins. - * - "name,loaded- This is called when name request ends. + * - "tile,load" - A map tile image load begins. + * - "tile,loaded" - A map tile image load ends. + * - "tile,loaded,fail" - A map tile image load fails. + * - "route,load" - Route request begins. + * - "route,loaded" - Route request ends. + * - "route,loaded,fail" - Route request fails. + * - "name,load" - Name request begins. + * - "name,loaded" - Name request ends. + * - "name,loaded,fail" - Name request fails. + * - "overlay,clicked" - A overlay is clicked. * * Available style for map widget: * - @c "default" @@ -88,27 +89,21 @@ typedef enum } Elm_Map_Zoom_Mode; /** - * Set route service to be used. By default used source is - * #ELM_MAP_ROUTE_SOURCE_YOURS. + * Set type of a external source (provider). * - * @see elm_map_route_source_set() - * @see elm_map_route_source_get() + * @see elm_map_sources_get() + * @see elm_map_source_get() + * @see elm_map_source_set() * * @ingroup Map */ typedef enum { - ELM_MAP_ROUTE_SOURCE_YOURS, /**< Routing service http://www.yournavigation.org/ . Set by default.*/ - ELM_MAP_ROUTE_SOURCE_MONAV, /**< MoNav offers exact routing without heuristic assumptions. Its routing core is based on Contraction Hierarchies. It's not working with Map yet. */ - ELM_MAP_ROUTE_SOURCE_ORS, /**< Open Route Service: http://www.openrouteservice.org/ . It's not working with Map yet. */ - ELM_MAP_ROUTE_SOURCE_LAST -} Elm_Map_Route_Sources; - -typedef enum -{ - ELM_MAP_NAME_SOURCE_NOMINATIM, - ELM_MAP_NAME_SOURCE_LAST -} Elm_Map_Name_Sources; + ELM_MAP_SOURCE_TYPE_TILE, /**< Map tile provider. */ + ELM_MAP_SOURCE_TYPE_ROUTE, /**< Route service provider. */ + ELM_MAP_SOURCE_TYPE_NAME, /**< Name service provider. */ + ELM_MAP_SOURCE_TYPE_LAST +} Elm_Map_Source_Type; /** * Set type of transport used on route. @@ -139,6 +134,20 @@ typedef enum ELM_MAP_ROUTE_METHOD_LAST } Elm_Map_Route_Method; +/** + * Set the name search method. + * + * This is for name module interface. + * + * @ingroup Map + */ +typedef enum +{ + ELM_MAP_NAME_METHOD_SEARCH, + ELM_MAP_NAME_METHOD_REVERSE, + ELM_MAP_NAME_METHOD_LAST +} Elm_Map_Name_Method; + /** * Set overlay type to be used. This type is resolved * when the overlay is created. @@ -156,16 +165,10 @@ typedef enum _Elm_Map_Overlay_Type ELM_MAP_OVERLAY_TYPE_NONE = 0, ELM_MAP_OVERLAY_TYPE_DEFAULT, ELM_MAP_OVERLAY_TYPE_CLASS, - ELM_MAP_OVERLAY_TYPE_BUBBLE + ELM_MAP_OVERLAY_TYPE_BUBBLE, + ELM_MAP_OVERLAY_TYPE_ROUTE } Elm_Map_Overlay_Type; -typedef enum -{ - ELM_MAP_NAME_METHOD_SEARCH, - ELM_MAP_NAME_METHOD_REVERSE, - ELM_MAP_NAME_METHOD_LAST -} Elm_Map_Name_Method; - typedef struct _Elm_Map_Marker Elm_Map_Marker; /**< A marker to be shown in a specific point of the map. Can be created with elm_map_marker_add() and deleted with elm_map_marker_remove(). */ typedef struct _Elm_Map_Marker_Class Elm_Map_Marker_Class; /**< Each marker must be associated to a class. It's required to add a mark. The class defines the style of the marker when a marker is displayed alone (not grouped). A new class can be created with elm_map_marker_class_new(). */ typedef struct _Elm_Map_Group_Class Elm_Map_Group_Class; /**< Each marker must be associated to a group class. It's required to add a mark. The group class defines the style of the marker when a marker is grouped to other markers. Markers with the same group are grouped if they are close. A new group class can be created with elm_map_marker_group_class_new(). */ @@ -178,17 +181,18 @@ typedef void (*Elm_Map_Marker_Del_Func)(Evas_Object *obj, typedef Evas_Object *(*Elm_Map_Marker_Icon_Get_Func)(Evas_Object *obj, Elm_Map_Marker *marker, void *data); /**< Icon fetching class function for marker classes. */ typedef Evas_Object *(*Elm_Map_Group_Icon_Get_Func)(Evas_Object *obj, void *data); /**< Icon fetching class function for markers group classes. */ -typedef void (*Elm_Map_Overlay_Get_Cb)(void *data, Evas_Object *map, Elm_Map_Overlay *overlay); /**< Get callback function for the overlay. */ +typedef void (*Elm_Map_Overlay_Get_Cb)(void *data, Evas_Object *map, const Elm_Map_Overlay *overlay); /**< Get callback function for the overlay. */ +typedef void (*Elm_Map_Name_Cb)(void *data, Evas_Object *map, const Elm_Map_Name *name); /**< Async-callback function for the name request. */ +typedef void (*Elm_Map_Route_Cb)(void *data, Evas_Object *map, const Elm_Map_Route *route); /**< Async-callback function for the route request. */ -typedef char *(*Elm_Map_Module_Source_Func)(void); -typedef int (*Elm_Map_Module_Zoom_Min_Func)(void); -typedef int (*Elm_Map_Module_Zoom_Max_Func)(void); -typedef char *(*Elm_Map_Module_Url_Func)(Evas_Object *obj, int x, int y, int zoom); -typedef int (*Elm_Map_Module_Route_Source_Func)(void); -typedef char *(*Elm_Map_Module_Route_Url_Func)(Evas_Object *obj, char *type_name, int method, double flon, double flat, double tlon, double tlat); -typedef char *(*Elm_Map_Module_Name_Url_Func)(Evas_Object *obj, int method, char *name, double lon, double lat); -typedef Eina_Bool (*Elm_Map_Module_Geo_Into_Coord_Func)(const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y); -typedef Eina_Bool (*Elm_Map_Module_Coord_Into_Geo_Func)(const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat); +typedef char *(*Elm_Map_Module_Source_Name_Func)(void); +typedef int (*Elm_Map_Module_Tile_Zoom_Min_Func)(void); +typedef int (*Elm_Map_Module_Tile_Zoom_Max_Func)(void); +typedef char *(*Elm_Map_Module_Tile_Url_Func)(Evas_Object *obj, int x, int y, int zoom); +typedef Eina_Bool (*Elm_Map_Module_Tile_Geo_to_Coord_Func)(const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y); +typedef Eina_Bool (*Elm_Map_Module_Tile_Coord_to_Geo_Func)(const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat); +typedef char *(*Elm_Map_Module_Route_Url_Func)(Evas_Object *obj, const char *type_name, int method, double flon, double flat, double tlon, double tlat); +typedef char *(*Elm_Map_Module_Name_Url_Func)(Evas_Object *obj, int method, const char *name, double lon, double lat); /** * Add a new map widget to the given parent Elementary (container) object. @@ -210,8 +214,8 @@ EAPI Evas_Object *elm_map_add(Evas_Object *parent); * * This sets the zoom level. * - * It will respect limits defined by elm_map_source_zoom_min_set() and - * elm_map_source_zoom_max_set(). + * It will respect limits defined by elm_map_zoom_min_set() and + * elm_map_zoom_max_set(). * * By default these values are 0 (world map) and 18 (maximum zoom). * @@ -219,8 +223,8 @@ EAPI Evas_Object *elm_map_add(Evas_Object *parent); * #ELM_MAP_ZOOM_MODE_MANUAL. This is the default mode, and can be set * with elm_map_zoom_mode_set(). * - * @see elm_map_zoom_mode_set(). - * @see elm_map_zoom_get(). + * @see elm_map_zoom_mode_set() + * @see elm_map_zoom_get() * * @ingroup Map */ @@ -287,6 +291,54 @@ EAPI void elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_ */ EAPI Elm_Map_Zoom_Mode elm_map_zoom_mode_get(const Evas_Object *obj); +/** + * Set the minimum zoom of the source. + * + * @param obj The map object. + * @param zoom New minimum zoom value to be used. + * + * By default, it's 0. + * + * @ingroup Map + */ +EAPI void elm_map_zoom_min_set(Evas_Object *obj, int zoom); + +/** + * Get the minimum zoom of the source. + * + * @param obj The map object. + * @return Returns the minimum zoom of the source. + * + * @see elm_map_zoom_min_set() for details. + * + * @ingroup Map + */ +EAPI int elm_map_zoom_min_get(const Evas_Object *obj); + +/** + * Set the maximum zoom of the source. + * + * @param obj The map object. + * @param zoom New maximum zoom value to be used. + * + * By default, it's 18. + * + * @ingroup Map + */ +EAPI void elm_map_zoom_max_set(Evas_Object *obj, int zoom); + +/** + * Get the maximum zoom of the source. + * + * @param obj The map object. + * @return Returns the maximum zoom of the source. + * + * @see elm_map_zoom_min_set() for details. + * + * @ingroup Map + */ +EAPI int elm_map_zoom_max_get(const Evas_Object *obj); + /** * Get the current geographic coordinates of the map. * @@ -295,14 +347,14 @@ EAPI Elm_Map_Zoom_Mode elm_map_zoom_mode_get(const Evas_Object *obj); * @param lat Pointer to store latitude. * * This gets the current center coordinates of the map object. It can be - * set by elm_map_geo_region_bring_in() and elm_map_geo_region_show(). + * set by elm_map_region_bring_in() and elm_map_region_show(). * - * @see elm_map_geo_region_bring_in() - * @see elm_map_geo_region_show() + * @see elm_map_region_bring_in() + * @see elm_map_region_show() * * @ingroup Map */ -EAPI void elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat); +EAPI void elm_map_region_get(const Evas_Object *obj, double *lon, double *lat); /** * Animatedly bring in given coordinates to the center of the map. @@ -316,12 +368,12 @@ EAPI void elm_map_geo_region_get(const Evas_Object *obj, double * already centered. This will use animation to do so and take a period * of time to complete. * - * @see elm_map_geo_region_show() for a function to avoid animation. - * @see elm_map_geo_region_get() + * @see elm_map_region_show() for a function to avoid animation. + * @see elm_map_region_get() * * @ingroup Map */ -EAPI void elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat); +EAPI void elm_map_region_bring_in(Evas_Object *obj, double lon, double lat); /** * Show the given coordinates at the center of the map, @b immediately. @@ -334,12 +386,31 @@ EAPI void elm_map_geo_region_bring_in(Evas_Object *obj, double * region containing the given @p lat and @p lon, that will be moved to the * center of the map. * - * @see elm_map_geo_region_bring_in() for a function to move with animation. - * @see elm_map_geo_region_get() + * @see elm_map_region_bring_in() for a function to move with animation. + * @see elm_map_region_get() * * @ingroup Map */ -EAPI void elm_map_geo_region_show(Evas_Object *obj, double lon, double lat); +EAPI void elm_map_region_show(Evas_Object *obj, double lon, double lat); + +/** + * Convert canvas coordinates into a geographic coordinate + * (longitude, latitude). + * + * @param obj The map object. + * @param x horizontal coordinate of the point to convert. + * @param y vertical coordinate of the point to convert. + * @param lon A pointer to the longitude. + * @param lat A pointer to the latitude. + * + * This gets longitude and latitude from canvas x, y coordinates. The canvas + * coordinates mean x, y coordinate from current viewport. + * + * see elm_map_rotate_get() + * + * @ingroup Map + */ +EAPI void elm_map_canvas_to_region_convert(const Evas_Object *obj, const Evas_Coord x, const Evas_Coord y, double *lon, double *lat); /** * Pause or unpause the map. @@ -377,975 +448,6 @@ EAPI void elm_map_paused_set(Evas_Object *obj, Eina_Bool paused */ EAPI Eina_Bool elm_map_paused_get(const Evas_Object *obj); -/** - * Set to show markers during zoom level changes or not. - * - * @param obj The map object. - * @param paused Use @c EINA_TRUE to @b not show markers or @c EINA_FALSE - * to show them. - * - * This sets the paused state to on (@c EINA_TRUE) or off (@c EINA_FALSE) - * for map. - * - * The default is off. - * - * This will stop zooming using animation, changing zoom levels will - * change instantly. This will stop any existing animations that are running. - * - * This sets the paused state to on (@c EINA_TRUE) or off (@c EINA_FALSE) - * for the markers. - * - * The default is off. - * - * Enabling it will force the map to stop displaying the markers during - * zoom level changes. Set to on if you have a large number of markers. - * - * @see elm_map_paused_markers_get() - * - * @ingroup Map - */ -EAPI void elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused); - -/** - * Get a value whether markers will be displayed on zoom level changes or not - * - * @param obj The map object. - * @return @c EINA_TRUE means map @b won't display markers or @c EINA_FALSE - * indicates it will. - * - * This gets the current markers paused state for the map object. - * - * @see elm_map_paused_markers_set() for details. - * - * @ingroup Map - */ -EAPI Eina_Bool elm_map_paused_markers_get(const Evas_Object *obj); - -/** - * Get the information of downloading status. - * - * @param obj The map object. - * @param try_num Pointer to store number of tiles being downloaded. - * @param finish_num Pointer to store number of tiles successfully - * downloaded. - * - * This gets the current downloading status for the map object, the number - * of tiles being downloaded and the number of tiles already downloaded. - * - * @ingroup Map - */ -EAPI void elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num); - -/** - * Convert a pixel coordinate (x,y) into a geographic coordinate - * (longitude, latitude). - * - * @param obj The map object. - * @param x the coordinate. - * @param y the coordinate. - * @param size the size in pixels of the map. - * The map is a square and generally his size is : pow(2.0, zoom)*256. - * @param lon Pointer to store the longitude that correspond to x. - * @param lat Pointer to store the latitude that correspond to y. - * - * @note Origin pixel point is the top left corner of the viewport. - * Map zoom and size are taken on account. - * - * @see elm_map_utils_convert_geo_into_coord() if you need the inverse. - * - * @ingroup Map - */ -EAPI void elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat); - -/** - * Convert a geographic coordinate (longitude, latitude) into a pixel - * coordinate (x, y). - * - * @param obj The map object. - * @param lon the longitude. - * @param lat the latitude. - * @param size the size in pixels of the map. The map is a square - * and generally his size is : pow(2.0, zoom)*256. - * @param x Pointer to store the horizontal pixel coordinate that - * correspond to the longitude. - * @param y Pointer to store the vertical pixel coordinate that - * correspond to the latitude. - * - * @note Origin pixel point is the top left corner of the viewport. - * Map zoom and size are taken on account. - * - * @see elm_map_utils_convert_coord_into_geo() if you need the inverse. - * - * @ingroup Map - */ -EAPI void elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y); - -/** - * Convert a geographic coordinate (longitude, latitude) into a name - * (address). - * - * @param obj The map object. - * @param lon the longitude. - * @param lat the latitude. - * @return name A #Elm_Map_Name handle for this coordinate. - * - * To get the string for this address, elm_map_name_address_get() - * should be used. - * - * @see elm_map_utils_convert_name_into_coord() if you need the inverse. - * - * @ingroup Map - */ -EAPI Elm_Map_Name *elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat); - -/** - * Convert a name (address) into a geographic coordinate - * (longitude, latitude). - * - * @param obj The map object. - * @param address The address. - * @return name A #Elm_Map_Name handle for this address. - * - * To get the longitude and latitude, elm_map_name_region_get() - * should be used. - * - * @see elm_map_utils_convert_coord_into_name() if you need the inverse. - * - * @ingroup Map - */ -EAPI Elm_Map_Name *elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address); - -/** - * Convert canvas coordinates into a geographic coordinate - * (longitude, latitude). - * - * @param obj The map object. - * @param x horizontal coordinate of the point to convert. - * @param y vertical coordinate of the point to convert. - * @param lon A pointer to the longitude. - * @param lat A pointer to the latitude. - * - * This gets longitude and latitude from canvas x, y coordinates. The canvas - * coordinates mean x, y coordinate from current viewport. - * elm_map_utils_convert_coord_into_geo() internally to get the geographic - * location. - * - * see elm_map_rotate_get() - * see elm_map_utils_convert_coord_into_geo() - * - * @ingroup Map - */ -EAPI void elm_map_canvas_to_geo_convert(const Evas_Object *obj, const Evas_Coord x, const Evas_Coord y, double *lon, double *lat); - -/** - * Add a new marker to the map object. - * - * @param obj The map object. - * @param lon The longitude of the marker. - * @param lat The latitude of the marker. - * @param clas The class, to use when marker @b isn't grouped to others. - * @param clas_group The class group, to use when marker is grouped to others - * @param data The data passed to the callbacks. - * - * @return The created marker or @c NULL upon failure. - * - * A marker will be created and shown in a specific point of the map, defined - * by @p lon and @p lat. - * - * It will be displayed using style defined by @p class when this marker - * is displayed alone (not grouped). A new class can be created with - * elm_map_marker_class_new(). - * - * If the marker is grouped to other markers, it will be displayed with - * style defined by @p class_group. Markers with the same group are grouped - * if they are close. A new group class can be created with - * elm_map_marker_group_class_new(). - * - * Markers created with this method can be deleted with - * elm_map_marker_remove(). - * - * A marker can have associated content to be displayed by a bubble, - * when a user click over it, as well as an icon. These objects will - * be fetch using class' callback functions. - * - * @see elm_map_marker_class_new() - * @see elm_map_marker_group_class_new() - * @see elm_map_marker_remove() - * - * @ingroup Map - */ -EAPI Elm_Map_Marker *elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data); - -/** - * Set the maximum numbers of markers' content to be displayed in a group. - * - * @param obj The map object. - * @param max The maximum numbers of items displayed in a bubble. - * - * A bubble will be displayed when the user clicks over the group, - * and will place the content of markers that belong to this group - * inside it. - * - * A group can have a long list of markers, consequently the creation - * of the content of the bubble can be very slow. - * - * In order to avoid this, a maximum number of items is displayed - * in a bubble. - * - * By default this number is 30. - * - * Marker with the same group class are grouped if they are close. - * - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_max_marker_per_group_set(Evas_Object *obj, int max); - -/** - * Remove a marker from the map. - * - * @param marker The marker to remove. - * - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_marker_remove(Elm_Map_Marker *marker); - -/** - * Get the current coordinates of the marker. - * - * @param marker marker. - * @param lat Pointer to store the marker's latitude. - * @param lon Pointer to store the marker's longitude. - * - * These values are set when adding markers, with function - * elm_map_marker_add(). - * - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat); - -/** - * Animatedly bring in given marker to the center of the map. - * - * @param marker The marker to center at. - * - * This causes map to jump to the given @p marker's coordinates - * and show it (by scrolling) in the center of the viewport, if it is not - * already centered. This will use animation to do so and take a period - * of time to complete. - * - * @see elm_map_marker_show() for a function to avoid animation. - * @see elm_map_marker_region_get() - * - * @ingroup Map - */ -EAPI void elm_map_marker_bring_in(Elm_Map_Marker *marker); - -/** - * Show the given marker at the center of the map, @b immediately. - * - * @param marker The marker to center at. - * - * This causes map to @b redraw its viewport's contents to the - * region containing the given @p marker's coordinates, that will be - * moved to the center of the map. - * - * @see elm_map_marker_bring_in() for a function to move with animation. - * @see elm_map_markers_list_show() if more than one marker need to be - * displayed. - * @see elm_map_marker_region_get() - * - * @ingroup Map - */ -EAPI void elm_map_marker_show(Elm_Map_Marker *marker); - -/** - * Move and zoom the map to display a list of markers. - * - * @param markers A list of #Elm_Map_Marker handles. - * - * The map will be centered on the center point of the markers in the list. - * Then the map will be zoomed in order to fit the markers using the maximum - * zoom which allows display of all the markers. - * - * @warning All the markers should belong to the same map object. - * - * @see elm_map_marker_show() to show a single marker. - * @see elm_map_marker_bring_in() - * - * @ingroup Map - */ -EAPI void elm_map_markers_list_show(Eina_List *markers); - -/** - * Get the Evas object returned by the Elm_Map_Marker_Get_Func callback - * - * @param marker The marker which content should be returned. - * @return Return the evas object if it exists, else @c NULL. - * - * To set callback function #Elm_Map_Marker_Get_Func for the marker class, - * elm_map_marker_class_get_cb_set() should be used. - * - * This content is what will be inside the bubble that will be displayed - * when an user clicks over the marker. - * - * This returns the actual Evas object used to be placed inside - * the bubble. This may be @c NULL, as it may - * not have been created or may have been deleted, at any time, by - * the map. Do not modify this object (move, resize, - * show, hide, etc.), as the map is controlling it. This - * function is for querying, emitting custom signals or hooking - * lower level callbacks for events on that object. Do not delete - * this object under any circumstances. - * - * @ingroup Map - */ -EAPI Evas_Object *elm_map_marker_object_get(const Elm_Map_Marker *marker); - -/** - * Update the marker - * - * @param marker The marker to be updated. - * - * If a content is set to this marker, it will call function to delete it, - * #Elm_Map_Marker_Del_Func, and then will fetch the content again with - * #Elm_Map_Marker_Get_Func. - * - * These functions are set for the marker class with - * elm_map_marker_class_get_cb_set() and elm_map_marker_class_del_cb_set(). - * - * @ingroup Map - */ -EAPI void elm_map_marker_update(Elm_Map_Marker *marker); - -/** - * Close all the bubbles opened by the user. - * - * @param obj The map object. - * - * A bubble is displayed with a content fetched with #Elm_Map_Marker_Get_Func - * when the user clicks on a marker. - * - * This functions is set for the marker class with - * elm_map_marker_class_get_cb_set(). - * - * @ingroup Map - */ -EAPI void elm_map_bubbles_close(Evas_Object *obj); - -/** - * Create a new group class. - * - * @param obj The map object. - * @return Returns the new group class. - * - * Each marker must be associated to a group class. Markers in the same - * group are grouped if they are close. - * - * The group class defines the style of the marker when a marker is grouped - * to others markers. When it is alone, another class will be used. - * - * A group class will need to be provided when creating a marker with - * elm_map_marker_add(). - * - * Some properties and functions can be set by class, as: - * - style, with elm_map_group_class_style_set() - * - data - to be associated to the group class. It can be set using - * elm_map_group_class_data_set(). - * - min zoom to display markers, set with - * elm_map_group_class_zoom_displayed_set(). - * - max zoom to group markers, set using - * elm_map_group_class_zoom_grouped_set(). - * - visibility - set if markers will be visible or not, set with - * elm_map_group_class_hide_set(). - * - #Elm_Map_Group_Icon_Get_Func - used to fetch icon for markers group classes. - * It can be set using elm_map_group_class_icon_cb_set(). - * - * @see elm_map_marker_add() - * @see elm_map_group_class_style_set() - * @see elm_map_group_class_data_set() - * @see elm_map_group_class_zoom_displayed_set() - * @see elm_map_group_class_zoom_grouped_set() - * @see elm_map_group_class_hide_set() - * @see elm_map_group_class_icon_cb_set() - * - * @ingroup Map - */ -EAPI Elm_Map_Group_Class *elm_map_group_class_new(Evas_Object *obj); - -/** - * Set the marker's style of a group class. - * - * @param clas The group class. - * @param style The style to be used by markers. - * - * Each marker must be associated to a group class, and will use the style - * defined by such class when grouped to other markers. - * - * The following styles are provided by default theme: - * @li @c radio - blue circle - * @li @c radio2 - green circle - * @li @c empty - * - * @see elm_map_group_class_new() for more details. - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style); - -/** - * Set the icon callback function of a group class. - * - * @param clas The group class. - * @param icon_get The callback function that will return the icon. - * - * Each marker must be associated to a group class, and it can display a - * custom icon. The function @p icon_get must return this icon. - * - * @see elm_map_group_class_new() for more details. - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, Elm_Map_Group_Icon_Get_Func icon_get); - -/** - * Set the data associated to the group class. - * - * @param clas The group class. - * @param data The new user data. - * - * This data will be passed for callback functions, like icon get callback, - * that can be set with elm_map_group_class_icon_cb_set(). - * - * If a data was previously set, the object will lose the pointer for it, - * so if needs to be freed, you must do it yourself. - * - * @see elm_map_group_class_new() for more details. - * @see elm_map_group_class_icon_cb_set() - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data); - -/** - * Set the minimum zoom from where the markers are displayed. - * - * @param clas The group class. - * @param zoom The minimum zoom. - * - * Markers only will be displayed when the map is displayed at @p zoom - * or bigger. - * - * @see elm_map_group_class_new() for more details. - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom); - -/** - * Set the zoom from where the markers are no more grouped. - * - * @param clas The group class. - * @param zoom The maximum zoom. - * - * Markers only will be grouped when the map is displayed at - * less than @p zoom. - * - * @see elm_map_group_class_new() for more details. - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom); - -/** - * Set if the markers associated to the group class @p clas are hidden or not. - * - * @param clas The group class. - * @param hide Use @c EINA_TRUE to hide markers or @c EINA_FALSE - * to show them. - * - * @param obj The map object. - * If @p hide is @c EINA_TRUE the markers will be hidden, but default - * is to show them. - * - * @ingroup Map - */ -EAPI void elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide); - -/** - * Create a new marker class. - * - * @param obj The map object. - * @return Returns the new group class. - * - * Each marker must be associated to a class. - * - * The marker class defines the style of the marker when a marker is - * displayed alone, i.e., not grouped to to others markers. When grouped - * it will use group class style. - * - * A marker class will need to be provided when creating a marker with - * elm_map_marker_add(). - * - * Some properties and functions can be set by class, as: - * - style, with elm_map_marker_class_style_set() - * - #Elm_Map_Marker_Icon_Get_Func - used to fetch icon for markers classes. - * It can be set using elm_map_marker_class_icon_cb_set(). - * - #Elm_Map_Marker_Get_Func - used to fetch bubble content for marker classes. - * Set using elm_map_marker_class_get_cb_set(). - * - #Elm_Map_Marker_Del_Func - used to delete bubble content for marker classes. - * Set using elm_map_marker_class_del_cb_set(). - * - * @see elm_map_marker_add() - * @see elm_map_marker_class_style_set() - * @see elm_map_marker_class_icon_cb_set() - * @see elm_map_marker_class_get_cb_set() - * @see elm_map_marker_class_del_cb_set() - * - * @ingroup Map - */ -EAPI Elm_Map_Marker_Class *elm_map_marker_class_new(Evas_Object *obj); - -/** - * Set the marker's style of a marker class. - * - * @param clas The marker class. - * @param style The style to be used by markers. - * - * Each marker must be associated to a marker class, and will use the style - * defined by such class when alone, i.e., @b not grouped to other markers. - * - * The following styles are provided by default theme: - * @li @c radio - * @li @c radio2 - * @li @c empty - * - * @see elm_map_marker_class_new() for more details. - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style); - -/** - * Set the icon callback function of a marker class. - * - * @param clas The marker class. - * @param icon_get The callback function that will return the icon. - * - * Each marker must be associated to a marker class, and it can display a - * custom icon. The function @p icon_get must return this icon. - * - * @see elm_map_marker_class_new() for more details. - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, Elm_Map_Marker_Icon_Get_Func icon_get); - -/** - * Set the bubble content callback function of a marker class. - * - * @param clas The marker class. - * @param get The callback function that will return the content. - * - * Each marker must be associated to a marker class, and it can display a - * a content on a bubble that opens when the user click over the marker. - * The function @p get must return this content object. - * - * If this content will need to be deleted, elm_map_marker_class_del_cb_set() - * can be used. - * - * @see elm_map_marker_class_new() for more details. - * @see elm_map_marker_class_del_cb_set() - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, Elm_Map_Marker_Get_Func get); - -/** - * Set the callback function used to delete bubble content of a marker class. - * - * @param clas The marker class. - * @param del The callback function that will delete the content. - * - * Each marker must be associated to a marker class, and it can display a - * a content on a bubble that opens when the user click over the marker. - * The function to return such content can be set with - * elm_map_marker_class_get_cb_set(). - * - * If this content must be freed, a callback function need to be - * set for that task with this function. - * - * If this callback is defined it will have to delete (or not) the - * object inside, but if the callback is not defined the object will be - * destroyed with evas_object_del(). - * - * @see elm_map_marker_class_new() for more details. - * @see elm_map_marker_class_get_cb_set() - * @see elm_map_marker_add() - * - * @ingroup Map - */ -EAPI void elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, Elm_Map_Marker_Del_Func del); - -/** - * Get the list of available sources. - * - * @param obj The map object. - * @return The source names list. - * - * It will provide a list with all available sources, that can be set as - * current source with elm_map_source_name_set(), or get with - * elm_map_source_name_get(). - * - * Available sources: - * @li "Mapnik" - * @li "Osmarender" - * @li "CycleMap" - * @li "Maplint" - * - * @see elm_map_source_name_set() for more details. - * @see elm_map_source_name_get() - * - * @ingroup Map - */ -EAPI const char **elm_map_source_names_get(const Evas_Object *obj); - -/** - * Set the source of the map. - * - * @param obj The map object. - * @param source_name The source to be used. - * - * Map widget retrieves images that composes the map from a web service. - * This web service can be set with this method. - * - * A different service can return a different maps with different - * information and it can use different zoom values. - * - * The @p source_name need to match one of the names provided by - * elm_map_source_names_get(). - * - * The current source can be get using elm_map_source_name_get(). - * - * @see elm_map_source_names_get() - * @see elm_map_source_name_get() - * - * - * @ingroup Map - */ -EAPI void elm_map_source_name_set(Evas_Object *obj, const char *source_name); - -/** - * Get the name of currently used source. - * - * @param obj The map object. - * @return Returns the name of the source in use. - * - * @see elm_map_source_name_set() for more details. - * - * @ingroup Map - */ -EAPI const char *elm_map_source_name_get(const Evas_Object *obj); - -/** - * Set the source of the route service to be used by the map. - * - * @param obj The map object. - * @param source The route service to be used, being it one of - * #ELM_MAP_ROUTE_SOURCE_YOURS (default), #ELM_MAP_ROUTE_SOURCE_MONAV, - * and #ELM_MAP_ROUTE_SOURCE_ORS. - * - * Each one has its own algorithm, so the route retrieved may - * differ depending on the source route. Now, only the default is working. - * - * #ELM_MAP_ROUTE_SOURCE_YOURS is the routing service provided at - * http://www.yournavigation.org/. - * - * #ELM_MAP_ROUTE_SOURCE_MONAV, offers exact routing without heuristic - * assumptions. Its routing core is based on Contraction Hierarchies. - * - * #ELM_MAP_ROUTE_SOURCE_ORS, is provided at http://www.openrouteservice.org/ - * - * @see elm_map_route_source_get(). - * - * @ingroup Map - */ -EAPI void elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source); - -/** - * Get the current route source. - * - * @param obj The map object. - * @return The source of the route service used by the map. - * - * @see elm_map_route_source_set() for details. - * - * @ingroup Map - */ -EAPI Elm_Map_Route_Sources elm_map_route_source_get(const Evas_Object *obj); - -/** - * Set the minimum zoom of the source. - * - * @param obj The map object. - * @param zoom New minimum zoom value to be used. - * - * By default, it's 0. - * - * @ingroup Map - */ -EAPI void elm_map_source_zoom_min_set(Evas_Object *obj, int zoom); - -/** - * Get the minimum zoom of the source. - * - * @param obj The map object. - * @return Returns the minimum zoom of the source. - * - * @see elm_map_source_zoom_min_set() for details. - * - * @ingroup Map - */ -EAPI int elm_map_source_zoom_min_get(const Evas_Object *obj); - -/** - * Set the maximum zoom of the source. - * - * @param obj The map object. - * @param zoom New maximum zoom value to be used. - * - * By default, it's 18. - * - * @ingroup Map - */ -EAPI void elm_map_source_zoom_max_set(Evas_Object *obj, int zoom); - -/** - * Get the maximum zoom of the source. - * - * @param obj The map object. - * @return Returns the maximum zoom of the source. - * - * @see elm_map_source_zoom_min_set() for details. - * - * @ingroup Map - */ -EAPI int elm_map_source_zoom_max_get(const Evas_Object *obj); - -/** - * Set the user agent used by the map object to access routing services. - * - * @param obj The map object. - * @param user_agent The user agent to be used by the map. - * - * User agent is a client application implementing a network protocol used - * in communications within a client–server distributed computing system - * - * The @p user_agent identification string will transmitted in a header - * field @c User-Agent. - * - * @see elm_map_user_agent_get() - * - * @ingroup Map - */ -EAPI void elm_map_user_agent_set(Evas_Object *obj, const char *user_agent); - -/** - * Get the user agent used by the map object. - * - * @param obj The map object. - * @return The user agent identification string used by the map. - * - * @see elm_map_user_agent_set() for details. - * - * @ingroup Map - */ -EAPI const char *elm_map_user_agent_get(const Evas_Object *obj); - -/** - * Add a new route to the map object. - * - * @param obj The map object. - * @param type The type of transport to be considered when tracing a route. - * @param method The routing method, what should be prioritized. - * @param flon The start longitude. - * @param flat The start latitude. - * @param tlon The destination longitude. - * @param tlat The destination latitude. - * - * @return The created route or @c NULL upon failure. - * - * A route will be traced by point on coordinates (@p flat, @p flon) - * to point on coordinates (@p tlat, @p tlon), using the route service - * set with elm_map_route_source_set(). - * - * It will take @p type on consideration to define the route, - * depending if the user will be walking or driving, the route may vary. - * One of #ELM_MAP_ROUTE_TYPE_MOTOCAR, #ELM_MAP_ROUTE_TYPE_BICYCLE, or - * #ELM_MAP_ROUTE_TYPE_FOOT need to be used. - * - * Another parameter is what the route should prioritize, the minor distance - * or the less time to be spend on the route. So @p method should be one - * of #ELM_MAP_ROUTE_METHOD_SHORTEST or #ELM_MAP_ROUTE_METHOD_FASTEST. - * - * Routes created with this method can be deleted with - * elm_map_route_remove(), colored with elm_map_route_color_set(), - * and distance can be get with elm_map_route_distance_get(). - * - * @see elm_map_route_remove() - * @see elm_map_route_color_set() - * @see elm_map_route_distance_get() - * @see elm_map_route_source_set() - * - * @ingroup Map - */ -EAPI Elm_Map_Route *elm_map_route_add(Evas_Object *obj, Elm_Map_Route_Type type, Elm_Map_Route_Method method, double flon, double flat, double tlon, double tlat); - -/** - * Remove a route from the map. - * - * @param route The route to remove. - * - * @see elm_map_route_add() - * - * @ingroup Map - */ -EAPI void elm_map_route_remove(Elm_Map_Route *route); - -/** - * Set the route color. - * - * @param route The route object. - * @param r Red channel value, from 0 to 255. - * @param g Green channel value, from 0 to 255. - * @param b Blue channel value, from 0 to 255. - * @param a Alpha channel value, from 0 to 255. - * - * It uses an additive color model, so each color channel represents - * how much of each primary colors must to be used. 0 represents - * absence of this color, so if all of the three are set to 0, - * the color will be black. - * - * These component values should be integers in the range 0 to 255, - * (single 8-bit byte). - * - * This sets the color used for the route. By default, it is set to - * solid red (r = 255, g = 0, b = 0, a = 255). - * - * For alpha channel, 0 represents completely transparent, and 255, opaque. - * - * @see elm_map_route_color_get() - * - * @ingroup Map - */ -EAPI void elm_map_route_color_set(Elm_Map_Route *route, int r, int g, int b, int a); - -/** - * Get the route color. - * - * @param route The route object. - * @param r Pointer to store the red channel value. - * @param g Pointer to store the green channel value. - * @param b Pointer to store the blue channel value. - * @param a Pointer to store the alpha channel value. - * - * @see elm_map_route_color_set() for details. - * - * @ingroup Map - */ -EAPI void elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g, int *b, int *a); - -/** - * Get the route distance in kilometers. - * - * @param route The route object. - * @return The distance of route (unit : km). - * - * @ingroup Map - */ -EAPI double elm_map_route_distance_get(const Elm_Map_Route *route); - -/** - * Get the information of route nodes. - * - * @param route The route object. - * @return Returns a string with the nodes of route. - * - * @ingroup Map - */ -EAPI const char *elm_map_route_node_get(const Elm_Map_Route *route); - -/** - * Get the information of route waypoint. - * - * @param route the route object. - * @return Returns a string with information about waypoint of route. - * - * @ingroup Map - */ -EAPI const char *elm_map_route_waypoint_get(const Elm_Map_Route *route); - -/** - * Get the address of the name. - * - * @param name The name handle. - * @return Returns the address string of @p name. - * - * This gets the coordinates of the @p name, created with one of the - * conversion functions. - * - * @see elm_map_utils_convert_name_into_coord() - * @see elm_map_utils_convert_coord_into_name() - * - * @ingroup Map - */ -EAPI const char *elm_map_name_address_get(const Elm_Map_Name *name); - -/** - * Get the current coordinates of the name. - * - * @param name The name handle. - * @param lat Pointer to store the latitude. - * @param lon Pointer to store The longitude. - * - * This gets the coordinates of the @p name, created with one of the - * conversion functions. - * - * @see elm_map_utils_convert_name_into_coord() - * @see elm_map_utils_convert_coord_into_name() - * - * @ingroup Map - */ -EAPI void elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat); - -/** - * Remove a name from the map. - * - * @param name The name to remove. - * - * Basically the struct handled by @p name will be freed, so conversions - * between address and coordinates will be lost. - * - * @see elm_map_utils_convert_name_into_coord() - * @see elm_map_utils_convert_coord_into_name() - * - * @ingroup Map - */ -EAPI void elm_map_name_remove(Elm_Map_Name *name); - /** * Rotate the map. * @@ -1407,30 +509,36 @@ EAPI void elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Boo */ EAPI Eina_Bool elm_map_wheel_disabled_get(const Evas_Object *obj); -#ifdef ELM_EMAP /** - * Add a track on the map + * Set the user agent used by the map object to access routing services. * * @param obj The map object. - * @param emap The emap route object. - * @return The route object. This is an elm object of type Route. + * @param user_agent The user agent to be used by the map. * - * @see elm_route_add() for details. + * User agent is a client application implementing a network protocol used + * in communications within a client–server distributed computing system + * + * The @p user_agent identification string will transmitted in a header + * field @c User-Agent. + * + * @see elm_map_user_agent_get() * * @ingroup Map */ -EAPI Evas_Object *elm_map_track_add(Evas_Object *obj, EMap_Route *emap); -#endif +EAPI void elm_map_user_agent_set(Evas_Object *obj, const char *user_agent); /** - * Remove a track from the map + * Get the user agent used by the map object. * * @param obj The map object. - * @param route The track to remove. + * @return The user agent identification string used by the map. + * + * @see elm_map_user_agent_set() for details. * * @ingroup Map */ -EAPI void elm_map_track_remove(Evas_Object *obj, Evas_Object *route); +EAPI const char *elm_map_user_agent_get(const Evas_Object *obj); + /** * Add a new overlay to the map object. This overlay has a default type. @@ -1491,7 +599,7 @@ EAPI void elm_map_overlay_del(Elm_Map_Overlay *overlay); * * @ingroup Map */ -EAPI Elm_Map_Overlay_Type elm_map_overlay_type_get(Elm_Map_Overlay *overlay); +EAPI Elm_Map_Overlay_Type elm_map_overlay_type_get(const Elm_Map_Overlay *overlay); /** * Set a pointer of user data for a overlay. @@ -1524,7 +632,7 @@ EAPI void * elm_map_overlay_data_get(const Elm_Map_Overlay *overl * @param overlay The overlay to be hidden. * @param hide Use @c EINA_TRUE to hide the overlay or @c EINA_FALSE to show. * - * @see elm_map_overlay_hide_get(). + * @see elm_map_overlay_hide_get() * * @ingroup Map */ @@ -1539,7 +647,7 @@ EAPI void elm_map_overlay_hide_set(Elm_Map_Overlay *overlay, Ei * * This gets the current hidden state for the overlay. * - * @see elm_map_overlay_hide_set(). + * @see elm_map_overlay_hide_set() * * @ingroup Map */ @@ -1554,7 +662,7 @@ EAPI Eina_Bool elm_map_overlay_hide_get(const Elm_Map_Overlay *overl * The overlay only will be displayed when the map is displayed at @p zoom * or bigger. * - * @see elm_map_overlay_displayed_zoom_min_get(). + * @see elm_map_overlay_displayed_zoom_min_get() * * @ingroup Map */ @@ -1566,7 +674,7 @@ EAPI void elm_map_overlay_displayed_zoom_min_set(Elm_Map_Overla * @param overlay The overlay to return the minimum zoom. * @return zoom The minimum zoom. * - * @see elm_map_overlay_displayed_zoom_min_set(). + * @see elm_map_overlay_displayed_zoom_min_set() * * @ingroup Map */ @@ -1602,7 +710,7 @@ EAPI void elm_map_overlay_paused_set(Elm_Map_Overlay *overlay, * * This gets the current paused state for the overlay. * - * @see elm_map_overlay_paused_set(). + * @see elm_map_overlay_paused_set() * * @ingroup Map */ @@ -1627,7 +735,7 @@ EAPI Eina_Bool elm_map_overlay_paused_get(const Elm_Map_Overlay *ove * * If @p obj is @c NULL, content inside the overlay is deleted. * - * @see elm_map_overlay_content_get(). + * @see elm_map_overlay_content_get() * * @ingroup Map */ @@ -1648,7 +756,7 @@ EAPI void elm_map_overlay_content_set(Elm_Map_Overlay *overlay, * * The content can be set by elm_map_overlay_content_set(). * - * @see elm_map_overlay_content_set(). + * @see elm_map_overlay_content_set() * * @ingroup Map */ @@ -1669,7 +777,7 @@ EAPI const Evas_Object * elm_map_overlay_content_get(const Elm_Map_Overlay *ov * * If @p icon is @c NULL, icon inside the overlay will be deleted. * - * @see elm_map_overlay_icon_get(). + * @see elm_map_overlay_icon_get() * * @ingroup Map */ @@ -1689,7 +797,7 @@ EAPI void elm_map_overlay_icon_set(Elm_Map_Overlay *overlay, Ev * * The icon can be set by elm_map_overlay_icon_set(). * - * @see elm_map_overlay_icon_set(). + * @see elm_map_overlay_icon_set() * * @ingroup Map */ @@ -1705,13 +813,13 @@ EAPI const Evas_Object * elm_map_overlay_icon_get(const Elm_Map_Overlay *overl * Only default and bubble type overlay support this function. * * This sets the center coordinates of the overlay. It can be - * get by elm_map_overlay_geo_get(). + * get by elm_map_overlay_region_get(). * - * @see elm_map_overlay_geo_get() + * @see elm_map_overlay_region_get() * * @ingroup Map */ -EAPI void elm_map_overlay_geo_set(Elm_Map_Overlay *overlay, double lon, double lat); +EAPI void elm_map_overlay_region_set(Elm_Map_Overlay *overlay, double lon, double lat); /** * Get the geographic coordinates of the overlay. @@ -1723,13 +831,57 @@ EAPI void elm_map_overlay_geo_set(Elm_Map_Overlay *overlay, dou * Only default and bubble type overlay support this function. * * This returns the center coordinates of the overlay. It can be - * set by elm_map_overlay_geo_set(). + * set by elm_map_overlay_region_set(). * - * @see elm_map_overlay_geo_set() + * @see elm_map_overlay_region_set() * * @ingroup Map */ -EAPI void elm_map_overlay_geo_get(const Elm_Map_Overlay *overlay, double *lon, double *lat); +EAPI void elm_map_overlay_region_get(const Elm_Map_Overlay *overlay, double *lon, double *lat); + + +/** + * Set the object color of the overlay. + * + * @param overlay The overlay to be set color. + * @param r Red channel value, from 0 to 255. + * @param g Green channel value, from 0 to 255. + * @param b Blue channel value, from 0 to 255. + * @param a Alpha channel value, from 0 to 255. + * + * It uses an additive color model, so each color channel represents + * how much of each primary colors must to be used. 0 represents + * absence of this color, so if all of the three are set to 0, + * the color will be black. + * + * These component values should be integers in the range 0 to 255, + * (single 8-bit byte). + * + * This sets the color used for the overlay. By default, it is set to + * solid red (r = 255, g = 0, b = 0, a = 255). + * + * For alpha channel, 0 represents completely transparent, and 255, opaque. + * + * @see elm_map_overlay_color_get() + * + * @ingroup Map + */ +EAPI void elm_map_overlay_color_set(Elm_Map_Overlay *overlay, int r, int g, int b, int a); + +/** + * Get the object color of the overlay. + * + * @param overlay The overlay to return color. + * @param r Pointer to store the red channel value. + * @param g Pointer to store the green channel value. + * @param b Pointer to store the blue channel value. + * @param a Pointer to store the alpha channel value. + * + * @see elm_map_overlay_color_set() + * + * @ingroup Map + */ +EAPI void elm_map_overlay_color_get(const Elm_Map_Overlay *overlay, int *r, int *g, int *b, int *a); /** * Show the given overlay at the center of the map, immediately. @@ -1768,6 +920,7 @@ EAPI void elm_map_overlays_show(Eina_List *overlays); * * @param overlay The overlay to own the get callback function. * @param get_cb The callback function. + * @param data The user callback data. * * You can delete this callback function by setting @c NULL. * @@ -1835,7 +988,7 @@ EAPI void elm_map_overlay_class_remove(Elm_Map_Overlay *clas, E * Overlay members in the class only will be grouped when the map * is displayed at less than @p zoom. * - * @see elm_map_overlay_class_zoom_max_get(). + * @see elm_map_overlay_class_zoom_max_get() * * @ingroup Map */ @@ -1849,7 +1002,7 @@ EAPI void elm_map_overlay_class_zoom_max_set(Elm_Map_Overlay *c * * @return The maximum zoom. * - * @see elm_map_overlay_class_zoom_max_set(). + * @see elm_map_overlay_class_zoom_max_set() * * @ingroup Map */ @@ -1873,7 +1026,7 @@ EAPI int elm_map_overlay_class_zoom_max_get(const Elm_Map_Over * @see elm_map_overlay_del() * @see elm_map_overlay_add() * @see elm_map_overlay_class_add() - * @see elm_map_overlay_geo_set() + * @see elm_map_overlay_region_set() * @see elm_map_overlay_bubble_follow() * * @ingroup Map @@ -1923,5 +1076,292 @@ EAPI void elm_map_overlay_bubble_content_append(Elm_Map_Overlay EAPI void elm_map_overlay_bubble_content_clear(Elm_Map_Overlay *bubble); /** - * @} + * Add a new route overlay to the map object. + * This overlay has a route type. + * + * @param obj The map object to add a new overlay. + * @param route The route object to make a overlay. + * @return The created overlay or @c NULL upon failure. + * + * This overlay has a route style layout and icon or content can not + * be set. + * + * The color scheme can be changed by elm_map_overlay_content_set(). + * + * Overlay created with this method can be deleted with elm_map_overlay_del(). + * + * @see elm_map_overlay_del() + * @see elm_map_overlay_class_add() + * @see elm_map_overlay_content_set() + * @see elm_map_overlay_content_get() + * + * @ingroup Map */ +EAPI Elm_Map_Overlay * elm_map_overlay_route_add(Evas_Object *obj, const Elm_Map_Route *route); + +/** + * Get the information of tile load status. + * + * @param obj The map object. + * @param try_num Pointer to store number of tiles download requested. + * @param finish_num Pointer to store number of tiles successfully downloaded. + * + * This gets the current tile loaded status for the map object. + * + * @ingroup Map + */ +EAPI void elm_map_tile_load_status_get(const Evas_Object *obj, int *try_num, int *finish_num); + +/** + * Get the names of available sources for a specific type. + * + * @param obj The map object. + * @param type source type. + * @return The char pointer array of source names. + * + * It will provide a list with all available sources. + * Current source can be set by elm_map_source_set(), or get with + * elm_map_source_get(). + * + * At least available sources of tile type: + * @li "Mapnik" + * @li "Osmarender" + * @li "CycleMap" + * @li "Maplint" + * + * At least available sources of route type: + * @li "Yours" + * + * At least available sources of name type: + * @li "Nominatim" + * + * @see elm_map_source_set() + * @see elm_map_source_get() + * + * @ingroup Map + */ +EAPI const char **elm_map_sources_get(const Evas_Object *obj, Elm_Map_Source_Type type); + +/** + * Set the current source of the map for a specific type. + * + * @param obj The map object. + * @param type source type. + * @param source_name The source to be used. + * + * Map widget retrieves tile images that composes the map from a web service. + * This web service can be set with this method + * for ELM_MAP_SOURCE_TYPE_TILE type. + * A different service can return a different maps with different + * information and it can use different zoom values. + * + * Map widget provides route data based on a external web service. + * This web service can be set with this method + * for ELM_MAP_SOURCE_TYPE_ROUTE type. + * + * Map widget also provide geoname data based on a external web service. + * This web service can be set with this method + * for ELM_MAP_SOURCE_TYPE_NAME type. + * + * The @p source_name need to match one of the names provided by + * elm_map_sources_get(). + * + * The current source can be get using elm_map_source_get(). + * + * @see elm_map_sources_get() + * @see elm_map_source_get() + * + * @ingroup Map + */ +EAPI void elm_map_source_set(Evas_Object *obj, Elm_Map_Source_Type type, const char *source_name); + +/** + * Get the name of currently used source for a specific type. + * + * @param obj The map object. + * @param type source type. + * @return Returns the name of the source in use. + * + * @see elm_map_sources_get() + * @see elm_map_source_set() + * + * @ingroup Map + */ +EAPI const char *elm_map_source_get(const Evas_Object *obj, Elm_Map_Source_Type type); + +/** + * Add a new route to the map object. + * + * @param obj The map object. + * @param type The type of transport to be considered when tracing a route. + * @param method The routing method, what should be prioritized. + * @param flon The start longitude. + * @param flat The start latitude. + * @param tlon The destination longitude. + * @param tlat The destination latitude. + * + * @return The created route or @c NULL upon failure. + * + * A route will be traced by point on coordinates (@p flat, @p flon) + * to point on coordinates (@p tlat, @p tlon), using the route service + * set with elm_map_route_source_set(). + * + * It will take @p type on consideration to define the route, + * depending if the user will be walking or driving, the route may vary. + * One of #ELM_MAP_ROUTE_TYPE_MOTOCAR, #ELM_MAP_ROUTE_TYPE_BICYCLE, or + * #ELM_MAP_ROUTE_TYPE_FOOT need to be used. + * + * Another parameter is what the route should prioritize, the minor distance + * or the less time to be spend on the route. So @p method should be one + * of #ELM_MAP_ROUTE_METHOD_SHORTEST or #ELM_MAP_ROUTE_METHOD_FASTEST. + * + * Routes created with this method can be deleted with + * elm_map_route_remove(), colored with elm_map_route_color_set(), + * and distance can be get with elm_map_route_distance_get(). + * + * @see elm_map_route_remove() + * @see elm_map_route_color_set() + * @see elm_map_route_distance_get() + * @see elm_map_route_source_set() + * + * @ingroup Map + */ +EAPI Elm_Map_Route *elm_map_route_add(Evas_Object *obj, Elm_Map_Route_Type type, Elm_Map_Route_Method method, double flon, double flat, double tlon, double tlat, Elm_Map_Route_Cb route_cb, void *data); + +/** + * Remove a route from the map. + * + * @param route The route to remove. + * + * @see elm_map_route_add() + * + * @ingroup Map + */ +EAPI void elm_map_route_del(Elm_Map_Route *route); + +/** + * Get the route distance in kilometers. + * + * @param route The route object. + * @return The distance of route (unit : km). + * + * @ingroup Map + */ +EAPI double elm_map_route_distance_get(const Elm_Map_Route *route); + +/** + * Get the information of route nodes. + * + * @param route The route object. + * @return Returns a string with the nodes of route. + * + * @ingroup Map + */ +EAPI const char *elm_map_route_node_get(const Elm_Map_Route *route); + +/** + * Get the information of route waypoint. + * + * @param route the route object. + * @return Returns a string with information about waypoint of route. + * + * @ingroup Map + */ +EAPI const char *elm_map_route_waypoint_get(const Elm_Map_Route *route); + +/** + * Request a address or geographic coordinates(longitude, latitude) + * from a given address or geographic coordinate(longitude, latitude). + * + * @param obj The map object. + * @param address The address. + * @param lon The longitude. + * @param lat The latitude. + * @param name_cb The callback function. + * @param data The user callback data. + * @return name A #Elm_Map_Name handle for this coordinate. + * + * If you want to get address from geographic coordinates, set input @p address + * as NULL and set @p lon, @p lat as you want to convert. + * If address is set except NULL, @p lon and @p lat are checked. + * + * To get the string for this address, elm_map_name_address_get() + * should be used after callback or "name,loaded" signal is called. + * + * To get the longitude and latitude, elm_map_name_region_get() + * should be used. + * + * @ingroup Map + */ +EAPI Elm_Map_Name *elm_map_name_add(const Evas_Object *obj, const char *address, double lon, double lat, Elm_Map_Name_Cb name_cb, void *data); + +/** + * Get the address of the name. + * + * @param name The name handle. + * @return Returns the address string of @p name. + * + * This gets the coordinates of the @p name, created with one of the + * conversion functions. + * + * @see elm_map_utils_convert_name_into_coord() + * @see elm_map_utils_convert_coord_into_name() + * + * @ingroup Map + */ +EAPI const char *elm_map_name_address_get(const Elm_Map_Name *name); + +/** + * Get the current coordinates of the name. + * + * @param name The name handle. + * @param lat Pointer to store the latitude. + * @param lon Pointer to store The longitude. + * + * This gets the coordinates of the @p name, created with one of the + * conversion functions. + * + * @see elm_map_utils_convert_name_into_coord() + * @see elm_map_utils_convert_coord_into_name() + * + * @ingroup Map + */ +EAPI void elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat); + +/** + * Remove a name from the map. + * + * @param name The name to remove. + * + * Basically the struct handled by @p name will be freed, so conversions + * between address and coordinates will be lost. + * + * @see elm_map_utils_convert_name_into_coord() + * @see elm_map_utils_convert_coord_into_name() + * + * @ingroup Map + */ +EAPI void elm_map_name_del(Elm_Map_Name *name); + +/** + * Add a track on the map + * + * @param obj The map object. + * @param emap The emap route object. + * @return The route object. This is an elm object of type Route. + * + * @see elm_route_add() for details. + * + * @ingroup Map + */ +EAPI Evas_Object *elm_map_track_add(Evas_Object *obj, void *emap); + +/** + * Remove a track from the map + * + * @param obj The map object. + * @param route The track to remove. + * + * @ingroup Map + */ +EAPI void elm_map_track_remove(Evas_Object *obj, Evas_Object *route); diff --git a/legacy/elementary/src/modules/test_map/mod.c b/legacy/elementary/src/modules/test_map/mod.c index 8466aa3169..a075cdd2a0 100644 --- a/legacy/elementary/src/modules/test_map/mod.c +++ b/legacy/elementary/src/modules/test_map/mod.c @@ -5,25 +5,25 @@ #endif EAPI char * -map_module_source_get(void) +map_module_source_name_get(void) { return strdup("test_map"); } EAPI int -map_module_zoom_min_get(void) +map_module_tile_zoom_min_get(void) { return 0; } EAPI int -map_module_zoom_max_get(void) +map_module_tile_zoom_max_get(void) { return 18; } EAPI char * -map_module_url_get(Evas_Object *obj __UNUSED__, int x, int y, int zoom) +map_module_tile_url_get(Evas_Object *obj __UNUSED__, int x, int y, int zoom) { char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png", @@ -31,32 +31,32 @@ map_module_url_get(Evas_Object *obj __UNUSED__, int x, int y, int zoom) return strdup(buf); } -EAPI int +EAPI char * map_module_route_source_get(void) { - return 0; + return NULL; } EAPI char * -map_module_route_url_get(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__) +map_module_route_url_get(Evas_Object *obj __UNUSED__, const char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__) { return strdup(""); } EAPI char * -map_module_name_url_get(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__) +map_module_name_url_get(Evas_Object *obj __UNUSED__, int method __UNUSED__, const char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__) { return strdup(""); } EAPI Eina_Bool -map_module_geo_into_coord(const Evas_Object *obj __UNUSED__, int zoom __UNUSED__, double lon __UNUSED__, double lat __UNUSED__, int size __UNUSED__, int *x __UNUSED__, int *y __UNUSED__) +map_module_tile_geo_to_coord(const Evas_Object *obj __UNUSED__, int zoom __UNUSED__, double lon __UNUSED__, double lat __UNUSED__, int size __UNUSED__, int *x __UNUSED__, int *y __UNUSED__) { return EINA_FALSE; } EAPI Eina_Bool -map_module_coord_into_geo(const Evas_Object *obj __UNUSED__, int zoom __UNUSED__, int x __UNUSED__, int y __UNUSED__, int size __UNUSED__, double *lon __UNUSED__, double *lat __UNUSED__) +map_module_tile_coord_to_geo(const Evas_Object *obj __UNUSED__, int zoom __UNUSED__, int x __UNUSED__, int y __UNUSED__, int size __UNUSED__, double *lon __UNUSED__, double *lat __UNUSED__) { return EINA_FALSE; }