mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

Do labels disappear when they are shorter than the lines?

Open Roxyi opened this issue 8 years ago • 1 comments

Hi, I am doing some experiments on the labels.

My client asked me to place labels in the center of the lines and place 1 label per segment. I tried different ways to get that effect. The best one I found so far is to use ST_LineSubstring to get shorter lines and place the labels on them. However, I found that the labels would disappear if they are shorter than the lines. Does anyone have an idea how to solve this problem? Also, any idea about placing the label in the center of the lines and 1 label per segment?

Here is a JSFiddle example I created: https://jsfiddle.net/yixu/s105gg46/ The black lines are original lines and the red lines are shorter ones.

Roxyi avatar Feb 02 '18 21:02 Roxyi

Hi @Roxyi Thank you for using GL JS.

Sorry to hear you're running into issues with label placement; it is a tricky problem. In Mapbox Streets, we create a separate layer of line features for the labels of the features for which we want exact placement (like lakes and rivers). Yes, if a label is longer than its line feature it will not be shown.

I encourage you to check out our guides and resources at https://www.mapbox.com/help/ or ask your question on a forum like Stack Overflow Due to the volume of issues and limited engineering resources, we are unable to provide additional support here on GitHub.

mollymerp avatar Feb 12 '18 22:02 mollymerp