基于 Mapbox 中的 non-string 特征属性的 GeoJSON 样式标记
Styling markers from GeoJSON based on non-string feature properties in Mapbox
如标题所示,我想为存储在 GeoJSON 文件中的一些标记设置样式。在每个功能中,我保存了一个"rotate":some_integer,基于我想如何旋转标记。
在 Mapbox 的 stylejson 中,我为标记编写了以下样式:
{
"id": "markers_test",
"type": "symbol",
"source": "markers_test",
"layout": {
"symbol-placement": "point",
"icon-image": "marker_{style_id}",
"icon-rotate": "{rotate}",
"text-field": "{name}",
"text-font": ["Open Sans Semibold"],
"text-anchor": "top-left",
"text-padding": 20,
"text-size": 10,
"text-optional": true
},
"paint": {
"text-color": "#dddddd",
"text-halo-color": "#0000ff",
"text-halo-width": 1,
"text-halo-blur": 1
}
}
设置正确的名称和图标可以完美地工作,但是当我尝试设置旋转时,它崩溃了,说值应该是一个数字,而不是一个字符串。仅 - 我如何在字符串外引用特征的 属性?
{token}
语法仅适用于 text-field
和 icon-image
。对于所有其他属性,您必须使用 property function syntax。
{
"id": "markers_test",
"type": "symbol",
"source": "markers_test",
"layout": {
"symbol-placement": "point",
"icon-image": "marker_{style_id}",
"icon-rotate": {
"property": "rotate",
"stops": [[0, 0], [365, 365]]
},
"text-field": "{name}",
"text-font": ["Open Sans Semibold"],
"text-anchor": "top-left",
"text-padding": 20,
"text-size": 10,
"text-optional": true
},
"paint": {
"text-color": "#dddddd",
"text-halo-color": "#0000ff",
"text-halo-width": 1,
"text-halo-blur": 1
}
}
如标题所示,我想为存储在 GeoJSON 文件中的一些标记设置样式。在每个功能中,我保存了一个"rotate":some_integer,基于我想如何旋转标记。
在 Mapbox 的 stylejson 中,我为标记编写了以下样式:
{
"id": "markers_test",
"type": "symbol",
"source": "markers_test",
"layout": {
"symbol-placement": "point",
"icon-image": "marker_{style_id}",
"icon-rotate": "{rotate}",
"text-field": "{name}",
"text-font": ["Open Sans Semibold"],
"text-anchor": "top-left",
"text-padding": 20,
"text-size": 10,
"text-optional": true
},
"paint": {
"text-color": "#dddddd",
"text-halo-color": "#0000ff",
"text-halo-width": 1,
"text-halo-blur": 1
}
}
设置正确的名称和图标可以完美地工作,但是当我尝试设置旋转时,它崩溃了,说值应该是一个数字,而不是一个字符串。仅 - 我如何在字符串外引用特征的 属性?
{token}
语法仅适用于 text-field
和 icon-image
。对于所有其他属性,您必须使用 property function syntax。
{
"id": "markers_test",
"type": "symbol",
"source": "markers_test",
"layout": {
"symbol-placement": "point",
"icon-image": "marker_{style_id}",
"icon-rotate": {
"property": "rotate",
"stops": [[0, 0], [365, 365]]
},
"text-field": "{name}",
"text-font": ["Open Sans Semibold"],
"text-anchor": "top-left",
"text-padding": 20,
"text-size": 10,
"text-optional": true
},
"paint": {
"text-color": "#dddddd",
"text-halo-color": "#0000ff",
"text-halo-width": 1,
"text-halo-blur": 1
}
}