Finished Google Maps API
This commit is contained in:
@@ -15,25 +15,29 @@ public class Map {
|
||||
|
||||
private WebEngine webEngine;
|
||||
private WebView webView;
|
||||
private boolean canLoad = false;
|
||||
|
||||
public Map(WebView webView){
|
||||
public Map(WebView webView, final RoutePath newRoute){
|
||||
this.webView = webView;
|
||||
webEngine = webView.getEngine();
|
||||
initMap();
|
||||
webEngine.getLoadWorker().stateProperty().addListener(
|
||||
new ChangeListener<Worker.State>() {
|
||||
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
|
||||
if (newState == Worker.State.SUCCEEDED){
|
||||
displayRoute(newRoute);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void initMap() {
|
||||
webEngine.load(getClass().getClassLoader().getResource("map.html").toExternalForm());
|
||||
}
|
||||
|
||||
public void displayRoute(final RoutePath newRoute) {
|
||||
webEngine.getLoadWorker().stateProperty().addListener(
|
||||
new ChangeListener<Worker.State>(){
|
||||
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState){
|
||||
String scriptToExecute = "displayRoute(" + newRoute.toJSONArray() + ");";
|
||||
webEngine.executeScript(scriptToExecute);
|
||||
}
|
||||
});
|
||||
public void displayRoute(RoutePath newRoute) {
|
||||
String scriptToExecute = "displayRoute(" + newRoute.toJSONArray() + ");";
|
||||
webEngine.executeScript(scriptToExecute);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user