我有一個mapbox樣式的mapbox,但是我很難添加一個基本的標記,但是文本出現在標記應該在的地方該標記將在那裏。在mapbox中通過mapbox添加一些基本的標記gl js
因此,這裏是與地圖樣式代碼:
mapboxgl.accessToken = 'pk.eyJ1Ijoic21pY2tpZSIsImEiOiJjaWtiM2JkdW0wMDJudnRseTY0NWdrbjFnIn0.WxGYL18BJjWUiNIu-r3MSA';
var map = new mapboxgl.Map({
container: 'map',
style: "mapbox://styles/smickie/cikb3fhvi0063cekqns0pk1f1",
center: [-30.50, 40],
zoom: 2,
interactive: false
});
這裏正在從一個例子中的API增加了一些標記:
map.on('style.load', function() {
map.addSource("markers", {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-77.03238901390978, 38.913188059745586]
},
"properties": {
"title": "Mapbox DC",
"marker-symbol": "monument"
}
}, {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-122.414, 37.776]
},
"properties": {
"title": "Mapbox SF",
"marker-color": "#ff00ff"
}
}]
}
});
map.addLayer({
"id": "markers",
"type": "symbol",
"source": "markers",
"layout": {
"icon-image": "{marker-symbol}-15",
"text-field": "{title}",
"text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
"text-offset": [0, 0.6],
"text-anchor": "top"
}
});
});
然而,只有文字,而不是圖標顯示。
問題是:我會如何添加一個普通的基本彩色標記到這張地圖,甚至沒有一個特殊的圖標?
謝謝。
當心,'default_marker'已更名爲'標記15'。 HTTP://計算器。com/a/38061574/3625228花了我一段時間來弄清楚它爲什麼不起作用。 – oelna