4

Styling a marker is possible with pointToLayer I don't know how to get a marker change style for mouse over and for click etc....

    var map = L.map('map', {
            zoom: 14,
            center: new L.latLng(35.948782,8.139912),
            layers: L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png')
        });

    var geojsonMarkerOptions = {
    radius: 4,
    fillColor: "black",
    weight: 1,
    opacity: 1,
    fillOpacity: 0.8
};
    var piky1=new L.geoJson(pick1,{
    pointToLayer: function (feature, latlng) {
    return L.circleMarker(latlng, geojsonMarkerOptions);
    },
        onEachFeature: function (feature, layer) {
        layer.on({
        'mousemove': function (e) {
        //I want to make the point a red syle ?
                color: 'red';
                piky1.bindPopup(feature.properties.Name);
       }});}}).addTo(map);

JsFiddle

1 Answer 1

3

You can use setStyle within the mousemove function:

layer.on({
    'mousemove': function (e) {
        //I want to make the point a red style ?
        this.setStyle({fillColor:"#f00"});
        ...
    }
});
0

Your Answer

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

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