This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void initialize(URL url, ResourceBundle rb) { | |
mapView.addMapInializedListener(this); | |
to.bindBidirectional(toTextField.textProperty()); | |
from.bindBidirectional(fromTextField.textProperty()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FXMLController implements Initializable, MapComponentInitializedListener, DirectionsServiceCallback { | |
protected StringProperty from = new SimpleStringProperty(); | |
protected StringProperty to = new SimpleStringProperty(); | |
@FXML | |
protected GoogleMapView mapView; | |
@FXML | |
protected TextField fromTextField; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<?import com.lynden.gmapsfx.GoogleMapView?> | |
<?import javafx.scene.control.TextField?> | |
<?import javafx.scene.layout.AnchorPane?> | |
<AnchorPane id="AnchorPane" prefHeight="443.0" prefWidth="711.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.65" fx:controller="com.lynden.gmaps.directions.FXMLController"> | |
<children> | |
<GoogleMapView fx:id="mapView" layoutX="-311.0" layoutY="-244.0" prefWidth="490.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> | |
<TextField fx:id="fromTextField" prefHeight="27.0" prefWidth="222.0" promptText="From:" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="10.0" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.gmapstestproject; | |
import com.lynden.gmapsfx.GoogleMapView; | |
import com.lynden.gmapsfx.MapComponentInitializedListener; | |
import com.lynden.gmapsfx.javascript.object.*; | |
import com.lynden.gmapsfx.service.geocoding.GeocoderStatus; | |
import com.lynden.gmapsfx.service.geocoding.GeocodingResult; | |
import com.lynden.gmapsfx.service.geocoding.GeocodingService; | |
import java.net.URL; | |
import java.util.ResourceBundle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.gmapstestproject; | |
import javafx.application.Application; | |
import static javafx.application.Application.launch; | |
import javafx.fxml.FXMLLoader; | |
import javafx.scene.Parent; | |
import javafx.scene.Scene; | |
import javafx.stage.Stage; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<?import javafx.scene.layout.AnchorPane?> | |
<?import javafx.scene.control.*?> | |
<?import com.lynden.gmapsfx.GoogleMapView?> | |
<AnchorPane id="AnchorPane" prefHeight="500" prefWidth="750" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.65" fx:controller="com.mycompany.gmapstestproject.FXMLController"> | |
<children> | |
<GoogleMapView fx:id="mapView" prefHeight="500.0" prefWidth="700.0" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0.0"/> | |
<TextField fx:id="addressTextField" onAction="#addressTextFieldAction" prefHeight="27.0" prefWidth="274.0" promptText="Address" AnchorPane.leftAnchor="10" AnchorPane.topAnchor="10" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FXML | |
public void addressTextFieldAction(ActionEvent event) { | |
geocodingService.geocode(address.get(), (GeocodingResult[] results, GeocoderStatus status) -> { | |
LatLong latLong = null; | |
if( status == GeocoderStatus.ZERO_RESULTS) { | |
Alert alert = new Alert(Alert.AlertType.ERROR, "No matching address found"); | |
alert.show(); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void mapInitialized() { | |
geocodingService = new GeocodingService(); | |
MapOptions mapOptions = new MapOptions(); | |
mapOptions.center(new LatLong(47.6097, -122.3331)) | |
.mapType(MapTypeIdEnum.ROADMAP) | |
.overviewMapControl(false) | |
.panControl(false) | |
.rotateControl(false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void initialize(URL url, ResourceBundle rb) { | |
mapView.addMapInializedListener(this); | |
address.bind(addressTextField.textProperty()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FXMLController implements Initializable, MapComponentInitializedListener { | |
@FXML | |
private GoogleMapView mapView; | |
@FXML | |
private TextField addressTextField; | |
private GoogleMap map; | |