Mapbox Filtering Multipe Tile Layers at Once - mapbox

Is it possible to set a filter for multiple tile layers at once? I currently have data stored in vector tile and the filters I am applying are near instantaneous - which is awesome!
That said, I would like to filter two different geometry types (line and circle) at once on the map. Each line will be tied to a circle.
Is this possible to do easily? It would be great if anyone knows of an example.
Thanks!!

Using mapbox-gl-js, it's as simple as:
for (const each layer of ['layer1', 'layer2']) {
map.setFilter(layer, myNewFilter)
}
Or with mapbox-gl-utils:
map.U.setFilter(['layer1', 'layer2'], myNewFilter);

Related

Calculate subregion projection matrix (oblique projection) for an existing camera in Unity

I'm trying to create a custom projection setup in Unity that will allow me to render the perspective of an original camera, given a full-sized render target, on to three sub textures, with each camera rendering only a section.
This is part of a large-scale projection system which runs the built project on multiple instances, passing an offset of the subregion to each and adjusting the render target size.
I've seen many examples that allow for constructing an oblique projection matrix from scratch based on simple parameters but my requirements are a little more complex. Simply, I need to take an existing projection matrix that might already have various projection properties set, and split it into subregions.
Is there a way to achieve a subregion projection matrix given an existing one and offset / crop parameters?
Here's a rough attempt at visualizing the problem:
Thank you!

Hide polygons that are within a specific area

I'm trying to create an experience where I have a couple of detailed 3D models of buildings on the map with extruded building footprints of neighboring buildings via a vector tile source. The 3D models would be the main focus point and the extruded footprints would be for reference. One challenge I'm running into is that I have a global building footprint layer and it has a footprint for the 3D buildings which doesn't match up perfectly. Additionally, when extruded, it ends up merging/overlapping the nice 3D models.
I'd like to be able to hide the individual footprints that overlap the 3D models. My original thought was to grab the bounding box of the 3D model and then use the new within style expression, but it looks like this will only filter points and lines, not polygons. The building footprint polygons have no unique information in them that I could use to filter on.
I know I could monitor map movements and query the rendered features and manually detect intersecting polygons, but since there is no unique property on the footprint, I can't filter or use feature state.
Any ideas of how to efficiently avoid rendering individual polygons in a specific area that come in from a vector tile source?
It is a common issue that the buildings layer in Mapbox Streets don't contain any unique attributes to allow filtering or rendering differently.
The best solution is usually to source a different buildings layer, and in this case, remove those redundant buildings in pre-processing.
I can think of one rather crazy workaround that might work here, although the performance may be poor.
Add the building layer with very low opacity, of type fill, essentially invisible. (Maybe invisible would work.) Call your main source buildings`.
Create a secondary building source of type geojson, and a secondary fill-extrusion layer. Call this source buildings-copy.
On map move or moveend, use querySourceFeatures to obtain a copy of all buildings.
Process this copy using Turf to remove the buildings you don't want, and call setData to set the copy as the data for buildings-copy.
You may need to do some clever caching to get reasonable performance.

How to create contour Heat-map: MAPBOX

I want to create contour heat-maps using data driven styling mapbox. (only based on data point magnitude)
I am using heat map layer and it looks something like this:
I want to create something like this (Done using Matlab):
Is it possible using map box? Any ideas to do this would be very helpful. The closest I could get was using heat map layer, and after trying different combinations of weight, intensity and radius still could not achieve anything better than the image below.

Mapbox - extruding lines

Is it possible to apply fill-extrusion for a GeoJSON LineString feature?
Basically I'm looking for a way to draw lines (can be 1 line or multiple connected) in a 3d mode with z-offset.
If that's not possible, maybe this can be done with a polygon instead?
Like, converting my lines to polygons (how can i do that?)
What you're asking for isn't yet implemented, but ticketed in Mapbox GL JS at https://github.com/mapbox/mapbox-gl-js/issues/3993.
For now you'll need to opt for your second suggestion of converting the LineString feature to a Polygon. You can do this with turf's buffer function http://turfjs.org/docs#buffer.
The whole line/polygon will be offset at the same height, so depending on your application you could use turf's linkChunk http://turfjs.org/docs#lineChunk to get it broken up into smaller features which you assign different height properties to.

mapbox - loading different geojson choropleth overlays at different zoom levels

so i have a mapbox base map and want to load a dynamic choropleth area map over the top of it. it will cover all continents. i've looked into doing this before using geojson but the resulting file was over 9mb. is there a way to have different geojson vectors loaded at different zoom levels as to reduce the file size ?
the reason the file was so big was because it was a very detailed vector overlay. basically i'd like to replicate the vectors of 'am map' but with the performance of mapbox, with much better vector resolution at bigger zoom levels. (http://www.amcharts.com/javascript-maps/)
the only other way to do this is by using geojson markers that are loaded on top of the base map, but this doesn't give the same visual impact of the fully coloured continent vectors..
any help would be greatly appreciated!
x
Well, you could watch zoomend on the map to add/remove overlays as needed.
map.on('zoomend', function() {
var currentZoom = map.getZoom();
overlayGroup.clearLayers() //remove existing
overlayGroup.addLayer(myZoomLevelMapping[currentZoom]) //add layer for this zoom level.
})