0
這裏是我的代碼添加地圖上的標記:如何更改標誌的顏色
var marker = {'depart':null, 'arrivee':null};
var DEPART = "depart";
var ARRIVEE = "arrivee";
function addMarkerIti(statut, data, countMarker) {
if (statut === "")
statut = DEPART;
var link = '<button type="submit" onclick="removeEtape('+ (statut === DEPART ? 1 : statut === ARRIVEE ? 2 : countRemoveMarker) + ');" class="btn btn-danger btn-xs btn-block btn-popup">Supprimer ce marker</button>';
var mm = L.marker([data.coordonnee[0], data.coordonnee[1]], statut === DEPART ? {icon: blueIcon} : statut === ARRIVEE ? {icon: greenIcon} : {icon: yellowIcon})
.addTo(lgMarkers).bindPopup((data.rue != "" ? "<strong>Adresse : </strong>" + (data.numero != "" ? data.numero + " " : "") + data.rue + "</br>" : "")
+ (data.quartier != "" ? "<strong>Quartier : </strong>" + data.quartier + "</br>" : "")
+ (data.cp != "" ? "<strong>Code Postal : </strong>" + data.cp + "</br>" : "")
+ (data.ville != "" ? "<strong>Ville : </strong>" + data.ville + "</br>" : "")
+ "<strong>Latitude : </strong>" + data.coordonnee[0] + "</br>"
+ "<strong>Longitude : </strong>" + data.coordonnee[1] + "</br>" + link);
if (statut === DEPART || statut === ARRIVEE) {
marker[statut] = mm;
}
標記的顏色由定義{圖標:blueIcon},{圖標:greenIcon}等...
var blueIcon = new MarkerIcon({iconUrl: '../js/leaflet/images/marker-icon.png'});
var greenIcon = new MarkerIcon({iconUrl: '../js/leaflet/images/marker-icon-green.png'});
var yellowIcon = new MarkerIcon({iconUrl: '../js/leaflet/images/marker-icon-yellow.png'});
我需要做一個函數來改變標記的顏色({icon:... Icon})。我如何修改標記的圖標?
感謝您的幫助。
它的作品!謝謝 !! – Grichka