https://github.com/kpouer/kmapview
A Swing component showing a map
https://github.com/kpouer/kmapview
java map swing
Last synced: 7 days ago
JSON representation
A Swing component showing a map
- Host: GitHub
- URL: https://github.com/kpouer/kmapview
- Owner: kpouer
- License: apache-2.0
- Created: 2021-01-30T22:27:14.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-01-15T08:46:13.000Z (over 2 years ago)
- Last Synced: 2025-01-10T09:24:10.498Z (over 1 year ago)
- Topics: java, map, swing
- Language: Java
- Homepage:
- Size: 240 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# K-MapView

[](https://central.sonatype.com/artifact/com.kpouer/k-mapview/1.2.0/versions)
A Swing component able to show a map
## Introduction
This component will download from a tile server and show them.
It is a simple component able to add markers. But there is no search ability included.

## Features
The map depends on a tile server. It can be OSM, but not necessary. You can find some examples here see https://wiki.openstreetmap.org/wiki/Tile_servers
It supports adding widgets to the map (dot, circles, or any other you create).
## Tiles servers
You will have to find a tile server. One of the most common choice is OSM tiles.
You can find various tiles servers here https://wiki.openstreetmap.org/wiki/Tile_servers
Beware, the term of use varies and most of them will not allow you to use them in a commercial product.
Tiles will be stored in a disk cache, but that cache is not managed by this component, it is up to you
to clean it when you want.
Retrieving queries can be load balanced between multiple servers.
## Example
```java
import com.kpouer.mapview.tile.DefaultTileServer;
import com.kpouer.mapview.tile.cache.ImageCacheImpl;
import javax.swing.*;
import java.io.IOException;
public class Sample {
public static void main(String[] args) throws IOException {
JFrame frame = new JFrame();
MapView mapView = new MapView(new DefaultTileServer(256,
1,
18,
2,
new ImageCacheImpl("Waze", "cache", 1000),
"https://a.tile.openstreetmap.org/${z}/${x}/${y}.png",
"https://b.tile.openstreetmap.org/${z}/${x}/${y}.png",
"https://c.tile.openstreetmap.org/${z}/${x}/${y}.png")));
String wkt2 = "POLYGON((12.493134831869419 41.91785801245087,12.559739446127232 41.88796130217409,12.4316800589202 41.874669382200494,12.469788884603794 41.96101743431704,12.493134831869419 41.91785801245087))";
Polygon polygon = WKT.parseShape(wkt2);
PolygonMarker marker = new PolygonMarker(polygon, 5, new Color(1.0f, 0.0f, 0.0f, 0.3f), true);
mapView.addMarker(marker);
contentPane.setMouseLocationLabelVisible(false);
frame.setContentPane(contentPane);
frame.setSize(800, 600);
frame.setVisible(true);
}
}
```
## Dependency
Available through Maven central
```xml
com.kpouer
k-mapview
1.0.1
```
## Note
The api is still under development and things might change
## Licence
K-MapView is open source and licensed under the Apache License 2.0.