Custom map sources which uses a similar URL scheme as Google/OpenStreetMap can be added to MOBAC. There are several types of map sources. Most of them are defined in an xml file in the mapsources
directory.
Note: For simple testing a custom XML map source you can also use Map Evaluator. Simply copy and paste the content of an custom map source XML file into the editor and execute it.
The following section shows is an example how the xml file has to be formatted. It defines an additional map source named “Custom OSM Mapnik” which shows map tiles identical to the predefined map source “OpenStreetMap Mapnik”.
<?xml version="1.0" encoding="UTF-8"?>
<[customMapSource]>
<name>Custom OSM Mapnik</name>
<minZoom>0</minZoom>
<maxZoom>18</maxZoom>
<tileType>png</tileType>
<url>http://tile.openstreetmap.org/{$z}/{$x}/{$y}.png</url>
<tileUpdate>None</tileUpdate>
<backgroundColor>#000000</backgroundColor>
<ignoreErrors>false</ignoreErrors>
<serverParts></serverParts>
</customMapSource>
The most important part of this definition is the <url> entry. It is a template containing specific placeholders, which are encapsulated by curly braces, and specify the requested tile.
Example file for download: Example custom map source.xml
A WMS server can be defined as a map source. EPSG:4326, EPSG:4171 and EPSG:3857 (WGS84) are supported as coordinate system.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customWmsMapSource>
<name>USGS EROS Ortho WMS</name>
<minZoom>0</minZoom>
<maxZoom>22</maxZoom>
<tileType>PNG</tileType>
<version>1.1.1</version>
<layers>0</layers>
<url>http://isse.cr.usgs.gov/arcgis/services/Orthoimagery/USGS_EROS_Ortho/ImageServer/WMSServer?</url>
<coordinatesystem>EPSG:4326</coordinatesystem>
<aditionalparameters><!CDATA&STYLES=default></aditionalparameters>
<backgroundColor>#000000</backgroundColor>
</customWmsMapSource>
It is recommended to wrap any field that has special charcters, such as an ampersand, inside a `<![CDATA[ ]]>` element. Otherwise you have to use their XML encoding, such as `&`
Example file for download: Example custom WMS map source.xml
Existing atlases or locally rendered tiles can be directly integrated into MOBAC as custom map source without having to set-up a local web-server.
Note: At the moment the formats used by OSMTracker, AndNav, BackCountry Navigator, Maverick and OSMAND are supported.
<?xml version="1.0" encoding="UTF-8"?>
<localTileFiles>
<name>Custom map from tile files</name>
<sourceType>DIR_ZOOM_X_Y</sourceType>
<sourceFolder>D:\MOBAC\LocalTiles\OSMAND\TilesAtHome</sourceFolder>
<invertYCoordinate>true</invertYCoordinate> <!-- optional -->
<backgroundColor>#000000</backgroundColor>
</localTileFiles>
Example file for download: Example custom tile files source.xml file, adapt the <sourcefolder> entry and place it in the mapsources directory.</sourcefolder>
Tiles can also be packed into one or more zip files and directly used by MOBAC.
<?xml version="1.0" encoding="UTF-8"?>
<localTileZip>
<name>Custom map from tile zips</name>
<sourceType>QUADKEY</sourceType>
<zipFile>D:\MOBAC\LocalTiles\MapCruncher_test.zip</zipFile>
<backgroundColor>#000000</backgroundColor>
</localTileZip>
Example file for download: Example custom tile zip source.xml
SQLite based atlas formats can also be used directly by MOBAC. Supported atlas formats are: RMaps, MBTiles, BigPlanetTracks, NaviComputer and OSMAND. Not supported: OruxMaps and Osmdroid
<?xml version="1.0" encoding="UTF-8"?>
<localTileSQLite>
<name>Custom SQLite atlas</name>
<sourceFile>D:\MOBAC\LocalTiles\Region.Mapnik.sqlitedb</sourceFile>
<atlasType>OSMAND</atlasType>
<backgroundColor>#000000</backgroundColor>
<tileImageType>PNG</tileImageType> <!-- optional -->
</localTileSQLite>
Example file for download: Example custom tile SQLite source.xml
BeanShell map sources as the can be developed using MapEvaluator can be used by MOBAC. To do so place the saved BeanShell code file (file extension .bsh ) in the mapsources directory. It will be loaded on next start-up of MOBAC.
Note: It is recommended to add a line defining the unique name of the map source to the BeanShell code.
name = "Your map source name here";
Example file for download: Example beanshell map source.bsh
Map sources which consist of two or more layers can be defined, similar to single-layer custom map sources.
Note: All map source layers, except the first in the list (the background layer), must have transparent parts. A non-transparent layer will hide all layers listed before it.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customMultiLayerMapSource>
<name>Custom OSM Mapnik with Hills </name>
<tileType>png</tileType>
<backgroundColor>#000000</backgroundColor>
<layersAlpha>1.0 0.8</layersAlpha>
<layers>
<customMapSource>
<name>Custom OSM Mapnik</name>
<minZoom>0</minZoom>
<maxZoom>18</maxZoom>
<tileType>png</tileType>
<tileUpdate>None</tileUpdate>
<url>http://tile.openstreetmap.org/{$z}/{$x}/{$y}.png</url>
</customMapSource>
<customMapSource>
<name>Custom transparent hillshade</name>
<minZoom>0</minZoom>
<maxZoom>18</maxZoom>
<tileType>png</tileType>
<tileUpdate>None</tileUpdate>
<url>http://www.wanderreitkarte.de/hills/{$z}/{$x}/{$y}.png</url>
</customMapSource>
</layers>
</customMultiLayerMapSource>
The most important part of this definition is the <layers> entry. It is an ordered list of map sources to be layered one on top of the other, where the last map source is the top-most.
Example files for download: Example custom multi-layer map source.xml
Example custom multi-layer map source2.xml
Developing a custom built-in map pack requires at least basic Java skills. Therefore the description on how to develop a custom map pack is only part of the source code release of MOBAC. You can get the source code of MOBAC by using the latest src release available in the files section at SourceForge or you can get it directly from the Subversion code repository using the latest trunk version.
Type: Optional Entry
Description: Defines a map source by the <url> of its tiles.
Contents:
Type: Required entry
Description: Map source name as it appears in the map sources list. The name has to be unique among the names of all map sources in MOBAC - built-in and user defined. The list of all available map sources and their names can be obtained via Show all map source names in the Debug menu.
Type: Required entry
Description: The minimum zoom level provided by the map source. For world wide maps this is usually 0 (one 256x256 tile showing the whole world) tile or sometimes 1 (four tiles showing the world). For regional map sources that cover only certain countries for example the value can be higher.
Type: Required entry
Description: The maximum zoom level provided by the map source.
Type: Required entry
Description: The image type provided by the map source.
Possible values are:
Note: values are case insensitive
Type: Required entry
Description: The URL for the tiles of the map source. It is a template containing specific placeholders which are encapsulated by curly brace:
Tile selection:
Alternatively for map sources that are using the quadtree key syntax (similar as it is used on Bing maps) there is the possibility to use the following parameter:
Server selection:
Note:
Ampersand characters & in an url have to be entity-escaped: & - otherwise you will get an error when MOBAC is starting and tries to load the custom map. Alternatively you can put the URL in an CDATA section:
Example URL outside of MOBAC: http://example.org/map&x={$x}&y={$y}&z={$z}
The same URL, prepared for MOBAC XML map source:
encoded:
<url>http://example.org/map&x={$x}&y={$y}&z={$z}</url>
or in CDATA:
<url><![CDATA[http://example.org/map&x={$x}&y={$y}&z={$z}]]></url>
Type: Optional entry
Description: If set to true, it inverts the y coordinate so that it starts south (min=0) and increases towards north (max=2^zoom -1). Supported since MOBAC 1.9.2
Default value if not present: false: Start north and increase towards south.
Type: Optional entry
MOBAC version: Supported since MOBAC 1.9 beta 7
Description: Use multiple servers for the map source. Contains a space-separated list of parts that replace the {$serverpart}
variable in the specified <url> pattern. This is especially useful for servers that perform load balancing among multiple server with different DNS names.
Example: (not functional - just to demonstrate how it works):
<url>http://{$serverpart}.openstreetmap.example/{$z}/{$x}/{$y}.png
</url>
<serverparts>a b 6 test
</serverparts>
Requests will be sent to
http://a.openstreetmap.example/...
http://b.openstreetmap.example/...
http://6.openstreetmap.example/...
http://test.openstreetmap.example/...
Type: Optional entry
Description: The background color of a map. This is useful for maps that use transparency. Additionally the background color will be used in case of missing tiles or tiles that could not be downloaded for atlas formats that require rectangular selections like OziExplorer, TrekBuddy, ...
Format: A hash character followed by a Hex triplet for an RGB color or quadruplet for an RGB color plus alpha transparency
Examples:
Default value if not present: Black: #000000FF
Type: Optional entry
Description: The server capabilities for conditional downloading of new/updated tiles.
Note: A tile is only downloaded if it is not present in the tile store or if the downloaded tile in the tile store has expired.
Possible Values:
Default value if not present: None
Type: Optional entry
Description: Handling of missing tiles errors. Useful for map sources that do only cover some tiles (sparse).
Possible Values:
Default value if not present: false
Type: Optional entry
Description: Allows the use of a WMS server as a map source.
Contents:
Type: Optional entry
Description: Allows the use of atlases or locally rendered tiles as a map source.
MOBAC version: MOBAC 1.9.3 and higher
Contents:
<sourcefolder>D:\MOBAC\LocalTiles\OSMAND\TilesAtHome
</sourcefolder>
Type: Mandatory entry for <localTileFiles> and <localTileZip> entries
Description: Specifies the directory structure and file name for local tile file and inside a tile Zip file
MOBAC version: MOBAC 1.9.3 and higher
Possible values:
Type: Optional entry
Description: Allows the use of atlases or locally rendered tiles and stored in a Zip file as a map source.
MOBAC version: MOBAC 1.9.3 and higher
Contents:
<zipfile>D:\MOBAC\LocalTiles\MapCruncher_test.zip
</zipfile>
Type: Optional entry
Description: Allows the use of atlases or locally rendered tiles and stored in a SQL file as a map source. Not
Contents:
<sourcefile>D:\MOBAC\LocalTiles\Region.Mapnik.sqlitedb
</sourcefile>
<tileimagetype>PNG
</tileimagetype>
Type: Mandatory entry for <localTileSQLite> entries
Description: Specifies the directory type of the SQL file, case sensitive.
Possible values:
Type: Optional entry
Description: Allows the use of multiple map sources as a layered map source
Contents:
Type: Mandatory entry for the <customMultiLayerMapSource> entry
Description: Specifies the map sources that will be combined into a single map. The first layer is located at the bottom, overlayed by all other map sources, and the top layer should be last.
Note: Make sure all the maps after the first contain transparent regions or use a <layersalpha> entry to add some transparency to them. Otherwise lower (earlier) layers will not be visible.</layersalpha>
Possible content:
<mapSource>
<name>Mapnik</name>
</mapSource>
Note: All built-in and BeanShell-defined map sources can be used freely. Moreover, a multi-layer map source described in file b.xml could use a map source from file a.xml.