Selectively display an area on mapsforge

60 views
Skip to first unread message

Deepak Sehrawat

unread,
Sep 18, 2016, 6:23:36 AM9/18/16
to mapsforge-dev

Hi everyone,

I am trying to display a multi-floor building via mapsforge. For each floor, I have created a map using JOSM (.osm file format). My problem is how to selectively display each floor on same spatial area (on top of mapsforge base tiles e..g like an overly vector image)? Any pointers will help.


Thanks in Advance,
Deepak

Emux

unread,
Sep 18, 2016, 6:58:05 AM9/18/16
to mapsfo...@googlegroups.com
There are several options:

- You can use multiple map files at the same time, see here.
i.e. use a common base map and put on top each floor in separate map.

- You can selectively turn on / off the layers of the map at the render theme, see here.
i.e. have all floors in same map and enable them via render theme.

- Even use regular overlays.

For all cases you can study the Samples app which has examples for these.

--
Emux

Deepak Sehrawat

unread,
Sep 18, 2016, 7:08:21 AM9/18/16
to mapsforge-dev
Gr8. Thanks a ton. Lemme try your suggested options.


On Sunday, 18 September 2016 16:28:05 UTC+5:30, Emux wrote:
There are several options:

- You can use multiple maps files at the same time, see here.

i.e. use a common base map and put on top each floor in separate map.

- You can selectively turn on / off the layers of the map at the render theme, see here.
i.e. have all floors in same map and enable them via render theme.

- Even use regular overlays.

For all cases you can study the Samples app which has examples for these.

--
Emux

Deepak Sehrawat

unread,
Sep 20, 2016, 11:06:27 AM9/20/16
to mapsforge-dev

Hi,

Going with the second option, I am using render theme4. My problem is how can I enable/disable an overlay on-the-fly e.g. by any event (say tap on screen). Is there any way to re-draw the overlays of a layer (after I have selectively enabled/disabled them on the fly)?

I want to dynamically enable or disable any of the overlays that i have defined in rendertheme-v4.xml.

I tried a couple of options but none of them seem to work:
this.redrawLayers();    (calls method from MapViewerTemplate.java)
- Following code is not efficient (long flicker)
for (TileCache tileCache : tileCaches) {
    tileCache.purge();
}
AndroidUtil.restartActivity(this);






On Sunday, 18 September 2016 16:28:05 UTC+5:30, Emux wrote:

Emux

unread,
Sep 20, 2016, 11:35:09 AM9/20/16
to mapsfo...@googlegroups.com
Study the Samples app (like RenderTheme4 and Settings classes)

e.g. select 1st example and check the preferences see them in action

--
Emux

Deepak Sehrawat

unread,
Sep 20, 2016, 11:52:56 AM9/20/16
to mapsforge-dev

I tried that and looks like it does the following on preference change; but is there any way we can do it without restarting the activity? e..g by just re-drawing overlays somehow?

Am i missing something here?

    for (TileCache tileCache : tileCaches) {
tileCache.purge();
}
AndroidUtil.restartActivity(this);
}


Emux

unread,
Sep 20, 2016, 12:12:46 PM9/20/16
to mapsfo...@googlegroups.com
That's for the specific implementation in the Samples.
It's not even necessary to do it that way, i.e. via preferences, could be via a dialog.

The tile cache needs to be cleared since it has the old layers in it.

And the map has to be refreshed, could be like when we set a new render theme in the map.
See the RenderThemeChanger example for that, without any restart at all.

--
Emux

Deepak Sehrawat

unread,
Sep 20, 2016, 1:03:54 PM9/20/16
to mapsforge-dev
Thanks a lot  :) it helped.
Reply all
Reply to author
Forward
0 new messages