javascript - put layer in foreground leaflet - javascript

I have different layer's arrays, but I want to put one of these in foreground when I change it latitude and longitude.
How I can do that in javascript?
Thanks!

Browse over to the trusty Leaflet documentation, and look at the setZIndex() function on all tile layers.
layer1.setZIndex(1);
layer2.setZIndex(2);

It depends on whether your layer is Raster or Vector.
For layers inheriting from Path, such as Polylines, Polygons, etc use bringToFront
layer.bringToFront()
For TileLayers (and layer types that inherit from TileLayers) use setZIndex
layer.setZIndex(<number>)

Related

Threebox with tile suorce

I'm new to threeBox and I'm developing a mapbox-gl-js map that has a 3D buildings (fill-extrusion) layer from tiles source. I want to add a symbol/icon layer with elevation from tile source useing threeBox (like icon over special buildings etc.).
From what I have seen so far threeBox layers in Mapbox can be added only GeoJson sources, is it possible to add to threeBox layer a tiles source as one adds to MapBox layers?
Thanks.
I guess ThreeBox doesn't support vector tiles.
You may be able to hack something to work by using map.querySourceFeatures() to access all the buildings in the loaded viewport as GeoJSON, then using that. There are lots of caveats that you will discover. :)

MapboxGL JS : clustering polygon instead of point

In mapbox GL JS, the ability to cluster is for point according to the documentation.
But can we cluster polygon ?
Thanks for your input ?
No, it is not possible to cluster polygons by "default" when using Mapbox GL JS. As noted here in the documentation for the cluster property of a GeoJSON source:
If the data is a collection of point features, setting this to true clusters the points by radius into groups.
Since polygons are not of type point (rather, they are of type polygon), the cluster option cannot be applied. This makes sense when you think about it, because polygons are far too arbitrary to "cluster." Points are well-defined in their shape and scope, meaning that they can be pre-clustered in the source object itself by specifying cluster: true as shown in this example from the Mapbox GL JS examples page.
You can create another source with points from your polygons:
https://gis.stackexchange.com/questions/304794/ogr2ogr-polygon-to-point-with-point-inside-the-polygon
Then just use the source with points for clustering when zoomed out and the source with polygons for rendering those polygons when zoomed in.

React Mapbox GL - How to draw images on the map using Layer and Feature instead of Markers

I am using React Mapbox GL in my project and as i use Marker for about 10000 data points and performance is not that good. I have read the documentation and it says
Note: When rendering many objects, avoid using Markers as it will negatively affect performance. Use Layers and Features instead.
How to use Layers and Feature to display markers?
To render something with layers and features, put one or more Feature components inside of a Layer component. You can give each Feature a position using the coordinates prop.
Now, what's left over is to style these features. How you do this depends on what your markers previously contained, but for example, if you'd like to draw circles for each of the positions, you can set the Layer's type to circle and under the paint prop, provide values for circle-color and circle-radius (these are described in the mapbox-gl API docs.
For drawing images for each coordinate, you can use the icon-image layout property on the Layer (you would have to either use a preexisting icon or upload one to Mapbox Studio).
You can see some sample code in the demos, for example the all-shapes demo styles data with circles.

Leaflet js fictional map

I am new to Leaflet and I would like to find out if how to create a fully interactive fictional map. I have an image that I would like to convert to a leaflet map. This image has a number of connections and points like a graph basically.
I want to first of all convert that image to the map, be able to hover over the points, highlight them and display information about them and also to create animations at some point but not immediately with the connections. There is also a requirement to display permanent labels next to each point.
Is that at all possible in Leaflet?
Is that at all possible in Leaflet?
Yes.
Start by reading the leaflet tutorial for non-geographical maps.

Display Raster Layer using ArcGIS Javascript API

I Want to display a raster layer on to my page using ArcGIS javascript API.
Loading Feature layer is easy and pretty forward but the raster layer is giving me hard time.
Here is the the MapService: http://ags.servirlabs.net/ArcGIS/rest/services/ReferenceNode/TRMM_30DAY/MapServer/0
which is Raster layer.
Do you have any ideas on how to do this?
How you add a map service layer depends on whether or not the service is cached. Look at http://ags.servirlabs.net/ArcGIS/rest/services/ReferenceNode/TRMM_30DAY/MapServer in a browser and see the following:
Single Fused Map Cache: false
Because it's not cached, you must use ArcGISDynamicMapServiceLayer, not ArcGISTiledMapServiceLayer. If it were cached, you could use either one.
map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer(
"http://ags.servirlabs.net/ArcGIS/rest/services/ReferenceNode/TRMM_30DAY/MapServer"));
Note that if you had a service with multiple layers in it and you wanted to display only a subset of them, you would create an ArcGISDynamicMapServiceLayer and then use its setVisibleLayers method to set which layers should be visible. In this case, you don't need to worry about it, because your map has only one layer in it.
You can add raster layers to your map using the ArcGISTiledMapService layer, for example:
// assuming 'map' is a reference to your map
map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://ags.servirlabs.net/ArcGIS/rest/services/ReferenceNode/TRMM_30DAY/MapServer"));
There are some good examples on the ArcGIS JavaScript API site here:
https://developers.arcgis.com/en/javascript/jssamples/#tiled_layers
One thing to be aware of with tiled layers is that you can only add tiled layers to your map if they are using the same spatial reference. You can't add a layer as a tiled layer with a different spatial reference as it's cache of tiles have already been produced using it's spatial reference. You can add a layer as a Dynamic layer to re-project it.

Categories