Skip to content

Instantly share code, notes, and snippets.

@tschaub
Created November 26, 2013 15:50
Show Gist options
  • Save tschaub/7660771 to your computer and use it in GitHub Desktop.
Save tschaub/7660771 to your computer and use it in GitHub Desktop.
Highlight a feature on the map based on user interaction with a feature table. The two examples below provide a "highlight" function. In both cases, the application would be responsible for getting a feature based on user interaction with a feature table. The highlight function just shows the code necessary to highlight the feature on the map.
/**
* Layer with a style that provides symbolizers for
* the "selected" render intent defined elsewhere.
*/
function highlight(feature) {
feature.setRenderIntent('selected');
}
/**
* Layer and highlightStyle defined elsewhere.
*/
function highlight(feature) {
var geometry = feature.getGeometry();
map.requestRenderFrame();
layer.setRenderGeometryFunction(function(candidate) {
return geometry !== candidate;
});
map.on('postcompose', function(evt) {
var render = evt.getRender();
render.drawFeature(feature, highlightStyle);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment