我正在使用https://github.com/caioariede/django-location-field https://github.com/caioariede/django-location-field使用 Django 构建位置视图的库。问题是我找不到说明如何定义我自己的 Google 地图 API 密钥的文档。
这是我的 settings.py 上的代码:
LOCATION_FIELD_PATH = STATIC_URL + 'location_field'
LOCATION_FIELD = {
'map.provider': 'google',
'map.zoom': 13,
'search.provider': 'google',
'search.suffix': '',
# Google
'provider.google.api': '//maps.google.com/maps/api/js',
'provider.google.api_key': 'MY_API_KEY_HERE',
'provider.google.map_type': 'ROADMAP',
# misc
'resources.root_path': LOCATION_FIELD_PATH,
'resources.media': {
'js': [
LOCATION_FIELD_PATH + '/js/jquery.livequery.js',
LOCATION_FIELD_PATH + '/js/form.js',
],
},
}
但这个解决方案似乎不起作用。
maps.google.com/maps-api-v3/api/js/28/11/util.js:219 Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys
我已经搜索了一段时间,但没有运气得到答案。
您可以使用Django 地理定位 https://github.com/philippbosch/django-geoposition代替Django 位置字段 https://github.com/caioariede/django-location-field。它具有相同的功能,并且还有简单的文档https://django-geoposition.readthedocs.io/en/latest/ https://django-geoposition.readthedocs.io/en/latest/.
您可以在以下位置找到如何定义您的 Google 地图 API 密钥:https://django-geoposition.readthedocs.io/en/latest/#installation https://django-geoposition.readthedocs.io/en/latest/#installation.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)