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:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user