Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change primaryRoadColor in Osmand Android?

Tags:

android

osmand

I tried changing the primaryRoadColor value to ff0000. When I compile, it is replaced with the default ff80a0 value. How and where can I create custom color for roads?

In my render folder, I have the following XML:

default.render.xml, Depends-template.render.xml, hud.render.xml, LightRS.render.xml, nautical.render.xml, regions.render.xml, skimap.render.xml, standalone-template.render.xml, test.render.xml, Topo-map-assimilation.render.xml,Touring-view_(more-contrast-and-details).render.xml, UniRS.render.xml

I followed this link, it didn't work out.

like image 613
DroidLearner Avatar asked Mar 14 '23 18:03

DroidLearner


1 Answers

It seems that this tutorial needs updating, a complete "Hello World!" style example would've been nice.

This is how I did it in OsmAnd+ 2.3.5.

My data storage folder (Settings -> General Settings -> Data storage folder) was in:

/storage/sdcard1/osmand-plus/osmand

so the custom renderer file had to go to:

/storage/sdcard1/osmand-plus/osmand/rendering

This directory may be empty at first but as you select map styles from Configure map -> Map style OsmAnd will drop the corresponding renderer XML files into that directory.

NOTE: You have to completely shut down the app and restart it again after adding new renderers or making changes to the existing ones for the app to pick the changes up.

I went the "inheritance" route and created a file called BLACK_ROADS.render.xml (following the <name-of-renderer>.render.xml naming requirement) that extended the default (default.render.xml) renderer.

Here is the content of my renderer. I made it into a sort of a template so I can later see what else can go into this file.

<?xml version="1.0" encoding="utf-8"?>

<!-- depends="default" -> default.render.xml -->
<renderingStyle name="Paints the roads black in day mode, white in night mode" 
    depends="default" defaultColor="#ffffff" version="1">

    <renderingAttribute name="primaryRoadColor">
        <!-- 40 -> 25% opacity, 80 -> 50% opacity, C0 -> 75% opacity, FF -> 100% opacity -->
        <!-- or remove first two hex digits for 100% opacity -->
        <!-- NIGHT MODE -->
        <case nightMode="true" attrColorValue="#80ffffff"/> <!-- white -->
        <!-- DAY MODE -->
        <case attrColorValue="#80000000"/> <!-- black -->
    </renderingAttribute>

    <!-- These are "global" variables (can have many of each), which 
         can be referenced throughout the file. -->
    <!--
    <renderingAttribute/>
    <renderingConstant/>
    <renderingProperty/>
    -->

    <!-- This section determines the order in which objects are rendered.
         Higher values will be on top. -->
    <order/>

    <!-- This section determines how text object are displayed. -->
    <text/>

    <!-- This section determines how point objects, which typically 
         have an icon associated with them, are displayed. -->
    <point/>

    <!-- This section determines how polygon objects are displayed. -->
    <polygon/>

    <!-- This section determines the look of roads, footpaths, coastlines etc.  
         Basically everything that is a line goes into this section. -->
    <line/>

</renderingStyle>

And here are the results:

  • OsmAnd style
  • new BLACK ROADS menu entry (taken from the file name)
  • BLACK ROADS style day mode
  • BLACK ROADS style night mode

OsmAnd style new BLACK ROADS menu entry BLACK ROADS style day mode BLACK ROADS style night mode

like image 144
Johnny Baloney Avatar answered Mar 29 '23 00:03

Johnny Baloney