开发者

Detecting Google Maps streetview mode

How do I know when the google map is in streetview mode or roadmap mode? Is there an event that gets fired? I tried looking through the docs, and there doe开发者_开发知识库sn't seem to be anything. Am I missing something?

When the user switches into streetview mode, I want the UI to change, but I don't know which event to bind to.


Detect the visible_changed event on the StreetViewPanorama associated with your Map object. You can get the panorama from the map by calling its getStreetView() method and bind the handler to that object's event. You will have to test the StreetViewPanorama's visibility by calling its getVisible() method.

For instance:

var map = new google.maps.Map(document.getElementById("theMap"), {streetViewControl: true});

var thePanorama = map.getStreetView();

google.maps.event.addListener(thePanorama, 'visible_changed', function() {

    if (thePanorama.getVisible()) {

        // Display your street view visible UI

    } else {

        // Display your original UI

    }

});

See the events section of the StreetViewPanorama Object Documentation for more events you can listen for on this object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜