Open lambdaupb opened 8 years ago
It is easy, and I have already done it for personal use. interestingly, on android 6 (probably not only, but I found it out after upgrading), the app you use the maps in needs storage permissions, not gms. I also wanted to make a setting in the microG settings, so you can enable/disable the feature, so there is a chance it gets merged, but when I finally realized how to do it, there was another problem: I wasn't able to read the preference correctly. I don't really know Java or Android programming (well I do more now than I did before trying this), so I suppose it's my fault. I also wanted to avoid ugly hacks, so it can be merged. Basically, You can choose compile-time that you want offline maps, and the path to the map file. Also, custom themes work with the map files, but vtm and mapsforge themes are incompatible, and there are no custom vtm themes whatsoever. I got KČT tracks to work though, so it is not all that bad.
So, if someone wants this, I believe you just have to change
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
to
import org.oscim.tiling.source.mapfile.MapFileTileSource;
and
OSciMap4TileSource tileSource = new OSciMap4TileSource();
to
MapFileTileSource tileSource = new MapFileTileSource(); tileSource.setMapFile(mapFile + "/mapfile.map");
.
If someone wants to help me make it ready for merge (I would LOVE that),
just let me know. Not sure what is the best way to do so, but I may check here when I am bored (probably more then one time a day most of the time).
I hope this helps someone, even if not everybody who would like it :)
Maybe we could use other apps API to access the maps, in addition to the default backend? So there is no need for microg to handle map storage, download, etc. For instance osmand seems to have APIs: http://osmand.net/build_it. I think it would be even better to have "maps providers" as there is for location, than having multiple complex implementations straight into the core.
the thing is, that the vtm already supports different map sources, it just should not be hardcoded. Your idea is not bad though, but unlike mine deserves the milestone 'later'. In vtm, I like the panning and 3d buildings, I would like mapsforge themes support. there is even no documentation on vtm themes AFAIK :/ Glad someone actually found my comment, even if you didn't help me to make this merge-able :)
I think that if we want to integrate offline maps, we also need a download interface, the ability to switch (automatically?) between offline and online, etc. I think that means a lot of code, and we might have the same problem as original google play service: size. IMHO it's a bit out of the scope of microG, but @mar-v-in feedback would be welcome. Then, the user will be forced to use a product. For people already using an offline map app, it could also mean having the same maps downloaded twice. Anyway I wouldn't have time to help you soon, sorry.
As @Mis012 already wrote, it wouldn't be too hard to implement this with the current base, but there are two problems:
Tangram-es seems nice, however there isn't any support for osmand tiles format. Btw, files used by osmand (obf) seems to be a pain to deal with. I'm really afraid that we will have to handle gigabytes of similar files, just because of the format...
What about mapsforge? It's what vtm forked off, and lot of apps support the map format
@Mis012: It is already using mapsforge/vtm (a fork of opensciencemap/vtm); it is the one having problems.
Tangram-es seems nice, however there isn't any support for osmand tiles format. Btw, files used by osmand (obf) seems to be a pain to deal with.
And still, adding support for a specific file format is very likely a lot easier than to handle bugs in native GL rendering code ;)
@ale5000-git not mapsforge/vtm, mapsforge/mapsforge
@Mis012 It's written in Java, so probably way slower than tangram-es, which is written in c++/openGL.
That makes sense, but does it matter? Apps using it work fine for me. Also, with mapsforge maps and themes, a lot is possible. I'm using a custom map with height lines and marked ways / cycling routes, and it looks and works really cool. The theme is not compatible with vtm though. And of course I can use the same map file with multiple applications. Is this possible with tangram-es?
I just looked, and it seems that there is tons of way to customize the map: https://mapzen.com/documentation/tangram/. What about using osmand: http://osmand.net/build_it#sample-holder?
The feature looks a little stalled yet demanded.
@Mis012 , would you make a little WIP PR to look how your little hack works? Thanks in advance.
Also I imagine a user normally wants both system maps support (w/ g-maps API) AND a (feature-rich) maps/navigation app. AFAIK OsmAnd satisfies 2nd yet Tangram-es doesn't have it? Then with Tangram a user would have to hold&update two sets of maps, right?
Then with Tangram a user would have to hold&update two sets of maps, right?
exactly my problem with Tangram.
would you make a little WIP PR to look how your little hack works? Thanks in advance.
I'll try if git diff looks understandable :) I have this on an old codebase ofc, I can find out the latest commit there if that's a problem.
it has some unrelated stuff, I didn't really use git back then
with (current) Mapbox backend this seems easier.
@token0 , with your MapLibre update would you look at this issue please?
@lambdaupb @mar-v-in @koko-ng @Mis012 @ildar I noticed that with the latest update with MapLibre, the functioning with some apps has improved, including the introduction of pupups at points of interest. I was also wondering whether it was possible to exploit offline Open street maps, such as "Osmad+" or even "Organic maps". It could be done in such a way that only selected apps take advantage of offline and for the others to go online. This would be very convenient for the app that manages my drone, as I cannot go online while flying it (the drone creates the wifi hotspot). It would also avoid data traffic and give the possibility to use some services completely offline and with only the gps active.
There are some local OSM vector tile renderer/provider that are used in some open source apps.
Maybe this can be implemented as an alternative backend.
I looked into the code a bit, and it seems that currently the https://github.com/microg/android_packages_apps_GmsCore/blob/master/play-services-core/src/main/java/org/microg/gms/maps/BackendMapView.java
uses
OSciMap4TileSource
and OpenScieneMaps also seems to provide other Sources likeMapFileTileSource
. Maybe it is reasonably easy to point microg to a file on sdcard or storage to use instead of the online map. - The locations could/should probably be settable in the microG Settings App.I might have a look when I have the time.