如何在街景视图中显示左下角的小地图部件(Google Map JS API)

How to show the bottom left minimap widget in streetview (Google Map JS API)

谁知道如何在通过 Google Maps JS API 调用的自定义街景视图中显示左下角的迷你地图?

我前段时间遇到了同样的问题,最后在街景全景图中做了一个自定义控件。似乎没有一种简单的方法可以用 API.

做这种事情

在此代码笔中:http://codepen.io/chmartinez/pen/pJLVRK您将看到一张允许您使用街景的地图。一旦你使用它,街景全景图就会加载它的控件,包括一个自定义控件,它是一个带有红色标记的新地图,让你可以做大部分你可以用maps.google.com中的街景小人做的事情。

"cool" 部分是:

// this is the main map (which will include a streetview panorama)
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
// this is the panorama
var panorama = new google.maps.StreetViewPanorama(document.getElementById('map-canvas'), panoramaOptions);
// this is the DOM element that will "contain" our custom control
var controlDiv = document.getElementById("map");

// this is the map inside the custom control
var mapControl = new google.maps.Map(controlDiv, {
    zoom: 16,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    draggable: true,
    mapTypeControl: false,
    zoomControl: false,
    rotateControl: false,
    scaleControl: false,
    panControl: false,
    streetViewControl: false
});
// setting the custom control in the panorama
panorama.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(controlDiv);
// set the panorama as streetview of the 'main' map 
map.setStreetView(panorama);

之后,您只需向自定义控件添加内容(我添加了标记和标记阴影。您还可以更改地图外观、设置新控件(控件-感知)等等!) ,设置你想要的听众就是这样。

希望对您有所帮助!