简体   繁体   中英

Wrong type of map when using ggmap and get_map

When I get a map using the watercolor option using this code:

ggmap(get_map(location=c(x = -97, y = 37), zoom = 4, maptype='watercolor')) 

It gives the following text in red:

maptype = "watercolor" is only available with source = "stamen".
resetting to source = "stamen"...

But it still works. In other words, it uses the watercolor option.

However, when I do something slightly different—specify the exact location:

ggmap(get_map(location=c(-123, 25, -70, 48), maptype='watercolor'))

Then it gives this message:

maptype = "watercolor" is only available with source = "stamen".
resetting to source = "stamen"...

And, importantly, it does NOT use the watercolor option, but reverts to something else. What can I do to use this latter version but still get the option that I want?

I think the issue has something to do with get_map(location(... calling Google for the location. Using get_stamenmap seems to alleviate that issue, but the syntax is slightly different in that it requires a bounding box (which you already provided) for the location.

Is this what you're wanting it to do?

library(ggmap)

ggmap(get_stamenmap(bbox=c(-123, 25, -70, 48), zoom = 5, 
              maptype='watercolor'))

在此处输入图片说明

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