«

»

Oct
27

Allowing Users To Add Markers On Maps With Google Maps Api

I have been working with Google Maps API to develop various things, so when a friends band asked for some help with an idea that involved allowinging visitors to their site to place markers on a map, I came up with this code:

<script type=”text/javascript”>
//<![CDATA[

var map = new GMap(document.getElementById("map"));
map.centerAndZoom(new GPoint(10.107421875,49.89463439573421), 14);
map.addControl(new GSmallMapControl());
map.addControl(new GScaleControl());
GEvent.addListener(map, 'click', function(overlay, point) {

if (overlay) {
map.removeOverlay(overlay);

else if (point) {
map.recenterOrPanToLatLng(point);
var marker = new GMarker(point);
map.addOverlay(marker);

);

// Recenter Map and add Coords by clicking the map
GEvent.addListener(map, 'click', function(overlay, point) {
document.getElementById("latbox").value=point.y;
document.getElementById("lonbox").value=point.x;
);

// bind a search control to the map, suppress result list

map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20)));
//]]>

</script>

<form method="POST" action="script.php">
<table>
<INPUT TYPE="hidden" ID="latbox" NAME="lat" value="" >
<INPUT TYPE="hidden" ID="lonbox" NAME="lon" value="" >
<input name="Submit" type="submit" value="Submit">
</form>

Take a look at Circus Envy Bands Traveling CD


Related posts:

  1. Google Page Rank Monitor Software About two years ago I wrote a script that would check the Google Page Rank of all my sites on a monthly basis and record that Page...

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>