mapbox / mapbox-maps-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
https://www.mapbox.com/mobile-maps-sdk
Other
464 stars 131 forks source link

addStyleImportFromJSON doesn't work #2471

Closed SamYStudiO closed 5 days ago

SamYStudiO commented 1 week ago

Environment

Observed behavior and steps to reproduce

I'm trying to add another style that return a simple transparent raster layer to be on top of a primary style using addStyleImportFromJSON but it has no effect, only main style is visible.

loadStyle(url) {
    val response = addStyleImportFromJSON("id", "style", null, null)
}

style json :

{"version": 8,
  "sources": {
    "raster-tiles-pentes": {
      "type": "raster",
      "scheme": "xyz",
      "tiles": ["https://data.geopf.fr/wmts?Service=WMTS&Request=GetTile&Version=1.0.0&Layer=GEOGRAPHICALGRIDSYSTEMS.SLOPES.MOUNTAIN&Style=normal&Tilematrixset=PM&TileMatrix={z}&TileRow={y}&TileCol={x}&Format=image/png"],
    }
  },
  "layers": [
    {
      "id": "simple-tiles-pentes",
      "type": "raster",
      "source": "raster-tiles-pentes",
      "minzoom": 6,
      "maxzoom": 17,
      "paint": {
         "raster-opacity": 0.5
      }
    }
  ]
}

response doesn't return any error looks everything is fine but imported style is not visible.

kiryldz commented 1 week ago

@SamYStudiO based on the info you provided second argument you provided is incorrect, it should be an actual JSON string while in your case it's "style". However I also could assume that you have this correct and just put this like that in the issue description. In any case complete reproducible example will be really appreciated so that we can take a look.

SamYStudiO commented 1 week ago

@kiryldz Here is an example you need to set :

MapboxImport.zip

ps : Could you open back this issue https://github.com/mapbox/mapbox-maps-android/issues/2445 that is still happening a lot in my production app

kiryldz commented 1 week ago

@SamYStudiO I checked the code and it seems that your style import is simply not valid (something wrong with the tiles you provided from what I see). You can check it yourself if you actually will try to load your JSON not as a style import but with map.loadStyle(yourStyleJSON) and then in the logs you will see the error message.

However from our end it seems we should also look into an issue why does addStyleImportFromJSON does not return an error if the imported style definition is not valid, I'll check this with the needed team.

SamYStudiO commented 5 days ago

@kiryldz Indeed a comma at the end of tiles node was the pb ! Sorry and thx!