views:

31

answers:

1

I want our users of a web site to be able to

  1. either search and pick an address or mark a location on a map
  2. decide how accurate this address/location is

I am in the process of implementing the first part with jquery, jquery ui's autocomplete, google map, and google geocoder. For the second part I will generate a radiobutton list based on the address elements/alternatives of the first part on the client side with jquery.

My concern, however, is how to convey the choices to the server side. The Google geocoder includes a number of useful metadata that I want to store.

  • A possibility is to store the complete json object in a hidden form field, but I can't trust the users. Such a solution would enable an unfriendly insertion of spam in the data.
  • If the addresses/locations would have a unique identifyer I could store just these and let the server refetch/evaluate the data. The alternative geonames.org web service has such ids. But are for example the formatted addresses of a Google location unique?

Any tips?

+1  A: 

To the best of my knowledge, the Google Geocoder does NOT have unique IDs for addresses.

An option, to make the response as quick as possible, might be to add a PHP file on your server to act as a proxy to the Google Geocoder. The user sends the search parameters to your proxy script, which could them reference an SQL table with that search parameter (and return the cached data, if it has been queried before), otherwise have it interact with the Google Geocoder API, cache the response, and then return the response through to the User.

In this way, too, you could issue your own Location IDs based on the key for the cached location data.

Lucanos