Hot answers tagged

8

Have you seen this issue created one the LeafLet github repo: https://github.com/Leaflet/Leaflet/issues/167 try to use addLayer(layer,true); to add a tile layer to the bottom. I'm afraid that's all there is and this second optional argument is not even documented. Update Sept 2014 Leaflet now supports setting the zIndex. Thanks to @knutole in the ...


7

It is not as easy as it used to be, but there are some helper methods for the collection. That should allow you to do similar things as ThomasG77 described above. Assuming you have a map named map, with 4 layers i.e. [base_layer, coastlines, heatmap, markers] Then you can get the collection via map.getLayers(), and the array of layers via ...


5

Try something like: map.getLayers().setAt(99, markers) The list of layers is in an object inheriting from an ol.Collection. See the API doc for it. Be careful, I'm pretty sure, you can't use arbitrary number like 99 in setAt: first arg is for the position in the array of layers and the second arg is for the layer element reference you want to move. To ...


4

The best way to achieve this would be to register an event handler for the map's changelayer event. Within this event handler you can identify the layer whose visibility has changed and its current z-index, which you can then use to calculate a delta that can be used with the map's raiseLayer function - or you could just use setLayerIndex and specify n + 1 ...


3

based on srussking answer I wrote the following code assuming the main map object called map and it is a global var, I preferred using find layer by name and not by id, here is my code: function moveLayerBefore(old_idx, new_idx){ if((old_idx === -1) || (new_idx === -1)){ return false; } layer = map.getLayers().removeAt(old_idx); ...


3

AFAIK the label of a feature has by default the same z-index than the marker and the "correct" way to change the z-index of a marker is with the constructor option zIndexOffset or the method setZIndexOffset.


2

You would first need to tweak the SpatiaLite provider by either add a OrderBy property and apply that to the relevant queries (GetGeometriesInView, ...), or update the provider to handle spatial views correctly. Then you need to apply a custom theme setting assigning the appropriate color in respect to ZOrder. Why don't you want several layers? Hth ...


2

neither createLayer or createVis return a leaflet layer, the right way would be var map = new L.map('map', { center : [42.339926, -83.04137], zoom : 13 }); // add here your mapbox layer createLayer(map,vizjson_url).addTo(map).done(function(layer) { layer.setZIndex(1); }) createLayer(map,vizjson_url2).addTo(map).done(function(layer) { ...


2

EDIT: An even more simple workaround would be to use the marker option riseOnHover (if you accept that behaviour on markers). Leaflet adjusts the marker z-index when you hover it (so that it appears above others), and the label will also be adujsted automatically, so it will also appear above all other markers! When instantiating your markers, simply make ...


1

If you are using ol.Map#forEachFeatureAtPixel for detecting clicks, you can set the optional layerFilter: map.forEachFeatureAtPixel(pixel, function(feature) { // do something with detected features }, undefined, function(layer) { return layer !== geolocationLayer; }); In the above snippet, geolocationLayer is the vector layer from the example you ...


1

As Thomas and nathansnider pointed out in the comments, vector layers are limited in terms of manipulation of stack order because of the use of SVG rendering in Leaflet 0.7.x. But basically, SVG renders the vectors the way they are in the DOM, and bringToFront/Back() do nothing else than appending/prepending the paths within the DOM. If you are ready to ...


1

It's not a bug like @chkri mentionned. It's just the way Leaflet handles its divs where it draws svg and where it draws canvas. SVGs (basically everything extending L.Path) are drawn on a div container (leaflet-overlay-pane) with a smaller z-index then the div containing the heatmap canvas, and thus heatmap will always be on top of SVG markers. A quick ...


1

Here is a working solution: var map = new L.map('map', { center : [42.339926, -83.04137], zoom : 13 }); L.tileLayer('http://tile.stamen.com/toner/{z}/{x}/{y}.png', { attribution: 'Stamen' }).addTo(map); var voices = cartodb.createLayer(map, 'http://opendetroit.cartodb.com/api/v2/viz/08140c18-8a05-11e3-ae46-0e49973114de/viz.json').addTo(map); ...


1

I understood the problem wrong, tried to jsfiddle this for a change. I assume you need a workaround, hence I'm going this road. Getting this to work on jsfiddle but had to do some things differently to make it work but I see your issue now. bugreport you opened has got it right, best solution is: beforefeaturehighlighted: function(e) { if ...


1

You can trigger the render intents (select, hover, default) in the stylemap with the SelectFeature control. Here is a DEMO var hoverControl = new OpenLayers.Control.SelectFeature(     [layer],     {         hover: true,         highlightOnly: true     } ); map.addControl(hoverControl); hoverControl.activate(); UPDATE: As you can see from this question ...



Only top voted, non community-wiki answers of a minimum length are eligible