plepe / OpenStreetBrowser

An application to ‘browse’ the information in the displayed part of the map. Similar to common Wikis and also the main page of http://www.openstreetmap.org the website shows a narrow menu on the left side, most of the page is used for the display of the map. In contrast to most Wikis the menu is not static, but rather the content of the map can be browsed in categories. For the map a special style has been developed (sorry guys, I neither like the default Mapnik nor Osmarender styles), and special overlays are displayed to support the current browsed categories. When you click on an object (either from the list or directly on the map) informations on this object are displayed.
http://www.openstreetbrowser.org
GNU General Public License v3.0
88 stars 20 forks source link

Displaying feature attributes when a marker is clicked #193

Closed govvin closed 7 months ago

govvin commented 7 months ago

Right now whenever I see a marker on the map and click on it, it shows just the following:

image

I don't remember which OSB category (or custom category) feature I saw, where instead of the above, the window actually display the attributes for the feature.

What do I need to add to a custom category to make that happen?

plepe commented 7 months ago

I think of the popups as a "user-friendly" display of the information about the map feature. Would you like any specific tags which should be shown in the popup?

You can see all attributes of the feature when you click 'show details'.

govvin commented 7 months ago

Yes, I understand that you can see more more information when you click on "show details" but what I meant to ask is that how to display the tags/attributes by default, without clicking anything.

I know I've seen it work with some other category, but couldn't remember which one, and hope to learn how to replicate that behavior.

It seems to be related to how populating the body of the pop-up. Could you point me to an example of how to list all the attributes of the selected object in the popup body?

plepe commented 7 months ago

Ah, I see.

The easiest would be the following snippet, which formats the tags as YAML output:

query: nwr[whatever=you_want]
feature:
  body: "<pre>{{ tags|yaml }}</pre>"

Alternatively, you could also use:

query: nwr[whatever=you_want]
feature:
  body: |
    {% for k, v in tags %}
    {{ k }}: {{ v }}<br>
    {% endfor %}

I hope this is helpful for you.

Learn more about how to create custom categories: