動態 地圖 的 StylesObject 架構參考指南
StylesObject
是表示StyleObject
狀態集樣式的陣列。 使用 Azure 地圖服務 Creator Feature State 服務,將狀態集樣式套用至室內地圖數據特徵。 建立狀態集樣式並與室內地圖功能建立關聯之後,您就可以使用它們來建立動態室內地圖。 如需建立動態室內地圖的詳細資訊,請參閱 實作建立者室內地圖的動態樣式。
StyleObject
StyleObject
是下列其中一個樣式規則:
下列 JSON 顯示三種樣式類型的範例用法。 BooleanTypeStyleRule
用來判斷屬性occupied
為 true 和 false 之功能的動態樣式。 NumericTypeStyleRule
用來判斷屬性落在特定範圍內之特徵temperature
的樣式。 最後, StringTypeStyleRule
是用來比對特定樣式與 meetingType
。
"styles": [
{
"keyname": "occupied",
"type": "boolean",
"rules": [
{
"true": "#FF0000",
"false": "#00FF00"
}
]
},
{
"keyname": "temperature",
"type": "number",
"rules": [
{
"range": {
"minimum": 50,
"exclusiveMaximum": 70
},
"color": "#343deb"
},
{
"range": {
"maximum": 70,
"exclusiveMinimum": 30
},
"color": "#eba834"
}
]
},
{
"keyname": "meetingType",
"type": "string",
"rules": [
{
"private": "#FF0000",
"confidential": "#FF00AA",
"allHands": "#00FF00",
"brownBag": "#964B00"
}
]
}
]
NumericTypeStyleRule
NumericTypeStyleRule
是 ,StyleObject
由下列屬性所組成:
屬性 | 類型 | 描述 | 必要 |
---|---|---|---|
keyName |
string | 狀態或動態屬性名稱。 在 keyName 陣列內應該是唯一的 StyleObject 。 |
Yes |
type |
string | 值為 numeric 。 |
Yes |
rules |
NumberRuleObject |
具有相關聯色彩的數值樣式範圍數位。 每個範圍都會定義當狀態值滿足範圍時要使用的色彩。 | Yes |
NumberRuleObject
NumberRuleObject
包含 RangeObject
和 color
屬性。 如果狀態值落入範圍中,其顯示色彩就是 屬性中指定的color
色彩。
如果您定義多個重疊範圍,選擇的色彩將會是滿足之第一個範圍中所定義的色彩。
在下列 JSON 範例中,當狀態值介於 50-60 之間時,這兩個範圍都會保留 true。 不過,所使用的色彩是因為 #343deb
它是清單中已滿足的第一個範圍。
{
"rules":[
{
"range": {
"minimum": 50,
"exclusiveMaximum": 70
},
"color": "#343deb"
},
{
"range": {
"minimum": 50,
"maximum": 60
},
"color": "#eba834"
}
]
}
]
屬性 | 類型 | 描述 | 必要 |
---|---|---|---|
range |
RangeObject | RangeObject 會定義一組邏輯範圍條件,如果 true ,請將狀態的顯示色彩變更為 屬性中指定的color 色彩。 如果未 range 指定,則一律會使用 屬性中 color 定義的色彩。 |
No |
color |
string | 當狀態值落入範圍時要使用的色彩。 屬性 color 是下列任一格式的 JSON 字串:
|
Yes |
RangeObject
RangeObject
定義的NumberRuleObject
數值範圍值。 若要讓 狀態 值落入範圍,所有定義的條件都必須保留 true。
屬性 | 類型 | 描述 | 必要 |
---|---|---|---|
minimum |
double | x ≥ minimum 的所有數位 x。 |
No |
maximum |
double | x ≤ maximum 的所有數位 x。 |
No |
exclusiveMinimum |
double | x 的所有數位 x >exclusiveMinimum 。 |
No |
exclusiveMaximum |
double | x 的所有數位 x <exclusiveMaximum 。 |
No |
NumericTypeStyleRule 的範例
下列 JSON 說明NumericTypeStyleRule
名為 temperature
的狀態。 在此範例中 NumberRuleObject
,包含兩個定義的溫度範圍及其相關聯的色彩樣式。 如果溫度範圍為 50-69,則顯示器應該使用色彩 #343deb
。 如果溫度範圍為 31-70,則顯示器應該使用色彩 #eba834
。
{
"keyname": "temperature",
"type": "number",
"rules":[
{
"range": {
"minimum": 50,
"exclusiveMaximum": 70
},
"color": "#343deb"
},
{
"range": {
"maximum": 70,
"exclusiveMinimum": 30
},
"color": "#eba834"
}
]
}
StringTypeStyleRule
StringTypeStyleRule
是 ,StyleObject
由下列屬性所組成:
屬性 | 類型 | 描述 | 必要 |
---|---|---|---|
keyName |
string | 狀態或動態屬性名稱。 在 keyName 陣列內應該是唯一的 StyleObject 。 |
Yes |
type |
string | 值為 string 。 |
Yes |
rules |
StringRuleObject |
狀態值的 N 個陣列。 | Yes |
StringRuleObject
StringRuleObject
由最多 N 個狀態值所組成,這些值是特徵屬性的可能字串值。 如果特徵的屬性值不符合任何已定義的狀態值,該功能就不會有動態樣式。 如果指定重複的狀態值,則第一個狀態值優先。
比對的字串值會區分大小寫。
屬性 | 類型 | 描述 | 必要 |
---|---|---|---|
stateValue1 |
string | 值字串為 stateValue1 時的色彩。 | No |
stateValue2 |
string | 值字串為 stateValue 時的色彩。 | No |
stateValueN |
string | 值字串為 stateValueN 時的色彩。 | No |
StringTypeStyleRule 的範例
下列 JSON 說明 StringTypeStyleRule
定義與特定會議類型相關聯之樣式的 。
{
"keyname": "meetingType",
"type": "string",
"rules": [
{
"private": "#FF0000",
"confidential": "#FF00AA",
"allHands": "#00FF00",
"brownBag": "#964B00"
}
]
}
BooleanTypeStyleRule
BooleanTypeStyleRule
是 ,StyleObject
由下列屬性所組成:
屬性 | 類型 | 描述 | 必要 |
---|---|---|---|
keyName |
string | 狀態或動態屬性名稱。 在 keyName 陣列內應該是唯一的 StyleObject 。 |
Yes |
type |
string | 值為 boolean 。 |
Yes |
rules |
BooleanRuleObject |
布爾值組,具有和 false 狀態值的色彩true 。 |
Yes |
BooleanRuleObject
BooleanRuleObject
定義和 false
值的色彩true
。
屬性 | 類型 | 描述 | 必要 |
---|---|---|---|
true |
string | 狀態值為 true 時要使用的色彩。 屬性 color 是下列任一格式的 JSON 字串:
|
Yes |
false |
string | 狀態值為 false 時要使用的色彩。 |
Yes |
BooleanTypeStyleRule 的範例
下列 JSON 說明BooleanTypeStyleRule
名為 occupied
的狀態。 BooleanRuleObject
會定義和 false
值的色彩true
。
{
"keyname": "occupied",
"type": "boolean",
"rules": [
{
"true": "#FF0000",
"false": "#00FF00"
}
]
}
下一步
閱讀下列內容以深入了解室內地圖的 Creator: