====== Show Footprints ======
This page describes how to track Resource updates to render [[glossary#Footprint|Footprints]] on the Reference Map.
===== Listening ====
You as a developer should listen for changes to the Reference Map extent. When it changes, footprints should be updated.
To listen to resource changes, use these signals :
* onResourceOpened : fired when a resource is opened.
* onResourceClosed : fired when a resource is closed.
When any of these events occur, footprints should be refreshed.
===== Loading =====
Use the ''getStreamingFootprints2D'' to retrieve footprints for a 2D map.
Depending on your host environment, it may be the case that "map extent" events are fired faster than you can handle them. In such a case, loading footprints should be rate-limited by limiting the calls to the ''getStreamingFootprints2D'' function.
For javascript, see [[https://www.npmjs.com/package/debounce]]
/**
* Update footprint data.
* Assumes reference map scale,crs,minX,minY,maxX and maxY properties are available in this context.
*/
function updateFootprints() {
// Get map extent
var bounds = Bounds.fromXY(crs,minX,minY,maxX,maxY);
// Get map objects
var mapObjects = viewer.getStreamingFootprints2D(null/*resourceIds*/,bounds,scale).then(renderFootprints);
// Render map objects
renderMapObjects(mapObjects);
}
// Listen to signals
viewer.onResourceOpened.add(updateFootprints);
viewer.onResourceClosed.add(updateFootprints);
===== Rendering =====
See [[mapobjects]].