Select to view content in your preferred language

Map not panning left or right post graphic update

236
0
12-28-2021 06:26 PM
RodneyBowden
Emerging Contributor

I am currently using the milstd2525d.stylx to generate my symbols. All seems to work well except after I do a graphic update be it either a delete or move the map no loner response to the mouse properly. It seems like there is still a active graphic but there isn't. It is like the identifyGraphics  is !=null . My code is below.  Hopefully someone will see my silly mistake. Again the graphic objects are being removed and also moving on the map as desired albeit the mouse appears to have lost drag on the map post

 

@FXML
void selectSymbol(MouseEvent event) throws InterruptedException, ExecutionException {
if (event.getButton() == MouseButton.PRIMARY) {
// set the cursor to default
sceneView.setCursor(Cursor.DEFAULT);

// clear any selected graphic
graphicsOverlay.clearSelection();

// create a point where the user clicked
mapViewPoint = new Point2D(event.getX(), event.getY());

// identify graphics on the graphics overlay
identifyGraphics = sceneView.identifyGraphicsOverlayAsync(graphicsOverlay, mapViewPoint, 10, false);


identifyGraphics.addDoneListener(() -> {

try {
if (!identifyGraphics.get().getGraphics().isEmpty()) {
// get the first identified graphic
identifiedGraphic = identifyGraphics.get().getGraphics().get(0);
// select the identified graphic
identifiedGraphic.setSelected(true);
sceneView.setOnMouseDragged(e -> {
if (identifiedGraphic.isSelected() && identifiedGraphic != null) {
// set the cursor to closed hand to indicate graphic dragging is active
sceneView.setCursor(Cursor.CLOSED_HAND);
// create a point from the dragged location
mapViewPoint = new Point2D(e.getX(), e.getY());
Point mapPoint = sceneView.screenToLocation(mapViewPoint);
// update the location of the graphic to the dragged location
identifiedGraphic.setGeometry(mapPoint);
updateonmap = mapPoint.toJson();
Map<String, Object> id1 = identifiedGraphic.getAttributes();
identifiedGraphicid = (String) id1.get("_id");
try {

moveSymbolTransmission(updateonmap);

} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

});
}

else if (event.getButton().equals(MouseButton.MIDDLE)) {
graphicsOverlay.getGraphics().remove(identifiedGraphic);
identifiedGraphic.setSelected(false);
Map<String, Object> id = identifiedGraphic.getAttributes();
identifiedGraphicid = (String) id.get("_id");

try {
networkMessages.sendGeoMessageDelete(null, identifiedGraphicid);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

} else if (event.getButton().equals(MouseButton.SECONDARY)) {
Point2D point = new Point2D(event.getX(), event.getY());
Point mapPoint = sceneView.screenToLocation(point);
try {
openSymbol(mapPoint, geoMessage, insertRecord);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}

0 Kudos
0 Replies