var directions;
var palm_desert;
var park_city;
Ext.onReady(function() {
if (GBrowserIsCompatible()) {
// Set the center and some controls
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
// Create an object for driving directions
directions = new GDirections(map, document.getElementById('directions'));
GEvent.addListener(directions, 'error', handleErrors);
// Set the markers
var palmDesert = function() {
this.className = 'palm_desert';
this.point = new GLatLng(33.7192190, -116.3880780);
this.html = 'Coda Gallery Palm Desert 73-151 El Paseo Palm Desert, CA 92260';
this.default_html = this.html + '
Directions: To here - From here' +
' Start address: ' +
'' +
' ' +
'';
this.from_html = this.html + '
Directions: To here - From here' +
' End address: ' +
'' +
' ' +
'';
this.createMarker = function() {
var default_html = this.default_html;
var marker = new GMarker(this.point);
this.marker = marker;
map.addOverlay(marker);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(default_html);
});
}
this.toHere = function() {
this.marker.openInfoWindowHtml(this.to_html);
}
this.fromHere = function() {
this.marker.openInfoWindowHtml(this.from_html);
}
}
map.setCenter(new GLatLng(33.7192190, -116.3880780), 15);
palm_desert = new palmDesert();
palm_desert.createMarker();
palm_desert.marker.openInfoWindowHtml(palm_desert.default_html)
}
});
function setDirections(fromAddress, toAddress) {
directions.load("from: " + fromAddress + " to: " + toAddress);
}
function handleErrors(){
if (directions.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + directions.getStatus().code);
else if (directions.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + directions.getStatus().code);
else if (directions.getStatus().code == G_GEO_MISSING_QUERY)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + directions.getStatus().code);
else if (directions.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + directions.getStatus().code);
else if (directions.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: " + directions.getStatus().code);
else alert("An unknown error occurred.");
}