jazzband/django-floppyforms

BaseGMapWidget Google Maps API error: MissingKeyMapError

jlariza opened this issue · 3 comments

Hello,

I am trying to use the BaseGMapWidget for a Django models.PointField. I am defining it as follows

class PointWidget(forms.gis.PointWidget, forms.gis.BaseGMapWidget):
    google_maps_api_key = settings.GOOGLE_MAPS_API_KEY

class MyModelForm(forms.ModelForm):
    location = floppyforms.gis.PointField(widget=PointWidget)

However, when I try to display the form field, I get the following error:
js?v=3&sensor=false:34 Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error

when I checked the html, the google maps call is <script type="text/javascript" src="https://maps.google.com/maps/api/js?v=3&amp;sensor=false"></script>

but it should be <script src="//maps.googleapis.com/maps/api/js?v=3&amp;sensor=false&amp;key=given_api_key"></script>

thank you

The setup you are using looks correct to me.

Which version of django-floppyforms are you using? This is something we recently introduced in version 1.7.0

@gregmuellegger My bad, I was using the 1.6.1 version. Thank you

Glad that the fix was so easy :) happy coding