Skip to content
Snippets Groups Projects
Commit 2407ca86 authored by dylan.peiry's avatar dylan.peiry
Browse files

Merge branch 'afficher-carte' into 'main'

feat(map): implemented map display

See merge request !3
parents 83b6e347 048300e4
No related branches found
No related tags found
3 merge requests!8feat(profile): implemented profile edition,!4feat(map): implemented map,!3feat(map): implemented map display
...@@ -15,11 +15,21 @@ ...@@ -15,11 +15,21 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>com.dlsc</groupId>
<artifactId>GMapsFX</artifactId>
<version>11.0.6</version>
</dependency>
<dependency> <dependency>
<groupId>org.openjfx</groupId> <groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId> <artifactId>javafx-controls</artifactId>
<version>17-ea+11</version> <version>17-ea+11</version>
</dependency> </dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-fontawesome5-pack</artifactId>
<version>12.3.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.openjfx</groupId> <groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId> <artifactId>javafx-fxml</artifactId>
......
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
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
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) {
}
}
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
package ch.dreamteam.geoconnect.helpers;
public class Params {
final static public String APP_NAME = "GeoConnect";
}
...@@ -5,7 +5,14 @@ module ch.dreamteam.geoconnect { ...@@ -5,7 +5,14 @@ module ch.dreamteam.geoconnect {
requires org.controlsfx.controls; requires org.controlsfx.controls;
requires com.dlsc.formsfx; requires com.dlsc.formsfx;
requires org.kordamp.ikonli.javafx; requires org.kordamp.ikonli.javafx;
requires com.dlsc.gmapsfx;
requires javafx.web;
requires org.kordamp.ikonli.fontawesome5;
opens ch.dreamteam.geoconnect to javafx.fxml; opens ch.dreamteam.geoconnect to javafx.fxml;
exports ch.dreamteam.geoconnect; 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
.icon:hover {
-fx-icon-color: red;
-fx-cursor: hand;
}
.active {
-fx-icon-color: black;
}
\ No newline at end of file
<?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>
<?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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment