最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Maps API disable street view UI - Stack Overflow

programmeradmin0浏览0评论

I'm using the Google Maps JavaScript API v3. Is it possible to disable/hide all street view UI in google maps?

I tried

disableDefaultUI: true

in the map options but doesn't disable the UI in street view.

I'm using the following code to display street view on a click marker event:

service.getPanoramaByLocation(marker.getPosition(), 200, function(result, status) {
    if (status == google.maps.StreetViewStatus.OK) {
        var panorama = map.getStreetView();
        panorama.setPosition(result.location.latLng);
        panorama.setVisible(true);
        disableDefaultUI: true;
    } else {
        alert("No street view is available within " + 200 + " meters");
        return;
    }
});

I'm using the Google Maps JavaScript API v3. Is it possible to disable/hide all street view UI in google maps?

I tried

disableDefaultUI: true

in the map options but doesn't disable the UI in street view.

I'm using the following code to display street view on a click marker event:

service.getPanoramaByLocation(marker.getPosition(), 200, function(result, status) {
    if (status == google.maps.StreetViewStatus.OK) {
        var panorama = map.getStreetView();
        panorama.setPosition(result.location.latLng);
        panorama.setVisible(true);
        disableDefaultUI: true;
    } else {
        alert("No street view is available within " + 200 + " meters");
        return;
    }
});
Share Improve this question asked Feb 2, 2014 at 3:09 CyberJunkieCyberJunkie 22.7k61 gold badges154 silver badges219 bronze badges 1
  • 1 disableDefaultUI: true; will produce a syntax error. What exactly do you want to disable? – Salman Arshad Commented Feb 2, 2014 at 9:22
Add a ment  | 

3 Answers 3

Reset to default 3

You have to use map option streetViewControl and set it to false like:

var mapOptions = {
    zoom: 15,
    center: new google.maps.LatLng(52.5, 13.4),
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    streetViewControl: false
};

You might want to check this: https://developers.google./maps/documentation/javascript/reference#StreetViewPanoramaOptions

var panoramaOptions = {
    disableDefaultUI: true
};

panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"), panoramaOptions);

Here is a demo.

If you are in angular 8 you can do it in the following way:

"@angular/google-maps": "^10.1.3", --> package.json

<google-map width="100%" height="100%" [center]="center" [zoom]="zoom" 
[options]="mapOptions">

The options to use are:

mapOptions = {
 fullscreenControl: false,
 disableDefaultUI: true
};
发布评论

评论列表(0)

  1. 暂无评论