Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 doesn'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.

like image 429
userinev Avatar asked Aug 31 '11 01:08

userinev


People also ask

How do I know if Street View is available?

Instead of clicking the "Street View" button, this is now accessed using the "pegman" button in the left hand corner. When the "pegman" icon is dragged over the map blue polylines appear where Street View is available and a small window will show the current Street View.

How long before Google updates Street View?

In general, Google tries to take new Street View photos in major cities once every year. Less populated areas can probably expect new photos every three years or so — but don't be surprised if it takes even longer.

Can you look at Google Maps in real time?

Navigate with Live View. Google Maps offers two views for walking navigation: the 2D map and Live View. With Live View, you get directions placed in the real world and on a mini map at the bottom of your screen. You can use Live View navigation during the walking portion of any type of trip.


1 Answers

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.

like image 178
lsuarez Avatar answered Oct 13 '22 19:10

lsuarez