2

How can I show the offline mapsforge openstreetmap in HTML5?

The mapsforge files are *.map files. Is there an javascript library to access the mapsforge tiles?

tm1701
  • 7,307
  • 17
  • 79
  • 168

2 Answers2

1

Mapsforge only supports Java (on Desktop and Android).

And unofficially for iOs written by medvedNick.

I have never seen a javascript implementation... I guess up till now for most people classical osm tiles are sufficient for html.

fupduck
  • 490
  • 4
  • 12
0

If this is still relevant:

Provided that you have a working implementation of your offline mapsforge map (on an Android device or a Desktop), you can make that implementation return the map tiles you need into a "mapcache" folder, for example, by adding the following line of code to your Mapview.

TileCache tileCache = AndroidUtil.createTileCache(activity, "mapcache", mapView.getModel().displayModel.getTileSize(), this.getScreenRatio(), mapView.getModel().frameBufferModel.getOverdrawFactor());

You can then use those map tiles in Leaflet or OpenLayers.

See also https://stackoverflow.com/a/33452744/3356270.

Community
  • 1
  • 1
kalabalik
  • 3,792
  • 2
  • 21
  • 50
  • Thanks. You making your app loading the tiles from the *.map file and putting them in a mapcache? This mapcache could be read by Leaflet or OpenLayers? – tm1701 Nov 23 '16 at 16:38
  • In my app, Mapsforge (which is included as a library) uses a .map file and a modified osmarender.xml style file to render a map. If you include the above code in your Android application and "visit" all the tiles you need (at every zoom level you need) by hand, Mapsforge will "calculate" each tile only once from the data and then save it to the "mapcache" folder on your mobile device. Get it from there via USB, for example. Since there is "manual work" involved here, I guess this procedure only makes sense if the area of your map is relatively small and covers relatively few zoom levels. – kalabalik Nov 24 '16 at 12:04
  • OK, gives insights. Will rethink my solution. – tm1701 Nov 24 '16 at 16:54