Open shazahm1 opened 6 years ago
Hi there!
Thanks for taking the time to investigate, code and finally post your results here! No doubt it will help someone coming here with the same or similar problem.
A lot has happened in the Google world since I first wrote the code to support the Google geocoder. Most importantly, checking their usage policy, I now see:
You can display Geocoding API results on a Google Map, or without a map. If you want to display Geocoding API results on a map, then these results must be displayed on a Google Map. It is prohibited to use Geocoding API data on a map that is not a Google map.
I think it's safe to say that for most users of Leaflet Control Geocoder, this means that using the Google geocoder is a violation of their policy. My current thinking is that removing the Google geocoder is probably the best solution.
@perliedman
In my specific use case, I only use the Google Geocoder when I'm displaying the Google Map Tile based on whether the user has setup a Google API key or not. So one can in be compliance with Google policy while using Leaflet Control Geocoder. So leaving support for Google in the plugin should be fine. Just update the readme to point to the Google policy so users are informed.
First I want to say thanks for your excellent plugin for Leaflet!
I'm new to Leaflet and have limited basic skill in regards to JavaScript so I may have approached this completely wrong.
I have two Google API keys. One has a referrer restriction, the other an IP restriction. Using either of those keys Google returns an error. The key with the referrer restriction returns an error about the API not supporting referring restriction. I forget the error for the IP restricted API key. Regardless neither worked. I suspect an unrestricted API would work just fine but I did not test that because that is not secure in the sense that someone could scrape that key and use it. Since Google has implemented "pay-as-you-go" billing, this could cause you to be charged for another using your API key.
Following, the DAWA Geocoder as an example I was able to extend yor plugin to add support for the Google "native" geocoder using the Google Maps JavaScript API.
This requires you to load the Maps JavaScript API using the API key on the page before using:
Address geocoding example:
Reverse geocoding example:
And finally my code:
Perhaps this can be added? If not, at least this issue might help others.