gpt4 book ai didi

google-maps - 在 Google Maps Street View 中禁用建筑物的室内 View

转载 作者:行者123 更新时间:2023-12-04 06:58:21 38 4
gpt4 key购买 nike

我正在开发一个项目,该项目在 Google map 上显示一堆标记,并允许用户搜索并获取有关位置的相关信息。我没有禁用街景,因为我想让用户有可能从外面看到建筑物。

但是,对于某些位置,当进入街景模式时,谷歌地图会立即显示相邻商家的室内情况。我想要的是能够在我的应用程序上完全禁用室内 View 。

有没有人知道 Google Maps API 中的某个设置可以做到这一点,或者可能是一个聪明的黑客来解决这个问题?老实说,我没有发现任何东西。

最佳答案

在实验版本(当前 v=3.21)中,现在有一个 StreetViewSource可以在 StreetViewLocationRequest 中提供

StreetViewSource类(class)

google.maps.StreetViewSource classIdentifiers to limit Street View searches to selected sources.ConstantDEFAULT Uses the default sources of Street View, searches will not be limited to specific sources.OUTDOOR Limits Street View searches to outdoor collections only.

code snippet (with source: OUTDOOR):

/*
* Click the map to set a new location for the Street View camera.
*/

var map;
var panorama;

function initMap() {
var myLatlng = new google.maps.LatLng(51.343364, 12.378962999999999);
var sv = new google.maps.StreetViewService();

panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'));

// Set up the map.
map = new google.maps.Map(document.getElementById('map'), {
center: myLatlng,
zoom: 16,
streetViewControl: false
});

// Set the initial Street View camera to the center of the map
sv.getPanorama({
location: myLatlng,
radius: 50,
source: google.maps.StreetViewSource.OUTDOOR
}, processSVData);

// Look for a nearby Street View panorama when the map is clicked.
// getPanoramaByLocation will return the nearest pano when the
// given radius is 50 meters or less.
map.addListener('click', function(event) {
sv.getPanorama({
location: event.latLng,
radius: 50
}, processSVData);
});
}

function processSVData(data, status) {
if (status === google.maps.StreetViewStatus.OK) {
var marker = new google.maps.Marker({
position: data.location.latLng,
map: map,
title: data.location.description
});

panorama.setPano(data.location.pano);
panorama.setPov({
heading: 270,
pitch: 0
});
panorama.setVisible(true);

marker.addListener('click', function() {
var markerPanoID = data.location.pano;
// Set the Pano to use the passed panoID.
panorama.setPano(markerPanoID);
panorama.setPov({
heading: 270,
pitch: 0
});
panorama.setVisible(true);
});
} else {
console.error('Street View data not found for this location.');
}
}
google.maps.event.addDomListener(window, 'load', initMap);
      html,
body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="map" style="width: 45%; height: 100%;float:left"></div>
<div id="pano" style="width: 45%; height: 100%;float:left"></div>

关于google-maps - 在 Google Maps Street View 中禁用建筑物的室内 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32256936/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com