custom marker icon with react-leaflet

后端 未结 3 1763
挽巷
挽巷 2021-01-03 23:56

I tried everything I found on the web, Stackoverflow and Github, and I still can\'t make it.

I want to make a custom marker with a custom icon, but with my code belo

3条回答
  •  耶瑟儿~
    2021-01-04 00:52

    I finally found the correct code for the Icon.js file :

    import L from 'leaflet';
    
    const iconPerson = new L.Icon({
        iconUrl: require('../img/marker-pin-person.svg'),
        iconRetinaUrl: require('../img/marker-pin-person.svg'),
        iconAnchor: null,
        popupAnchor: null,
        shadowUrl: null,
        shadowSize: null,
        shadowAnchor: null,
        iconSize: new L.Point(60, 75),
        className: 'leaflet-div-icon'
    });
    
    export { iconPerson };
    

提交回复
热议问题