Can objects (nodes or ways) be clickable on the map?

37 views
Skip to first unread message

Mario Pavlic

unread,
Apr 24, 2021, 11:23:10 AMApr 24
to Mapsforge & VTM
I have an .osm file containing data about bunch of nodes and ways and each of these nodes and ways has some specific tags. I used Osmosis to convert this .osm file to a .map file and I have successfully displayed the .map file in my Android app.

Now, is there a way to make these nodes and ways from .map file clickable on the map, as I would like to display some extra info about every one of them (like values from their tags)?

Note: I know how custom tag mapping and render theme rules work.

Thanks in advance!

Emux

unread,
Apr 24, 2021, 11:30:07 AMApr 24
to mapsfo...@googlegroups.com
Mapsforge maps were designed (and store tags) for fast map rendering, not for database searching.

The best you can get is reverse geocoding (see the example) and only for the stored displayed tags.

For advanced use you can check the POI API.

--
Emux

Mario Pavlic

unread,
Apr 26, 2021, 11:12:00 AMApr 26
to Mapsforge & VTM
Thanks, reverse geocoding works fine, but somehow only for POIs. https://github.com/mapsforge/mapsforge/blob/master/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/ReverseGeocodeViewer.java (line 76) - none of the Ways that are visible on the map are read, mapReadResult.ways.size() is 0 no matter where I click. I'm not sure how readLabels method works, but is there a catch with how the Way should look to be read by that method?

Emux

unread,
Apr 26, 2021, 11:15:47 AMApr 26
to mapsfo...@googlegroups.com
See the sample documentation and study the code.

Probably it reads closed ways containing the touch point (like polygons).

If you need something different, you could change the filter code in the sample.

--
Emux

Mario Pavlic

unread,
Apr 26, 2021, 11:33:02 AMApr 26
to Mapsforge & VTM
Yes, I tried removing the entire filter, but the problem occurs before filtering, because none of the Ways are read at all. Do Ways appear in MapReadResult even if none of their latLongs are in the Tile that is being read? Lets say the way's starting latLong is in Tile1 and way's ending latLong is in Tile3. If I read labels from Tile2 (which doesnt contain way's latLongs, but way's line crosses the Tile2) will the Way be added?

Emux

unread,
Apr 26, 2021, 11:58:40 AMApr 26
to mapsfo...@googlegroups.com
(you can study the code for the details)

The tiles are expected to contain the map data that can be rendered inside those tiles.

--
Emux
Reply all
Reply to author
Forward
0 new messages