We are trying to enable or disable some elements on our page base on whether or not the center of the HERE Map has moved since the map was initially loaded with some given center coordinates.
We can store the initial coordinates in some JS variables, so it could be a matter of just checking whether or not the current center of the map matches those provided coordinates. But what's the most efficient way to only check after the map has been panned or zoomed in a way so that the center may have been moved? So far, I can detect when the map is dragged but not when there has been a zoom or zoom action that results in a different center.
We are using:
<script src="https://js.api.here.com/v3/3.0/mapsjs-core.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-service.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-ui.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-mapevents.js" type="text/javascript" charset="utf-8"></script>
Currently trying:
hereMap = new H.Map(
mapContainer,
maptypes.normal.map,
{
zoom: 12,
center: initCenter
});
var mapEvents = new H.mapevents.MapEvents(hereMap);
var ui = H.ui.UI.createDefault(hereMap, maptypes);
hereMap.addEventListener('drag', function(e) {
// do stuff here
});
var behavior = new H.mapevents.Behavior(mapEvents);
But it is not working as expected.
Any tips?
Please see below documentation about "Prefer mapviewchangeend Event to mapviewchange"
https://developer.here.com/documentation/maps/topics/best-practices.html
Hope for the Best!