Geocoding
If you need to convert an address (for example: “243 S Wabash Ave, Chicago, IL, USA”) into geographical coordinates (latitude and longitude), web2py provides a function to do so.
from gluon.tools import geocode
address = '243 S Wabash Ave, Chicago, IL, USA'
(latitude, longitude) = geocode(address)
The function geocode
requires a network connection and it connects to the Google geocoding service for the geocoding. The function returns (0,0)
in case of failure. Notice that the Google geocoding service caps the number of requests, so you should check their service agreement. The geocode
function is built on top of the fetch
function and thus it works on GAE.