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';
관련 문서
Plugin Backlinks: 아무 것도 없습니다.