(The first two parameters to the gload function set the initial centre of the map. This is pulled from the database.
Javascript
function gload(lat,lon,gheight,gwidth){
if(mapload(lat,lon,gheight,gwidth)){
tb_show('Click to add marker', '#TB_inline?height='+((gheight*1)-5)+'&width='+((gwidth*1))+'&inlineId=map',true);
}
}
function mapload(lat,lon,gheight,gwidth) {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_window"), {size: new GSize(gwidth,gheight)});
var mapControl = new GMapTypeControl();
map.addControl(mapControl);
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng(lat,lon),13);
GEvent.addListener(map, "click", function(overlay, latlng) {
if (latlng) {
marker = new GMarker(latlng, {draggable:true});
map.addOverlay(marker);
var lat = latlng.lat();
var lng = latlng.lng();
document.getElementById("lat").value=parseFloat(parseFloat(lat).toFixed(6));
document.getElementById("long").value=parseFloat(parseFloat(lng).toFixed(6));
}
});
GEvent.addListener(marker, "dragend", function() {
var latlng = marker.getLatLng();
var lat = latlng.lat();
var lng = latlng.lng();
document.getElementById("lat").value=parseFloat(parseFloat(lat).toFixed(6));
document.getElementById("long").value=parseFloat(parseFloat(lng).toFixed(6));
});
return true;
}
}
The mapload function adds a click function to the map and a dragend function to the marker which both update the lat and long coordinates on the form.
You will also need to load the google map api javascript file and include your Map Key.