mayfly
mayfly

Reputation: 151

HERE Maps API event delays

When panning a map with the HERE maps API, the 'mapviewchangeend' event is triggered a short time after the animation completes. This means that is difficult to synchronise, say, a Leaflet overlay without the overlaid objects lagging behind.

var map = new H.Map(document.getElementById('mapContainer'),
                    defaultLayers.normal.map, ...    
var lMap = L.map('mapContainer', {zoomControl: false});

...

function onMapViewChange() {
   lMap.setView(map.getCenter(), map.getZoom(), {animation: false});
}

map.addEventListener('mapviewchange', function () {
   onMapViewChange();
});

map.addEventListener('mapviewchangeend', function () {
   onMapViewChange();
});

Is there a way to remove this delay? I have experimented with different kinetic settings for H.mapevents.Behavior but so far without success.

Upvotes: 1

Views: 667

Answers (1)

echom
echom

Reputation: 932

I think you can hook into the sync events being fired by the the view model and the viewport. I seem to recall that these events fire synchronously when the map renders...

After some digging, I found the example showing something very similar on github:

maps-api-for-javascript-examples/ground-overlay

Upvotes: 1

Related Questions