asked on
My body tag says ... <body onload="javascript:initialize();showlocamap();"> .. and this gets the ball rolling and correct maps 123 Main St for me...
<script src="http://maps.google.com/maps?file=api&v=2.x&key=<%=gcGoogleAPIKey%>" type="text/javascript"></script>
<script type="text/javascript">
var map;
var geocoder;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(34, 0), 1);
geocoder = new GClientGeocoder();
}
function showlocamap() {
geocoder.getLocations('123 Main St, Portland, OR', AddressToMap);
}
function AddressToMap(response) {
map.setCenter(new GLatLng(34, 0 ), 5);
var mapControl = new GMapTypeControl();
map.addControl(mapControl);
map.addControl(new GLargeMapControl());
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Sorry, we were unable to geocode that address");
} else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
Clip_Lat = place.Point.coordinates[1];
Clip_Long = place.Point.coordinates[0];
document.mapform.txtLat_Value.value = Clip_Lat;
document.mapform.txtLong_Value.value = Clip_Long;
marker = new GMarker(point,{draggable:true});
GEvent.addListener(marker, 'dragend', function() {marker.openInfoWindow('Now What?';});
map.addOverlay(marker);
marker.openInfoWindowHtml(place.address + '<br>' +
'<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
}
}
</script>