5

I am facing a problem to get the map bounds in Here maps after dragend event. I need the new lat,lng to get some items/points within the new changed viewports. I Just want to get the alternatives of google maps map.getBounds().getNorthEast().lat() when the drag ends.

I have tried these methods but none of them returned the lat,lng position of the Northeast and southwest coordinate.


 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);
  • Hi, would you please give more detail codes? There is a good example for this https://developer.here.com/api-explorer/maps-js/markers/draggable-marker –  Jul 22 '19 at 02:19
  • Hi, Just want to get the alternatives of google maps `map.getBounds().getNorthEast().lat()` when the drag ends.I don't need to make the marker draggable.I want to know the new viewport bounds after the map drag to a new position – alamin_cse07 Jul 22 '19 at 04:12
  • The sample code shows how to handle dragend event. –  Jul 23 '19 at 05:55

2 Answers2

4

Please see this document:

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.Rect https://developer.here.com/documentation/maps/topics_api/h-geo-rect.html#h-geo-rect

Here is some snipped code:

map.addEventListener('dragend', (ev) => {
    var bounds = map.getViewModel().getLookAtData().bounds;
});
Mathias
  • 1,819
  • 4
  • 22
  • 34
0
              var bounds = map.getViewModel().getLookAtData().bounds.getBoundingBox();
              var SWlong = bounds.getLeft();
              var SWlat = bounds.getBottom();
              var NElong = bounds.getRight();
              var NElat = bounds.getTop();

This is my working code to get 4 corner of view port bounding box

hoogw
  • 4,982
  • 1
  • 37
  • 33