我想尝试一个实现Gmaps v3的示例演示,并从Google的文档中尝试了这个示例,但没有输出,页面只加载几秒钟然后空白,没有输出.
<!DOCTYPE html>
<html lang = "en">
<head>
<style type="text/css">
html{height: 100%}
body{height: 100%; margin: 0; padding: 0}
#map-canvas{height: 100%}
</style>
<title>GMaps Demo</title>
<script src = "https://maps.googleapis.com/maps/api/js?
key=${API_KEY}&sensor=false">
</script>
<script>
function initialize(){
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = google.maps.Map(
document.getElementById("map-canvas"),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id = "map-canvas">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我正在尝试编程地理编码.我创建了API密钥,但是当我将它添加到我的网站代码中时,我没有得到任何东西,但是当我不使用API时,一切都运行良好.当我发送时:
https://maps.googleapis.com/maps/api/geocode/json?address=".$adres."&key=KLUCZ_XXX
Run Code Online (Sandbox Code Playgroud)
我收到回复:
Browser API keys cannot have referer restrictions when used with this API.
Run Code Online (Sandbox Code Playgroud)
如果我使用:
https://maps.googleapis.com/maps/api/geocode/json?address=".$adres"
Run Code Online (Sandbox Code Playgroud)
结果是正确的,但每天查询的数量是有限的.
关键约束:引用HTTP(Web) - 设置为召唤查询的域.界面Google Maps Geocoding API已启用.
API密钥是否也必须在其他地方激活才能工作?
我已经在我的网站上请求了一个用于嵌入谷歌地图的链接
https://developers.google.com/maps/documentation/embed/start
Run Code Online (Sandbox Code Playgroud)
并授权每个人都使用链接来使用它
Referers: Any referer allowed
https://code.google.com/apis/console/
Run Code Online (Sandbox Code Playgroud)
但我还是收到了
The Google Maps API server rejected your request. This API project is not authorized
to use this API. Please ensure that this API is activated in the APIs Console:
Learn more: https://code.google.com/apis/console
Run Code Online (Sandbox Code Playgroud)
是否有其他方法可以在本地使用嵌入式谷歌地图测试我的网站?
编辑:他们说:
Easy embedding
Google Maps Embed API maps are easy to add to your webpage—just set the URL
you build as the value of an iframe's src attribute. Control the size of the
map with the iframe's height …Run Code Online (Sandbox Code Playgroud) 我有一个API密钥.它是"浏览器应用程序的关键(带有引用者).它工作正常,但当我尝试在我的本地开发服务器上使用它时,我没有被授权.我使用MAMP,我的本地URL如下所示:http://mysite.dev.
在"Referers"部分,我有:
mysite.com/*
mysite.dev/*
Run Code Online (Sandbox Code Playgroud)
制作一个(.com)工作正常,所以我很确定我的语法是正确的.但无论我尝试使用本地版本,我都会收到Google的授权错误信息,告诉我:
Google已禁止将Maps API用于此应用程序.提供的密钥不是有效的Google API密钥,也未授权此网站上的Google Maps Javascript API v3.如果您是此应用程序的所有者,则可以在此处了解如何获取有效密钥:https: //developers.google.com/maps/documentation/javascript/tutorial#api_key
肯定有办法让这个工作!它是什么?
Google API 密钥限制 - HTTP 引荐来源网址
我把我的 Azure 网站 url xxxx.scm.azurewebsites.net 放在那里,但不起作用(Google Places API Web 服务停止工作)。
localhost:44300 也不起作用。
我必须将密钥限制设置为“无”,然后 Google Places API Web 服务才能工作。
我做错了什么?