diff --git a/pom.xml b/pom.xml index c82d1d985309d18b56c4afe1d08d6048aa66a0c2..5b2cb015f16ad62a921003b4fb77b0c3e6716c64 100644 --- a/pom.xml +++ b/pom.xml @@ -15,11 +15,21 @@ </properties> <dependencies> + <dependency> + <groupId>com.dlsc</groupId> + <artifactId>GMapsFX</artifactId> + <version>11.0.6</version> + </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>17-ea+11</version> </dependency> + <dependency> + <groupId>org.kordamp.ikonli</groupId> + <artifactId>ikonli-fontawesome5-pack</artifactId> + <version>12.3.0</version> + </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-fxml</artifactId> diff --git a/src/main/java/ch/dreamteam/geoconnect/HelloApplication.java b/src/main/java/ch/dreamteam/geoconnect/HelloApplication.java deleted file mode 100644 index a1ca6f5f0ac6c3ca966784b6d7ca24584ef4fffa..0000000000000000000000000000000000000000 --- a/src/main/java/ch/dreamteam/geoconnect/HelloApplication.java +++ /dev/null @@ -1,23 +0,0 @@ -package ch.dreamteam.geoconnect; - -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Scene; -import javafx.stage.Stage; - -import java.io.IOException; - -public class HelloApplication extends Application { - @Override - public void start(Stage stage) throws IOException { - FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 320, 240); - stage.setTitle("Hello!"); - stage.setScene(scene); - stage.show(); - } - - public static void main(String[] args) { - launch(); - } -} \ No newline at end of file diff --git a/src/main/java/ch/dreamteam/geoconnect/HelloController.java b/src/main/java/ch/dreamteam/geoconnect/HelloController.java deleted file mode 100644 index 9fb1d7deb23c7ddf7b2136ca272c63a4f26d557e..0000000000000000000000000000000000000000 --- a/src/main/java/ch/dreamteam/geoconnect/HelloController.java +++ /dev/null @@ -1,14 +0,0 @@ -package ch.dreamteam.geoconnect; - -import javafx.fxml.FXML; -import javafx.scene.control.Label; - -public class HelloController { - @FXML - private Label welcomeText; - - @FXML - protected void onHelloButtonClick() { - welcomeText.setText("Welcome to JavaFX Application!"); - } -} \ No newline at end of file diff --git a/src/main/java/ch/dreamteam/geoconnect/MainApplication.java b/src/main/java/ch/dreamteam/geoconnect/MainApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..831aee582ca1a78b6ec991cad033b32745b1a35a --- /dev/null +++ b/src/main/java/ch/dreamteam/geoconnect/MainApplication.java @@ -0,0 +1,96 @@ +package ch.dreamteam.geoconnect; + +import ch.dreamteam.geoconnect.helpers.Params; +import com.dlsc.gmapsfx.GoogleMapView; +import com.dlsc.gmapsfx.MapComponentInitializedListener; +import com.dlsc.gmapsfx.javascript.object.*; +import com.dlsc.gmapsfx.service.directions.DirectionStatus; +import com.dlsc.gmapsfx.service.directions.DirectionsResult; +import com.dlsc.gmapsfx.service.directions.DirectionsServiceCallback; +import com.dlsc.gmapsfx.service.elevation.ElevationResult; +import com.dlsc.gmapsfx.service.elevation.ElevationServiceCallback; +import com.dlsc.gmapsfx.service.elevation.ElevationStatus; +import com.dlsc.gmapsfx.service.geocoding.GeocoderStatus; +import com.dlsc.gmapsfx.service.geocoding.GeocodingResult; +import com.dlsc.gmapsfx.service.geocoding.GeocodingServiceCallback; +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.web.WebEvent; +import javafx.stage.Stage; + +import java.io.IOException; + +public class MainApplication extends Application implements MapComponentInitializedListener, ElevationServiceCallback, GeocodingServiceCallback, DirectionsServiceCallback { + + protected static GoogleMapView mapComponent; + protected GoogleMap map; + protected DirectionsPane directions; + + + public static void main(String[] args) { + launch(args); + } + + public static GoogleMapView getMapComponent() { + return mapComponent; + } + + @Override + public void start(Stage primaryStage) throws IOException { + initializeMapComponent(); + + /*Load FXML file*/ + FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("views/home-view.fxml")); + Scene scene = new Scene(fxmlLoader.load(), 1400, 900); + primaryStage.setTitle(Params.APP_NAME); + primaryStage.setScene(scene); + primaryStage.show(); + } + + private void initializeMapComponent() { + mapComponent = new GoogleMapView(null, "AIzaSyBME8EFus9n7fjurdqU3Bsm1Y-BfgroA2o"); + mapComponent.addMapInitializedListener(this); + mapComponent.setDisableDoubleClick(true); + mapComponent.getWebview().getEngine().setOnAlert((WebEvent<String> event) -> System.out.println("Event event: " + event)); + } + + @Override + public void mapInitialized() { + LatLong center = new LatLong(46.2050242, 6.1090692); + mapComponent.addMapReadyListener(() -> { + // This call will fail unless the map is completely ready. + //checkCenter(center); + }); + + MapOptions options = new MapOptions(); + options.center(center) + .zoom(13) + .overviewMapControl(true) + .panControl(true) + .rotateControl(true) + .scaleControl(true) + .streetViewControl(true) + .zoomControl(true) + .mapType(MapTypeIdEnum.ROADMAP); + + map = mapComponent.createMap(options); + + map.setHeading(123.2); + } + + @Override + public void directionsReceived(DirectionsResult results, DirectionStatus status) { + + } + + @Override + public void elevationsReceived(ElevationResult[] results, ElevationStatus status) { + + } + + @Override + public void geocodedResultsReceived(GeocodingResult[] results, GeocoderStatus status) { + + } +} diff --git a/src/main/java/ch/dreamteam/geoconnect/controllers/MainController.java b/src/main/java/ch/dreamteam/geoconnect/controllers/MainController.java new file mode 100644 index 0000000000000000000000000000000000000000..f7dd4b563bd8991e87b4bae2d33af5d82c4d0daf --- /dev/null +++ b/src/main/java/ch/dreamteam/geoconnect/controllers/MainController.java @@ -0,0 +1,35 @@ +package ch.dreamteam.geoconnect.controllers; + +import ch.dreamteam.geoconnect.MainApplication; +import com.dlsc.gmapsfx.GoogleMapView; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; + +import java.net.URL; +import java.util.ResourceBundle; + + +public class MainController implements Initializable { + @FXML + private HBox iconsContainer; + @FXML + private VBox container; + + @FXML + private VBox mapContainer; + + @FXML + private VBox menuContainer; + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + System.out.println("initialize"); + GoogleMapView mapComponent = MainApplication.getMapComponent(); + //mapComponent.setPrefSize(mapContainer.getWidth(), mapContainer.getHeight()); + mapComponent.setPrefHeight(mapContainer.getPrefHeight()); + mapComponent.setPrefWidth(mapContainer.getPrefWidth()); + mapContainer.getChildren().add(mapComponent); + } +} \ No newline at end of file diff --git a/src/main/java/ch/dreamteam/geoconnect/helpers/Params.java b/src/main/java/ch/dreamteam/geoconnect/helpers/Params.java new file mode 100644 index 0000000000000000000000000000000000000000..e51b77aae5abc60dfc56b886caff8eeeebda716b --- /dev/null +++ b/src/main/java/ch/dreamteam/geoconnect/helpers/Params.java @@ -0,0 +1,5 @@ +package ch.dreamteam.geoconnect.helpers; + +public class Params { + final static public String APP_NAME = "GeoConnect"; +} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index adb6438fa6beab9aa2ff4713435f5497783c813e..6311ce4d56ed76153c8665bbfa00071689eb6ba1 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -5,7 +5,14 @@ module ch.dreamteam.geoconnect { requires org.controlsfx.controls; requires com.dlsc.formsfx; requires org.kordamp.ikonli.javafx; + requires com.dlsc.gmapsfx; + requires javafx.web; + requires org.kordamp.ikonli.fontawesome5; opens ch.dreamteam.geoconnect to javafx.fxml; exports ch.dreamteam.geoconnect; + exports ch.dreamteam.geoconnect.helpers; + opens ch.dreamteam.geoconnect.helpers to javafx.fxml; + exports ch.dreamteam.geoconnect.controllers; + opens ch.dreamteam.geoconnect.controllers to javafx.fxml; } \ No newline at end of file diff --git a/src/main/resources/ch/dreamteam/geoconnect/css/style.css b/src/main/resources/ch/dreamteam/geoconnect/css/style.css new file mode 100644 index 0000000000000000000000000000000000000000..4a98f492d950d2a3a4d8dd3f577afaec95b8da3d --- /dev/null +++ b/src/main/resources/ch/dreamteam/geoconnect/css/style.css @@ -0,0 +1,8 @@ +.icon:hover { + -fx-icon-color: red; + -fx-cursor: hand; +} + +.active { + -fx-icon-color: black; +} \ No newline at end of file diff --git a/src/main/resources/ch/dreamteam/geoconnect/hello-view.fxml b/src/main/resources/ch/dreamteam/geoconnect/hello-view.fxml deleted file mode 100644 index 64d013f19917b7a8a1765ec602bfac8abf0e6b9c..0000000000000000000000000000000000000000 --- a/src/main/resources/ch/dreamteam/geoconnect/hello-view.fxml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<?import javafx.geometry.Insets?> -<?import javafx.scene.control.Label?> -<?import javafx.scene.layout.VBox?> - -<?import javafx.scene.control.Button?> -<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml" - fx:controller="ch.dreamteam.geoconnect.HelloController"> - <padding> - <Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/> - </padding> - - <Label fx:id="welcomeText"/> - <Button text="Hello!" onAction="#onHelloButtonClick"/> -</VBox> diff --git a/src/main/resources/ch/dreamteam/geoconnect/views/home-view.fxml b/src/main/resources/ch/dreamteam/geoconnect/views/home-view.fxml new file mode 100644 index 0000000000000000000000000000000000000000..891f2883804b1265b2cdd08fb462f16b9cddff58 --- /dev/null +++ b/src/main/resources/ch/dreamteam/geoconnect/views/home-view.fxml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.layout.*?> +<?import org.kordamp.ikonli.javafx.FontIcon?> +<AnchorPane prefHeight="900.0" prefWidth="1400.0" xmlns="http://javafx.com/javafx/11.0.14-internal" + xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.dreamteam.geoconnect.controllers.MainController" + stylesheets="@../css/style.css"> + <VBox fx:id="container" layoutX="14.0" layoutY="47.0" prefHeight="900.0" prefWidth="1400.0" + AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" + AnchorPane.topAnchor="0.0"> + <VBox fx:id="mapContainer" prefHeight="850.0" prefWidth="1400.0"/> + <VBox fx:id="menuContainer" prefHeight="50.0" prefWidth="1400.0"> + <HBox fx:id="iconsContainer" alignment="CENTER" spacing="15" style="-fx-padding: 5 15 5 15"> + <FontIcon styleClass="icon" iconLiteral="fas-map-marker-alt" iconSize="32" iconColor="#99b0ff"/> + <FontIcon styleClass="icon,active" iconLiteral="far-user-circle" iconSize="32" iconColor="#99b0ff"/> + </HBox> + </VBox> + </VBox> +</AnchorPane>