首页 文章

Google Maps JavaScript API警告:NoApiKeys

提问于
浏览
1

我们的网站提供警告提示"This page can't load Google Maps correctly" . 我正在使用"ivory-google-map"捆绑的symfony2 . 在控制台中,我们发现警告为“Google Maps JavaScript API警告:NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys”任何帮助都会非常感激 .

2 回答

  • 3

    如错误消息所示,您需要APIKey来删除此错误 .

    你可以从https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key获得APIKey

    并将该密钥应用于您的代码,如:

    <script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" type="text/javascript"></script>
    

    之后,上面的错误将不复存在!

  • 0

    如果您不想购买API密钥并且只需要静态 Map ,则可以使用iFrame执行此操作 .

    <div class="mapouter"><div class="gmap_canvas"><iframe width="600" height="500" id="gmap_canvas" src="https://maps.google.com/maps?q=university%20of%20san%20francisco&t=&z=13&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe><a href="https://www.pureblack.de"></a></div><style>.mapouter{text-align:right;height:500px;width:600px;}.gmap_canvas {overflow:hidden;background:none!important;height:200px;width:300px;}</style></div>
    

    但我不知道这可能会持续多久

相关问题