ThinkGeo.com    |     Documentation    |     Premium Support

Determining if user clicked on edge of shape

Currently, I allow users to edit a single feature at a time by moving it to the EditShapesLayer in the EditOverlay. Normally, you can click on the edge of the shape to add a vertex. However, in my app a single click while in edit mode will move the shape to the click location. So I need a different way to add that vertex in. Is there a built-in function to determine if a mouse click is on a shape’s edge or not?

Hi Dan,

I think we don’t have an API to know whether the target point(clicked point) is on the shape’s edge.

But you can implement it like this:

A.

  1. Loop all line part of target shape, get distance from clicked point to each line part
  2. If any distance is smaller than a tolerance value you set, you think the clicked point is in this part

B.

  1. Buffer the point to a very small rectangle
  2. Adjust whether the rectangle intersect the shape but it’s not contained by it, if so it should be in the edge

Wish that’s helpful.

Regards,

Ethan