I need to merge the attributes on a leaflet geojson layer and another geojson based on a common field. I have tried the following code, which does put the keys in the layer but all values are undefined. How do I also get the value to transfer to the layer. geojson is the variable that holds the attributes that I want merged in the layer.
var schemaL = new L.GeoJSON(schema);
// get RG attributes
schemaL.eachLayer(function (layer) {
for (var i = 0; i < geojson.features.length; i++) {
if (layer.feature.properties.CodeLink === geojson.features[i].properties.SiteId) {
for (var key in geojson.features[i].properties) {
layer.feature.properties[key] = geojson[key];
}
}
}
});