0

I've got a question, it's concerning, shiny and leaflet, I'm using leafet on shiny, but I'd like to use the baselayer of googleMaps and I've found a leafletJs add-on that do the job by using just a little bit of code, but I was wondering how to translate this into shiny R, the code is this :

In the head section of the HTML page Include the GMaps JS API in your HTML, plus Leaflet:

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY" async defer></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>

Include the GoogleMutant javascript file:

<script src='https://unpkg.com/leaflet.gridlayer.googlemutant@latest/Leaflet.GoogleMutant.js'></script>

create an instance of L.GridLayer.GoogleMutant on your JS code:

var roads = L.gridLayer.googleMutant({
    type: 'terrain' // valid values are 'roadmap', 'satellite', 'terrain' and 'hybrid'}).addTo(map);

The point is, I'm not familiar with Js, so maybe you could help me with this...?

Thanks.

Killian
  • 31
  • 2
  • if the google mutant layer is dependent on leaflet > 1.0 then will need to use this branch https://github.com/timelyportfolio/leaflet/tree/v1.0 by `devtools::install_github("timelyportfolio/leaflet@v1.0")`. If I have some time today I will try to work up a solution, but for now you could see if the last solution on http://stackoverflow.com/questions/36554605/cant-loop-with-rs-leaflet-package-to-produce-multiple-maps helps. – timelyportfolio Apr 19 '17 at 13:01
  • Oh thanks that's great if you could have a look, actually I managed to display the map but I can't intereact with it. If u are interested I could send what I've done so far. – Killian Apr 19 '17 at 16:33
  • Have you tried to do something about that question? I'm still digging on that.. – Killian Apr 20 '17 at 13:07
  • I would simply suggest to not to use google map layer. If I remember correct, using google map as base layer in leaflet is not fully compatible with the google map API requirement. The plugin works but it's kind of hack, not guaranteed to work in future. I think the here maps layer in leaflet providers are good for most purposes. You only need to register an API key, and they have good street map and satellite maps. – dracodoc Jan 04 '18 at 15:26

0 Answers0