We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
text-offset
mapbox-gl-js version: 3.2.0
i got a warning when i click a label use text-offset data-driven:
Expected value to be of type array<number, 2>, but found string instead.
i couldn't fix it and console the target feature, find that the properties.offset was converted to a string
properties.offset
so is that what caused the warning? and why?
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>demo</title> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"> <link href="https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.css" rel="stylesheet"> <script src="https://api.mapbox.com/mapbox-gl-js/v3.0.1/mapbox-gl.js"></script> <style> body { margin: 0; padding: 0; } #map { position: absolute; top: 0; bottom: 0; width: 100%; } </style> </head> <body> <div id="map"></div> <script> // mapboxgl.accessToken = '<KEY>'; const map = new mapboxgl.Map({ container: 'map', center: [-77.4144, 25.0759], zoom: 15, style: 'mapbox://styles/mapbox/streets-v12', }); map.on('load', () => { map.addSource('point', { 'type': 'geojson', 'data': { 'type': 'FeatureCollection', 'features': [ { 'type': 'Feature', properties: { text: 'Hello, world!', offset: [1, -1], }, 'geometry': { 'type': 'Point', 'coordinates': [-77.4144, 25.0759] } } ] } }); map.addLayer({ id: 'point', type: 'symbol', source: 'point', layout: { "text-field": "{text}", "text-size": 16, "text-offset": ['get', 'offset'], } }) map.on('click', 'point', function (e) { console.log(e.features[0].properties); // offset was converted to "[1,-1]" }) }) </script> </body> </html>
The text was updated successfully, but these errors were encountered:
may be you can try the key words "literal" in expressionshttps://docs.mapbox.com/style-spec/reference/expressions#types-literal
Sorry, something went wrong.
"literal" treats ['get', 'offset'] as literal array rather than data expression
"literal"
No branches or pull requests
mapbox-gl-js version: 3.2.0
Question
i got a warning when i click a label use
text-offset
data-driven:Expected value to be of type array<number, 2>, but found string instead.
i couldn't fix it and console the target feature, find that the
properties.offset
was converted to a stringso is that what caused the warning? and why?
Links to related documentation
The text was updated successfully, but these errors were encountered: