--- trunk/src/map-tool.c 2009/08/28 07:52:01 84 +++ trunk/src/map-tool.c 2009/09/01 11:16:30 89 @@ -33,6 +33,7 @@ // #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/" @@ -138,31 +139,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; } @@ -232,10 +237,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 = @@ -443,6 +452,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; @@ -484,6 +497,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); @@ -511,8 +525,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,