How to detect streetview entry and exit in the Google Maps API v3

Is there a way to detect when a user logs in and out of StreetView in Google Maps in API v3?

I want to call the existing Hide Menu function when the user enters StreetView (since the menu does not matter), and then re-display the menu when they exit.

+5
source share
2 answers

Watch the visible_changed -event of streetView, visible -property will be true or false (open or closed)

  function initialize() { var mapOptions = { center: new google.maps.LatLng(52.5498783, 13.425209), zoom: 8 }; var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); google.maps.event.addListener(map.getStreetView(),'visible_changed',function(){ alert('streetview is ' +(this.getVisible()?'open':'closed')); }); } google.maps.event.addDomListener(window, 'load', initialize); 
  html,body,#map-canvas { height: 100%; margin: 0; padding: 0; } 
 <script src="https://maps.googleapis.com/maps/api/js?v=3&.js"></script> <div id="map-canvas"></div> 
+9
source

You must use the visible_changed event listener, and add the doAlert () function. This will allow you to browse the street to warn you when you enter the street, as well as when leaving the view of the street.

0
source

Source: https://habr.com/ru/post/1214385/


All Articles