How to fully disable streetview from google maps

1.6k views Asked by At

I've disabled streetview controls like so:

var mapOptions = {
  zoom: 16,
  center: myCenter,
  streetViewControl:false
};
var map = new google.maps.Map(
  document.getElementById("map"),
  mapOptions
);

Which takes the streetview control off of the map BUT if you click on a point of interest with a panoramic image / link to streetview then click that image you are again taken into streetview mode.

I want to keep my points of interest but I want to disable maps from going into streetview mode. Is this possible?

streetview photo option in google maps

Solution

Using the answer below I added a few more items:

.gm-rev, .gm-sv-label{display:none;}
.gm-iw, .gm-sm, .gm-wsv{pointer-events:none;}
1

There are 1 answers

1
Dr.Molle On BEST ANSWER

2 possible options(there may be more):

  1. prevent the streetView from being visible:

     google.maps.event.addListener(map.getStreetView(), 'visible_changed', function(){
      if(this.getVisible()){this.setVisible(false)}
     });
    
  2. try to make the streetview-link in the infowindow un-clickable

    .gm-sv-label{display:none;}
    .gm-wsv{pointer-events:none;}
    

I would suggest to use both options together, because the 2nd option may fail in the future(the classNames may change)