Search code examples
google-mapsgoogle-maps-api-3google-street-view

How to grab the event when we drop the pegman on any marker in the map


I need to grab the event if a user drags and then drop the pegman on a marker which is there on the map. How to do this?


Solution

  • You can set the pegman's location manually, as it is done in this example:

    The short code version is like this:

    var G = google.maps;
    
    var svpOptions = {
    //      navigationControl: false,
    //      addressControl: false,
    //      linksControl: false,
            addressControlOptions: {
                style: { 
                  border: '1px solid white', 
                  backgroundColor: 'black',
                  font: 'normal 10px verdana',
                  color: 'white'
                }
            }
        };
    
        var latlon = new google.maps.LatLng(45.0, -90.0);
        svpContainer = document.getElementById('svpDiv');
        var svp = new G.StreetViewPanorama(svpContainer,svpOptions);
        svp.setPosition(latlon);