最佳答案
我不久前遇到了同样的问题,最终在街景全景图中做了一个自定义控件。似乎没有一种简单的方法可以使用 API 来完成此类操作。
在此代码笔中:http://codepen.io/chmartinez/pen/pJLVRK您将看到一张允许您使用街景的 map 。一旦你使用它,街景全景图就会加载它的控件,包括一个自定义控件,它是一个带有红色标记的新 map ,可以让你做大部分你可以在maps.google.com中使用街景小人做的事情。
“酷”的部分是:
// 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);
之后,您只需向自定义控件添加内容(我添加了一个标记和一个标记阴影。您还可以更改 map 外观和感觉,设置新控件(control-ception)等等!),设置您想要的听众就是这样。
希望对你有帮助!
关于google-maps - 如何在街景中显示左下角的小 map 小部件(Google Map JS API),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34298418/