简体   繁体   中英

The `get_map` map function ignores the “source” parameter in ggmap package

When using the function get_map() I receive an error prompting to supply an google-API-key though I use the parameter "source":

location = colMeans(city[,c('coords_x1', 'coords_x2')])#mitte
names(location) <- c('lat', 'lon')

get_map(location = location, source='osm')
note : locations should be specified in the lon/lat format, not lat/lon.
Error: Google now requires an API key.
       See ?register_google for details.

It seems as if the parameter is ignored.

The solution lies in the way "location" is used in the query. As long as no bbox is supplied ggmap will lookup in google for a correct bounding box. Henceforth the error occurs. Thus the following code works:

bbox <- make_bbox(stadt$coords_x1, stadt$coords_x2, f = .05)


map <- get_map(location = bbox, source='osm') 
ggmap(map) + geom_point(data=stadt, aes(x=coords_x1, y=coords_x2, color=akaQuote))

Using OSM as a source a bounding box has to be passed to the get_map function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM