0

I would like to change the map which I am using on the following app:

Right now I am working with worldHires, but I would like to use a nicer map (with all the respect), like google maps.

Trying to use RgoogleMaps, I copied the following example for Canada:

library(RgoogleMaps)

  lat=c(48,64) 
  lon=c(-140,-110) 
  center=c(mean(lat), mean(lon))
  zoom=5
  terrmap=GetMap(
  center=center,
  zoom=zoom,
  maptype="terrain",
  destfile = "terrain.png")

However, I got just a link:

 [1] "http://maps.google.com/maps/api/staticmap?
 center=56,-125&zoom=5&size=640x640&maptype=terrain&format=png32&sensor=true"

Do you know how can I put it directly on my app?

user3224026
  • 83
  • 1
  • 6

1 Answers1

0

Your code loads an image from Google Maps and stores it in terrain.png in your working directory. The return value is the URL of the image, as it should be.

You can display the map using:

tmp <- PlotOnStaticMap(terrmap, lat = NA, lon = NA,
                      col=c( 'red','blue','green'), add=FALSE)

See the documentation for PlotOnStatisMap(...) for more details.

jlhoward
  • 58,004
  • 7
  • 97
  • 140
  • I was already trying that, but it seams to get really slow... and at the end it doesn't open... Btw: what's the "col=c( 'red','blue','green'), add=FALSE" – user3224026 Feb 07 '14 at 18:34
  • It works for me in RStudio. Since you did not post your Shiny code, I can't comment on that. I used `col=` because sometimes the maps render in B/W if you don't do that, but in this case you don't need it. And the rendering is really slow - takes about 0.5s on my system. – jlhoward Feb 07 '14 at 18:42