My view have multiple CA layers arranged like UITableView Cells. I have created the layer dynamically one after other in a top down order.
But I want to create a layer between the two layers, I want to create the layer between two layers when I pinch out between two layers. How can i do that.
I am new to this, so any help or direction to something closer would be great.
...
Thanks in Advance..
You can use one of the CALayer methods
- (void)insertSublayer:(CALayer *)aLayer atIndex:(unsigned)index
- (void)insertSublayer:(CALayer *)aLayer below:(CALayer *)sublayer
- (void)insertSublayer:(CALayer *)aLayer above:(CALayer *)sublayer
to insert a new layer at a specific point in the sublayers array.
dont know if I get it.. but when you create the layers, make sure they are in the same layer tree (sublayers (or subsublayers) of the same layer)
so l1 has l2 has l3
then the zorder would be there already
now you have l_parent has {l1 and l2 and l3 and l4} ... lx are siblings
TODO:
set the zindex of the layers
After digging alot here and there, I got my answer from an Example here.
It not just gave me my answer, I actually learned some new stuff about CALayer and core animation, some of its details are here
Related
I have a Mapbox with my own layers, says labels of towns and landmarks...
say I want to highlight one specific landmark and I want to move its z-index higher because otherwise, it would overlap with some other elements...
Can I use map.setLayoutProperty or is there anything else that I can do?
If I got your question correctly, you're looking for a way to change z-index of some layer above another layer. (not some feature above another feature). Here it the way:
https://www.mapbox.com/mapbox-gl-js/api/#map#movelayer
map.moveLayer(yourLandmarkLayerId, someAnotheLayerId);
If you would like just to move landmark layer to top of layer hierarchy:
map.moveLayer(yourLandmarkLayerId);
P.S. For moving layer, you should know it's ID:
var layers = map.getStyle().layers;
var layerId = layers[i].id;
For someone looking to do it on android, the simplest way to do it is to remove the layer and add it again above or below another layer. I do not find a better way:
/**
* Remove the target layer and add it again above the specific layer
*/
fun moveLayerAvobe(layer: Layer, breakpointLayerID: String, style: Style) {
// Remove Layer
style.removeLayer(layer)
// Add it again
style.addLayerAbove(layer, breakpointLayerID)
}
I created a custom circle layer. I want to show this layer only on water and not on land. I managed to do the opposite (ie: showing the layer on land and not on water) using below command. Refer this image for better understanding
map.moveLayer('polygon','water');
Now I need to know the land layer which is used by mapboxgl so that I can call function map.moveLayer('polygon','land'); to achieve what i want.
I need help to find the different layers present in the mapboxgl-streets map. But unfortunately, Mapboxgl doesn't have map.eachLayer function.
You can use the Map#getStyle method to get a serialized representation of the entire style including the layers.
map.getStyle().layers
It depends on the map style you're using. In general, you either have to look at its source or load it in Mapbox Studio to identify the correct layer name. Also keep an eye on https://github.com/mapbox/mapbox-gl-js/issues/4173.
Just to add to Lucas' answer (which is still correct), map.getStyle().layers provides all layers in the style, including ones you have explicitly added (via map.addLayer()), and those that are included in the style (which could be a lot). Careful how you filter through these. For my case, I created arrays to hold the layers I created myself, to make future iteration simpler.
When I use the following code to go through all the layers in a leaflet map,
map.eachLayer(function (layer) {
console.log(layer);
});
I just wants what rule is used to create this order. Is it because of the ZIndex of the layer? Or is it because the layer is added in different time? If the layer is added early, it will be in the bottom.
Thanks,
Good question, it seems the LeafletJS docs don't say anything about the ordering of the layers via eachLayer, so...
Looking at the code on github, L.Map.eachLayer loops through L.Map._layers which is an object (not an array). So technically the layers could come back in any order...
That said, the individual layers are added to the _layers object in the order they are added to the map. So in all likelihood, eachLayer will be iterating over the layers in that same order (whatever order they were added to the map).
this question applies to any item but in this case I would like to position my image above the map, currently it gets place below the map.
I am new to swift 1.2 so I do not know how to put together an example, any help would be greatly appreciated.
Are you talking about above in X-Y terms or in Z terms? If Z terms, and using interface builder, you can go to editor->Arrange->Bring forward, or just move the image in the relation to the other UI elements, as their order in the below menu defines their Z-order.
sorry for stupid question, i need to animate all sublayers in some particular layer. How to iterate through all the sublayers?
You can iterate sublayers of a layer via for-in loop
for child in layer.subLayers
child.animate
properties:
x: Utils.randomNumber(100)
y: Utils.randomNumber(100)
if you need an index of each sublayer, you can change loop like this
for child, i in layer.subLayers
I came across this question looking for a similar solution. I wanted to change all subLayers in a given layer, even deep nested layers. In the Docs I found descendants. Adding here in case someone is looking for a solution to iterate all nested subLayers.
for descendant in layers
descendant.ignoreEvents