--- trunk/src/map-tool.c 2009/08/25 12:49:03 77 +++ trunk/src/map-tool.c 2009/09/02 12:25:51 93 @@ -17,6 +17,11 @@ * along with GPXView. If not, see . */ +/* + * http://topo.geofabrik.de/relief/${z}/${x}/${y}.png 8-15 + * http://topo.geofabrik.de/trail/${z}/${x}/${y}.png 8-15 + */ + #include "gpxview.h" #include "converter.h" #include // for isnan @@ -31,7 +36,9 @@ #include #endif -#define MAP_SOURCE OSM_GPS_MAP_SOURCE_OPENSTREETMAP +// #define MAP_SOURCE OSM_GPS_MAP_SOURCE_OPENSTREETMAP +#define MAP_SOURCE OSM_GPS_MAP_SOURCE_OPENCYCLEMAP +// #define MAP_SOURCE OSM_GPS_MAP_SOURCE_GOOGLE_STREET #define GPS_DEFAULT_ZOOM 13 #define PROXY_KEY "/system/http_proxy/" @@ -77,8 +84,15 @@ if(but == OSD_GPS) { pos_t *refpos = get_pos(context->appdata); if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { - osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget), - refpos->lat, refpos->lon, GPS_DEFAULT_ZOOM); + gint zoom; + g_object_get(OSM_GPS_MAP(context->widget), "zoom", &zoom, NULL); + if(zoom < 10) + osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget), + refpos->lat, refpos->lon, GPS_DEFAULT_ZOOM); + else + osm_gps_map_set_center(OSM_GPS_MAP(context->widget), + refpos->lat, refpos->lon); + /* re-enable centering */ g_object_set(context->widget, "auto-center", TRUE, NULL); } else { @@ -130,31 +144,35 @@ GdkEventConfigure *event, map_context_t *context) { - /* set default values if they are invalid */ - if(!context->appdata->map.zoom || - isnan(context->appdata->map.pos.lat) || - isnan(context->appdata->map.pos.lon)) { - printf("no valid map position found\n"); - - pos_t *refpos = get_pos(context->appdata); - if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { - /* use gps position if present */ - context->appdata->map.pos = *refpos; - context->appdata->map.zoom = GPS_DEFAULT_ZOOM; - } else { - /* use world map otherwise */ - context->appdata->map.pos.lat = 0.0; - context->appdata->map.pos.lon = 0.0; - context->appdata->map.zoom = 1; + if(!context->map_complete) { + + /* set default values if they are invalid */ + if(!context->appdata->map.zoom || + isnan(context->appdata->map.pos.lat) || + isnan(context->appdata->map.pos.lon)) { + printf("no valid map position found\n"); + + pos_t *refpos = get_pos(context->appdata); + if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) { + /* use gps position if present */ + context->appdata->map.pos = *refpos; + context->appdata->map.zoom = GPS_DEFAULT_ZOOM; + } else { + /* use world map otherwise */ + context->appdata->map.pos.lat = 0.0; + context->appdata->map.pos.lon = 0.0; + context->appdata->map.zoom = 1; + } } + + /* jump to initial position */ + osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget), + context->appdata->map.pos.lat, + context->appdata->map.pos.lon, + context->appdata->map.zoom); + context->map_complete = TRUE; } - /* jump to initial position */ - osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget), - context->appdata->map.pos.lat, - context->appdata->map.pos.lon, - context->appdata->map.zoom); - return FALSE; } @@ -224,10 +242,14 @@ GdkEventButton *event, map_context_t *context) { OsmGpsMap *map = OSM_GPS_MAP(context->widget); + /* check if we actually clicked parts of the OSD */ + if(osm_gps_map_osd_check(map, event->x, event->y) != OSD_NONE) + return FALSE; + /* got a press event without release event? eat it! */ if(context->press_on != NULL) { printf("PRESS: already\n"); - return TRUE; + return FALSE; } pos_t pos = @@ -435,6 +457,10 @@ context->appdata->map.pos.lat = lat; context->appdata->map.pos.lon = lon; + gint source; + g_object_get(map, "map-source", &source, NULL); + context->appdata->map.source = source; + #if MAEMO_VERSION_MAJOR == 5 /* restore cur_view */ context->appdata->cur_view = context->old_view; @@ -476,6 +502,7 @@ context = appdata->map.context = g_new0(map_context_t, 1); context->appdata = appdata; + context->map_complete = FALSE; /* cleanup old (pre 0.8.7) path if it exists */ char *old_path = g_strdup_printf("%s/map/", appdata->image_path); @@ -503,8 +530,11 @@ const char *proxy = get_proxy_uri(appdata); + gint source = context->appdata->map.source; + if(!source) source = MAP_SOURCE; + context->widget = g_object_new(OSM_TYPE_GPS_MAP, - "map-source", MAP_SOURCE, + "map-source", source, "tile-cache", path, "auto-center", FALSE, "record-trip-history", FALSE,