【问题标题】:How to get bounds after map drag in Here Maps如何在此处地图中拖动地图后获得边界
【发布时间】:2019-11-29 20:44:17
【问题描述】:

在 dragend 事件之后,我在 Here maps 中获取地图边界时遇到问题。 我需要新的 lat,lng 在新更改的视口中获取一些项目/点。 我只想在拖动结束时获得谷歌地图 map.getBounds().getNorthEast().lat() 的替代品。

我试过这些方法,但都没有返回东北和西南坐标的经纬度位置。


 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);

【问题讨论】:

  • 您好,能否提供更详细的代码?这有一个很好的例子developer.here.com/api-explorer/maps-js/markers/…
  • 嗨,只是想在拖动结束时获得谷歌地图map.getBounds().getNorthEast().lat() 的替代品。我不需要使标记可拖动。我想知道地图拖动后的新视口边界到一个新的位置
  • 示例代码展示了如何处理dragend事件。

标签: maps here-api


【解决方案1】:

请参阅此文档:

H.map.ViewModelhttps://developer.here.com/documentation/maps/topics_api/h-map-viewmodel.html#h-map-viewmodel__getlookatdata

H.map.ViewModel.ILookAtDatahttps://developer.here.com/documentation/maps/topics_api/h-map-viewmodel-ilookatdata.html#h-map-viewmodel-ilookatdata__bounds

H.geo.Rect https://developer.here.com/documentation/maps/topics_api/h-geo-rect.html#h-geo-rect

这里是一些截断的代码:

map.addEventListener('dragend', (ev) => {
    var bounds = map.getViewModel().getLookAtData().bounds;
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多