更新:根据 OVER_QUERY_LIMIT 的建议,我找到了一个很有前途的解决方案,我今晚会尝试。
最初,我无法在我的 PC 上显示 Google Map API v3。相同的代码在亚马逊服务器上运行。我已经搬到 Rackspace,现在它不显示了。这是我正在使用的代码:
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBiv-nrDCYEEGzD1mk3jAfapfrBH878pqc&sensor=true">
</script>
<script>
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var phpAddressInit = "<?php echo $mapAddress ?>";
//document.write("phpAddressInit: " + phpAddressInit);
//var latlng = new google.maps.LatLng(-34.397, 150.644);
var latlng = new google.maps.LatLng(33.5750, -117.7256);
var mapOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
geocoder.geocode( { 'address': phpAddressInit}, function(results, status) {
//alert("---address3: " + phpAddressInit);
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
function codeAddress(control,ctrlAddress) {
//alert("---in codeAddress; " + "control: " + control
// + "ctrlAddress: " + ctrlAddress);
//var address = document.getElementById('address').value;
//aws.push
var address;
if ( control == 1 )
{
address = document.getElementById('address').value;
}
else
{
address = ctrlAddress;
}
geocoder = new google.maps.Geocoder();
//alert("---address1: " + address);
geocoder.geocode( { 'address': address}, function(results, status) {
//alert("---address2: " + address);
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
</script>
...
我已经用谷歌搜索了几个小时,尝试了几个不同的例子,但它不会显示。我错过了什么?