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
    Commented May 1, 2016 at 14:33
  • Does layer.bringToBack() can be used for overlay layer?
    – GIStrator
    Commented May 2, 2016 at 8:37
  • Depends on what your layer is made of. Just give it a try…
    – ghybs
    Commented May 2, 2016 at 9:31
  • layer.bringToBack() doesn't work for this geojson overlay layer
    – GIStrator
    Commented May 31, 2016 at 8:36

Solved it! Using Jquery and CartoDB SQL API:

        function onEachFeature(feature, layer) {

            mouseover: function (e) {
            mouseout: function (e) {
            click: function (e) {

    $.getJSON("https://USERNAME.carto.com/api/v2/sql?format=GEOJSON&q=SELECT * FROM TABLENAME", function(data) {
        geojson = L.geoJson(data, {
            style: style,
            onEachFeature: onEachFeature


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.