Google Map Api v3 drag event on map

Both Map objects and Marker objects have drag events, although you probably want dragend so that you can do something when a user is done dragging rather than do something while a user is dragging. So you could do something like this: google.maps.event.addListener(map, ‘dragend’, function() { alert(‘map dragged’); } ); google.maps.event.addListener(marker, ‘dragend’, function() { alert(‘marker …

Read more

Change marker size in Google maps V3

This answer expounds on John Black’s helpful answer, so I will repeat some of his answer content in my answer. The easiest way to resize a marker seems to be leaving argument 2, 3, and 4 null and scaling the size in argument 5. var pinIcon = new google.maps.MarkerImage( “http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|FFFF00”, null, /* size is determined …

Read more

Capture Coordinates in Google Map on User Click

You should add the click listener on marker will give you the position of marker. //Add listener google.maps.event.addListener(marker, “click”, function (event) { var latitude = event.latLng.lat(); var longitude = event.latLng.lng(); console.log( latitude + ‘, ‘ + longitude ); }); //end addListener Edit: You need something like this //Add listener google.maps.event.addListener(marker, “click”, function (event) { var …

Read more

Check if infowindow is opened Google Maps v3

This is an undocumented feature, and is therefore subject to change without notice, however the infoWindow.close() method sets the map on the object to null (this is why infoWindow.open(map, [anchor]) requires that you pass in a Map), so you can check this property to tell if it is currently being displayed: function isInfoWindowOpen(infoWindow){ var map …

Read more

Using Google maps API v3 how do I get LatLng with a given address?

There is a pretty good example on https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple To shorten it up a little: geocoder = new google.maps.Geocoder(); function codeAddress() { //In this case it gets the address from an element on the page, but obviously you could just pass it to the method instead var address = document.getElementById( ‘address’ ).value; geocoder.geocode( { ‘address’ : …

Read more

Retrieve latitude and longitude of a draggable pin via Google Maps API V3

Either of these work google.maps.event.addListener(marker, ‘click’, function (event) { document.getElementById(“latbox”).value = event.latLng.lat(); document.getElementById(“lngbox”).value = event.latLng.lng(); }); google.maps.event.addListener(marker, ‘click’, function (event) { document.getElementById(“latbox”).value = this.getPosition().lat(); document.getElementById(“lngbox”).value = this.getPosition().lng(); }); You might also consider using the dragend event also google.maps.event.addListener(marker, ‘dragend’, function (event) { document.getElementById(“latbox”).value = this.getPosition().lat(); document.getElementById(“lngbox”).value = this.getPosition().lng(); });