Google Maps API Released!

Google Maps API was recently released and it has me all excited about the endless possabilities in web-based mapping. Until now you had to "hack" around to play with it using something like Google Maps Standalone Mode. Check out my demo map that re-centers the map where you click it, creates a marker, and gives you the coordinates of the position in a call out box.

My Code:

\\ General map setup elements
var map = new GMap(document.getElementById("map"));
map.centerAndZoom(new GPoint(-92.27722, 34.74875), 4);

\\ Creates a default marker icon on the map center
\\ near our office in Little Rock, AR
var point = new GPoint(-92.27722, 34.74875);
var marker = new GMarker(point);
map.addOverlay(marker);

\\ Creates icon anywhere you click on the map
GEvent.addListener(map, 'click', function(overlay, point) {
if (overlay) {
map.removeOverlay(overlay);
} else if (point) {
map.recenterOrPanToLatLng(point);

\\ Re-defines the 'marker' variable to the new point
var marker = new GMarker(point);
map.addOverlay(marker);

\\ Sets the callout box message equal to coords of the
\\ newly defined point
var message = "Location: " + point + "";
marker.openInfoWindowHtml(message); }
});


Posted by brady on 06/30/05 | Comments (0) | Trackbacks (1)


Comments

There are no comments.
None

Post a comment






(include http://)






Type the word in the image: