1

I want to use the

  • base vector terrain style in Mapbox
  • add a custom XYZ raster layer over that (only covers a specific corridor)
  • add additional vector layers over that (visible above the raster, which is visible above terrain map)

I downloaded the base terrain style file, which already includes my additional vector layers. Motivation is: since I can't add a raster XYZ tile hosted somewhere else via Mapbox Studio, I have to add it by editing the json style file.

I'm assuming the layers array itself defines the layer draw order. Is this correct?

I'm also having issues adding the source for my raster layer, which is defined like so:

"of-source": {
    "type": "raster",
    "tiles": [
        "http://192.168.200.11:4000/rasters/of/{z}/{x}/{y}.png"
    ],
    "tileSize": 256,
    "minzoom": 14,
    "maxzoom": 22
}

The error I'm getting when trying to upload the complete style file is:

sources[1].url: Expected a valid Mapbox tileset url

I will never have a mapbox URL for this type of dataset, so is it even possible to do it this way?

Should be somehow, since I can add such a layer programmatically wihout issues at runtime.

EDIT1:

If I change the style definition like so:

"of-source": {
    "type": "raster",       
    "url":"http://192.168.200.11:4000/rasters/of/{z}/{x}/{y}.png"
    "tileSize": 256,
    "minzoom": 14,
    "maxzoom": 22
}

Problem persists

1 Answer 1

2

I found a programmatic workaround. The function map.addLayer accepts a second argument, which is the id of the layer that you will insert your layer after.

So I load the style first via published style URL, then insert my XYZ raster layer

https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addlayer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.