注意(更新):将非谷歌地图与街景结合使用不符合谷歌的服务条款:http://cloud.google.com/maps-platform/terms
从技术上讲是可能的:
您可以将Google Street View Service 与自定义地图框地图一起使用。
要创建街景全景图,您需要对其进行初始化:
panorama = new google.maps.StreetViewPanorama(document.getElementById('panorama'), {
position: { lng: 23.332791136054766, lat: 42.69581966446731 },
pov: { heading: 165, pitch: 0 },
addressControl: false,
linksControl: true, // guide arrows
panControl: false, // compass
zoomControl: false,
/*
zoomControlOptions: {
position: google.maps.ControlPosition.LEFT_TOP
},*/
fullscreenControl: true,
fullscreenControlOptions: {
position: google.maps.ControlPosition.LEFT_TOP
},
zoom: 5,
visible: true,
mode: 'html5' // fixes bug in FF: http://stackoverflow.com/questions/28150715/remove-google-street-view-panorama-effect
});
然后您可以根据来自您的 mapbox 地图的事件更新全景位置:
panorama.setPov({
heading: +building.heading || 0,
pitch: +building.pitch || 0,
zoom: +building.zoom || 1
});
panorama.setPosition({
lng: +building.lng,
lat: +building.lat
});
// NOTE: this fixes broken behavior:
panorama.setVisible(false);
panorama.setVisible(true);
或者,您可以查看Mapillary,它是比 Google 街景更开放的替代方案。他们实际上在explorer UI 中使用了 mapbox-gl。