Currently, on http://velo300.free.fr/debug,
feature highlights on 'featureOver' creating a white new feature on top of mouse-overed feature.
Problem: i need also to work with 'featureclick' for another function.
How can i manage to create this new white feature below the mouse-overed feature and not on top?
Other relevent solution: how to use setcartoCSS() wihtout redraw rhe whole layer?
2 Answers 2
You do realize that your tutorial for "featureOver"
makes you superimpose a new layer / feature above your track. Therefore, the latter can no longer be clicked on.
You could either implement your "featureClick"
listener on the added layer / feature as well, so that it opens your sidebar.
Or you could rather change the display properties of the mouse-overed track, so that it highlights by changing its color, instead of super-imposing another layer on top of it.
-
Thank you Ghybs, you see my problem. Previously, I thought about two solutions like yours for my purpose but i don't know if they can be implemented: - Is there a way to use set.cartocss() without redraw the whole layer? ( not like this )- Or is there a way to superimpose a new feature not on top but below the mouse-overed track ?GIStrator– GIStrator2016年05月01日 14:33:30 +00:00Commented May 1, 2016 at 14:33
-
Does layer.bringToBack() can be used for overlay layer?GIStrator– GIStrator2016年05月02日 08:37:38 +00:00Commented May 2, 2016 at 8:37
-
Depends on what your layer is made of. Just give it a try...ghybs– ghybs2016年05月02日 09:31:54 +00:00Commented May 2, 2016 at 9:31
-
layer.bringToBack() doesn't work for this geojson overlay layerGIStrator– GIStrator2016年05月31日 08:36:36 +00:00Commented May 31, 2016 at 8:36
Solved it! Using Jquery and CartoDB SQL API:
function onEachFeature(feature, layer) {
layer.on({
mouseover: function (e) {
highlight(e.target);
},
mouseout: function (e) {
dehighlight(e.target);
},
click: function (e) {
select(e.target);
}
});
}
$.getJSON("https://USERNAME.carto.com/api/v2/sql?format=GEOJSON&q=SELECT * FROM TABLENAME", function(data) {
geojson = L.geoJson(data, {
style: style,
onEachFeature: onEachFeature
}).addTo(map);