I'm making a program in Java that displays a map using JMapViewer and draws a static polygon. When the user clicks in the map the program say "the point where you have clicked is in polygon" or "not in polygon". How I can do for calculate when the point is in polygon or not? Is there any ready method/class to do that?
Thank you, Luca
In outline,
Construct a
MapPolygonas shown here.Detect mouse clicks using a custom
DefaultMapControlleras shown here.In
mouseClicked(), construct ajava.awt.Polygonby iterating through theList<ICoordinate>returned byMapPolygon::getPoints; use theJMapViewer::getPositionmethod to convert eachICoordinateto aPoint.Use
Polygon::containsto determine whether the mouse coordinates are inside thisPolygon.