Reputation: 815
How can I have roads and labels to be placed on top of an image overlay without using the map editor in my account? I am using non-custom maps and just need the labels over the image (example below). Example code of my source and overlay is :
topleftmapbox.on('load', function() {
topleftmapbox.addSource("source_KEWX_REFLECTIVITY_SWEEP0_13", {
"type": "image",
"url": "images/KEWX_Z_SWEEP0_13.gif",
"coordinates": [
[-98.3868664444, 30.062422],
[-97.6698002222,30.062422],
[-97.6698002222, 29.3453557778],
[-98.3868664444, 29.3453557778]
]
})
topleftmapbox.addLayer({
"id": "overlay_KEWX_REFLECTIVITY_SWEEP0_13",
"source": "source_KEWX_REFLECTIVITY_SWEEP0_13",
"type": "raster",
"layout": {"visibility": "none"},
"paint": {
"raster-opacity": 0.99,
}
})
});
Upvotes: 0
Views: 817
Reputation: 3050
addlayer
has an optional parameter,named before
, the description is:
The ID of an existing layer to insert the new layer before. If this argument is omitted, the layer will be appended to the end of the layers array.
please refer the API https://www.mapbox.com/mapbox-gl-js/api/#map#addlayer
sample usage
https://www.mapbox.com/mapbox-gl-js/example/geojson-layer-in-stack/
Upvotes: 1