Skip to content

Geometry operator - proximity analysis

This sample demonstrates the use of the proximityOperator. You can visually explore the differences between finding the nearest vertex and the nearest coordinate.

The Introduction to geometry operators guide topic offers an overview of all the SDK's capabilities for performing client-side geometric operations on points, multipoints, lines, polygons and extents.

Getting started

To use this sample, start by moving your mouse cursor around the inside and outside of the polygon. By default, the sample will use the proximityOperator's getNearestVertex() method. The sample uses the mouse's location to determine the nearest vertex. It draws a blue line from the cursor's location to the respective vertex on the polygon, and then sets a blue circle marker on the vertex.

To try out the getNearestCoordinate() method, select the Nearest coordinate option in the upper, left-hand corner of the application. The sample locates the coordinates nearest to the mouse cursor's location, where the coordinates may be a vertex or any point along a segment. It then draws a blue line from the cursor's location to the coordinate on the polygon, and then sets a blue circle marker at that point.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.