3

I run simple examples of leaflet package in R like:

library(leaflet)
library(ggmap)

>somePlace <-ggmap::geocode("Vienna")  
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Vienna&sensor=false  
>somePlace 
lon      lat
1 16.37382 48.20817
>leaflet(somePlace) %>% addTiles() %>% addMarkers()

Map shows grey space with a blue marker:

enter image description here

No trace of OSM spatial visualisation. Could you point out where is the problem?

Thanks in advance for constructive discussion!

My configuration: R version 3.2.4 (2016-03-10), Platform: x86_64-w64-mingw32/x64 (64-bit), Windows Server 2012 x64 (build 9200), ggmap_2.6.1, leaflet_1.0.1.

Similar problems (but without a suitable solution): R leaflet package produces blank (grey) map [Ubuntu 14.04] R leaflet RStudio Viewer blank (grey) map [Windows 7]

Patrik_P
  • 3,066
  • 3
  • 22
  • 39

3 Answers3

5

The answer to my own question is that the local firewall settings prevented me from downloading the tiles from OSM. The way how to solve it was to set proxy (from within R > link). The con of this solution is that the viewer still doesn`t deliver tiles as the proxy settings at the moment do not apply to RStudio Viewer. Although, the leaflet output appears properly in browser, therefore works also with Shiny Apps. Thanks for the support contributing to the solution!

Patrik_P
  • 3,066
  • 3
  • 22
  • 39
  • 1
    I have had similar issues, I have to use a proxy service to get past our silly security settings to access tiles, and stackoverflow! – sconfluentus Sep 06 '16 at 21:51
2

Your code is working in R 3.2.3 and also in RStudio. Let it load, it takes time. Before loading it looks like the screenshot you have pasted above.I am using Windows 10.

enter image description here

Sowmya S. Manian
  • 3,723
  • 3
  • 18
  • 30
  • Thnx for your answer. It's loading now 30 min while I try to find a solution. How long can it take? – Patrik_P Apr 04 '16 at 07:33
  • @Patrik: it takes not even 1 minute on my side. I am not working on server. SO I have no idea how it would work there. In both R and R Studio, it just loads in 30 seconds. – Sowmya S. Manian Apr 04 '16 at 07:36
  • As pointed out [here](http://gis.stackexchange.com/questions/187926/leaflet-output-is-grey), the issue seems to be related with the local Java installation @SowmyaS.Manian. – fdetsch Apr 04 '16 at 07:49
  • The java problem was solved & the problem persits therefore a solution still needed. Any ideas? – Patrik_P Apr 04 '16 at 09:43
  • @Patrik still not able to see map?? – Sowmya S. Manian Apr 04 '16 at 10:31
  • No issue is persisting. I seems it has something to do with http://stackoverflow.com/questions/20532675/having-trouble-connecting-to-openstreetmap. That is assigning properly java proxy setting. – Patrik_P Apr 04 '16 at 10:35
  • Most of them having this problem are windows 7 people..and some in ubuntu. Will see if anywhere they have reported on how to solve this isssue. You can try running the same in other windows machine like 8 or 10. – Sowmya S. Manian Apr 04 '16 at 10:40
  • Try resizing the width to 100% resizing might load, not sure though – Sowmya S. Manian Apr 04 '16 at 10:44
2

Try replacing

addTiles()

with

addProviderTiles(providers$OpenStreetMap)

Seems to force leaflet to provide the tiles to knitr's html.

zek19
  • 1,043
  • 8
  • 9