我通过从MSSQL数据库中拉出坐标来放置标记。Mapbox标记符号颜色变化
我想使标记物(圆圈)不同的颜色(红色[#FF0000]或蓝色[#0000FF]根据在数据库中的另一个变量,但所有的标志物是棕色(参见源,下面的链接) 。
这里是一个例子:
map.addSource("markers", {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-98.00371, 38.65447]
},
"properties": {
"description": "<strong>UTEP 5560</strong>
<p>Ellsworth Co., Kansas: 38.65447, -98.00371: : JOHNSON, JD</p>",
"marker-size": "small",
"marker-color": "#0000ff",
"marker-symbol": "circle"
}
},....
map.addLayer({
"id": "markers",
"type": "symbol",
"source": "markers",
"layout": {
"icon-image": "{marker-symbol}-11",
"icon-allow-overlap": true,
"text-field": "{title}",
"text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
"text-offset": [0, 0.6],
"text-anchor": "top"
}
});
完整的源代码可以在这里看到:http://webapps.fhsu.edu/ksfaunatest/account.aspx?o=33&t=75