0
votes

I'm currently building a small commnunity where users can mark specific positions on a map.

To save the Map points I need to save lat/lng to my database, but the user don't know lat/lng, so I have to use the (reverse) geocoding API.

I've looked into geonames.org but the results of the Fulltext-Search is...well not so good. If i search for "München" for example I get about 5 Results with the same title/name.

Testing the same City in Google Maps Api, the results are much better, so i want to use the Google Gecoder.

The only problem left is, on the documentation page there's a limit mentioned - max 2500 requests/day.

Well that sounds a lot, but if my Community gets bigger it's not that much...

So my question is, is it possible to do a Geocode Request to Google Maps Api using the Guests IP-Address, so Google don't count it as request from my server?

Currently "my way" to geocode something is to get a seperate PHP file through AJAX (jQuery) while passing the search string to it. The PHP file then get the results with "simplexml_load_file", and then give it back to the main document.

If you look at this Geocoder: http://www.gpsvisualizer.com/geocoder/

You can see in the Footer this description: "This form uses JavaScript-On-Demand (JSON) code that causes your Web browser to be the one making the request (rather than gpsvisualizer.com), which means your queries don't count against my server's limit."

2
You should use the javascript api if you want to geocode from the client. developers.google.com/maps/documentation/javascript/geocoding - Kevin B
So if i use the "Javascript Way", Google thinks the request is done by the guest? - Patrick
Yes, because it IS done by the guest. - Kevin B
Yes, it is done by client but it does not mean it s not using your quota. The visitor still request by your URL and API key etc. so it still uses your quato. I don t think there is a way for this. - Onur Topal
@KevinB It looks like the Google Maps JavaScript library builds a request with a signature token, probably based on the API key. It's quite possible that client-side JS queries do count against your domain/key limit, since the heavily-obfuscated Google Maps library knows your key and domain. - apsillers

2 Answers

0
votes

Short: no, sorry.

Alternative: you may use the javascript geolocationAPI of the browsers (as far as they are supported) to get the coordinates. That allows you to use, for example, the google geocoder api. Some starting point might be here: support and link page

Note: A user might use the google map widget to mark their own position, where you can retrive the coordinates too.

0
votes

Well, i've found something. It seems that Kevin B was right.

Look at this: https://developers.google.com/maps/articles/geocodestrat?hl=de

According to that...

When to Use Client-Side Geocoding

The basic answer is "almost always." As geocoding limits are per user session, there is no risk that your application will reach a global limit as your userbase grows. Client-side geocoding will not face a quota limit unless you perform a batch of geocoding requests within a user session. Therefore, running client-side geocoding, you generally don't have to worry about your quota.

... it IS possible, simply using the Javascript API!

The User searches for "Paris, France", the Google JS API returns lat/lng, i store it in the DB (Caching) and show it on a Google Map, so i don't need any Server-Side Geocoding-Request!