static void
my_map_longpressed(void *data, Evas_Object *obj __UNUSED__, void *event_info)
{
+ printf("longpressed\n");
double lon, lat;
Evas_Coord ox, oy, x, y, w, h;
int zoom;
static void
my_map_clicked_double(void *data, Evas_Object *obj, void *event_info)
{
+ printf("clicked,double\n");
double lon, lat;
double flon, flat, tlon, tlat;
Evas_Coord ox, oy, x, y, w, h, rx, ry, tx, ty;
static void
my_map_anim_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- printf("anim,start\n");
+ printf("scroll,anim,start\n");
}
static void
my_map_anim_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- printf("anim,stop\n");
+ printf("scroll,anim,stop\n");
}
static void
my_map_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
+ printf("scroll,drag,start\n");
evas_object_smart_callback_del(data, "longpressed", my_map_longpressed);
}
static void
my_map_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
+ printf("scroll,drag,stop\n");
evas_object_smart_callback_add(data, "longpressed", my_map_longpressed, data);
}
static void
my_map_scroll(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
+ printf("scroll\n");
double lon, lat;
elm_map_geo_region_get(obj, &lon, &lat);
printf("scroll longitude : %f latitude : %f\n", lon, lat);
static void
my_map_route_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- printf("route_load\n");
+ printf("route,load\n");
}
static void
my_map_route_loaded(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
+ printf("route,loaded\n");
double d;
const char *w, *n;
d = elm_map_route_distance_get(route);
static void
my_map_name_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- printf("name_load\n");
+ printf("name,load\n");
}
static void
my_map_name_loaded(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
+ printf("name,loaded\n");
if (!name) return;
double lon, lat;
const char *addr = elm_map_name_address_get(name);
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, 18);
+ elm_map_zoom_set(data, elm_map_source_zoom_max_get(data));
elm_map_paused_set(data, b);
}
}
}
static void
-_populate(void *data, Elm_Menu_Item *item)
+_populate(void *data, Elm_Object_Item *menu_it)
{
int idx;
- if ((!data) || (!item) || (!source_names)) return;
+ if ((!data) || (!menu_it) || (!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]);
+ elm_menu_item_add(menu, menu_it, "", source_names[idx], map_source,
+ &ms[idx]);
}
}
_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;
+ Elm_Object_Item *menu_it;
if (!down) return;
if (down->button == 2)
else if (down->button == 3)
{
menu = elm_menu_add(obj);
- item = elm_menu_item_add(menu, NULL, NULL, "Source", NULL, NULL);
- _populate(data, item);
+ menu_it = elm_menu_item_add(menu, NULL, NULL, "Source", NULL, NULL);
+ _populate(data, menu_it);
elm_menu_item_add(menu, NULL, NULL, "Show Urmatt", map_show_urmatt, 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);
nb_elts = 13;
- evas_object_smart_callback_add(map, "clicked", my_map_clicked, win);
- evas_object_smart_callback_add(map, "press", my_map_press, win);
+ 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, win);
- evas_object_smart_callback_add(map, "loaded,detail", my_map_loaded_detail, win);
- evas_object_smart_callback_add(map, "zoom,start", my_map_zoom_start, win);
- evas_object_smart_callback_add(map, "zoom,stop", my_map_zoom_stop, win);
- 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, "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, win);
+ 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);
typedef struct _Track_Dump Track_Dump;
#define CACHE_ROOT_PATH "/tmp/elm_map"
-#define CACHE_PATH CACHE_ROOT_PATH"/%d/%d/%d/"
-#define CACHE_FILE_PATH "%s%d.png"
+#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"
static char *_mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
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 *_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);
/*
{
{"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},
+ {"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},
};
struct _Url_Data
struct {
int x, y, w, h;
} src, out;
- Eina_Bool have : 1;
+
+ Eina_Bool file_have : 1;
Ecore_File_Download_Job *job;
int try_num;
};
Widget_Data *wd = elm_widget_data_get(data);
Map_Sources_Tab *s;
Eina_List *l;
- int idx;
+ unsigned int idx;
if (!wd) return;
- for (idx = 0; idx < 4; idx++)
+ for (idx = 0; idx < sizeof(default_map_sources_tab)/sizeof(Map_Sources_Tab); idx++)
{
s = calloc(1, sizeof(Map_Sources_Tab));
EINA_SAFETY_ON_NULL_RETURN(s);
{
ERR("Image loading error (%s): %s", gi->file, evas_load_error_str(err));
ecore_file_remove(gi->file);
- gi->have = EINA_FALSE;
+ gi->file_have = EINA_FALSE;
}
else
{
obj_rotate_zoom(gi->wd->obj, gi->img);
evas_object_show(gi->img);
- gi->have = EINA_TRUE;
+ gi->file_have = EINA_TRUE;
//evas_object_text_text_set(gi->txt, gi->file);
//evas_object_show(gi->txt);
}
{
WRN("Download failed from %s to %s (%d) ", gi->source, gi->file, status);
ecore_file_remove(gi->file);
- gi->have = EINA_FALSE;
+ gi->file_have = EINA_FALSE;
}
- evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, 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");
if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
yy - wd->pan_y + oy,
ww, hh,
- cvx, cvy, cvw, cvh))
- {
- wd->download_list = eina_list_remove(wd->download_list, gi);
- continue;
- }
- if (gi->zoom != wd->zoom)
+ cvx, cvy, cvw, cvh) ||
+ (gi->zoom != wd->zoom))
{
wd->download_list = eina_list_remove(wd->download_list, gi);
continue;
if (gi->wd->download_num >= MAX_CONCURRENT_DOWNLOAD) break;
- DBG("Download request from %s to %s", gi->source, gi->file);
Eina_Bool ret = ecore_file_download_full(gi->source, gi->file, _tile_downloaded, NULL, gi, &(gi->job), wd->ua);
- if (!ret || !gi->job) WRN("Can't start to download from %s to %s", gi->source, gi->file);
+ if (!ret || !gi->job) ERR("Can't start to download from %s to %s", gi->source, gi->file);
else
{
gi->wd->download_num++;
for (zoom = wd->src->zoom_min; zoom <= wd->src->zoom_max; zoom++)
{
g = calloc(1, sizeof(Grid));
+ EINA_SAFETY_ON_NULL_RETURN(g);
g->zoom = zoom;
g->tsize = wd->tsize;
g->wd = wd;
DBG("DOWNLOAD abort %s", gi->file);
ecore_file_download_abort(gi->job);
ecore_file_remove(gi->file);
- gi->have = EINA_FALSE;
+ gi->file_have = EINA_FALSE;
gi->job = NULL;
wd->try_num--;
}
}
EINA_LIST_FREE(wd->download_list, gi);
- if (!ecore_file_recursive_rm(CACHE_ROOT_PATH)) WRN("Deletion of %s failed", CACHE_ROOT_PATH);
+ if (!ecore_file_recursive_rm("/tmp/elm_map/")) WRN("Deletion of /tmp/elm_map/ failed");
}
{
gi = eina_matrixsparse_cell_data_get(cell);
- if (gi->have)
+ if (gi->file_have)
{
evas_object_hide(gi->img);
//evas_object_hide(gi->txt);
ww, hh,
cvx, cvy, cvw, cvh))
{
- if (gi->have)
+ if (gi->file_have)
{
evas_object_hide(gi->img);
//evas_object_hide(gi->txt);
}
else if (gi->job)
{
- DBG("Download abort: %s", gi->file);
+ DBG("Download abort %s", gi->file);
ecore_file_download_abort(gi->job);
ecore_file_remove(gi->file);
gi->job = NULL;
if (!gi)
{
- char buf[PATH_MAX], buf2[PATH_MAX];
+ char buf[PATH_MAX];
+ char buf2[PATH_MAX];
char *source;
gi = calloc(1, sizeof(Grid_Item));
+ EINA_SAFETY_ON_NULL_RETURN(gi);
gi->wd = wd;
gi->g = g;
gi->zoom = g->zoom;
+ gi->file_have = EINA_FALSE;
+ gi->job = NULL;
gi->src.x = x * g->tsize;
gi->src.y = y * g->tsize;
snprintf(buf, sizeof(buf), CACHE_PATH, wd->id, g->zoom, x);
snprintf(buf2, sizeof(buf2), CACHE_FILE_PATH, buf, y);
if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
- eina_stringshare_replace(&gi->file, buf2);
+ eina_stringshare_replace(&gi->file, buf2);
source = wd->src->url_cb(obj, x, y, g->zoom);
if ((!source) || (strlen(source)==0))
{
else eina_stringshare_replace(&gi->source, source);
if (source) free(source);
- gi->have = EINA_FALSE;
- gi->job = NULL;
-
eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
}
- if (gi->have) _tile_update(gi);
- else if (!gi->job) _add_download_list(obj, gi);
- else DBG("Downloading is in progress: %s from %s", gi->file, gi->source);
+ if (gi->file_have)
+ {
+ DBG("File exists: %s", gi->file);
+ _tile_update(gi);
+ }
+ else if (!gi->job)
+ {
+ DBG("Added to download list: %s", gi->file);
+ _add_download_list(obj, gi);
+ }
}
}
}
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->zoom == g->zoom) grid_load(sd->wd->obj, g);
- else if (sd->wd->zoom-1 != g->zoom && sd->wd->zoom+1 != g->zoom) grid_unload(sd->wd->obj, g);
+ if (sd->wd->zoom == g->zoom) grid_load(sd->wd->obj, g);
+ else if (sd->wd->zoom-1 != g->zoom && sd->wd->zoom+1 != g->zoom) grid_unload(sd->wd->obj, g); // remain only adjacent grids
grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
if (sd->wd->zoom == g->zoom) 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);
}
}
+Grid *_get_current_grid(Widget_Data *wd)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+ Eina_List *l;
+ Grid *g = NULL, *ret = NULL;
+ EINA_LIST_FOREACH(wd->grids, l, g)
+ {
+ if (wd->zoom == g->zoom)
+ {
+ ret = g;
+ break;
+ }
+ }
+ return ret;
+}
+
static Eina_Bool
_route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
{
if (wd->grids)
{
- Eina_List *l;
Grid *g;
Evas_Coord ox, oy, ow, oh;
evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
- EINA_LIST_FOREACH(wd->grids, l, g)
- {
- if (wd->zoom == g->zoom) break;
- }
+ g = _get_current_grid(wd);
route_place(wd->obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
}
edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
if (wd->grids)
{
- Eina_List *l;
Grid *g;
Evas_Coord ox, oy, ow, oh;
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
- EINA_LIST_FOREACH(wd->grids, l, g)
- {
- if (wd->zoom == g->zoom) break;
- }
+ g = _get_current_grid(wd);
marker_place(obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
}
if (wd->grids)
{
- Eina_List *l;
Grid *g;
Evas_Coord ox, oy, ow, oh;
evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
- EINA_LIST_FOREACH(wd->grids, l, g)
- {
- if (wd->zoom == g->zoom) break;
- }
+ g = _get_current_grid(wd);
marker_place(wd->obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
}
#else
clas->hide = hide;
if (wd->grids)
{
- Eina_List *l;
Grid *g;
Evas_Coord ox, oy, ow, oh;
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
- EINA_LIST_FOREACH(wd->grids, l, g)
- {
- if (wd->zoom == g->zoom) break;
- }
+ g = _get_current_grid(wd);
marker_place(obj, g, wd->pan_x, wd->pan_y, ox, oy, ow, oh);
}
#else
_mapnik_url_cb(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",
- zoom, x, y);
+ // ((x+y+zoom)%3)+'a' is requesting map images from distributed tile servers (eg., a, b, c)
+ snprintf(buf, sizeof(buf), "http://%c.tile.openstreetmap.org/%d/%d/%d.png", ((x+y+zoom)%3)+'a', zoom, x, y);
return strdup(buf);
}
_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
{
char buf[PATH_MAX];
- snprintf(buf, sizeof(buf),
- "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
- zoom, x, y);
+ snprintf(buf, sizeof(buf), "http://%c.tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png", ((x+y+zoom)%3)+'a', zoom, x, y);
return strdup(buf);
}
_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
{
char buf[PATH_MAX];
- snprintf(buf, sizeof(buf),
- "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
- zoom, x, y);
+ snprintf(buf, sizeof(buf), "http://%c.tile.opencyclemap.org/cycle/%d/%d/%d.png", ((x+y+zoom)%3)+'a', zoom, x, y);
return strdup(buf);
}
static char *
-_maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+_mapquest_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
{
char buf[PATH_MAX];
- snprintf(buf, sizeof(buf),
- "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
- zoom, x, y);
+ snprintf(buf, sizeof(buf), "http://otile%d.mqcdn.com/tiles/1.0.0/osm/%d/%d/%d.png", ((x+y+zoom)%4)+1, zoom, x, y);
+ return strdup(buf);
+}
+
+static char *
+_mapquest_aerial_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf), "http://oatile%d.mqcdn.com/naip/%d/%d/%d.png", ((x+y+zoom)%4)+1, zoom, x, y);
return strdup(buf);
}