25 lines
1.0 KiB
HTML
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 class="form-inline">
|
|
<label for="hitTolerance">Hit tolerance for selecting features: </label>
|
|
<select id="hitTolerance" class="form-control">
|
|
<option value="0" selected>0 Pixels</option>
|
|
<option value="5">5 Pixels</option>
|
|
<option value="10">10 Pixels</option>
|
|
</select>
|
|
Area:
|
|
<canvas id="circle" style="vertical-align: middle" />
|
|
</form>
|