microg / GmsCore

Free implementation of Play Services
https://microg.org
Apache License 2.0
7.71k stars 1.62k forks source link

Maps: local file vector map provider #150

Open lambdaupb opened 8 years ago

lambdaupb commented 8 years ago

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 like MapFileTileSource. 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.

Mis012 commented 6 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 :)

koko-ng commented 6 years ago

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.

Mis012 commented 6 years ago

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 :)

koko-ng commented 6 years ago

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.

mar-v-in commented 6 years ago

As @Mis012 already wrote, it wouldn't be too hard to implement this with the current base, but there are two problems:

  1. Always consider UX. I want to put a higher focus on user interfaces with the upcoming releases because this has been considered problematic by some users. It would be wise to use local osmand database when possible (and this doesn't require any user interface), but other things will require a download/select downloaded files user interface.
  2. vtm is not very actively developed anymore and has some serious bugs which noone seems to be able to fix (the prior core dev does no longer work on it). These bugs are more important for microG than other usecases (where it is sometimes possible to workaround them) and are a serious problem for user experience. Moreover vtm still lacks some features microG would need and they are unlikely to be added upstream. My idea is to move to tangram-es which is more actively developed and had better performance on devices I tested it.
koko-ng commented 6 years ago

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...

Mis012 commented 6 years ago

What about mapsforge? It's what vtm forked off, and lot of apps support the map format

ale5000-git commented 6 years ago

@Mis012: It is already using mapsforge/vtm (a fork of opensciencemap/vtm); it is the one having problems.

mar-v-in commented 6 years ago

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 ;)

Mis012 commented 6 years ago

@ale5000-git not mapsforge/vtm, mapsforge/mapsforge

koko-ng commented 6 years ago

@Mis012 It's written in Java, so probably way slower than tangram-es, which is written in c++/openGL.

Mis012 commented 6 years ago

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?

koko-ng commented 6 years ago

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?

ildar commented 5 years ago

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.

ildar commented 5 years ago

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?

Mis012 commented 5 years ago

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.

Mis012 commented 5 years ago

changes.diff.txt

Mis012 commented 5 years ago

it has some unrelated stuff, I didn't really use git back then

ildar commented 3 years ago

with (current) Mapbox backend this seems easier.

ildar commented 1 year ago

@token0 , with your MapLibre update would you look at this issue please?

MoonDragon-MD commented 11 months ago

@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.