var map; var gdir; Ext.onReady(function() { var from_field = new Ext.form.TextField({ renderTo: 'from_el', name: 'from_field', width: 220 }); var to_field = new Ext.form.ComboBox({ renderTo: 'to_el', name: 'category_selector', width: 220, emptyText: 'Select Location', store: new Ext.data.SimpleStore({ fields : ['value', 'label'], data : [ ['1101-18 Uptown Park Blvd. Houston, TX 77056', 'Uptown Park / Reserve Room'], ['818 Town and Country Blvd., Suite 100 Houston, TX 77024', 'City Centre'], ['2409 West Alabama St. Houston, TX 77098', 'River Oaks'] ] }), mode: 'local', valueField: 'value', displayField: 'label', typeAhead: true, editable: false, triggerAction: 'all' }); var button = new Ext.Button({ renderTo: 'button_el', text: 'Go', handler: function() { setDirections(from_field.getValue(), to_field.getValue()); } }); if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.enableScrollWheelZoom(); // Uptown Park var point1 = new GLatLng(29.755970, -95.457649); var marker1 = new GMarker(point1); var html1 = 'Uptown Park / Reserve Room
1101-18 Uptown Park Blvd.
Houston, TX 77056'; map.addOverlay(marker1); GEvent.addListener(marker1, "click", function() { map.openInfoWindowHtml(point1, html1); }); // City Centre var point2 = new GLatLng(29.776985, -95.560478); var marker2 = new GMarker(point2); var html2 = 'City Centre
818 Town and Country Blvd., Suite 100
Houston, TX 77024'; map.addOverlay(marker2); GEvent.addListener(marker2, "click", function() { map.openInfoWindowHtml(point2, html2); }); // River Oaks var point3 = new GLatLng(29.738520, -95.416968); var marker3 = new GMarker(point3); var html3 = 'River Oaks
2409 West Alabama St.
Houston, TX 77098'; map.addOverlay(marker3); GEvent.addListener(marker3, "click", function() { map.openInfoWindowHtml(point3, html3); }); gdir = new GDirections(map, document.getElementById("directions")); GEvent.addListener(gdir, "error", handleErrors); } }); function setDirections(fromAddress, toAddress) { gdir.load("from: " + fromAddress + " to: " + toAddress); } function handleErrors() { if (gdir.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: " + gdir.getStatus().code); else if (gdir.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: " + gdir.getStatus().code); else if (gdir.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: " + gdir.getStatus().code); else if (gdir.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: " + gdir.getStatus().code); else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code); else alert("An unknown error occurred."); }