Skip navigation links

Leaflet Java API 1.0-SNAPSHOT API

This is Java version of leaflet library for rendering of mobile friendly interactive maps.

See: Description

Packages 
Package Description
net.java.html.leaflet
Leaflet API for Java built around the Map class.
net.java.html.leaflet.event
Listeners and events for the leaflet API

This is Java version of leaflet library for rendering of mobile friendly interactive maps. The API has been designed by students of Johannes Kepler University of Linz (Andreas Grimmer, Christoph Sperl, Stefan Wurzinger) as part of their 2015 API Design course. The API has been adopted and is distributed as part of the DukeScript project. Here is a sample code to help you relalize where the Johannes Kepler University is:

// Create a map zoomed to Linz.
MapOptions mapOptions = new MapOptions()
        .setCenter(new LatLng(48.336614, 14.319305))
        .setZoom(15);
final Map map = new Map("map", mapOptions);

// add a tile layer to the map
TileLayerOptions tlo = new TileLayerOptions();
tlo.setAttribution("Map data &copy; <a href='http://www.thunderforest.com/opencyclemap/'>OpenCycleMap</a> contributors, "
        + "<a href='http://creativecommons.org/licenses/by-sa/2.0/'>CC-BY-SA</a>, "
        + "Imagery © <a href='http://www.thunderforest.com/'>Thunderforest</a>");
tlo.setMaxZoom(18);
TileLayer layer = new TileLayer("http://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png", tlo);
map.addLayer(layer);

// Add a polygon. When you click on the polygon a popup shows up
Polygon polygonLayer = new Polygon(new LatLng[] {
        new LatLng(48.335067, 14.320660),
        new LatLng(48.337335, 14.323642),
        new LatLng(48.335238, 14.328942),
        new LatLng(48.333883, 14.327612)
});
polygonLayer.addMouseListener(MouseEvent.Type.CLICK, new MouseListener() {
     @Override
    public void onEvent(MouseEvent ev) {
        PopupOptions popupOptions = new PopupOptions().setMaxWidth(400);
        Popup popup = new Popup(popupOptions);
        popup.setLatLng(ev.getLatLng());
        popup.setContent("The Leaflet API for Java has been created here!");
        popup.openOn(map);
    }
});
map.addLayer(polygonLayer);

Result of the Program

Skip navigation links

Copyright © 2017. All rights reserved.