Finished Google Maps API

main
YaFedImYaEatIm 9 years ago
parent ae3fbefd0d
commit a9edea7690

Binary file not shown.

@ -326,8 +326,8 @@ public class Dataset {
"`Heading` TEXT, " +
"`Altitude` INTEGER, " +
"`Tot_Dist` INTEGER, " +
"`Longitude` REAL, " +
"`Latitude` REAL, " +
"`Longitude` REAL, " +
"`Leg_Dist` INTEGER, " +
"`Order` INTEGER)";
stmt.execute(createFlightPointTable);
@ -689,7 +689,7 @@ public class Dataset {
flightPathToAdd.setID(flightPathId);
//ADDED
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
" `Altitude`, `Longitude`, `Latitude`) VALUES ";
" `Altitude`, `Latitude`, `Longitude`) VALUES ";
int numOfFlights = 0;
for (int i = 0; i < flightPointsToImport.size(); i ++){
String flightPointIdentifier = flightPointsToImport.get(i).getType() + flightPointsToImport.get(i).getName() +
@ -1076,7 +1076,7 @@ public class Dataset {
stmt = c.createStatement();
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
" `Altitude`, `Longitude`, `Latitude`, `Heading`, `Tot_Dist`, `Leg_Dist`, `Via`) VALUES ";
" `Altitude`, `Latitude`, `Longitude`, `Heading`, `Tot_Dist`, `Leg_Dist`, `Via`) VALUES ";
String flightType = type.replace("\"", "\"\"");
String flightName = name.replace("\"", "\"\"");
insertFlightPointQuery += "(" + id +", \""+ flightName +"\", \"" + flightType + "\", "+ altitudeVal + ", " +

@ -7,7 +7,7 @@ public class FlightPath {
private ArrayList<FlightPoint> flightPoints;
private String departureAirport;
private String arrivalAirport;
private RoutePath routePath;
final private RoutePath routePath = new RoutePath();
/**
*
@ -91,8 +91,7 @@ public class FlightPath {
}
public RoutePath getRoutePath(){
if (routePath == null){
routePath = new RoutePath();
if (routePath.getRoute().size() == 0){
for (FlightPoint point: flightPoints){
routePath.addPosition(new Position(point.getLatitude(), point.getLongitude()));
}

@ -22,6 +22,10 @@ public class RoutePath {
route.add(position);
}
public ArrayList<Position> getRoute() {
return route;
}
public String toJSONArray() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("[");
@ -32,4 +36,5 @@ public class RoutePath {
stringBuilder.append("]");
return stringBuilder.toString();
}
}

@ -1,5 +1,7 @@
package seng202.group9.GUI;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
@ -11,6 +13,7 @@ import seng202.group9.Controller.App;
import seng202.group9.Controller.Dataset;
import seng202.group9.Controller.SceneCode;
import seng202.group9.Core.FlightPath;
import seng202.group9.Core.RoutePath;
import seng202.group9.Map.Map;
import java.net.URL;
@ -68,7 +71,16 @@ public class FlightSummaryController extends Controller {
} catch (Exception e) {
e.printStackTrace();
}
map = new Map(mapView);
if (theDataSet.getFlightPaths().size() > 0){
map = new Map(mapView, theDataSet.getFlightPaths().get(0).getRoutePath());
}else{
map = new Map(mapView, new RoutePath());
}
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
map.displayRoute(theDataSet.getFlightPaths().get(flightPathListView.getSelectionModel().getSelectedIndices().get(0)).getRoutePath());
}
});
}
}

@ -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);
}
}

@ -36,6 +36,19 @@
});
}
function displayAirport(position){
map = new google.maps.Map(document.getElementById('map'), {
center: position[0],
zoom: 15
});
new google.maps.Marker({
position: position[0],
map: map,
title: '\u0048\u0061\u0072\u0061\u006d\u0062\u0065'
});
}
function displayRoute(flightPath) {
// CLEAR EXISTING MARKERS
if (marker1 !== undefined && marker2 !== undefined && path !== undefined) {

Loading…
Cancel
Save