Description
Now that expression support has landed in GL JS master, this plugin can demetricate any length measurements that occur in labels if the user agent specifies a U.S. locale, based on the following properties in the Mapbox Streets source:
building
layer:height
andmin_height
state_label
andwater_label
layers:area
road_label
layer:len
mountain_peak_label
layer:elevation_m
(useelevation_ft
)
Of these properties, height
, min_height
, and elevation_m
/elevation_ft
are the most likely to appear in labels. area
and len
are projected areas and lengths, respectively, which aren’t particularly practical for labeling.
For most of these properties, we’ll need to introduce expressions that convert between meters and feet or between square kilometers and square miles or acres. This will require the library to use the new expression syntax instead of the legacy property function syntax, although perhaps we could detect the absence of expression support and still adjust property functions if needed.
For elevation_m
, we’ll simply switch to elevation_ft
. One challenge will be localizing units that are written out alongside the property: for example, the mountain_peak_label
documentation recommends specifying a text field of {elevation_m}m
, but {elevation_m} meters
could occur instead.
Demetrication should be an option, not mandatory, since meters are used in technical contexts in the U.S.