change leaflet marker icon

后端 未结 4 1965
醉梦人生
醉梦人生 2021-02-20 04:17

I am using Leaflet Slider, of Dennis Wilhelm, to show changes in data on a Leaflet map.

I am trying to change the change the marker icon but not getting it right. So,How

4条回答
  •  星月不相逢
    2021-02-20 04:52

    Just in case if anyone is wondering how to do it in Typescript with vue2-leaflet, below is one sample code. You can even use v-for on l-marker to plot multiple markers in one go:

    // inside template
    
                
                      
                        mdi-target
                      
                
    
    
    // default icon in script
    defaultIcon = L.icon({
          iconUrl: "https://unpkg.com/leaflet@1.0.3/dist/images/marker-icon.png",
          shadowUrl: require('../static/marker.png'),
          iconSize: [20, 30],
          iconAnchor: [18, 18],
          popupAnchor: [0, -10],
          shadowSize: [0, 0],
          shadowAnchor: [10, 10]
        });
    

提交回复
热议问题