Есть планировка дома. Есть этажи, секции и квартиры.
Требуется передавать в js свободна квартира или нет, и в зависимости от этого выставлять цвет, либо зеленый либо красный.
Создал поле Да/нет
UF_4
const getRoomSettings = settingsItem => ({
key: settingsItem.key,
selected: true,
isDeselectable: false,
fillColor: settingsItem.color,
})
const getRoomsSettings = settings => ({
fillOpacity: 0.5,
fillColor: "E1FFC8",
stroke: false,
strokeColor: "red",
strokeOpacity: 0.7,
strokeWidth: 4,
singleSelect: false,
mapKey: 'name',
listKey: 'name',
areas: settings.map(getRoomSettings)
})
const runMapster = (selector, keys) => {
var image = $(selector);
image.mapster(getRoomsSettings(keys))
}
runMapster('#vegetables-1', [{key: 'sec1kv1', color: 'ff7a5c'}, { key: 'sec1kv2', color: 'ff7a5c'},{key: 'sec1kv3', color: 'ff7a5c'},{key: 'sec1kv4', color: 'ff7a5c'},{key: 'sec1kv5', color: 'ff7a5c'},{key: 'sec1kv6', color: 'ff7a5c'}])
runMapster('#vegetables-2', [{key: 'sec2kv1', color: 'c4ff92'}, { key: 'sec2kv2', color: 'ff7a5c'}, { key: 'sec2kv3', color: 'ff7a5c'}, { key: 'sec2kv4', color: 'ff7a5c'}, { key: 'sec2kv5', color: 'ff7a5c'}, { key: 'sec2kv6', color: 'c4ff92'}])
runMapster('#vegetables-3', [{key: 'sec3kv1', color: 'ff7a5c'}, { key: 'sec3kv2', color: 'ff7a5c'}, { key: 'sec3kv3', color: 'ff7a5c'}, { key: 'sec3kv4', color: 'ff7a5c'}, { key: 'sec3kv5', color: 'ff7a5c'}, { key: 'sec3kv6', color: 'ff7a5c'}])
runMapster('#vegetables-4', [{key: 'sec4kv1', color: 'ff7a5c'}, { key: 'sec4kv2', color: 'ff7a5c'}, { key: 'sec4kv3', color: 'ff7a5c'}, { key: 'sec4kv4', color: 'ff7a5c'}, { key: 'sec4kv5', color: 'ff7a5c'}, { key: 'sec4kv6', color: 'ff7a5c'}])
runMapster('#vegetables-5', [{key: 'sec5kv1', color: 'ff7a5c'}, { key: 'sec5kv2', color: 'ff7a5c'}, { key: 'sec5kv3', color: 'ff7a5c'}, { key: 'sec5kv4', color: 'ff7a5c'}, { key: 'sec5kv5', color: 'ff7a5c'}, { key: 'sec5kv6', color: 'ff7a5c'}])
runMapster('#vegetables-6', [{key: 'sec6kv1', color: 'ff7a5c'}, { key: 'sec6kv2', color: 'ff7a5c'}, { key: 'sec6kv3', color: 'ff7a5c'}, { key: 'sec6kv4', color: 'ff7a5c'}, { key: 'sec6kv5', color: 'ff7a5c'}, { key: 'sec6kv6', color: 'ff7a5c'}, { key: 'sec6kv7', color: 'ff7a5c'}, { key: 'sec6kv8', color: 'ff7a5c'}])
runMapster('#vegetables-7', [{key: 'sec7kv1', color: 'ff7a5c'}, { key: 'sec7kv2', color: 'ff7a5c'}, { key: 'sec7kv3', color: 'ff7a5c'}, { key: 'sec7kv4', color: 'ff7a5c'}, { key: 'sec7kv5', color: 'ff7a5c'}, { key: 'sec7kv6', color: 'ff7a5c'}])