3

I am trying to use tiles generated with the Google static API with Leaflet and I am facing issues because the generated tile seems to be displayed "off-centred".

My original question has been posted on Stack Overflow.

I am asking the question here in case this site is more suitable (I will also move the question here if the answer is given in this site).

6

I know this is too late to answer this question. But I want to share my knowledge in this question. For the static purpose you can freely add the google map tiles inside your leaflet. For the static tiles, you can add following code, for street,

googleStreets = L.tileLayer('http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',{
    maxZoom: 20,
    subdomains:['mt0','mt1','mt2','mt3']
});

Hybrid,

googleHybrid = L.tileLayer('http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}',{
    maxZoom: 20,
    subdomains:['mt0','mt1','mt2','mt3']
});

satellite,

googleSat = L.tileLayer('http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}',{
    maxZoom: 20,
    subdomains:['mt0','mt1','mt2','mt3']
});

Terrain

googleTerrain = L.tileLayer('http://{s}.google.com/vt/lyrs=p&x={x}&y={y}&z={z}',{
    maxZoom: 20,
    subdomains:['mt0','mt1','mt2','mt3']
});

Note that difference in the "lyrs" parameter in the URL:

Hybrid: s,h;
Satellite: s;
Streets: m;
Terrain: p;
3
  • Do you have any information regarding the maximum usage limits for that link? – fabiofcferreira Apr 14 '20 at 12:45
  • 1
    This provides the google map as a tile-layer Not along with their data. So It doesn't have maximum usage limit. You can use how much you need – gis Apr 15 '20 at 2:19
  • Interesting. Thought it was limited. – fabiofcferreira Apr 15 '20 at 4:08
2

Use the leaflet-google plugin that orchestrates the gmaps api to get the images and provides a custom layer to leaflet

https://gist.github.com/crofty/2197042

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.