/**
* Copyright reserved to Gustavo Granados Medina - TavoGM@Gmail.com
* if you find any problem contact me at http://software506.com
* fell free to visit my code section http://code.software506.com
*/
//Class definitions
function Location(address, description)
{
this.address = address;
this.description = description;
this.getAddress = function()
{
return this.address;
}
this.getDescription = function()
{
return this.description;
}
this.setAddress = function(newAddress)
{
this.address = newAddress;
}
this.setDescription = function(newDescription)
{
this.description = newDescription;
}
}
/*-----------------------------------------------------------------*/
var map = null;
var geocoder = null;
// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
var baseIcon = new GIcon();
baseIcon.iconSize = new GSize(29, 46);
baseIcon.shadowSize = new GSize(29, 46);
baseIcon.iconAnchor = new GPoint(13, 47);
baseIcon.infoWindowAnchor = new GPoint(0, 0);
baseIcon.infoShadowAnchor = new GPoint(0, 0);
var points = new Array();
function fitMap(map, 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());
}
function showAddress(location, index, last)
{
if (geocoder)
{
geocoder.getLatLng(location.getAddress(),
function(point)
{
if (!point)
{
//alert(location.getAddress() + " not found");
}
else
{
map.setCenter(point, 10);
var letteredIcon = new GIcon(baseIcon);
//letteredIcon.image = "../gd_images/getImage.php?index="+index;
letteredIcon.image = "http://www.weeklyplus.com/beta/gd_images/getImage.php?index="+index;
// Set up our GMarkerOptions object
markerOptions = { icon:letteredIcon };
var marker = new GMarker(point, markerOptions);
GEvent.addListener(marker, "click",
function()
{
var myHtml = location.getDescription();
map.openInfoWindowHtml(point, myHtml);
}
);
map.addOverlay(marker);
points[points.length] = point;
if (last)
{
fitMap(map, points);
}
}
}
);
}
}
function loadMap()
{
if (GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
//map.addControl(new GMapTypeControl());
map.enableScrollWheelZoom();
geocoder = new GClientGeocoder();
}
location1 = new Location("80124 10345 Park Meadows Drive Littleton, CO", "Sonoma'z Wine Bar and Grill
10345 Park Meadows Drive
Littleton,
80124");
showAddress(location1, 1, 0);
}