如何在Google地图上显示GoogleStreetView图层?

问题描述 投票:-1回答:1
  1. 是否有API在地图上显示GoogleStreetView(GSV)?

  2. [GoogleMAP可以像下面这样在GMAP上打开/关闭GSV位置。

    打开

    enter image description here关闭

    enter image description here

  3. 但是我只是找不到要切换的API

    enter image description here

google-maps-api-3 layer google-street-view
1个回答
0
投票

StreetViewCoverageLayer在文档中进行了描述:

StreetViewCoverageLayer类google.maps.StreetViewCoverageLayer类别

说明街景视图可用位置的图层。

此类扩展了MVCObject。

构造函数StreetViewCoverageLayer | StreetViewCoverageLayer()参数:无创建StreetViewCoverageLayer的新实例。

proof of concept fiddle

screenshot of resulting map

代码段:

function initialize() {
  var fenway = {lat: 42.345573, lng: -71.098326};
  var map = new google.maps.Map(document.getElementById('map'), {
    center: fenway,
    zoom: 14
  });
  var streetViewLayer = new google.maps.StreetViewCoverageLayer();
  streetViewLayer.setMap(map);
}
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
#map {
  height: 100%;
  width: 100%;
}
<div id="map"></div>
<!-- Replace the value of the key parameter with your own API key. -->
<script async defer
        src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk&callback=initialize">
    </script>
© www.soinside.com 2019 - 2024. All rights reserved.