admin管理员组文章数量:1406177
I want to add a Text inside a circle, which is my marker, but it doesnt show anything.
I have two layers, one for the circles and one for the text.
I am trying to get it to work by adding a text-field property, but nothigs gets rendered.
This are my two layers, the one where im trying to add the text is the second one called singles-count
map.addLayer({
id: "singles",
// type: "symbol",
type: "circle",
source: "users",
filter: ["!has", "point_count"],
// layout: {
// "icon-image": "custom-marker"
// },
paint: {
'circle-radius': {
'base': 10,
'stops': [[5, 20], [15, 500]]
},
'circle-color': '#ddffc8',
}
});
});
map.addLayer({
id: "singles-count",
type: "symbol",
source: "users",
filter: ["has", "singles_count"],
layout: {
"text-field": "XXX",
"text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Bold"],
"text-size": 12
}
});
But, it doesnt render the XXX nor throws any error, Any ideas?
I want to add a Text inside a circle, which is my marker, but it doesnt show anything.
I have two layers, one for the circles and one for the text.
I am trying to get it to work by adding a text-field property, but nothigs gets rendered.
This are my two layers, the one where im trying to add the text is the second one called singles-count
map.addLayer({
id: "singles",
// type: "symbol",
type: "circle",
source: "users",
filter: ["!has", "point_count"],
// layout: {
// "icon-image": "custom-marker"
// },
paint: {
'circle-radius': {
'base': 10,
'stops': [[5, 20], [15, 500]]
},
'circle-color': '#ddffc8',
}
});
});
map.addLayer({
id: "singles-count",
type: "symbol",
source: "users",
filter: ["has", "singles_count"],
layout: {
"text-field": "XXX",
"text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Bold"],
"text-size": 12
}
});
But, it doesnt render the XXX nor throws any error, Any ideas?
Share Improve this question asked Jun 25, 2019 at 21:56 user2643810user26438103 Answers
Reset to default 3There are 3 possible things that could go wrong here:
filter: ["has", "singles_count"]
results infalse
for each
feature and no symbols are being rendered because of that.It seems like you have a pretty big circle radius
'stops': [[5, 20], [15, 500]]
. It is possible that thesingles
layer overlapssingles-count
layer pletely and the text is actually being rendered but it is under the circle. To fix this you need to specifybeforeId
parameter ofaddLayer
function like this:
map.addLayer({
id: "singles-count",
type: "symbol",
source: "users",
filter: ["has", "singles_count"],
layout: {
"text-field": "XXX",
"text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Bold"],
"text-size": 12
}, 'singles');
- The font glyphs for
["DIN Offc Pro Medium", "Arial Unicode MS Bold"]
can not be found on your map tiles hosting servier. (404
error in networks tab)
Can you make a test case with jsfiddle/codepen? Layers look right but filters might be filtering out all data.
A bit late to the party
本文标签: javascriptHow to add a text inside a circle in Mapbox Gl JsStack Overflow
版权声明:本文标题:javascript - How to add a text inside a circle in Mapbox Gl Js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744961621a2634689.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论