Thursday, March 12, 2009

Incorporate Google Map to page.

SCRIPT START HERE src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAchOdSzCPe0fgAm8Ow24YYhQZMjxVy-0fy3B1JroJth17tbEUrRQwDlqM1PUlwiawvBO4RMVpYVIfLA"
type="text/javascript"
/SCRIPT END HERE

2ND SCRIPT TAG START HERE

var map = null;
var geocoder = null;

function load()
{
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);

geocoder = new GClientGeocoder();
var address =document.getElementById('TextBox1').value;

showAddress(address);
}
return false;
}
function showAddress(address)
{
if (geocoder)
{
geocoder.getLatLng(address,function(point) {
if (!point) {alert(address + " not Valid Address ");}
else {
map.setCenter(point, 13);

var baseIcon = new GIcon();
baseIcon.shadow = "images/star_location.gif";

baseIcon.iconSize = new GSize(19, 18);
baseIcon.shadowSize = new GSize(19, 18);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
function createMarker(point, index) {
// Create a lettered icon for this point using our icon class
var letter = String.fromCharCode("A".charCodeAt(0) + index);
var icon = new GIcon(baseIcon);
icon.image = "images/star_location.gif";
var marker = new GMarker(point, icon);

GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(address);});
return marker;
}

map.addOverlay(createMarker(point, 13));
}
}
);
}
}
/2ND SCRIPT TAG END HERE.


//DIV IN HTML PAGE

divSTART id="map" style="width: 600px; height: 600px;">
/divEND

//BUTTON BODY:

asp:button id="Button1" onclientclick="javascript:return load();" runat="server" text="Button"

1 comment: