在dragend事件后,我遇到了在这里地图中获取地图边界的问题。我需要新的纬度,lng 在新更改的视口中获取一些项目/点。我只想在拖动结束时获得谷歌地图map.getBounds((.getNorthEast((.lat((的替代方案。
我尝试过这些方法,但没有一个返回东北和西南坐标的纬度,lng位置。
Heremap.addEventListener('dragend', (ev) => {
const target = ev.target;
// console.log(map.getViewModel().getLookAtData().bounds);
// console.log(map.getBounds());
// console.log(target.getViewPort());
// console.log(target.getBoundingBox());
}, false);
请参阅此文档:
H.map.ViewModel :https://developer.here.com/documentation/maps/topics_api/h-map-viewmodel.html#h-map-viewmodel__getlookatdata
H.map.ViewModel.ILookAtData :https://developer.here.com/documentation/maps/topics_api/h-map-viewmodel-ilookatdata.html#h-map-viewmodel-ilookatdata__bounds
H.geo.Recthttps://developer.here.com/documentation/maps/topics_api/h-geo-rect.html#h-geo-rect
这是一些截取的代码:
map.addEventListener('dragend', (ev) => {
var bounds = map.getViewModel().getLookAtData().bounds;
});
var bounds = map.getViewModel().getLookAtData().bounds.getBoundingBox();
var SWlong = bounds.getLeft();
var SWlat = bounds.getBottom();
var NElong = bounds.getRight();
var NElat = bounds.getTop();
这是我的工作代码,以获取视口边界框的 4 角