Geocode

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def geocode_user(user):
    formats = (
        '%(housenumber)s,%(street)s,%(city)s,%(country)s',
        '%(housenumber)s,%(street)s,%(country)s',
        '%(street)s,%(city)s,%(country)s',
        '%(street)s,%(country)s',
    )
    
    address = get_address_parts(user)
    
    lat = lng = None
    
    for f in formats:
        lat, lng = geocode(f % address)
        
        if lat and lng:
            break
            
    return lat,lng

More like this

  1. template code for "Google v3 geocoding for Geodjango admin site" by samhag 1 year, 5 months ago
  2. Google Geocode Lookup by tonyskyday 6 years, 9 months ago
  3. Retrieve Latitude & Longitude for an Address from Google Geocoder V3 by whardeman 3 years, 5 months ago
  4. Uk postcode googlemap templetag by _ben_ 5 years, 1 month ago
  5. Google v3 geocoding for Geodjango admin site by samhag 1 year, 5 months ago

Comments

(Forgotten your password?)