open:leaflet-marker

L.icon 으로 아이콘을 생성한다.

snippet.javascript
var oldCameraIcon = L.icon({
    iconUrl: '/img/camera-0.png',			    
    iconSize:     [30, 30], // size of the icon			    
    iconAnchor:   [15, 15], // point of the icon which will correspond to marker's location			    
    popupAnchor:  [0, -10] // point from which the popup should open relative to the iconAnchor
});
 
var newCameraIcon = L.icon({
    iconUrl: '/img/camera-1.png',			    
    iconSize:     [30, 30], // size of the icon			    
    iconAnchor:   [15, 15], // point of the icon which will correspond to marker's location			    
    popupAnchor:  [0, -10] // point from which the popup should open relative to the iconAnchor
});			

베이스가 되는 코드를 만들고, 아이콘의 경로만 변경한다.

snippet.javascript
var baseIcon = L.icon({
    iconSize:     [30, 30], 	// size of the icon		    
    iconAnchor:   [15, 15], 	// point of the icon which will correspond to marker's location
    popupAnchor:  [0, -10] 		// point from which the popup should open relative to the iconAnchor
});
 
var oldCameraIcon = baseIcon.options.iconUrl = '/img/camera-0.png';

  • open/leaflet-marker.txt
  • 마지막으로 수정됨: 2020/06/02 09:25
  • 저자 127.0.0.1