User Tools

Site Tools


manual:advanced:customization:online_maps

This is an old revision of the document!


Custom Online maps


Page under re-construction

Basic information

  • required version: 1.9.5
  • XML file - that contains description of Online map providers (more below). Name and path to this file on storage card (or internal memory) is /CARD_ROOT/Locus/mapsOnline/custom/<somename>.xml (you can have more than one xml in the folder, Locus will add all of them)
  • PNG images (optional) - for every map provider name. This icon is not required! It's just displayed next to maps in Online manager. Name of this icon should be same as text in name tag

Example map

Example of OpenPiste map (OSM based) created from three layers.

  1. layer is background, which is not visible in list but required.
  2. layer is contour layer, which is visible but not really required. On some places should not be this layer, so when server return 404 code for tile, you can still see background layer!
  3. layer is shade. This layer will be visible is map list, so fill correct “mode” and “area” (optional). This layer is also not required.

Map code in providers.xml file

Example of OpenPiste map (OSM based) created from two layers here (in app is together with third shade layer). First layer is background, which is not visible in list but required. Second is contour layer, which is visible but not really required. On some places should not be this layer so when server return 404 code for tile, you can still see background layer! Referer added to header is not recommended in this case. It's only as example.

providers.xml
<?xml version="1.0" encoding="UTF-8"?>
    <providers>
       <provider id="1000" type="0" visible="false" required="true" background="-1">
          <name>OSM</name>
          <mode>background</mode>
          <url><![CDATA[http://tiles.openpistemap.org/nocontours/{z}/{x}/{y}.png]]></url>
          <zoomPart>{z}-8</zoomPart>
          <zoomMin>8</zoomMin>
          <zoomMax>24</zoomMax>
          <tileSize>256</tileSize>
          <extraHeader>Referer#http://locus.asamm.cz/</extraHeader>
       </provider>
       <provider id="1001" type="0" visible="false" required="false" background="1000">
          <name>OSM</name>
          <mode>contours</mode>
          <url><![CDATA[http://tiles.openpistemap.org/contours-only/{z}/{x}/{y}.png]]></url>
          <zoomPart>{z}-8</zoomPart>
          <zoomMin>8</zoomMin>
          <zoomMax>24</zoomMax>
          <tileSize>256</tileSize>
          <extraHeader>Referer#http://locus.asamm.cz/</extraHeader>
       </provider>
       <provider id="1002" type="0" visible="true" required="false" background="1001">
          <name>OSM</name>
          <mode>OpenPiste</mode>
          <url><![CDATA[http://tiles2.openpistemap.org/landshaded/{z}/{x}/{y}.png]]></url>
          <zoomPart>{z}-8</zoomPart>
          <zoomMin>8</zoomMin>
          <zoomMax>24</zoomMax>
          <tileSize>256</tileSize>
          <countries>World</countries>
          <usage>hiking,ski</usage>
          <extraHeader>Referer#http://locus.asamm.cz/</extraHeader>
       </provider>
    </providers>

Specifications of map definition

  • id - required identificator, must be greater or equal 1000. Values before are reserved to Locus
  • type - type of map provider
    • 0 - Spherical mercator, projection Spheric, inverse Y
    • 1 - Spherical mercator, projection Spheric, normal Y
    • 2 - Spherical mercator, projection Ellipsoid, inverse Y
    • 3 - Spherical mercator, projection Ellipsoid, normal Y
    • 4 - Spherical Mercator, projection Spheric, Y from center
    • 5 - Spherical mercator, projection Spheric, Quadkey map system (more info http://msdn.microsoft.com/en-us/library/bb259689.aspx)
      • use {c} for coordinate part only. There are no X, Y, Z coordinates in URL, just {c}!
  • visible - if provider will be visible in list
  • required - is tile from this provider required? When server returns 404, use rest of multilayer map or not?
  • background - ID of background layer
  • name - name of provider
  • mode - little description
  • area - deprecated, not used anymore
  • url - http://tile… - base url for tiles which don''t change with requests. {z}/{x}/{y} syntax for tiles, where {x} and others will be replaced for X, Y coordinates and Zoom
    • {x} - replace by X tile
    • {y} - replace by Y tile
    • {z} - replace by zoom level after applied zoomPart computation
    • {s} (optional) - replace by server text
  • serverPart - you can define {s} item in main url. In serverPart can then be defined array of items that will be randomly set as {s} item. So for example <serverPart>0;1;2</serverPart> and url started as <url><![CDATA[http://tiles{s}.open ….. {z}/{x}/{y}.png]]></url> will set every call to be randomly http://tiles0.open…, or http://tiles1.open…, or http://tiles2.open
  • zoomPart - {z}-8 - syntax for recompute correct zoom value for request. This value is usually Zoom - minimum zoom, but should be different
  • zoomMin - minimum zoom
  • zoomMax - maximum zoom
  • tileSize - size of tiles in pixel
  • countries - list of countries (separated by comma), where map may be used. These values are used for separating maps in “Online map tab”.
  • usage - list of possible usage of this map (separated by comma). Current possibilities are: aero, city, cycle, hiking, nautical, overlay, photo, road, ski, transport. These values are used for separating maps in “Online map tab”.
  • extraHeader - extra Http request that will be added to tile request on server. These additional data consist of two parts with syntax part1#part2. Part1 is name of this request, Part2 is value of this request. Also this TAG should be in XML for every provider more then once.
  • attribution - small text displayed at map screen at bottom. Please use this when you're using maps that have any owner (other then yours) and require attribution in their terms of use

ZoomValues (zoomMin, zoomMax) have to be counted as valid zoom level by 2^x. So whole world have one tile 256×256 px, which means 2^8, so X = 8!. That's why almost all maps in Locus start with zoomMin = 8 but have zoomPart {z} - 8. This is because in URL, zooms usually starts from 0 - some max value

I'm sure that this solution should be improved so if you have any ideas, tell me. Also if here will be any little bit experienced developer on android, we should try to create some mechanist for adding external providers through ContentProviders or services.

Now you know syntax of providers, so you should add your custom ones. Please, share links with others and enjoy

Hints

  • providers with same name will be grouped together!
  • if you add PNG icon into custom directory with same name as provider name, icon will be attached into online map screen

How to obtain required info

Suggested is to use Firefox browser with extension HttpFox

  • Start Firefox browser and open webpage with map. Nice example on http://www.openstreetmap.org/.
  • Open HttpFox from Tools menu or by SHIFT-F2. And press top green Start button.
  • Now zoom by one level and you'll see list of requests on map server. Viz screenshot below.
  • So I'll take selected URL line. On right side is required URL, so when we separate part with coordinates then 12/2215/1389 will be cooPart written as {z}/{x}/{y}.
  • Rest will be url part, so it will look http://c.tile.openstreetmap.org/{c}.png.
  • These are main values needed to add map. Tilesize is usually 256px. Min and max zoom values have to be tested manually. Also zoomPart is usually z-8, which mean that zoom 20 in Locus will be served as 12 in request on server.

manual/advanced/customization/online_maps.1432298717.txt.gz · Last modified: 2015/05/22 14:45 by mstupka