hover hand cursor on GeoJSON Polyline

674 views
Skip to first unread message

Μάριος Βόντας

unread,
Jan 19, 2013, 7:39:31 AM1/19/13
to leafl...@googlegroups.com
Hi everyone,

I use geojson to draw polylines on the map and I have an 'onclick' event to change the color of the polyline.
The problem is that the hand cursor that is shown on hover for the the other geometries is not shown for polylines. That makes clicking on the polyline hard for the user (he has to try many times to click the polyline).
I wanted to ask if it is possible to have it at some future release of leaflet? and if not, why? and what other options do I have?
I include my javascript code segment bellow. Thank you all!

var geoJSON = L.geoJson({
    "type": "Feature",
    "properties": {
        "id1": myarr[i][0],
        "id2": myarr[i][1]
    },
    "geometry": {
        "type": "LineString",
        "coordinates": myarr[i][2]
    }
}, {
    style: {
        weight: 2,
        color: '#0033ff',
        opacity: 1.0
    },
    onEachFeature: function (featureData, layer) {
        layer.bindPopup("[ ID1, ID2 ] = [ " + featureData.properties.id1 + ", " + featureData.properties.id2 + " ]");
    }
}).addTo(map);

geoJSON.on('click', function(e) {
    e.target.eachLayer(function (layer) {
        if (layer.options.weight == 2) {
            e.target.setStyle({
                weight: 5,
                color: 'red',
                opacity: 1.0
            });
            
            if (!L.Browser.ie && !L.Browser.opera) {
                e.target.bringToFront();
            }
        } else {
            geoJSON.resetStyle(e.target);
        }
    });
});

Μάριος Βόντας

unread,
Jan 20, 2013, 9:25:45 AM1/20/13
to leafl...@googlegroups.com
Actually if I remove L_PREFER_CANVAS the hand pointer is shown on polyline hover. I would like though to be able to use canvas to gain speed because I draw many geometries on the map.
Is there a possibility to fix this in a future version?
Reply all
Reply to author
Forward
0 new messages