I have created a map of pedestrian collisions in Toronto in CartoDB. I would like the border of each neighbourhood to be outlined in a dark colour on hover. Is it possible to modify the CSS to achieve that effect?
1 Answer
That would not be possible from within the CartoDB Editor. You would need to create a custom map using cartodb.js
Also, as maps are created by requesting tiles, changing the style properties on hover may result a bit laggy. Your app would need to change the cartoCSS for the sublayer on hover, request new tiles and redraw the map. There is an example here.
There is also another option that would involve using Leaflet in order to work with vector geometries that could be restyled on the fly. You would need to retrieve the geometries, store them in a L.GeoJSON object, then manage to pair the hovered CartoDB feature with it's vectorial equivalent and change its style properties. Find an example here
Hope you find this helpful
-
I used the Leaflet option and it works perfectly. Here is an example I created - the10and3.com/TorontoPublicTransit.html– zgall1Commented Mar 25, 2016 at 4:27