<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=GOOGLE MAP CODE" type="text/javascript"></script>
<div id="map_canvas" style="width: 414px; height: 300px"></div>
<div id="street" style="width: 414px; height: 300px"></div>
<script>
var map;
var panorama;
var geocoder = null;
</script>
<script>
function initialize() {
address='地址';
geocoder = new GClientGeocoder();
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(point, 16);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(address);
var option = { latlng:point };
var scontainer = document.getElementById("street");
panorama = new GStreetviewPanorama(scontainer, option);
GEvent.addListener(map, "click", moveCenter);
geocoder = new GClientGeocoder();
}
}
);
}
}
function moveCenter(overlay, latlng){
var client = new GStreetviewClient();
client.getNearestPanoramaLatLng(latlng, getLatLng);
}
function getLatLng(newlatlng){
map.panTo(newlatlng);
panorama.setLocationAndPOV(newlatlng);
}
if (document.all) {
window.attachEvent('onload', initialize);
window.attachEvent('onunload', GUnload);
}
else {
window.addEventListener('load', initialize, false);
window.addEventListener('onunload', GUnload, false);
}
</script>
關鍵字:javascript,網頁設計,網頁,html, |