我想在谷歌地图中添加我的自定义图像,但页面未加载,提供错误说明MissingKeyMapError。我想我必须添加身份验证密钥,但我无法添加身份验证密钥
https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error
<!DOCTYPE html>
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?key=xyzKey" type="text/javascript"></script>
<script>
var myCenter = new google.maps.LatLng(22.8046, 86.2029);
function initialize()
{
var mapProp = {
center:myCenter,
zoom:14,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var marker=new google.maps.Marker({
position:myCenter,
icon:'dustbin3.png'
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:1500px;height:880px;"></div>
</body>
</html>
答案 0 :(得分:0)
在脚本网址
中添加api密钥<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY" type="text/javascript"></script>
参考https://developers.google.com/maps/documentation/javascript/get-api-key