On my site, companies are able to enter in locations (addresses, etc) for each of their branches. Rather than geocod开发者_Python百科ing through Google each an every time that I would like to display it on a (Google) map, it seems better to simply geocode each address upon entry, and store the coordinates for later.
With all the legal jargon, however, I am confused if this is a regular practice, or whether developers usually geocode on the fly each time?
Yes, it is a common practice especially when you are running in a bandwidth-limited environment. However, you are not allowed to store all the data indefinitely. Some restrictions apply on the content you are downloading from the API.
Here is Google take on this problem (Google Maps API Family Terms Of Service, http://code.google.com/apis/maps/terms.html ; 10.1.3.b):
You must not pre-fetch, cache, or store any Content, except that you may store: (i) limited amounts of Content for the purpose of improving the performance of your Maps API Implementation if you do so temporarily, securely, and in a manner that does not permit use of the Content outside of the Service
The most important parts are:
- You are not allowed to pre-fetch
- Data conservation has to be temporary
- Data has to be kept in small amounts
One thing to consider is that the geocoded coordinate and your address isn't always describing the same point. No geocoding service is perfect in this matter, due to interpolation of street numbers and other inaccuracies. Depending on what you are using the coordinates for, it is quite often so that you will be able to relocate the point and therefore have to save it in your data.
For instance if you have a set of companys with addresses like "Kings street 11-15", where is the main entrance to the company? Where will deliveries be made? Things like this can make it impossible to geocode on the fly.
Even if you want to use the geocoded coordinat "as is", I can recall that Bing Maps did an exception to the rule of "not saving any data" as to allow storing of geocoded locations. Not sure if Google does the same though...
Ofcourse - its not like geocode (which essentially just is latitude and longitude) is something google are the only ones to use. Its a pretty much how everyone does it (and has been done for the last decade)
With my Google Maps project for SugarCRM, I am storing limited amounts of data from the Google Maps Geocoding API in the database (Address Cache Module). I don't store the entire object, just parts of it. Just store what you need for efficiency.
Mainly:
- Full One Line Address
- Geocode Status
- Longitude
- Latitude
The data is stored in an Address Cache to identify addresses with status "OK". So, I'm only storing limited amounts of the data returned from Google Maps. Which I think it absolutely fine to do so.
ALso, I'm only storing this as Address Cache, which can be destroyed and repopulated at any time. Without the "pre-populated" Longitude/Latitude information it would take several minutes to populate a map with 5,000 records. With the cache, a Map with 5,000 records can be displayed in under 10 seconds.
http://www.jjwdesign.com/sugarcrm/google-maps-for-sugarcrm
Questions to Ponder:
- What does Google Maps consider "Limited Amounts of Content"? Under a 1GB of data?
- How do you interpret "purpose of improving the performance"? Using the service on-the-fly perhaps?
精彩评论