Giving the map a getFeatureInfoForPixel method

This method is an entry point for getting feature information.
Renderers can use a hit canvas or defer to a layer (source) to
get matching features for a pixel.

For now this is only implemented for vector layers, and it uses
a bbox query because we cannot refine the result because of
missing geometry intersection functions yet.
This commit is contained in:
ahocevar
2013-04-29 16:26:29 +02:00
parent a0340faa63
commit cc1b70c74b
5 changed files with 83 additions and 1 deletions

View File

@@ -42,6 +42,15 @@ var map = new ol.Map({
})
});
map.on('mousemove', function(evt) {
var features = map.getFeatureInfoForPixel(evt.getPixel(), [vector]);
var info = [];
for (var i = 0, ii = features.length; i < ii; ++i) {
info.push(features[i].get('name'));
}
document.getElementById('map').title = info.join(', ');
});
var geojson = new ol.parser.GeoJSON();
var url = 'data/countries.json';