How to add Google Maps to Nukedit and other websites

To make a map similar to this, simply view source and copy from GOOGLE MAP START to GOOGLE MAP FINISH. Alternatively, view the google documentation below to build your own from strath or use some additional features.

Firstly, you'll need a GoogleMap API code.
Get one here http://www.google.com/apis/maps/signup.html

Examples

Each of the following examples shows only the relevant JavaScript code, not the full HTML file. You can plug the JS code into the skeleton HTML file shown earlier, or you can download the full HTML file for each example by clicking the link after the example.

The Basics

The following example creates a map and centers it on Palo Alto, California.

var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);

View example (simple.html)

Map Movement and Animation

The following example displays a map, waits two seconds, and then pans to a new center point.

The panTo method centers the map at a given point. If the specified point is in the visible part of the map, then the map pans smoothly to the point; if not, the map jumps to the point.

var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
window.setTimeout(function() {
map.panTo(new GLatLng(37.4569, -122.1569));
}, 1000);

View example (animate.html)

Adding Controls to the Map

You can add controls to the map with the addControl method. In this case, we add the built-in GSmallMapControl and GMapTypeControl controls, which let us pan/zoom the map and switch between Map and Satellite modes, respectively.

var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(37.4419, -122.1419), 13);

View example (controls.html)

Event Listeners

To register an event listener, call the GEvent.addListener method. Pass it a map, an event to listen for, and a function to call when the specified event occurs. In the following example code, we display the latitude and longitude of the center of the map after the user drags the map.

var map = new GMap2(document.getElementById("map"));
GEvent.addListener(map, "moveend", function() {
var center = map.getCenter();
document.getElementById("message").innerHTML = center.toString();
});
map.setCenter(new GLatLng(37.4419, -122.1419), 13);

View example (event.html)


More Documentation: http://www.google.com/apis/maps/documentation/


Tell a friend about our websiteTell A Friend  Leave FeedbackComment On Page  Add to favoritsBookmark  Print this pagePrint Page
 
 
 


Powered by Nukedit - Web Content Management
Insurance - Car Insurance
Last Modified: 13 July 2006
Generated in 0 seconds.