I am confused on how this code below has access to a nested property. The addLayer function takes in a object which has a nested property textfield which comes from the above addSource method's properties.storeId.
I am confused on how the textfield can be written as {storeId}. The object is not destructed anywhere therefore how can it be written like this?
const loadmap = () => {
map.on("load", () => {
map.addSource("point", {
type: "geojson",
data: {
type: "FeatureCollection",
features: [
{
type: "Feature",
geometry: {
type: "Point",
coordinates: [-71.157895, 42.707741],
},
properties: {
storeId: "0001",
icon: "store"
},
},
],
},
});
map.addLayer({
id: "points",
type: "symbol",
source: "point", // reference the data source
layout: {
"icon-image": "airfield-11", // reference the image
"text-field": "{storeId}",
},
});
});
};
{storeId} between double quotations is just a string,
otherwise it's a shorthand for
let object={storeId:storeId}
another example:
let name="erfan"
let obj = {name} /// equivalent to {name:name}