diff --git a/src/eu/simstadt/regionchooser/RegionChooser.fxml b/src/eu/simstadt/regionchooser/RegionChooser.fxml index 2e4f3e6a188b8084092c46e184b1343ba5418ba2..086b4ddafa3cd8f1f41a6d04456aee55d42752f5 100644 --- a/src/eu/simstadt/regionchooser/RegionChooser.fxml +++ b/src/eu/simstadt/regionchooser/RegionChooser.fxml @@ -11,7 +11,7 @@
- +
diff --git a/src/eu/simstadt/regionchooser/RegionChooserController.java b/src/eu/simstadt/regionchooser/RegionChooserController.java index 7b2b86a24fe05da4fc99b149ee96cdc9831150f7..e858e890e2a47e0ef02d4d65e12887e564a53598 100644 --- a/src/eu/simstadt/regionchooser/RegionChooserController.java +++ b/src/eu/simstadt/regionchooser/RegionChooserController.java @@ -1,14 +1,18 @@ package eu.simstadt.regionchooser; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import javafx.concurrent.Service; import javafx.concurrent.Task; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.TextArea; + import com.lynden.gmapsfx.GoogleMapView; import com.lynden.gmapsfx.MapComponentInitializedListener; +import com.lynden.gmapsfx.javascript.JavascriptObject; import com.lynden.gmapsfx.javascript.object.GoogleMap; import com.lynden.gmapsfx.javascript.object.InfoWindow; import com.lynden.gmapsfx.javascript.object.InfoWindowOptions; @@ -17,13 +21,14 @@ import com.lynden.gmapsfx.javascript.object.MapTypeIdEnum; import com.lynden.gmapsfx.javascript.object.Marker; import com.lynden.gmapsfx.javascript.object.MarkerOptions; + import eu.simstadt.nf.Coord; import eu.simstadt.nf.NFJobBuilder; public class RegionChooserController implements MapComponentInitializedListener { - List regionPolygon; + ArrayList regionPolygon = new ArrayList<>(); @FXML private TextArea outputTA; @@ -89,12 +94,10 @@ public void mapInitialized() { InfoWindow bochumInfoWindow = new InfoWindow(infoWindowOptions); bochumInfoWindow.open(map, bochumMarker); - regionPolygon = Arrays.asList( - new Coord(bochumLoc.getLatitude(), bochumLoc.getLongitude()), - new Coord(hamburgLoc.getLatitude(), bochumLoc.getLongitude()), - new Coord(stuttgartLoc.getLatitude(), bochumLoc.getLongitude()), - new Coord(dresdenLoc.getLatitude(), bochumLoc.getLongitude()) - ); + regionPolygon.add(new Coord(bochumLoc.getLatitude(), bochumLoc.getLongitude())); + regionPolygon.add(new Coord(hamburgLoc.getLatitude(), bochumLoc.getLongitude())); + regionPolygon.add(new Coord(stuttgartLoc.getLatitude(), bochumLoc.getLongitude())); + regionPolygon.add(new Coord(dresdenLoc.getLatitude(), bochumLoc.getLongitude())); } // Build the nF export job description from a region polygon @@ -116,4 +119,23 @@ protected String call() throws Exception { }); exportRunner.start(); } + + @FXML + void clicked() { + // Test, if this LatLong will be returned by getCenter(). Seams to work. + System.out.println("Center: " + map.getCenter()); + + // Adding a fifth marker to the map seams to work without any problems. + LatLong loc = new LatLong(48.880003, 9.216849); + MarkerOptions markerOptions = new MarkerOptions(); + markerOptions.position(loc); + Marker marker = new Marker(markerOptions); + map.addMarker(marker); + + // Now I want to obtain the current coordinates from the map at the mouse position in order + // to instantiate and set a new marker. + // + // This statement fails. Why? + mapView.getMap().getLatLong(); + } } \ No newline at end of file