Another style directive question

I’m trying to create a label using style directives that will display in my Garmin maps.

I want to display the ref and distance, and possibly some other information, from nodes tagged as highway=milestone. My attempts so far haven’t worked.

What I want to see alongside my custom milemarker icon is the highway’s ref number and the distance tag on that particular milestone. For example, starting wth these tags:

highway=milestone
ref=1268
distance=22
inscription:en=Chiang Mai 22

I want to end up with this 1268 : 22 km

My directive (that doesn’t work) is here:

highway=milestone {name '${ref}' : '${distance}' | '${ref}' | '${distance}' } [0x10f0b resolution 24]

I’ve tried other things, setting labels, etc., but so far haven’t had any luck. The icon does in fact display, so that part is working fine.

Suggestions, please.

Nothing wrong with that code, as long as you put it in your point file?
Or maybe your device cannot render icon 0x10f0b, try something like 0x1a0a ?

The icon displays properly. That part is fine. But I cannot get any text to display. Note that there is no “name” tag in the milestone tags. Does that make a difference?

No that doesnt make a difference, mkgmap converts ref and distance as name tags.
Where/how did you test that map, in Mapsource and Basecamp you see for instance the label Chm. 4021 : 33 in blue with a shopping cart with that code you provided

Well now, that’s interesting. I’m using my Montana and Basecamp, both running the newest releases. I have Mapsource but because I’m not installing the map, only creating an IMG and copying it onto my Montana’s SD card, I cannot tell what it looks like in Mapsource. All my other customizations display as they should but those don’t use any special style directives to display tag information. No labels display in Basecamp v 4.4.6

Hmmm???

Looks like you had a typo:

highway=milestone {name '${ref} : ${distance}' | '${ref}' | '${distance}' } [0x10f0b resolution 24]

@MH no those quotes should not make any difference
@Dave Can you put your img and styles somewhere online so that I check it? Do you use a typ file? It doesnt matter if you use Mapsource or Basecamp, they both display the label fine.

I’ve tried the quotes in various places. I’ve tried it the way you suggest too. The code snippet I showed was just my last go at it.

Sure thing: TYP file is here: https://dl.dropboxusercontent.com/u/6233140/24983djs.typ
Points styles here: https://dl.dropboxusercontent.com/u/6233140/Generic_new_styles/points
Lines styles here: https://dl.dropboxusercontent.com/u/6233140/Generic_new_styles/lines
Polygons here: https://dl.dropboxusercontent.com/u/6233140/Generic_new_styles/polygons

Dropbox won’t give me a public link to the styles folder but those are the only ones I’ve modified.

Thanks very much…

Also, here is my IMG file, Lanna.IMG ; https://dl.dropboxusercontent.com/u/6233140/Lanna.img

And my batch file containing the mkgmap command line: https://dl.dropboxusercontent.com/u/6233140/make.bat

In your points style you have

highway=milestone {name '${ref}' : '${distance}' | '${ref}' | '${distance}' } [0x10f0b resolution 24 default_name 'M/M']

Those quotes actually does make a difference, you should set it as you stated before, name ‘${ref} : ${distance}’
In the typ file I see FontStyle=NoLabel (invisible) so that makes sense too. You have to set it to visible (I use typviewer).
Try

[_point]
Type=0x10f
SubType=0x0b
String1=0x04,milestone
ExtendedLabels=Y
FontStyle=NormalFont

Wonderful! Thank you very much. I set it to invisible while developing the icon and then promptly forgot about it.

When the quotes surround the entire label code, ‘${ref} : ${distance}’ as you said, that gives the desired result. Perfect.

I reckon I can get back to work on the next set of icons and labels.

Again, thanks so much…

Great to hear that it is solved now!

Let me propose another related question. I want to do this but it isn’t critical. It’s more about trying to better understand the style directives. Let’s say that for certain milestones, only those that have distance=0, I want to have a different label, perhaps “Km Zero Milestone : Route 1268”. Other milestones should display the normal way: 1268 : 22 km. Is this sort of conditional styling possible?

I know the style directives must be written or arranged most restrictive first but beyond that, I would have to experiment.

Suggestions?

Yes mkgmap can do some conversions to the tags.
Try highway=milestone & distance=0 {set distance=‘Zero Milestone’}
Or highway=milestone & distance=0 {name ‘Km Zero Milestone : ${ref}’}

See the manual at http://www.mkgmap.org.uk/doc/pdf/style-manual.pdf for more complex examples

Yikes, awesome! It does seem to matter where the style is placed in the file. The following set of styles works:

highway=milestone & distance=0 {name 'Km Zero Milestone ${ref}'} [0x10f0b resolution 22]
highway=milestone {name '${ref} : ${distance} km.' | '${ref}' | '${distance} km.' } [0x10f0b resolution 22]

But not the other way round.

I’ve looked at the manual and it helps but not as much as it could. Very terse instructions with short and overly brief explanations.

Anyway, that’s all for now.

Many thanks ligfietser :slight_smile: