1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| class MarkerManager {
constructor() {
this.markers = [];
this.position = location.position;
this.title = location.name;
this.icon = "images/biker_green.png";
}
add(hire) {
let marker = new google.maps.Markers({
map: createMap.map,
position: this.position,
title : this.name,
icon : {
url: this.icon,
scaledSize : new google.maps.Size(47, 47),
}
});
this.markers.push(marker);
}
couleurIcon() {
if (location.available_bikes <= 0) {
marker.icon = 'images/biker_red.png';
} else if (location.available_bikes < 3) {
marker.icon = 'images/biker_orange.png';
} else {
marker.icon = 'images/biker_green.png';
}
};
};
let marker = new MarkerManager();
marker.add(hire);
marker.couleurIcon(); |