XAML-Map-Control/MapsforgeTiles/README.md

44 lines
2.1 KiB
Markdown
Raw Normal View History

2026-02-12 21:53:40 +01:00
# MapsforgeTiles
Tile source libraries for loading map content from vector map files.
2026-02-23 16:47:53 +01:00
The `MapsforgeTileSource` class in these libraries uses parts of the [Mapsforge](https://github.com/mapsforge/mapsforge)
Java library, which is made accessible to .NET via [IKVM](https://github.com/ikvmnet/ikvm), a Java Virtual Machine for .NET.
2026-02-12 21:53:40 +01:00
[Mapsforge](https://github.com/mapsforge/mapsforge) is published under a simplified variant of the
2026-02-15 17:49:55 +01:00
[LGPL v3 license](https://www.gnu.org/licenses/lgpl-3.0).
2026-02-12 21:53:40 +01:00
Map files can be downloaded from the [Mapsforge Download Server](https://download.mapsforge.org/).
2026-02-24 10:19:28 +01:00
`MapsforgeTileSource` is initialized by a static `LoadMaps` method that takes the file path to either a single map file
or a directory containing multiple map files.
2026-02-12 21:53:40 +01:00
2026-02-23 16:47:53 +01:00
The `MapsforgeTileSource` instance constructor takes a string parameter that specifies a Mapsforge theme. This is either
the full path of an XML `rendertheme` file, or the name of one of the built-in themes (ignoring case), e.g. `Default`.
2026-02-12 21:53:40 +01:00
See [MapsforgeThemes.java](https://github.com/mapsforge/mapsforge/blob/master/mapsforge-themes/src/main/java/org/mapsforge/map/rendertheme/internal/MapsforgeThemes.java)
2026-02-24 10:19:28 +01:00
for available theme names. An additional constructor parameters specifies the size of the tile source's internal cache.
2026-02-12 21:53:40 +01:00
Code sample:
```
2026-02-24 10:19:28 +01:00
MapControl.MapsforgeTiles.MapsforgeTileSource.Initialize(".\mapfiles");
2026-02-12 21:53:40 +01:00
map.MapLayer = new MapTileLayer
{
TileSource = new MapControl.MapsforgeTiles.MapsforgeTileSource("Default")
};
```
---
2026-02-16 10:18:19 +01:00
While building with IKVM's `MavenReference` succeeds, running a `RenderThemeFuture`
2026-02-14 00:02:29 +01:00
always fails with a `NoClassDefFoundError` exception for `org.xmlpull.v1.XmlPullParserFactory`.
2026-02-12 21:53:40 +01:00
2026-02-16 10:18:19 +01:00
An alternative approach is to import Mapsforge classes by an `IkvmReference` that references a
local JAR file with all required dependencies. This JAR is built from `pom.xml` in the MapsforgeTiles
directory, by a custom PreBuild event in the project files which executes the command
2026-02-12 21:53:40 +01:00
```
mvn package
```
2026-02-13 21:20:35 +01:00
2026-02-16 10:18:19 +01:00
So in order to build the MapsforgeTiles libraries, a [Maven](https://maven.apache.org/)
2026-02-13 21:20:35 +01:00
installation is required.