我有一些基于Google可拖动标记示例的地图。他们已经工作了几年但昨天破产了。它们似乎不会显示我设置的标记,也不会仅显示卫星视图的路线图视图。知道为什么停止工作了。这是一个小项目,所以我无法想象我达到了使用限制。这是完整的代码。我主要是试图让它正确显示所以不要过多地处理这些功能(除非你认为这是问题)
提前感谢您提供的任何帮助!
标记
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0089)http://gmaps-samples-v3.googlecode.com/svn/trunk/draggable- markers/draggable-markers.html -->
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="initial-scale=1.0, user-scalable=no" name=viewport>
<SCRIPT src="http://maps.google.com/maps/api/js?sensor=false" type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript>
var geocoder = new google.maps.Geocoder();
function geocodePosition(pos) {
geocoder.geocode({
latLng: pos
}, function(responses) {
if (responses && responses.length > 0) {
updateMarkerAddress(responses[0].formatted_address);
} else {
updateMarkerAddress('Cannot determine address at this location.');
}
});
}
function updateMarkerStatus(str) {
document.getElementById('markerStatus').innerHTML = str;
}
function updateMarkerPosition(latLng) {
document.getElementById('info').innerHTML = [
latLng.lat(),
latLng.lng()
].join(', ');
}
function updateMarkerAddress(str) {
document.getElementById('address').innerHTML = str;
}
function initialize() {
var latLng = new google.maps.LatLng(37.6770227, -121.8849154);
var map = new google.maps.Map(document.getElementById('mapCanvas'), {
zoom: 14,
center: latLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new google.maps.Marker({
position: latLng,
title: 'Work Location',
map: map,
draggable: true
});
// Update current position info.
updateMarkerPosition(latLng);
geocodePosition(latLng);
// Add dragging event listeners.
google.maps.event.addListener(marker, 'dragstart', function() {
updateMarkerAddress('Dragging...');
});
google.maps.event.addListener(marker, 'drag', function() {
updateMarkerStatus('Dragging...');
updateMarkerPosition(marker.getPosition());
});
google.maps.event.addListener(marker, 'dragend', function() {
updateMarkerStatus('Drag ended');
geocodePosition(marker.getPosition());
});
}
// Onload handler to fire off the app.
google.maps.event.addDomListener(window, 'load', initialize);
</SCRIPT>
<META content="MSHTML 6.00.6000.16981" name=GENERATOR></HEAD>
<BODY>
<STYLE>#mapCanvas {
FLOAT: left; WIDTH: 600px; HEIGHT: 500px
}
#infoPanel {
FLOAT: left; MARGIN-LEFT: 10px
}
#infoPanel DIV {
MARGIN-BOTTOM: 5px
}
</STYLE>
<DIV id=mapCanvas></DIV>
<DIV id=infoPanel><B>Marker status:</B>
<DIV id=markerStatus><I>Click and drag the marker.</I></DIV>
<DIV id=info></DIV><B>Closest matching address:</B>
<DIV id=address></DIV></DIV></BODY></HTML>