I am using a jQuery plugin called Mapael and am attempting to do something rather simple.
The "plots" object at the bottom of the function is going to add plot points to a map. The plot points are also objects.
My goal is to dynamically generate these plot points based on an external JSON file. I have made a few plot points for practice and am storing them in the country object.
Is there any way to use the "country" object as the value for the "plots" object?
var country = {
"XM": {
value: 100,
latitude: 22.99131,
longitude: 54.77059
},
"VE": {
value: 200,
latitude: 64.42689,
longitude: 145.23237
},
"SE": {
value: 300,
latitude: 8.96106,
longitude: -15.09699
},
"XF": {
value: 300,
latitude: 50.93900,
longitude: 55.38883
}
}
$('.world').mapael({
// ... other mapael objects to initialize map
plots: {
// country object
}
});
Yes. Omit the braces and just reference the variable:
$('.world').mapael({
// ...
plots: country
});