10

リーフレットの地図に 1 つのマーカーがあります。

var centerMarker = L.marker(centerPoint, { title: 'unselected' }).bindLabel(schools[i][0]);
centerMarker.on('click', selectMarker);
centerMarker.addTo(map);

クリック時にそのマーカーのサイズを変更したい。

アイコンを変更できることはわかっていますが、マーカーの同じアイコンのサイズを変更したいだけです。

4

4 に答える 4

1

これは古い質問ですが、誰かが回答されたもの以外の別の可能なオプションを探している場合に備えて.

L.marker([coord.latitude, coord.longitude], {
    color: 'red',
    icon: getIcon(), 
    data: coord
}).addTo(myMap).on("click", circleClick);

function getIcon(total_dead_and_missing) {
    var icon_size = [50, 50];   //for dynamic icon size, 
    var image_url = '1.png';        //for dynamic images

    L.icon({
        iconUrl: image_url,
        shadowUrl: 'leaf-shadow.png',

        iconSize:    icon_size , // size of the icon
        shadowSize:   [50, 64], // size of the shadow
        iconAnchor:   [22, 94], // point of the icon which will correspond to marker's location
        shadowAnchor: [4, 62],  // the same for the shadow
        popupAnchor:  [-3, -76] // point from which the popup should open relative to the iconAnchor
    });
}

リソース: https://leafletjs.com/examples/custom-icons/

于 2020-01-20T19:42:29.853 に答える