Search code examples
google-mapsgoogle-street-view

Get the coordinates when the Pegman is dropped.


How can I get the co-ordinates of the location where the Pegman is dropped? Couldn't find any helpful articles here in Stackoverflow and in Google API. Is there any event that can be captured on Pegman drop?


Solution

  • For the map try with a listener on the click event

      google.maps.event.addListener(map,    'click',    function(event){
                    alert(event.latLng );
                });
    

    for streetview look at this google sample (below you see the concept but for a complete the sample is better)

     google.maps.event.addListener(panorama, 'position_changed', function() {
         alert(panorama.getPosition()) ;
     });