I need some code that allows users to add their own markers to my map. Does anybody have an example?
Thanks!
var initialLocation;
var siberia = new goog
It's not a hard job:
Set a click event on the map
google.maps.event.addListener(map, 'click', function(event) { placeMarker(event.latLng); });
Place the marker and make an AJAX call to the server to save the location in the database:
function placeMarker(location) { var marker = new google.maps.Marker({ position: location, map: map }); map.setCenter(location); $.ajax({ url: 'myPHP', data: location, succes: function(){ alert('marker was added'); }, error: function(){ alert('marker wasn't added'); marker.setMap(null); } }); }