Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Leaflet with Google Maps?

Currently I am using Google Maps API 3 to display about 1000 users spread all over the world. This is for free, as long as I have less then 25.000 downloaded maps views per day.

Recently, I found out about the amazing JS Library Leaflet. I want to use it with OpenStreetMaps. As far as I have understood, one should not use tiles provided by OpenStreetMaps (Tile usage policy) but instead third party provider that makes tiles from OSM data, or generate your own.

I cannot provide my own tiles because I do not have appropriate hardware requirements. Unfortunately I found that many third party provider for tiles have very strict limits, like MapQuest which is only for free as long as you do not exceed 15.000 map views per month (which seems not very attractive in comparison with Google Maps where you can use it for free as long as you do not exceed 25.000 map views per day).

So I wonder, is it possible to use Leaflet with Google Maps, so that I only have a limit of 25.000 map views per day?

According to this question the answer is clearly no. However, according to Leaflet Map API with Google Satellite Layer the answer is yes.

like image 499
Adam Avatar asked Jun 05 '16 11:06

Adam


1 Answers

Well, a lot to say here.

1) You can use OSM tiles as long as your usage is reasonable. If you find MapQuest limits quite restrictive, then indeed, you would probably be in the "over-reasonable" situation.

2) You have plenty 3rd party alternatives for tile sources (including MapQuest and Google Maps). If you are in the situation where you generate several thousands of views per month or day, then it is probably worth paying for a commercial service and ensure some availability service level. Of course Google Maps is still free and attractive for a high usage, at the cost of complying with their conditions (below).

3) Google Maps terms state that you can use Google Maps tiles only through Google Maps API. That is what some Leaflet plugins provide: they act as a proxy and use Google Maps API, so you should be compliant with Google Maps service terms. That is where you should probably provide your API key.

4) Therefore, the code snippet you show, which directly uses Google Maps tile template URL, is very probably not compliant with their terms, even though it may technically work.

As a side note, among the commercial 3rd party services for tile source, there is Mapbox. I do not especially like advertising, but I mention it because this is the company where the main Leaflet author works.

like image 99
ghybs Avatar answered Sep 22 '22 02:09

ghybs