I have a list of objects that provide information to a variable, which creates "markers":
var markers = [
//testPOW
{ mesh: ["campDome","POW"],
color: iconRed,
location: {lat: 43.30985465943113, lng: 11.898409657895801},
visible: true,
id: "TestPOW",
category: "POW"
},
//testCamps
{ mesh: ["campDome","Camps"],
color: iconBlue,
location: {lat: 27.051081239338288, lng: 21.074973750899662},
visible: true,
id: "TestCamp",
category: "Camps"
},
//testInternedCivilians
{ mesh: ["campDome","InternedCivilians"],
color: iconYellow,
location: {lat: 47.866084023826794, lng: 2.61794289751219},
visible: true,
id: "TestInternedCivilians",
category: "InternedCivilians"
},
]
The below code creates the markers: //Generate Markers
for ( var i=0; i < markers.length; i++ ) {
var marker = this.addMarker( {
mesh : markers[i].mesh,
color: markers[i].color,
color2: 'white',
location : markers[i].location,
scale: 0.4,
offset: 0,
visible: markers[i].visible,
id: markers[i].id,
category: markers[i].category
} );
};
Outside the marker generating loop, the variable marker
is like this:
Earth.Marker {options: {...}, object3d: Vn, isMarker: true, earth: Earth, mesh: Array(2), ...}
It represents the last marker generated.
However, inside the loop it appears as:
scripts.js:244
Earth.Marker {options: {...}, object3d: Vn, isMarker: true, earth: Earth, mesh: Array(2), ...}
scripts.js:244
Earth.Marker {options: {...}, object3d: Vn, isMarker: true, earth: Earth, mesh: Array(2), ...}
.
.
.
The question is, how can I make the marker
variable include all the generated objects even when called outside the loop?