Reputation: 35
I want to write a client - Server navigation app in Java, the client only sends its position to the server, the server is building a map with the client position and any route. How can I create a map in java ? maybe there is a way to use Google Maps ?
Upvotes: 0
Views: 2543
Reputation: 17613
For the server side:
Google has a Java Google Maps Web Services you can use. This enables you to work with Google Maps web services on your server.
For the client side:
To make a Java google maps program, try to delve into JavaFX, thanks to Java 1.8. It has WebEngine and WebView classes which you can use to load the google maps URL.
Here's a snippet:
@Override public void start(Stage stage) {
// create web engine and view
final WebEngine webEngine = new WebEngine(getClass().getResource("googlemap.html").toString());
final WebView webView = new WebView(webEngine);
// create scene
stage.setTitle("Web Map");
Scene scene = new Scene(webView,1000,700, Color.web("#666970"));
stage.setScene(scene);
// show stage
stage.setVisible(true);
}
Here's a link to the full tutorial.
If you want you can also explore into GMapsFX,a wrapper to the Google Map's Javascript API, allowing you to use and interact with maps using a pure Java API.
Upvotes: 1