google-maps - 如何在街景中显示左下角的小 map 小部件(Google Map JS API)

标签 google-maps google-street-view

有人知道如何在通过 Google Maps JS API 调用的自定义街景上显示左下角的小 map 吗?

Google Map minimap widget

最佳答案

我不久前遇到了同样的问题,最终在街景全景图中做了一个自定义控件。似乎没有一种简单的方法可以使用 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/

相关文章:

java - 在 CameraUpdateFactory.newLatLngBounds 周围添加额外的填充

android - 谷歌街景: Conversion between FOV and Zoom

android - 尝试通过在 android 中使用 Google Maps Android API v2 来显示 StreetView 但无法使其正常工作

javascript - 谷歌街景显示路线路线

image - 检测谷歌地图街景静态图片的 "we have no imagery"

api - 从当前位置到标记的 Google map API 路线

r - 使用谷歌地图按公司名称查找坐标

ios - GMSPanoramaView 方向与网络上的 Google map 不一致

android - 在 android 谷歌地图中更改 clustermanager 项目图标

android - 如何在android中保存实例状态Marker对象