Files
openlayers/examples/hit-tolerance.html
2022-08-22 19:26:23 +02:00

25 lines
1.0 KiB
HTML

---
layout: example.html
title: Hit Tolerance
shortdesc: Example using the hitTolerance parameter.
docs: >
By default, the map.forEachFeatureAtPixel() function only considers features that are directly under the provided
pixel. This can make it difficult to interact with features on touch devices. To consider features within some
distance of the provided pixel, use the hitTolerance option. For example,
map.forEachFeatureAtPixel(pixel, callback, {hitTolerance: 3}) will call the callback with all features that are
within three pixels of the provided pixel.
tags: "hitTolerance"
---
<div id="map" class="map"></div>
<span id="status">Try to click the line in the map.</span>
<form>
<label for="hitTolerance">Hit tolerance for selecting features: &nbsp;</label>
<select id="hitTolerance">
<option value="0" selected>0 Pixels</option>
<option value="5">5 Pixels</option>
<option value="10">10 Pixels</option>
</select>
&nbsp; Area: &nbsp;
<canvas id="circle" style="vertical-align: middle"></canvas>
</form>