Commits

Daniel Greenfeld committed d2daaec

Adding Google API key to help when you get blocked

Comments (0)

Files changed (2)

 Then add 'easy_maps' to INSTALLED_APPS and run ``./manage.py syncdb``
 (or ``./manage.py migrate easy_maps`` if South is in use)
 
+Settings
+========
+
+If working on localhost you can run into Google Maps API lockdown. If this happens
+then create a EASY_MAPS_GOOGLE_KEY in your settings.py file::
+
+    EASY_MAPS_GOOGLE_KEY = "your-google-maps-api-key"
+
 Usage
 =====
 

easy_maps/models.py

+from django.conf import settings
 from django.db import models
 from django.utils.encoding import smart_str
 from geopy import geocoders
             self.geocode_error = True
             return
         try:
-            g = geocoders.Google(resource='maps')
+            if hasattr(settings, "EASY_MAPS_GOOGLE_KEY"):
+                g = geocoders.Google(settings.EASY_MAPS_GOOGLE_KEY)
+            else:
+                g = geocoders.Google(resource='maps')
             address = smart_str(self.address)
             self.computed_address, (self.latitude, self.longitude,) = g.geocode(address)
             self.geocode_error = False