asked on
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<HEAD>
<script src="http://maps.google.com/maps?file=api&v=2&key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" type="text/javascript"></script>
<script type="text/javascript">
var theaddress='';
initialize = function() {
if (GBrowserIsCompatible()) {
// Points to be plotted
var points = new Array();
var theaddress;
// Initialize Map
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4319,-122.1419), 4);
geocoder = new GClientGeocoder();
// Which Map Control to Use
map.addControl(new GLargeMapControl());
// Add a scale control ?
map.addControl(new GScaleControl());
// Which Map Types
map.addControl(new GMapTypeControl());
// Add Overview Map Control
map.addControl(new GOverviewMapControl());
function getAddress(overlay, latlng) {
if (latlng != null) {
address = latlng;
var theaddress='';
geocoder.getLocations(latlng, showAddress);
}
}
function showAddress(response) {
// map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Status Code:" + response.Status.code);
theaddress = 'Unable to locate address.';
}
else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
// marker.openInfoWindowHtml( '<b>orig latlng:</b>' + response.name + '<br/>' + '<b>latlng:</b>' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '<br>' + '<b>Status Code:</b>' + response.Status.code + '<br>' + '<b>Status Request:</b>' + response.Status.request + '<br>' + '<b>Address:</b>' + place.address + '<br>' + '<b>Accuracy:</b>' + place.AddressDetails.Accuracy + '<br>' + '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
theaddress = '<b>Address:</b> ' + place.address + '<br><b>coord:</b> ' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + ' ' + '(stat ' + response.Status.code + ') (accur:' + place.AddressDetails.Accuracy + ')<br>';
}
}
// If we have coordinates, use those
point = new GLatLng(37.4349, -122.1219);
marker1 = new GMarker(point);
points.push(point);
// Calculate current address and add into floater
GEvent.addListener(marker1, "click",
function() {
// theaddress = 'hi';
point = new GLatLng(37.4349, -122.1219);
// alert('theaddress1: ' + theaddress);
getAddress(map, point);
// alert(null);
marker1.openInfoWindowHtml('03/27/2009 11:58<BR>This is point 1.<BR>'+ theaddress );
});
map.addOverlay(marker1);
// If we have coordinates, use those
point = new GLatLng(37.3239, -121.9299);
marker10 = new GMarker(point);
points.push(point);
// Calculate current address and add into floater
GEvent.addListener(marker10, "click",
function() {
point = new GLatLng(37.3239, -121.9299);
getAddress(map, point);
marker10.openInfoWindowHtml('03/27/2009 11:58<BR>This is point 10.<BR>'+ theaddress );
});
map.addOverlay(marker10);
var polyline = new GPolyline( [
new GLatLng(37.4349, -122.1219), new GLatLng(37.4269, -122.0819), new GLatLng(37.4179, -122.0489),
new GLatLng(37.3979, -122.0399), new GLatLng(37.3889, -122.0249), new GLatLng(37.3809, -122.0009),
new GLatLng(37.3679, -121.9899), new GLatLng(37.3509, -121.9809), new GLatLng(37.3349, -121.9569),
new GLatLng(37.3239, -121.9299)
], "#ff0000", 10);
map.addOverlay(polyline);
// Scale the zoom level to the points on the map and center between the points.
var bounds = new GLatLngBounds();
for (var i=0; i< points.length; i++) {
bounds.extend(points[i]);
}
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter());
}
}
</script>
</HEAD>
<body onload="initialize();" onunload="GUnload()">
<style>
body,td {font-family: arial; font-size: 10pt;}
</style>
<div id="map_canvas" style="width: 700px; height: 500px"></div>
</body>
</HTML>
Bad.JPG