Accurate hit detection
With this change, hit detection for lines and points gets very accurate, because the vector renderer instance keeps track of line widths and point symbol sizes. After doing a bbox query in the RTree, returned lines and points are evaluated against the thresholds of their line width or symbol size. The KML example with its different symbolizers now has getFeatureInfo too to show this in action.
This commit is contained in:
@@ -43,6 +43,20 @@ var map = new ol.Map({
|
||||
var kml = new ol.parser.KML({
|
||||
maxDepth: 1, dimension: 2, extractStyles: true, extractAttributes: true});
|
||||
|
||||
map.on('mousemove', function(evt) {
|
||||
map.getFeatureInfo({
|
||||
pixel: evt.getPixel(),
|
||||
layers: [vector],
|
||||
success: function(features) {
|
||||
var info = [];
|
||||
for (var i = 0, ii = features.length; i < ii; ++i) {
|
||||
info.push(features[i].get('name'));
|
||||
}
|
||||
document.getElementById('info').innerHTML = info.join(', ') || ' ';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var url = 'data/kml/lines.kml';
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
|
||||
Reference in New Issue
Block a user