【问题标题】:Remove Streetview Controls删除街景控件
【发布时间】:2015-03-23 22:35:11
【问题描述】:

我正在开发我开发的应用程序的前端,并希望从此处显示的 Google StreetView 嵌入中删除控件:

function displayGoogleSV(address_str) {
var geocoder = new google.maps.Geocoder();
var myStreetView = null;

var marker = null;

var address = address_str;
geocoder.geocode({
'address': address
}, function (results, status) {
//alert (results);
if (status == google.maps.GeocoderStatus.OK) {
//alert(results[0].geometry.location);
myStreetView = new google.maps.StreetViewPanorama(document.getElementById("streetview"));
myStreetView.setPosition(results[0].geometry.location);
google.maps.event.addListenerOnce(myStreetView, 'status_changed', function () {
var heading = google.maps.geometry.spherical.computeHeading(myStreetView.getLocation().latLng, results[0].geometry.location);
myStreetView.setPov({
heading: heading,
pitch: 0
});

我会在哪里看到这里看到的控件:https://developers.google.com/maps/documentation/javascript/examples/streetview-controls

谢谢!

【问题讨论】:

  • 如果您仔细查看链接的代码,您会发现它们设置了linksControl: false, panControl: false,。你试过吗? 提示: myStreetView.setOptions(...);
  • 我看到了我需要实现的代码,我只是不确定我需要将它粘贴到我的应用程序的 javascript 中的哪个位置。

标签: javascript api google-street-view


【解决方案1】:

您应该使用街景选项中的链接选项来禁用它们:

/* ... */
myStreetView.setPov({
    heading: heading,
    pitch: 0
});

var panoOptions = {
    addressControlOptions: {
      position: google.maps.ControlPosition.BOTTOM_CENTER
    },
    linksControl: false,
    panControl: false,
    zoomControlOptions: {
      style: google.maps.ZoomControlStyle.SMALL
    },
    enableCloseButton: false
};

myStreetView.setOptions( panoOptions );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-25
    • 2015-03-24
    • 1970-01-01
    • 1970-01-01
    • 2014-08-31
    相关资源
    最近更新 更多