Android Question OSM MapsForge Custom Render

jamesnz

Active Member
Licensed User
Longtime User
Hi,
I'm using OSMDroid 4.1 library from @warwound and the Mapsforge vector tilesource
everything works fine until I set a render theme, like so
B4X:
Dim InputStream1 As InputStream
InputStream1 = File.OpenInput( File.DirAssets    , "osmarender.xml")
MapsForgeTileSource1.GetMapsForgeTileSourceOptions.SetRenderTheme(InputStream1)

All I get is a blank grid, no error messages

The render theme is
B4X:
<?xml version="1.0" encoding="UTF-8"?>
<rendertheme xmlns="http://mapsforge.org/renderTheme" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://mapsforge.org/renderTheme renderTheme.xsd" version="1">

    <!-- matches all ways with a "highway=trunk" or a "highway=motorway" tag -->
    <rule e="way" k="highway" v="trunk|motorway">
        <line stroke="#FF9900" stroke-width="2.5" />
    </rule>

    <!-- matches all closed ways (first node equals last node) with an "amenity=…" tag -->
    <rule e="way" k="amenity" v="*" closed="yes">
        <area fill="#DDEECC" stroke="#006699" stroke-width="0.3" />
    </rule>

    <!-- matches all nodes with a "tourism=hotel" tag on zoom level 16 and above -->
    <rule e="node" k="tourism" v="hotel" zoom-min="16">
        <symbol src="file:/path/to/symbol/icon/hotel.png" />
        <caption k="name" font-style="bold" font-size="10" fill="#4040ff" />
    </rule>
</rendertheme>

and comes from https://github.com/mapsforge/mapsforge/blob/master/docs/Rendertheme.md
I see another thread some years ago having difficulties with a custom render https://www.b4x.com/android/forum/threads/openstreetmap-using-pbf.38596/page-3
keen to know if it was resolved or anyone has been able to achieve this
 

jamesnz

Active Member
Licensed User
Longtime User
here is the demo with a small map of monaco attached, uncomment line 60
 

Attachments

  • mapsforgecustomrender.zip
    89.4 KB · Views: 341
Upvote 0

PamazFit

Member
Licensed User
Just stumbled on this myself, so I don't know if you allready found the answer and the question is stil relevant.

I also did not manage to get the above Rendertheme working, and indeed, a blanc screen with no Errors. I think thats probably because Mapsforge handels Errors internally.
And did not know where to put the symbols and patterns folder as this is required in the above theme : <file:/path/to/symbol/icon/hotel.png" />

What works however is to copy and edit the rendertheme that is allready present within the Mapsforge library.
I have succesfully added Cycling nodes for the Netherlands to it.

You can find the original Rendertheme 'osmarender.xml' inside the jar when you extract its contents (OSMDroid_4_1_MapsForgeTileSource\assets\rendertheme\osmarender.xml)
You can then load your new rendertheme with the code you allready supplied

B4X:
Dim InputStream1 As InputStream
InputStream1 = File.OpenInput(File.DirAssets, "my-osmarender.xml")
MapsForgeTileSource1.GetMapsForgeTileSourceOptions.SetRenderTheme(InputStream1)


Kind regards,
Patrick
 
Upvote 0

jamesnz

Active Member
Licensed User
Longtime User
Just stumbled on this myself, so I don't know if you allready found the answer and the question is stil relevant.

I also did not manage to get the above Rendertheme working, and indeed, a blanc screen with no Errors. I think thats probably because Mapsforge handels Errors internally.
And did not know where to put the symbols and patterns folder as this is required in the above theme : <file:/path/to/symbol/icon/hotel.png" />

What works however is to copy and edit the rendertheme that is allready present within the Mapsforge library.
I have succesfully added Cycling nodes for the Netherlands to it.

You can find the original Rendertheme 'osmarender.xml' inside the jar when you extract its contents (OSMDroid_4_1_MapsForgeTileSource\assets\rendertheme\osmarender.xml)
You can then load your new rendertheme with the code you allready supplied

B4X:
Dim InputStream1 As InputStream
InputStream1 = File.OpenInput(File.DirAssets, "my-osmarender.xml")
MapsForgeTileSource1.GetMapsForgeTileSourceOptions.SetRenderTheme(InputStream1)


Kind regards,
Patrick
Ha, it does too, thanks for the tip !
 
Upvote 0
Top