Documentation‎ > ‎

JxMaps JavaFX Quick Start Guide

In this Quick Start Guide you will learn how to get started with JxMaps library.

1. Download Library

To download JxMaps library navigate to https://www.teamdev.com/jxmaps and click Download button. Unzip the downloaded archive into a directory on your computer (e.g. D:\Projects\MyProject). When you unzip the archive it will give you directory structure inside D:\Projects\MyProject\ as follows:

lib\
    jxmaps.jar          // JxMaps library
    jxmaps-win.jar      // JxMaps binaries for Windows
    jxmaps-mac.jar      // JxMaps binaries for macOS
    jxmaps-linux32.jar   // JxMaps binaries for Linux 32-bit
    jxmaps-linux64.jar   // JxMaps binaries for Linux 64-bit
samples\                // API samples
doc\javadoc\            // Public API Javadocs
doc\guide\              // Programmer's and Quick Start Guide
demo\                   // Demo application
Readme.txt              // Readme file
License agreement.txt   // License agreement

2. Getting Evaluation Licence

To get free JxMaps 30-days evaluation licence please fill the web form and click Get Evaluation button. You will receive an email with a link that you can use to download evaluation license file — license.jar. Download the license.jar file and save it in the D:\Projects\MyProject\lib\ directory.

lib\
    jxmaps.jar          // JxMaps library
    jxmaps-win.jar      // JxMaps binaries for Windows
    jxmaps-mac.jar      // JxMaps binaries for macOS
    jxmaps-linux32.jar   // JxMaps binaries for Linux 32-bit
    jxmaps-linux64.jar   // JxMaps binaries for Linux 64-bit
    license.jar

3. Create a Java project

Create a new Java Project using your favorite IDE.

4. Add JxMaps libraries to the project

Add JxMaps libraries and evaluation license to the Project in the IDE:

D:\Projects\MyProject\lib\jxmaps.jar
D:\Projects\MyProject\lib\jxmaps-win.jar
D:\Projects\MyProject\lib\jxmaps-mac.jar
D:\Projects\MyProject\lib\jxmaps-linux32.jar
D:\Projects\MyProject\lib\jxmaps-linux64.jar
D:\Projects\MyProject\lib\license.jar

5. Create Hello, World! application

In your Java Project create a new HelloWorld Java class with the following content:

package com.teamdev.jxmaps.examples;

/*
* Copyright (c) 2000-2017 TeamDev Ltd. All rights reserved.
* Use is subject to Apache 2.0 license terms.
*/

import com.teamdev.jxmaps.GeocoderCallback;
import com.teamdev.jxmaps.GeocoderRequest;
import com.teamdev.jxmaps.GeocoderResult;
import com.teamdev.jxmaps.GeocoderStatus;
import com.teamdev.jxmaps.InfoWindow;
import com.teamdev.jxmaps.Map;
import com.teamdev.jxmaps.MapReadyHandler;
import com.teamdev.jxmaps.MapStatus;
import com.teamdev.jxmaps.Marker;
import com.teamdev.jxmaps.javafx.MapView;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;


public class HelloWorld extends Application {
@Override
public void init() throws Exception {
MapView.
InitJavaFX();
}

@Override
public void start(final Stage primaryStage) {
final MapView mapView = new MapView();

mapView.setOnMapReadyHandler(
new MapReadyHandler() {
@Override
public void onMapReady(MapStatus status) {
if (status == MapStatus.MAP_STATUS_OK) {
final Map map = mapView.getMap();
map.setZoom(
5.0);
GeocoderRequest request =
new GeocoderRequest();
request.setAddress(
"Kharkiv, UA");

mapView.getServices().getGeocoder().geocode(request, new GeocoderCallback(map) {
@Override
public void onComplete(GeocoderResult[] result, GeocoderStatus status) {
if (status == GeocoderStatus.OK) {
map.setCenter(result[0].getGeometry().getLocation());
Marker marker =
new Marker(map);
marker.setPosition(result[
0].getGeometry().getLocation());

final InfoWindow window = new InfoWindow(map);
window.setContent(
"Hello, World!");
window.open(
map, marker);
}
}
});
}
}
});

Scene scene =
new Scene(new BorderPane(mapView), 700, 500);
primaryStage.setTitle(
"JxMaps - Hello, World!");
primaryStage.setScene(scene);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);
}
}

6. Run the Program

Compile and run HelloWorld program. You will see the following window: