我的电脑中有一个名为“GMPos.html”的文件,该文件包含1个标记:
<script src='https://maps.googleapis.com/maps/api/js?v=3.4&key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'></script>
<script type="text/javascript">
var icon_shadow = new google.maps.MarkerImage('icons/mm_20_shadow.png',
new google.maps.Size(28,22),
new google.maps.Point(0,0),
new google.maps.Point(10,21));
var a_icon = new google.maps.MarkerImage('icons/mm_20_red.png',
new google.maps.Size(22,22),
new google.maps.Point(0,0));
var map;
function loadMap() {
var myLatLng = new google.maps.LatLng(14.60192,-90.53268);
var myOptions = {
center: myLatLng,
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
var marker = new google.maps.Marker({
position: myLatLng,
icon: a_icon,
shadow: icon_shadow,
map: map,
title:'Id: GUA001'
});
}
</script>
当我尝试在Firefox中打开文件时,出现以下错误:
“Google Maps API错误:Google Maps API错误: RefererNotAllowedMapError https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error 您要授权的网站网址:file:/// C:/RunTime/Mss/GMH/GMPos.html“
所以,我添加了以下引用:
*C:/RunTime/Mss*
file:///C:/RunTime/Mss/GMH/GMPos.html
*file:///C:/RunTime/Mss/GMH/GMPos.html*
但仍然会抛出相同的错误,请帮忙。
提前谢谢
答案 0 :(得分:1)
请在Google API控制台中检查与密钥相关的API限制。标记API被视为“ Maps JavaScript API”限制。