#endif
#ifndef ELM_LIB_QUICKLAUNCH
+#define SOURCE_MAX 10
#define MARKER_MAX 1000
#define NAME_ENTRY_TEXT "Enter freeform address"
const char *file;
} Marker_Data;
+typedef struct Map_Source
+{
+ Evas_Object *map;
+ char *source_name;
+} Map_Source;
static Elm_Map_Marker_Class *itc1, *itc2, *itc_parking;
static Elm_Map_Group_Class *itc_group1, *itc_group2, *itc_group_parking;
-static Evas_Object *rect;
+static Evas_Object *rect, *menu;
static int nb_elts;
-static Elm_Map_Marker *markers[MARKER_MAX];
+/*static Elm_Map_Marker *markers[MARKER_MAX];*/
static Elm_Map_Marker *route_from, *route_to;
static Elm_Map_Route *route;
static Elm_Map_Name *name;
-static Eina_List *names;
+static const char **source_names = NULL;
+static Evas_Coord old_x, old_y;
+static Evas_Coord old_d;
+static Map_Source ms[SOURCE_MAX];
Marker_Data data1 = {PACKAGE_DATA_DIR"/images/logo.png"};
Marker_Data data2 = {PACKAGE_DATA_DIR"/images/logo_small.png"};
evas_object_geometry_get(data, &ox, &oy, &w, &h);
zoom = elm_map_zoom_get(data);
elm_map_geo_region_get(obj, &lon, &lat);
- elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, zoom)*256, &x, &y);
+ elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, zoom) * 256, &x, &y);
x += down->output.x - (w / 2) - ox;
y += down->output.y - (h / 2) - oy;
- elm_map_utils_convert_coord_into_geo(obj, x, y, pow(2.0, zoom)*256, &lon, &lat);
+ elm_map_utils_convert_coord_into_geo(obj, x, y, pow(2.0, zoom) * 256, &lon, &lat);
name = elm_map_utils_convert_coord_into_name(data, lon, lat);
-
- itc1 = elm_map_marker_class_new(data);
-
- elm_map_marker_class_del_cb_set(itc1, NULL);
-
- itc_group1 = elm_map_group_class_new(data);
- elm_map_group_class_icon_cb_set(itc_group1, _group_icon_get);
- elm_map_group_class_data_set(itc_group1, (void *)PACKAGE_DATA_DIR"/images/bubble.png");
- elm_map_group_class_style_set(itc_group1, "empty");
- elm_map_group_class_zoom_displayed_set(itc_group1, 5);
-
- names = eina_list_append(names, elm_map_marker_add(data, lon, lat, itc1, itc_group1, NULL));
}
static void
evas_object_geometry_get(data, &ox, &oy, &w, &h);
zoom = elm_map_zoom_get(data);
- if (zoom<5) return;
+ if (zoom < 5) return;
size = pow(2.0, zoom) * 256;
elm_map_geo_region_get(obj, &lon, &lat);
elm_map_utils_convert_geo_into_coord(obj, lon, lat, size, &x, &y);
}
static void
-my_map_drag_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+my_map_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- printf("drag,start\n");
+ evas_object_smart_callback_del(data, "longpressed", my_map_longpressed);
}
static void
-my_map_drag_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+my_map_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- printf("drag_stop\n");
+ evas_object_smart_callback_add(data, "longpressed", my_map_longpressed, data);
}
static void
}
static void
-my_bt_show_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_show_seoul(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Eina_Bool b = elm_map_paused_get(data);
elm_map_paused_set(data, EINA_TRUE);
}
static void
-my_bt_bring_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_bring_seoul(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
elm_map_geo_region_bring_in(data, 126.977969, 37.566535);
}
static void
-my_bt_zoom_in(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_paused_set(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- double zoom;
-
- zoom = elm_map_zoom_get(data);
- zoom += 1;
- elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL);
- if (zoom >= (1.0 / 32.0)) elm_map_zoom_set(data, zoom);
-}
-
-static void
-my_bt_rotate_cw(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- double d;
- Evas_Coord x, y, w, h;
- float half_w, half_h;
- evas_object_geometry_get(data, &x, &y, &w, &h);
- half_w = (float)w * 0.5;
- half_h = (float)h * 0.5;
-
- elm_map_rotate_get(data, &d, NULL, NULL);
- d += 15.0;
- elm_map_rotate_set(data, d, x + half_w, y + half_h);
+ elm_map_paused_set(data, EINA_TRUE);
}
static void
-my_bt_rotate_ccw(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_paused_unset(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- double d;
- Evas_Coord x, y, w, h;
- float half_w, half_h;
- evas_object_geometry_get(data, &x, &y, &w, &h);
- half_w = (float)w * 0.5;
- half_h = (float)h * 0.5;
-
- elm_map_rotate_get(data, &d, NULL, NULL);
- d -= 15.0;
- elm_map_rotate_set(data, d, x + half_w, y + half_h);
+ elm_map_paused_set(data, EINA_FALSE);
}
static void
-my_bt_zoom_out(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_zoom_in(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- double zoom;
+ int zoom;
- zoom = elm_map_zoom_get(data);
- zoom -= 1;
+ zoom = elm_map_zoom_get(data) + 1;
elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL);
- if (zoom <= 256.0) elm_map_zoom_set(data, zoom);
+ elm_map_zoom_set(data, zoom);
}
static void
-my_bt_pause(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_zoom_out(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- elm_map_paused_set(data, !elm_map_paused_get(data));
-}
+ int zoom;
-static void
-my_bt_markers_pause(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- elm_map_paused_markers_set(data, !elm_map_paused_markers_get(data));
+ zoom = elm_map_zoom_get(data) - 1;
+ elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_MANUAL);
+ elm_map_zoom_set(data, zoom);
}
static void
-my_bt_zoom_fit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_zoom_fit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_AUTO_FIT);
}
static void
-my_bt_zoom_fill(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_zoom_fill(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
elm_map_zoom_mode_set(data, ELM_MAP_ZOOM_MODE_AUTO_FILL);
}
static void
-my_bt_source_mapnik(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_rotate_cw(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- elm_map_source_set(data, ELM_MAP_SOURCE_MAPNIK);
-}
+ double d;
+ Evas_Coord x, y, w, h;
+ float half_w, half_h;
+ evas_object_geometry_get(data, &x, &y, &w, &h);
+ half_w = (float)w * 0.5;
+ half_h = (float)h * 0.5;
-static void
-my_bt_source_osmarender(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- elm_map_source_set(data, ELM_MAP_SOURCE_OSMARENDER);
+ elm_map_rotate_get(data, &d, NULL, NULL);
+ d += 15.0;
+ elm_map_rotate_set(data, d, x + half_w, y + half_h);
}
static void
-my_bt_source_cyclemap(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_rotate_ccw(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- elm_map_source_set(data, ELM_MAP_SOURCE_CYCLEMAP);
+ double d;
+ Evas_Coord x, y, w, h;
+ float half_w, half_h;
+ evas_object_geometry_get(data, &x, &y, &w, &h);
+ half_w = (float)w * 0.5;
+ half_h = (float)h * 0.5;
+
+ elm_map_rotate_get(data, &d, NULL, NULL);
+ d -= 15.0;
+ elm_map_rotate_set(data, d, x + half_w, y + half_h);
}
static void
-my_bt_source_maplint(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_rotate_reset(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- elm_map_source_set(data, ELM_MAP_SOURCE_MAPLINT);
+ Evas_Coord x, y, w, h;
+ float half_w, half_h;
+ evas_object_geometry_get(data, &x, &y, &w, &h);
+ half_w = (float)w * 0.5;
+ half_h = (float)h * 0.5;
+
+ elm_map_rotate_set(data, 0.0, x + half_w, y + half_h);
}
static void
-my_bt_source_module(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_source(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- elm_map_source_set(data, ELM_MAP_SOURCE_MODULE);
+ Map_Source *ms = data;
+
+ if (!ms) return;
+ elm_map_source_name_set(ms->map, ms->source_name);
}
+/*
static void
-my_bt_add(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_marker_add(void *data)
{
int i;
Elm_Map_Group_Class *g_clas;
}
static void
-my_bt_remove(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+map_marker_remove(void *data __UNUSED__)
{
int i;
name = elm_map_utils_convert_name_into_coord(data, addr);
if (addr) free (addr);
}
+*/
static Evas_Object *
_marker_get(Evas_Object *obj, Elm_Map_Marker *marker __UNUSED__, void *data)
evas_object_move(rect,x,y);
}
+static void
+_populate(void *data, Elm_Menu_Item *item)
+{
+ int idx;
+
+ if ((!data) || (!item) || (!source_names)) return;
+ for (idx = 0; source_names[idx]; idx++)
+ {
+ if (idx >= SOURCE_MAX) break;
+ ms[idx].map = data;
+ ms[idx].source_name = strdup(source_names[idx]);
+ elm_menu_item_add(menu, item, "", source_names[idx], map_source, &ms[idx]);
+ }
+}
+
+static void
+_map_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
+{
+ Evas_Event_Mouse_Down *down = event_info;
+ Elm_Menu_Item *item;
+ if (!down) return;
+
+ if (down->button == 2)
+ {
+ old_x = down->output.x;
+ old_y = down->output.y;
+ old_d = 0.0;
+ }
+ else if (down->button == 3)
+ {
+ menu = elm_menu_add(obj);
+ item = elm_menu_item_add(menu, NULL, NULL, "Source", NULL, NULL);
+ _populate(data, item);
+ elm_menu_item_add(menu, NULL, NULL, "Show Seoul", map_show_seoul, data);
+ elm_menu_item_add(menu, NULL, NULL, "Bring Seoul", map_bring_seoul, data);
+ elm_menu_item_add(menu, NULL, NULL, "Paused Set", map_paused_set, data);
+ elm_menu_item_add(menu, NULL, NULL, "Paused Unset", map_paused_unset, data);
+ elm_menu_item_add(menu, NULL, NULL, "Zoom +", map_zoom_in, data);
+ elm_menu_item_add(menu, NULL, NULL, "Zoom -", map_zoom_out, data);
+ elm_menu_item_add(menu, NULL, NULL, "Zoom Fit", map_zoom_fit, data);
+ elm_menu_item_add(menu, NULL, NULL, "Zoom Fill", map_zoom_fill, data);
+ elm_menu_item_add(menu, NULL, NULL, "Add Marker", NULL, NULL);
+ elm_menu_item_add(menu, NULL, NULL, "Rotate CW", map_rotate_cw, data);
+ elm_menu_item_add(menu, NULL, NULL, "Rotate CCW", map_rotate_ccw, data);
+ elm_menu_item_add(menu, NULL, NULL, "Reset Rotate", map_rotate_reset, data);
+
+ elm_menu_move(menu, down->canvas.x, down->canvas.y);
+ evas_object_show(menu);
+ }
+}
+
+static void
+_map_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+{
+ Evas_Event_Mouse_Move *move = event_info;
+ Evas_Coord x, y, w, h;
+ float half_w, half_h;
+ int d, d_diff;
+ double cur_d;
+ if (!move) return;
+
+ if (move->buttons == 2)
+ {
+ evas_object_geometry_get(data, &x, &y, &w, &h);
+ half_w = (float)w * 0.5;
+ half_h = (float)h * 0.5;
+ elm_map_rotate_get(data, &cur_d, NULL, NULL);
+
+ d = move->cur.output.x - old_x;
+ if (!old_d) old_d = d;
+ else
+ {
+ d_diff = old_d - d;
+ if (d_diff > 0)
+ {
+ old_d --;
+ cur_d += 1.0;
+ }
+ else if (d_diff < 0)
+ {
+ old_d ++;
+ cur_d -= 1.0;
+ }
+ old_d = d;
+ elm_map_rotate_set(data, cur_d, x + half_w, y + half_h);
+ }
+ }
+}
+
+static void
+_map_mouse_up(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+{
+ Evas_Event_Mouse_Up *up = event_info;
+ if (!up) return;
+
+ if (up->button == 2)
+ {
+ old_x = 0;
+ old_y = 0;
+ }
+}
+
void
test_map(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- Evas_Object *win, *bg, *map, *tb2, *bt, *bx, *en;
+ Evas_Object *win, *bg, *map;
+ int idx = 0;
win = elm_win_add(NULL, "map", ELM_WIN_BASIC);
elm_win_title_set(win, "Map");
map = elm_map_add(win);
if (map)
{
- srand( time(NULL) );
+ srand(time(NULL));
+
+ source_names = elm_map_source_names_get(map);
+
+ if (!source_names) return;
+ printf("map sources [ ");
+ 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);
elm_win_resize_object_add(win, map);
_map_move_resize_cb, map);
evas_object_event_callback_add(map, EVAS_CALLBACK_MOVE,
_map_move_resize_cb, map);
+ evas_object_event_callback_add(map, EVAS_CALLBACK_MOUSE_DOWN,
+ _map_mouse_down, map);
+ evas_object_event_callback_add(map, EVAS_CALLBACK_MOUSE_MOVE,
+ _map_mouse_move, map);
+ evas_object_event_callback_add(map, EVAS_CALLBACK_MOUSE_UP,
+ _map_mouse_up, map);
elm_map_marker_add(map, 2.352, 48.857, itc1, itc_group1, &data1);
elm_map_marker_add(map, 2.355, 48.857, itc1, itc_group1, &data3);
evas_object_smart_callback_add(map, "zoom,change", my_map_zoom_change, win);
evas_object_smart_callback_add(map, "scroll,anim,start", my_map_anim_start, win);
evas_object_smart_callback_add(map, "scroll,anim,stop", my_map_anim_stop, win);
- evas_object_smart_callback_add(map, "scroll,drag,start", my_map_drag_start, win);
- evas_object_smart_callback_add(map, "scroll,drag,stop", my_map_drag_stop, win);
+ 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, win);
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, "name,loaded", my_map_name_loaded, map);
evas_object_show(map);
-
- tb2 = elm_table_add(win);
- evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, tb2);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Z -");
- evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_out, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.1, 0.1);
- elm_table_pack(tb2, bt, 0, 0, 1, 1);
- evas_object_show(bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Z +");
- evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_in, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.9, 0.1);
- elm_table_pack(tb2, bt, 2, 0, 1, 1);
- evas_object_show(bt);
-
- bx = elm_box_add(win);
- evas_object_show(bx);
- evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bx, 0.5, 0.1);
- elm_table_pack(tb2, bx, 1, 0, 1, 1);
-
- //
- en = elm_scrolled_entry_add(win);
- evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
- elm_scrolled_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
- elm_scrolled_entry_entry_set(en, NAME_ENTRY_TEXT);
- elm_scrolled_entry_single_line_set(en, 1);
- elm_box_pack_end(bx, en);
- evas_object_smart_callback_add(en, "focused", my_map_entry_focused, win);
- evas_object_smart_callback_add(en, "activated", my_map_entry_activated, map);
- evas_object_show(en);
-
- //
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Add 1000 markers");
- evas_object_smart_callback_add(bt, "clicked", my_bt_add, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.5, 0.1);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "remove 1000 markers");
- evas_object_smart_callback_add(bt, "clicked", my_bt_remove, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.5, 0.1);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
- //
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Show Seoul");
- evas_object_smart_callback_add(bt, "clicked", my_bt_show_reg, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.1, 0.5);
- elm_table_pack(tb2, bt, 0, 1, 1, 1);
- evas_object_show(bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Bring Seoul");
- evas_object_smart_callback_add(bt, "clicked", my_bt_bring_reg, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.9, 0.5);
- elm_table_pack(tb2, bt, 2, 1, 1, 1);
- evas_object_show(bt);
-
- //
- bx = elm_box_add(win);
- evas_object_show(bx);
- evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bx, 0.1, 0.9);
- elm_table_pack(tb2, bx, 0, 2, 1, 1);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Pause On/Off");
- evas_object_smart_callback_add(bt, "clicked", my_bt_pause, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.1, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Markers pause On/Off");
- evas_object_smart_callback_add(bt, "clicked", my_bt_markers_pause, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.1, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "R +");
- evas_object_smart_callback_add(bt, "clicked", my_bt_rotate_cw, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.1, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "R -");
- evas_object_smart_callback_add(bt, "clicked", my_bt_rotate_ccw, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.1, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
- //
-
- //
- bx = elm_box_add(win);
- evas_object_show(bx);
- evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bx, 0.5, 0.9);
- elm_table_pack(tb2, bx, 1, 2, 1, 1);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Fit");
- evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fit, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.5, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Fill");
- evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fill, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 0.5, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
- //
-
- //
- bx = elm_box_add(win);
- evas_object_show(bx);
- evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bx, 1.0, 0.9);
- elm_table_pack(tb2, bx, 2, 2, 1, 1);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Mapnik");
- evas_object_smart_callback_add(bt, "clicked", my_bt_source_mapnik, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 1.0, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Osmarender");
- evas_object_smart_callback_add(bt, "clicked", my_bt_source_osmarender, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 1.0, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Cycle Map");
- evas_object_smart_callback_add(bt, "clicked", my_bt_source_cyclemap, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 1.0, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Maplint");
- evas_object_smart_callback_add(bt, "clicked", my_bt_source_maplint, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 1.0, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
-
- bt = elm_button_add(win);
- elm_button_label_set(bt, "Module");
- evas_object_smart_callback_add(bt, "clicked", my_bt_source_module, map);
- evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(bt, 1.0, 0.9);
- evas_object_show(bt);
- elm_box_pack_end(bx, bt);
- //
-
- evas_object_show(tb2);
}
evas_object_resize(win, 800, 800);
typedef struct _Grid Grid;
typedef struct _Grid_Item Grid_Item;
typedef struct _Marker_Group Marker_Group;
-typedef struct _Mod_Api Mod_Api;
typedef struct _Event Event;
typedef struct _Route_Node Route_Node;
typedef struct _Route_Waypoint Route_Waypoint;
#define DEST_DIR_ZOOM_PATH "/tmp/elm_map/%d/%d/"
#define DEST_DIR_PATH DEST_DIR_ZOOM_PATH"%d/"
#define DEST_FILE_PATH "%s%d.png"
-#define MOD_AS "map/api"
#define DEST_ROUTE_XML_FILE "/tmp/elm_map-route-XXXXXX"
#define DEST_NAME_XML_FILE "/tmp/elm_map-name-XXXXXX"
#define NOMINATIM_ATTR_LON "lon"
#define NOMINATIM_ATTR_LAT "lat"
-#define PINCH_ZOOM_MIN 0.25
-#define PINCH_ZOOM_MAX 3.0
+#define PINCH_ZOOM_MIN 0.1
+#define PINCH_ZOOM_MAX 5.0
// 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
typedef struct _Map_Sources_Tab
{
- Elm_Map_Sources source;
const char *name;
int zoom_min;
int zoom_max;
- ElmMapSourceURLFunc url_cb;
+ ElmMapModuleUrlFunc url_cb;
Elm_Map_Route_Sources route_source;
- ElmMapRouteSourceURLFunc route_url_cb;
- ElmMapNameSourceURLFunc name_url_cb;
+ ElmMapModuleRouteUrlFunc route_url_cb;
+ ElmMapModuleNameUrlFunc name_url_cb;
+ ElmMapModuleGeoIntoCoordFunc geo_into_coord;
+ ElmMapModuleCoordIntoGeoFunc coord_into_geo;
} Map_Sources_Tab;
#define ZOOM_MAX 18
static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
static char *_maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char *_module_url_cb(Evas_Object *obj, int x, int y, int zoom);
-static char * _custom1_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char * _custom2_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char * _custom3_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char * _custom4_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char * _custom5_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char * _custom6_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 *_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 char *_route_custom1_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-static char *_route_custom2_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-static char *_route_custom3_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-static char *_route_custom4_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-static char *_route_custom5_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-static char *_route_custom6_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-/*
-static char *_route_module_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 *_name_custom1_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-static char *_name_custom2_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-static char *_name_custom3_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-static char *_name_custom4_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-static char *_name_custom5_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-static char *_name_custom6_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-
-static Map_Sources_Tab map_sources_tab[] =
-{
- {ELM_MAP_SOURCE_MAPNIK, "Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
- {ELM_MAP_SOURCE_OSMARENDER, "Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
- {ELM_MAP_SOURCE_CYCLEMAP, "Cycle Map", 0, 17, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
- {ELM_MAP_SOURCE_MAPLINT, "Maplint", 12, 16, _maplint_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_1, "Custom 1", 0, 18, _custom1_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_1, _route_custom1_url_cb, _name_custom1_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_2, "Custom 2", 0, 18, _custom2_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_2, _route_custom2_url_cb, _name_custom2_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_3, "Custom 3", 0, 18, _custom3_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_3, _route_custom3_url_cb, _name_custom3_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_4, "Custom 4", 0, 18, _custom4_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_4, _route_custom4_url_cb, _name_custom4_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_5, "Custom 5", 0, 18, _custom5_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_5, _route_custom5_url_cb, _name_custom5_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_6, "Custom 6", 0, 18, _custom6_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_6, _route_custom6_url_cb, _name_custom6_url_cb},
- {ELM_MAP_SOURCE_MODULE, "Module", 0, 18, _module_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb}
+
+static Map_Sources_Tab default_map_sources_tab[] =
+{
+ {"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, 17, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
+ {"Maplint", 12, 16, _maplint_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb, NULL, NULL},
};
struct _Url_Data
Ecore_Timer *scr_timer;
Ecore_Timer *long_timer;
Ecore_Animator *zoom_animator;
- double t_start, t_end;
+ double t;
struct {
int w, h;
int ow, oh, nw, nh;
Eina_List *groups_clas; // list of Elm_Map_Group_Class*
Eina_List *markers_clas; // list of Elm_Map_Markers_Class*
- Elm_Map_Sources source;
Elm_Map_Route_Sources route_source;
- Elm_Module *m;
Eina_List *s_event_list;
int try_num;
int finish_num;
double wheel_zoom;
Ecore_Timer *wheel_timer;
Eina_Bool wheel_disabled : 1;
-};
-struct _Mod_Api
-{
- Eina_Bool (*obj_hook) (Evas_Object *obj);
- Eina_Bool (*obj_unhook) (Evas_Object *obj);
- char * (*obj_url_request) (Evas_Object *obj, int x, int y, int zoom);
- Eina_Bool (*obj_convert_coord_into_geo) (const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat);
- Eina_Bool (*obj_convert_geo_into_coord) (const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y);
+ Eina_Array *modules;
+ Eina_List *map_sources_tab;
+ const char **source_names;
+ Evas_Map *map;
+ Ecore_Timer *zoom_timer;
+ Map_Sources_Tab *src;
};
+
struct _Pan
{
Evas_Object_Smart_Clipped_Data __clipped_data;
free(ev);
}
-static void
-module(Evas_Object *obj)
+static Eina_Bool
+module_list_cb(Eina_Module *m, void *data)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- const char *p, *pe;
+ ELM_CHECK_WIDTYPE(data, widtype) EINA_FALSE;
+ Widget_Data *wd = elm_widget_data_get(data);
+ Map_Sources_Tab *s;
+ ElmMapModuleSourceFunc source;
+ ElmMapModuleZoomMinFunc zoom_min;
+ ElmMapModuleZoomMaxFunc zoom_max;
+ ElmMapModuleUrlFunc url;
+ ElmMapModuleRouteSourceFunc route_source;
+ ElmMapModuleRouteUrlFunc route_url;
+ ElmMapModuleNameUrlFunc name_url;
+ ElmMapModuleGeoIntoCoordFunc geo_into_coord;
+ ElmMapModuleCoordIntoGeoFunc coord_into_geo;
+ const char *file;
- if (wd->m)
+ if (!wd) return EINA_FALSE;
+
+ file = eina_module_file_get(m);
+ if (!eina_module_load(m))
{
- Mod_Api *api = wd->m->api;
- if ((api) && (api->obj_unhook)) api->obj_unhook(obj);
- _elm_module_del(wd->m);
- wd->m = NULL;
+ ERR("could not load module \"%s\": %s", file, eina_error_msg_get(eina_error_get()));
+ return EINA_FALSE;
}
- p = _elm_config->modules;
- pe = p;
- for (;;)
+ 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))
{
- if ((*pe == ':') || (!*pe))
- {
- if (pe > p)
- {
- char *n = malloc(pe - p + 1);
- if (n)
- {
- char *nn;
+ ERR("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 = calloc(1, sizeof(Map_Sources_Tab));
+ EINA_SAFETY_ON_NULL_RETURN_VAL(s, EINA_FALSE);
+ 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->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
- strncpy(n, p, pe - p);
- n[pe - p] = 0;
- nn = strchr(n, '>');
- if (nn)
- {
- *nn = 0;
- nn++;
- if (!strcmp(nn, MOD_AS))
- {
- wd->m = _elm_module_add(n, nn);
- _elm_module_load(wd->m);
- }
- }
- free(n);
- }
- }
- if (!*pe) break;
- p = pe + 1;
- pe = p;
- }
- else
- pe++;
+ return EINA_TRUE;
+}
+
+static void
+module_init(void *data)
+{
+ ELM_CHECK_WIDTYPE(data, widtype);
+ Widget_Data *wd = elm_widget_data_get(data);
+
+ if (!wd) return;
+ wd->modules = eina_module_list_get(wd->modules, MODULES_PATH, 1, &module_list_cb, data);
+}
+
+static void
+source_init(void *data)
+{
+ ELM_CHECK_WIDTYPE(data, widtype);
+ Widget_Data *wd = elm_widget_data_get(data);
+ Map_Sources_Tab *s;
+ Eina_List *l;
+ int idx;
+
+ if (!wd) return;
+ for (idx = 0; idx < 4; idx++)
+ {
+ s = calloc(1, sizeof(Map_Sources_Tab));
+ EINA_SAFETY_ON_NULL_RETURN(s);
+ 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->map_sources_tab = eina_list_append(wd->map_sources_tab, s);
+ if (!idx) wd->src = s;
}
+ module_init(data);
- if (!wd->m) return;
- if (!wd->m->api) wd->m->api = malloc(sizeof(Mod_Api));
- ((Mod_Api *)(wd->m->api) )->obj_hook =
- _elm_module_symbol_get(wd->m, "obj_hook");
- ((Mod_Api *)(wd->m->api) )->obj_unhook =
- _elm_module_symbol_get(wd->m, "obj_unhook");
- ((Mod_Api *)(wd->m->api) )->obj_url_request =
- _elm_module_symbol_get(wd->m, "obj_url_request");
- ((Mod_Api *)(wd->m->api) )->obj_convert_coord_into_geo =
- _elm_module_symbol_get(wd->m, "obj_convert_coord_into_geo");
- ((Mod_Api *)(wd->m->api) )->obj_convert_geo_into_coord =
- _elm_module_symbol_get(wd->m, "obj_convert_geo_into_coord");
+ int n = eina_list_count(wd->map_sources_tab);
+ wd->source_names = malloc(sizeof(char *) * (n + 1));
+ if (!wd->source_names)
+ {
+ ERR("init source names failed.");
+ return;
+ }
+ idx = 0;
+ EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
+ {
+ wd->source_names[idx] = strdup(s->name);
+ INF("source : %s", wd->source_names[idx]);
+ idx++;
+ }
+ wd->source_names[idx] = NULL;
}
static void
wd->pinch.cy = wd->rotate.cy;
}
- Evas_Map *map = evas_map_new(4);
- if (!map) return;
-
- evas_map_util_points_populate_from_object_full(map, obj, 0);
- evas_map_util_zoom(map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy);
- evas_map_util_rotate(map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
+ evas_map_util_points_populate_from_object_full(wd->map, obj, 0);
+ evas_map_util_zoom(wd->map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy);
+ evas_map_util_rotate(wd->map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
evas_object_map_enable_set(obj, EINA_TRUE);
- evas_object_map_set(obj, map);
- evas_map_free(map);
+ evas_object_map_set(obj, wd->map);
}
static void
if (g_xx < 0) g_xx = 0;
g_yy = wd->pan_y / wd->tsize;
if (g_yy < 0) g_yy = 0;
- g_ww = ow / wd->tsize + 1;
+ g_ww = (ow / wd->tsize) + 1;
if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
- g_hh = oh / wd->tsize + 1;
+ g_hh = (oh / wd->tsize) + 1;
if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
//hide groups no more displayed
}
}
+ if (!wd->marker_zoom)
+ {
+ g_ww = 0;
+ g_hh = 0;
+ }
+
for (y = g_yy; y <= g_yy + g_hh; y++)
{
for (x = g_xx; x <= g_xx + g_ww; x++)
static Grid *
grid_create(Evas_Object *obj)
{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Grid *g;
+ if ((!wd) || (!wd->src)) return NULL;
g = calloc(1, sizeof(Grid));
g->zoom = wd->zoom;
g->tsize = wd->tsize;
g->wd = wd;
- if (g->zoom > map_sources_tab[wd->source].zoom_max) return NULL;
- if (g->zoom < map_sources_tab[wd->source].zoom_min) return NULL;
+ if (g->zoom > wd->src->zoom_max) return NULL;
+ if (g->zoom < wd->src->zoom_min) return NULL;
int size = pow(2.0, wd->zoom);
g->gw = size;
Eina_Matrixsparse_Cell *cell;
Grid_Item *gi;
- if (!wd) return;
+ if ((!wd) || (!wd->src)) return;
evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
}
eina_iterator_free(it);
- xx = wd->pan_x / size;
+ xx = wd->pan_x / size - 1;
if (xx < 0) xx = 0;
- yy = wd->pan_y / size;
+ yy = wd->pan_y / size - 1;
if (yy < 0) yy = 0;
- ww = ow / size + 1;
+ ww = ow / size + 2;
if (xx + ww >= g->gw) ww = g->gw - xx - 1;
- hh = oh / size + 1;
+ hh = oh / size + 2;
if (yy + hh >= g->gh) hh = g->gh - yy - 1;
for (y = yy; y <= yy + hh; y++)
snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y);
- source = map_sources_tab[wd->source].url_cb(obj, x, y, g->zoom);
+ source = wd->src->url_cb(obj, x, y, g->zoom);
if ((!source) || (strlen(source)==0)) continue;
eina_stringshare_replace(&gi->file, buf2);
}
}
-static void
-_grid_raise(Grid *g)
-{
- Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
- Eina_Matrixsparse_Cell *cell;
-
- g->wd->size.w = g->w;
- g->wd->size.h = g->h;
-
- EINA_ITERATOR_FOREACH(it, cell)
- {
- Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
- evas_object_raise(gi->img);
- //evas_object_raise(gi->txt);
- }
- eina_iterator_free(it);
-}
-
static Eina_Bool
_scr_timeout(void *data)
{
}
static Eina_Bool
+_zoom_timeout(void *data)
+{
+ ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
+ Widget_Data *wd = elm_widget_data_get(data);
+
+ if (!wd) return ECORE_CALLBACK_CANCEL;
+ wd->zoom_timer = NULL;
+ wd->pinch.level = 1.0;
+ zoom_do(data);
+ evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool
_zoom_anim(void *data)
{
ELM_CHECK_WIDTYPE(data, widtype) ECORE_CALLBACK_CANCEL;
Evas_Object *obj = data;
Widget_Data *wd = elm_widget_data_get(obj);
- double t;
if (!wd) return ECORE_CALLBACK_CANCEL;
- t = ecore_loop_time_get();
- if (t >= wd->t_end)
- t = 1.0;
- else if (wd->t_end > wd->t_start)
- t = (t - wd->t_start) / (wd->t_end - wd->t_start);
+ if (wd->zoom_method == ZOOM_METHOD_IN) wd->t += 0.1 ;
+ else if (wd->zoom_method == ZOOM_METHOD_OUT) wd->t -= 0.05;
else
- t = 1.0;
- if (wd->zoom_method == ZOOM_METHOD_IN) t = 1.0 + (t * t);
- else if (wd->zoom_method == ZOOM_METHOD_OUT) t = 1.0 - (t * t);
- else return ECORE_CALLBACK_CANCEL;
-
- if ((t >= 2.0) || (t <= 0.5))
{
wd->zoom_animator = NULL;
- wd->pinch.level = 1.0;
zoom_do(obj);
- evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
+ evas_object_smart_callback_call(data, SIG_ZOOM_STOP, NULL);
return ECORE_CALLBACK_CANCEL;
}
- else if (t != 1.0)
+
+ if (wd->t >= 2.0)
+ {
+ wd->zoom_animator = NULL;
+ wd->pinch.level = 2.0;
+ if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
+ wd->zoom_timer = ecore_timer_add(0.35, _zoom_timeout, obj);
+ return ECORE_CALLBACK_CANCEL;
+ }
+ else if (wd->t <= 0.5)
+ {
+ wd->zoom_animator = NULL;
+ wd->pinch.level = 0.5;
+ if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
+ wd->zoom_timer = ecore_timer_add(1.35, _zoom_timeout, obj);
+ return ECORE_CALLBACK_CANCEL;
+ }
+ else if (wd->t != 1.0)
{
Evas_Coord x, y, w, h;
float half_w, half_h;
half_h = (float)h * 0.5;
wd->pinch.cx = x + half_w;
wd->pinch.cy = y + half_h;
- wd->pinch.level = t;
+ wd->pinch.level = wd->t;
if (wd->calc_job) ecore_job_del(wd->calc_job);
wd->calc_job = ecore_job_add(_calc_job, wd);
}
Event *ev0;
if (!wd) return;
- if (ev->button == 2)
- {
- if (wd->wheel_timer) ecore_timer_del(wd->wheel_timer);
- wd->wheel_timer = ecore_timer_add(0.35, _wheel_timer_cb, data);
- return;
- }
-
ev0 = get_event_object(data, 0);
if (ev0) return;
ev0 = create_event_object(data, obj, 0);
Event *ev0;
Event *ev;
+ if ((!wd) || (!wd->src)) return;
ev = get_event_object(data, move->device);
if (!ev) return;
tt = wd->pinch.diff;
wd->pinch.diff = (double)(ev->pinch_dis - ev->pinch_start_dis);
t = (wd->pinch.diff * 0.01) + 1.0;
- if ((!wd->zoom) || ((wd->zoom + (int)t - 1) <= map_sources_tab[wd->source].zoom_min) ||
- ((wd->zoom + (int)t - 1) >= map_sources_tab[wd->source].zoom_max) ||
+ if (((wd->zoom + (int)t - 1) < wd->src->zoom_min) ||
+ ((wd->zoom + (int)t - 1) > wd->src->zoom_max) ||
(t > PINCH_ZOOM_MAX) || (t < PINCH_ZOOM_MIN))
{
wd->pinch.diff = tt;
Event *ev0;
Event *ev;
Eina_Bool tp;
- double t = 0.0;
+ int zoom = 0;
wd->multi_count--;
if (wd->calc_job) ecore_job_del(wd->calc_job);
}
tp = wd->paused;
wd->paused = EINA_TRUE;
- if (wd->pinch.diff >= 0.0) t = wd->pinch.diff * 0.01;
- else if (wd->pinch.diff < 0.0) t = -1.0 / ((wd->pinch.diff * 0.01) + 1.0);
- elm_map_zoom_set(data, wd->zoom + (int)ceil(t));
+ if (wd->pinch.diff >= 0.0) zoom = (int)ceil((wd->pinch.diff * 0.01) - 1.0);
+ else if (wd->pinch.diff < 0.0) zoom = (int)floor(-1.0 / ((wd->pinch.diff * 0.005) + 1.0));
+ elm_map_zoom_set(data, wd->zoom + zoom);
wd->pinch.level = 1.0;
wd->paused = tp;
wd->rotate.a = 0.0;
Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
Evas_Coord x, y, w, h;
float half_w, half_h;
+
+ if (!wd) return;
evas_object_geometry_get(data, &x, &y, &w, &h);
half_w = (float)w * 0.5;
half_h = (float)h * 0.5;
if (ev->z > 0)
{
wd->zoom_method = ZOOM_METHOD_OUT;
- wd->wheel_zoom -= 0.1;
+ wd->wheel_zoom -= 0.05;
if (wd->wheel_zoom <= PINCH_ZOOM_MIN) wd->wheel_zoom = PINCH_ZOOM_MIN;
}
else
{
wd->zoom_method = ZOOM_METHOD_IN;
- wd->wheel_zoom += 0.1;
+ wd->wheel_zoom += 0.2;
if (wd->wheel_zoom >= PINCH_ZOOM_MAX) wd->wheel_zoom = PINCH_ZOOM_MAX;
}
+ if (!wd->paused)
+ {
wd->pinch.level = wd->wheel_zoom;
wd->pinch.cx = x + half_w;
wd->pinch.cy = y + half_h;
if (wd->calc_job) ecore_job_del(wd->calc_job);
wd->calc_job = ecore_job_add(_calc_job, wd);
+ }
+
+ if (wd->wheel_timer) ecore_timer_del(wd->wheel_timer);
+ wd->wheel_timer = ecore_timer_add(0.35, _wheel_timer_cb, data);
}
Widget_Data *wd = elm_widget_data_get(data);
int zoom;
- wd->wheel_timer = NULL;
+ if (!wd)
+ {
+ wd->wheel_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
if (wd->zoom_method == ZOOM_METHOD_IN) zoom = (int)ceil(wd->wheel_zoom - 1.0);
else if (wd->zoom_method == ZOOM_METHOD_OUT) zoom = (int)floor((-1.0 / wd->wheel_zoom) + 1.0);
- else return ECORE_CALLBACK_CANCEL;
+ else
+ {
+ wd->wheel_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+ wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
elm_map_zoom_set(data, wd->zoom + zoom);
wd->wheel_zoom = 0.0;
+ wd->wheel_timer = NULL;
return ECORE_CALLBACK_CANCEL;
}
}
}
+ if (wd->map) evas_map_free(wd->map);
+ if (wd->source_names) free(wd->source_names);
if (wd->calc_job) ecore_job_del(wd->calc_job);
if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
if (wd->long_timer) ecore_timer_del(wd->long_timer);
- if ((wd->m) && (wd->m->api))
- {
- Mod_Api *api = wd->m->api;
- if (api->obj_unhook) api->obj_unhook(obj);
- }
if (wd->user_agent) eina_stringshare_del(wd->user_agent);
if (wd->ua) eina_hash_free(wd->ua);
Widget_Data *wd = data;
Evas_Coord minw, minh;
+ if (!wd) return;
minw = wd->size.w;
minh = wd->size.h;
if (wd->resized)
{
- wd->resized = 0;
+ wd->resized = EINA_FALSE;
if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
{
double tz = wd->zoom;
if (!sd) return;
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
if ((ow == w) && (oh == h)) return;
- sd->wd->resized = 1;
+ sd->wd->resized = EINA_TRUE;
if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
}
rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
EINA_LIST_FOREACH(sd->wd->grids, l, g)
{
- if (sd->wd->pinch.level == 1.0) grid_load(sd->wd->obj, g);
+ if ((sd->wd->pinch.level == 1.0) || (sd->wd->pinch.level == 0.5)) grid_load(sd->wd->obj, g);
grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
- double zoom;
+ int zoom;
Evas_Coord x = 0;
Evas_Coord y = 0;
Evas_Coord step_x = 0;
}
else if (!strcmp(ev->keyname, "KP_Add"))
{
- zoom = elm_map_zoom_get(obj);
- zoom += 1;
+ zoom = elm_map_zoom_get(obj) + 1;
elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
elm_map_zoom_set(obj, zoom);
return EINA_TRUE;
}
else if (!strcmp(ev->keyname, "KP_Subtract"))
{
- zoom = elm_map_zoom_get(obj);
- zoom -= 1;
+ zoom = elm_map_zoom_get(obj) - 1;
elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
elm_map_zoom_set(obj, zoom);
return EINA_TRUE;
attrs = eina_simple_xml_tag_attributes_find(value, length);
if (attrs)
{
- if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT)-1)) dump->id = NAME_XML_NAME;
+ if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME;
else dump->id = NAME_XML_NONE;
eina_simple_xml_attributes_parse
char *source;
int fd;
- if (!wd) return NULL;
+ if ((!wd) || (!wd->src)) return NULL;
Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
if (!name) return NULL;
name->lon = lon;
name->lat = lat;
- source = map_sources_tab[wd->source].name_url_cb(wd->obj, method, address, lon, lat);
+ source = wd->src->name_url_cb(wd->obj, method, address, lon, lat);
INF("name url = %s", source);
wd->names = eina_list_append(wd->names, name);
evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
+ source_init(obj);
wd->obj = obj;
+ wd->map = evas_map_new(4);
+ if (!wd->map) return NULL;
wd->markers_max_num = 30;
- wd->source = ELM_MAP_SOURCE_MAPNIK;
wd->pinch.level = 1.0;
evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
evas_object_show(wd->rect);
evas_object_color_set(wd->rect, 0, 0, 0, 0);
- wd->zoom = -1;
wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
wd->id = ((int)getpid() << 16) | idnum;
idnum++;
wd->tsize = 256;
-
edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
&minw, &minh);
evas_object_size_hint_min_set(obj, minw, minh);
+ wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
+ evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
+
wd->paused = EINA_TRUE;
elm_map_zoom_set(obj, 0);
wd->paused = EINA_FALSE;
-
_sizing_eval(obj);
- wd->calc_job = ecore_job_add(_calc_job, wd);
-
- wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
- evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
-
// TODO: convert Elementary to subclassing of Evas_Smart_Class
// TODO: and save some bytes, making descriptions per-class and not instance!
evas_object_smart_callbacks_descriptions_set(obj, _signals);
{
ERR("Ecore must be built with curl support for the map widget!");
}
+
return obj;
}
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- Eina_List *l, *lr;
+ Eina_List *l;
Grid *g, *g_zoom = NULL;
Evas_Coord rx, ry, rw, rh;
Evas_Object *p;
Elm_Map_Route *r;
- int z;
- int zoom_changed = 0, started = 0;
+ int z = 0, zoom_changed = 0, started = 0;
- if ((!wd) || (wd->zoom_animator)) return;
+ if ((!wd) || (!wd->src) || (wd->zoom_animator)) return;
if (zoom < 0 ) zoom = 0;
- if (zoom > map_sources_tab[wd->source].zoom_max)
- zoom = map_sources_tab[wd->source].zoom_max;
- if (zoom < map_sources_tab[wd->source].zoom_min)
- zoom = map_sources_tab[wd->source].zoom_min;
+ if (zoom > wd->src->zoom_max) zoom = wd->src->zoom_max;
+ if (zoom < wd->src->zoom_min) zoom = wd->src->zoom_min;
if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT;
else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN;
else wd->zoom_method = ZOOM_METHOD_NONE;
+ if (wd->zoom != zoom ) zoom_changed = 1;
wd->zoom = zoom;
wd->size.ow = wd->size.w;
wd->size.oh = wd->size.h;
elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
- EINA_LIST_FOREACH(wd->route, lr, r)
+ EINA_LIST_FOREACH(wd->route, l, r)
{
if (r)
{
}
}
- if (wd->mode == ELM_MAP_ZOOM_MODE_MANUAL)
- {
- wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
- wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
- }
- else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
+ if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
{
int p2w, p2h;
int cumulw, cumulh;
}
p2h--;
- if (p2w < p2h)
- z = p2w;
- else
- z = p2h;
-
- wd->zoom = z;
- wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
- wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
- }
- else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
- {
- int p2w, p2h;
- int cumulw, cumulh;
-
- cumulw = wd->tsize;
- p2w = 0;
- while (cumulw <= rw)
+ if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
{
- p2w++;
- cumulw *= 2;
+ if (p2w < p2h) z = p2w;
+ else z = p2h;
}
- p2w--;
-
- cumulh = wd->tsize;
- p2h = 0;
- while (cumulh <= rh)
+ else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
{
- p2h++;
- cumulh *= 2;
+ if (p2w > p2h) z = p2w;
+ else z = p2h;
}
- p2h--;
-
- if (p2w > p2h)
- z = p2w;
- else
- z = p2h;
-
wd->zoom = z;
- wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
- wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
}
+ wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
+ wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
- EINA_LIST_FOREACH(wd->grids, l, g)
- {
- if (g->zoom == wd->zoom)
- {
- _grid_raise(g);
- goto done;
- }
- }
g = grid_create(obj);
if (g)
{
free(g);
}
}
-done:
- wd->t_start = ecore_loop_time_get();
- wd->t_end = wd->t_start + _elm_config->zoom_friction;
+ wd->t = 1.0;
if ((wd->size.w > 0) && (wd->size.h > 0))
{
wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.ow;
wd->size.spos.x = 0.5;
wd->size.spos.y = 0.5;
}
+
if (rw > wd->size.ow) wd->size.spos.x = 0.5;
if (rh > wd->size.oh) wd->size.spos.y = 0.5;
if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
if (wd->paused)
{
zoom_do(obj);
+ if (wd->calc_job) ecore_job_del(wd->calc_job);
+ wd->calc_job = ecore_job_add(_calc_job, wd);
}
else
{
started = 1;
}
}
- if (wd->zoom_animator)
- {
- if (!_zoom_anim(obj))
- {
- ecore_animator_del(wd->zoom_animator);
- wd->zoom_animator = NULL;
- }
- }
- if (wd->calc_job) ecore_job_del(wd->calc_job);
- wd->calc_job = ecore_job_add(_calc_job, wd);
+
if (!wd->paused)
{
- if (started)
- evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
- if (!wd->zoom_animator)
- evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
+ if (started) evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
+ if (!wd->zoom_animator) evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
}
- if (zoom_changed)
- evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
+ if (zoom_changed) evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
}
/**
*
* @ingroup Map
*/
-EAPI double
+EAPI int
elm_map_zoom_get(const Evas_Object *obj)
{
- ELM_CHECK_WIDTYPE(obj, widtype) 1.0;
+ ELM_CHECK_WIDTYPE(obj, widtype) 0;
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return 1.0;
+ if (!wd) return 0;
return wd->zoom;
}
* elm_map_zoom_set() and will stay at that level until changed by code
* or until zoom mode is changed. This is the default mode.
* The Automatic modes will allow the map object to automatically
- * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT) will
+ * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT will
* adjust zoom so the map fits inside the scroll frame with no pixels
* outside this area. ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but
* ensure no pixels within the frame are left unfilled. Do not forget that the valid sizes are 2^zoom, consequently the map may be smaller than the scroller view.
if (!wd) return;
if (wd->mode == mode) return;
wd->mode = mode;
+
+ if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
{
- double tz = wd->zoom;
- wd->zoom = 0.0;
+ int tz = wd->zoom;
+ wd->zoom = 0;
elm_map_zoom_set(wd->obj, tz);
}
}
{
if (wd->zoom_animator)
{
- ecore_animator_del(wd->zoom_animator);
+ if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
wd->zoom_animator = NULL;
zoom_do(obj);
evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- int zoom = floor(log(size/256) / log(2));
-
- if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
- if ((wd->m) && (wd->m->api))
- {
- Mod_Api *api = wd->m->api;
- if ((api) && (api->obj_convert_coord_into_geo))
- if (api->obj_convert_coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
- }
+ 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)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- int zoom = floor(log(size/256) / log(2));
-
- if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
- if ((wd->m) && (wd->m->api))
- {
- Mod_Api *api = wd->m->api;
- if ((api) && (api->obj_convert_geo_into_coord))
- if (api->obj_convert_geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
- }
+ 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);
+ *y = floor((1.0 - log( tan(lat * ELM_PI / 180.0) + 1.0 / cos(lat * ELM_PI / 180.0)) / ELM_PI) / 2.0 * size);
}
/**
Widget_Data *wd;
EINA_SAFETY_ON_NULL_RETURN(markers);
-
EINA_LIST_FOREACH(markers, l, marker)
{
wd = marker->wd;
lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
- for (zoom = map_sources_tab[wd->source].zoom_max; zoom>map_sources_tab[wd->source].zoom_min; zoom--)
+ for (zoom = wd->src->zoom_max; zoom > wd->src->zoom_min; zoom--)
{
Evas_Coord size = pow(2.0, zoom)*wd->tsize;
elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
}
/**
+ * Get the list of the sources.
+ *
+ * @param obj The map object
+ * @return sources the source list
+ *
+ * @ingroup Map
+ */
+
+EAPI const char **
+elm_map_source_names_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ if (!wd) return NULL;
+ return wd->source_names;
+}
+
+/**
* Set the source of the map.
*
* Elm_Map retrieves the image which composed 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 value.
*
- * @param clas the group class
+ * @param obj the map object
* @param source the new source
*
* @ingroup Map
*/
EAPI void
-elm_map_source_set(Evas_Object *obj, Elm_Map_Sources source)
+elm_map_source_name_set(Evas_Object *obj, const char *source_name)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
+ Map_Sources_Tab *s;
+ Eina_List *l;
Grid *grid;
int zoom;
- Mod_Api *api = NULL;
if (!wd) return;
- _elm_config_sub_init();
- if (source == ELM_MAP_SOURCE_MODULE)
- {
- module(obj);
- api = wd->m->api;
- if ((api) && (api->obj_hook)) api->obj_hook(obj);
- }
-
- if (wd->source == source ) return;
- if (!map_sources_tab[source].url_cb) return;
+ if ((wd->src) && (!strcmp(wd->src->name, source_name))) return;
+ if ((wd->src) && (!wd->src->url_cb)) return;
EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid);
-
- wd->source = source;
+ EINA_LIST_FOREACH(wd->map_sources_tab, l, s)
+ {
+ if (!strcmp(s->name, source_name))
+ {
+ wd->src = s;
+ break;
+ }
+ }
zoom = wd->zoom;
wd->zoom = -1;
- if (map_sources_tab[wd->source].zoom_max < zoom)
- zoom = map_sources_tab[wd->source].zoom_max;
- if (map_sources_tab[wd->source].zoom_min > zoom)
- zoom = map_sources_tab[wd->source].zoom_min;
+ if (wd->src->zoom_max < zoom)
+ zoom = wd->src->zoom_max;
+ if (wd->src->zoom_min > zoom)
+ zoom = wd->src->zoom_min;
elm_map_zoom_set(obj, zoom);
}
/**
- * Set the source of the route.
+ * Get the name of a source.
*
- * @param clas the group class
- * @param source the new source
+ * @param source the source
+ * @return Returns the name of the source
*
* @ingroup Map
*/
-EAPI void
-elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
+EAPI const char *
+elm_map_source_name_get(const Evas_Object *obj)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- wd->source = source;
+ if ((!wd) || (!wd->src)) return NULL;
+ return wd->src->name;
}
/**
- * Get the current source
+ * Set the source of the route.
*
- * @param obj the map object
- * @return Returns the maximum zoom of the source
+ * @param clas the group class
+ * @param source the new source
*
* @ingroup Map
*/
-EAPI Elm_Map_Sources
-elm_map_source_get(const Evas_Object *obj)
+EAPI void
+elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
{
- ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_SOURCE_MAPNIK;
+ ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return ELM_MAP_SOURCE_MAPNIK;
- return wd->source;
+ if (!wd) return;
+ wd->route_source = source;
}
/**
}
/**
- * Set the API of a custom source.
- *
- * A custom web service can be associated to the source ELM_MAP_SOURCE_CUSTOM_(1..7).
- *
- * @param source the source ID (ELM_MAP_SOURCE_CUSTOM_(1..7))
- * @param name the name of the source
- * @param zoom_min the minimum zoom of the source, must be >= 0
- * @param zoom_max the maximum zoom of the source, must be <= ZOOM_MAX
- * @param url_cb the callback used to create the url from where a tile (png or jpeg file) is downloaded.
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_source_custom_api_set(Elm_Map_Sources source, const char *name, int zoom_min, int zoom_max, ElmMapSourceURLFunc url_cb, ElmMapRouteSourceURLFunc route_url_cb, ElmMapNameSourceURLFunc name_url_cb)
-{
- EINA_SAFETY_ON_NULL_RETURN(name);
- EINA_SAFETY_ON_NULL_RETURN(url_cb);
- map_sources_tab[source].name = name;
- map_sources_tab[source].zoom_min = zoom_min;
- map_sources_tab[source].zoom_max = zoom_max;
- map_sources_tab[source].url_cb = url_cb;
- map_sources_tab[source].route_url_cb = route_url_cb;
- map_sources_tab[source].name_url_cb = name_url_cb;
-}
-
-/**
* Get the maximum zoom of the source.
*
* @param source the source
* @ingroup Map
*/
EAPI int
-elm_map_source_zoom_max_get(Elm_Map_Sources source)
+elm_map_source_zoom_max_get(const Evas_Object *obj)
{
- return map_sources_tab[source].zoom_max;
+ ELM_CHECK_WIDTYPE(obj, widtype) 18;
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ if ((!wd) || (!wd->src)) return 18;
+ return wd->src->zoom_max;
}
/**
* @ingroup Map
*/
EAPI int
-elm_map_source_zoom_min_get(Elm_Map_Sources source)
+elm_map_source_zoom_min_get(const Evas_Object *obj)
{
- return map_sources_tab[source].zoom_min;
-}
+ ELM_CHECK_WIDTYPE(obj, widtype) 0;
+ Widget_Data *wd = elm_widget_data_get(obj);
-/**
- * Get the name of a source.
- *
- * @param source the source
- * @return Returns the name of the source
- *
- * @ingroup Map
- */
-EAPI const char *
-elm_map_source_name_get(Elm_Map_Sources source)
-{
- return map_sources_tab[source].name;
+ if ((!wd) || (!wd->src)) return 0;
+ return wd->src->zoom_min;
}
/**
* @ingroup Map
*/
EAPI const char *
-elm_map_user_agent_get(Evas_Object *obj)
+elm_map_user_agent_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
-
- if (!wd) return NULL;
char buf[PATH_MAX];
char *source;
char *type_name = NULL;
int fd;
+
+ if ((!wd) || (!wd->src)) return NULL;
+
Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
if (!route) return NULL;
break;
}
- source = map_sources_tab[wd->source].route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
+ 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);
* @ingroup Map
*/
EAPI void
-elm_map_route_color_get(Elm_Map_Route *route, int *r, int *g , int *b, int *a)
+elm_map_route_color_get(const Elm_Map_Route *route, int *r, int *g , int *b, int *a)
{
EINA_SAFETY_ON_NULL_RETURN(route);
if (r) *r = route->color.r;
* @ingroup Map
*/
EAPI double
-elm_map_route_distance_get(Elm_Map_Route *route)
+elm_map_route_distance_get(const Elm_Map_Route *route)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
return route->info.distance;
*/
EAPI const char*
-elm_map_route_node_get(Elm_Map_Route *route)
+elm_map_route_node_get(const Elm_Map_Route *route)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
return route->info.nodes;
*/
EAPI const char*
-elm_map_route_waypoint_get(Elm_Map_Route *route)
+elm_map_route_waypoint_get(const Elm_Map_Route *route)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
return route->info.waypoints;
* @ingroup Map
*/
EAPI const char *
-elm_map_name_address_get(Elm_Map_Name *name)
+elm_map_name_address_get(const Elm_Map_Name *name)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
return name->address;
* @ingroup Map
*/
EAPI void
-elm_map_name_region_get(Elm_Map_Name *name, double *lon, double *lat)
+elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
{
EINA_SAFETY_ON_NULL_RETURN(name);
if (lon) *lon = name->lon;
return strdup(buf);
}
-static char *
-_custom1_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_custom2_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_custom3_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_custom4_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_custom5_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_custom6_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_module_url_cb(Evas_Object *obj, int x, int y, int zoom)
-{
- char *buf = NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
- if ((wd->m) && (wd->m->api))
- {
- Mod_Api *api = wd->m->api;
- if ((api) && (api->obj_url_request)) buf = api->obj_url_request(obj, x, y, zoom);
- }
-
- if (!buf) buf = strdup("");
-
- return buf;
-}
-
static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
{
char buf[PATH_MAX];
}
*/
-static char *_route_custom1_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
-{
- return strdup("");
-}
-
-static char *_route_custom2_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
-{
- return strdup("");
-}
-
-static char *_route_custom3_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
-{
- return strdup("");
-}
-
-static char *_route_custom4_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
-{
- return strdup("");
-}
-
-static char *_route_custom5_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
-{
- return strdup("");
-}
-
-static char *_route_custom6_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
-{
- return strdup("");
-}
-/*
-static char *_route_module_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
-{
- // TODO: make example route module
- return strdup("");
-}
-*/
-
static char *
_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
{
return strdup(buf);
}
-static char *
-_name_custom1_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_name_custom2_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_name_custom3_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_name_custom4_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_name_custom5_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
-{
- return strdup("");
-}
-
-static char *
-_name_custom6_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
-{
- return strdup("");
-}
-