我通過從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