我的代码如下。一切都很好。现在地图没有显示出来。没有改变网站上的任何内容。有什么想法吗?
错误:
InvalidValueError: handleApiReady is not a function
代码:
<form...>
<input type="hidden" name="latitude" id="latitude" value="<?php echo $latitude;?>" />
<input type="hidden" name="longitude" id="longitude" value="<?php echo $longitude;?>" />
<script type="text/javascript" src="//maps.google.com/maps/api/js?key=myKey&callback=handleApiReady"></script>
<script type="text/javascript">
var map=null;
var myLatlng=null;
function handleApiReady() {
myLatlng = new google.maps.LatLng(28.318890, -16.494598);
var myOptions = {
zoom: 16,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
draggable: true,
title: 'Fotos',
icon: '//google-maps-icons.googlecode.com/files/factory.png',
map: map
});
google.maps.event.addListener(marker, 'dragend', function (event) {
document.getElementById("latitude").value = this.getPosition().lat();
document.getElementById("longitude").value = this.getPosition().lng();
});
}
</script>
<div id="map_canvas" style="width:379px;height:390px;"></div>
</form>
答案 0 :(得分:1)
我只需要改变
<script async defer src="//maps.google.com/maps/api/js?key=myKey&callback=handleApiReady"></script>
到
{
"members": [
{
"host": "db1.example.com",
"port": "27017"
},
{
"host": "db2.example.com",
"port": "27017"
}
]
}
它解决了这个问题。