Hi, is it possible to have a drawing tool to create a polyline in the jxmap?

164 views Asked by At

enter image description here

I want to add a route fence within the jxmap is it possible? like the picture above, with the feature of directly drawing a polyline in the map

1

There are 1 answers

2
Vitaly Eremenko On

Current version of JxMaps doesn't implement drawing tools.(https://developers.google.com/maps/documentation/javascript/examples/drawing-tools). This functionality will be included to one of next JxMaps releases.

But you can implement own logic using map events and polylines. For example you can add mouse click handler to the Map instance:

LatLng[] path = new LatLng[count];

map.addEventListener("click", new MapMouseEvent() {
  @Override
  public void onEvent(MouseEvent mouseEvent) {
      path[current] = mouseEvent.latLng();
  }
});

Using this handler you can collect positions and then write polyline with them:

Polyline polyline = new Polyline(map);
polyline.setPath(path);