Django django-location-field缺少API密钥 [英] Django django-location-field missing API Keys

查看:81
本文介绍了Django django-location-field缺少API密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 https://github.com/caioariede/django-location-field 库以使用Django构建位置视图.问题是我找不到说明如何定义自己的Google Maps API KEY的文档.

I am using the https://github.com/caioariede/django-location-field library to build a Location View using Django. The issue is that I can't find a documentation saying how to define my own Google Maps API KEY.

这是我的settings.py中的代码:

This is the code I have on my 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',
        ],
    },
}

但是这种解决方案似乎无效.

But this solution dose not seem to work.

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

我已经搜索了一段时间,但没有找到答案的运气.

I have been searching for a while now, but no luck in getting the answer.

推荐答案

您可以使用 django-geoposition 代替 django-location-field .它具有相同的功能,还具有一个简单的文档 https://django-geoposition.readthedocs. io/en/latest/.

You may use django-geoposition instead of django-location-field. It has the same functionality and also has a simple documentation https://django-geoposition.readthedocs.io/en/latest/.

您可以在 https://中找到如何定义Google Maps API KEY的方法django-geoposition.readthedocs.io/zh-CN/latest/#installation .

这篇关于Django django-location-field缺少API密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆