oscarfonts / mapbox-gl-cordova-offline

Offline vector maps in Cordova using Mapbox GL JS
Other
60 stars 36 forks source link

Possibility to load multiple paths for mbtiles in sources #31

Closed uladDvi closed 5 years ago

uladDvi commented 5 years ago

Hello! First of all thanks for your great work.

Problem: As i understood, now it's possible to load only one mbtile at a time on style.json sources property : "sources": { "openmaptiles": { "type": "mbtiles", "path": "assets/mapStyles/2017-07-03_iceland_reykjavik.mbtiles", "attribution": "<a href=\"http://www.openmaptiles.org/\" target=\"_blank\">&copy; OpenMapTiles</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap contributors</a>" } },

Property path takes only String value.

Expected result : 1) "sources": { "openmaptiles": { "type": "mbtiles", "path": ["assets/mapStyles/2017-07-03_iceland_reykjavik.mbtiles", "Another_greate_tile.mbtiles"], "attribution": "<a href=\"http://www.openmaptiles.org/\" target=\"_blank\">&copy; OpenMapTiles</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap contributors</a>" } }, 2) OR "sources": { "openmaptiles": { "type": "mbtiles", "path": "assets/mapStyles/2017-07-03_iceland_reykjavik.mbtiles", "attribution": "<a href=\"http://www.openmaptiles.org/\" target=\"_blank\">&copy; OpenMapTiles</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap contributors</a>" }, openmaptiles": { "type": "mbtiles", "path": "Another_greate_tile.mbtiles", "attribution": "<a href=\"http://www.openmaptiles.org/\" target=\"_blank\">&copy; OpenMapTiles</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap contributors</a>" } },

It would be really convenient to use this plugin , if multiple sources paths will be available. If i just did not catch how to make it , please tell me. And if there is much work to do, could you just give a brief comment Where to start looking to create such a feature in your code.

michogar commented 5 years ago

Hi @uladDvi,

I don't understand very well your question. Now the library is ready to load multiple mbtiles in the same style.json. In the code that you write us, in point 2 you are calling both sources with the same name, and maybe this is the problem.

In a correctly way you should write your style.json like this:

{
    "sources": {
        "openmaptiles": {
            "type": "mbtiles",
            "path": "assets/mapStyles/2017-07-03_iceland_reykjavik.mbtiles",
            "attribution": "<a href=\"http://www.openmaptiles.org/\" target=\"_blank\">&copy; OpenMapTiles</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap contributors</a>"
        },
        "another_source_id": {
            "type": "mbtiles",
            "path": "Another_greate_tile.mbtiles ",
            "attribution": " < a href = \"http://www.openmaptiles.org/\" target=\"_blank\">&copy; OpenMapTiles</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap contributors</a>"
        }
    }
}

Cheers!!.