Using `text-variable-anchor` removes label
pbnsilva opened this issue · 0 comments
pbnsilva commented
Platform: node
Mapbox SDK version: 5.0.2
I understand this is for a platform that is no longer supported, but I suspect this may be something simple that I am missing.
Steps to trigger behavior
- Removed all text layers from the style except one;
- Rendered a tile with and without
text-variable-anchor
(['center', 'top', 'bottom', 'left', 'right']) .
Expected behavior
Expect that text-variable-anchor
has no effect if there's enough space to render the labels. So the labels are rendered.
Actual behavior
Using this style.
Without text-variable-anchor
the label gets rendered (top). With it, it does not (bottom). See the label San Francisco
(code):
Code
const mbgl = require('@mapbox/mapbox-gl-native')
const request = require('request')
const utils = require('./utils')
const config = require('./config')
const sharp = require('sharp')
const readline = require('readline')
const fs = require('fs')
var tile1 = {
zoom: 11.2,
width: 4099,
height: 4099,
pxWidth: 931,
pxHeight: 931,
center: [ -121.892441, 37.638385],
bearing: 0,
pitch: 0,
ratio: 0.2271310075628202
}
renderTile('tile1', tile1)
function mapRequest(req, callback) {
var url = req.url
if (url.indexOf('access_token') === -1) {
var urlObject = utils.parseURL(url)
url = utils.makeAPIURL(urlObject, config.ACCESS_TOKEN)
}
makeRequest(url, callback)
}
function makeRequest(url, callback) {
request({
url: url,
encoding: null,
gzip: true
}, function (err, res, body) {
if (err) {
callback(err)
} else if (res.statusCode == 200) {
var response = {}
if (res.headers.modified) { response.modified = new Date(res.headers.modified) }
if (res.headers.expires) { response.expires = new Date(res.headers.expires) }
if (res.headers.etag) { response.etag = res.headers.etag }
response.data = body
callback(null, response)
} else {
callback(new Error(JSON.parse(body).message))
}
})
}
function renderTile(name, tile) {
var options = {
request: mapRequest,
ratio: tile.ratio,
mode: 'tile'
}
var map = new mbgl.Map(options)
map.load(require('./style.json'))
map.render({
zoom: tile.zoom,
width: tile.width,
height: tile.height,
center: tile.center,
bearing: 0,
pitch: 0,
}, function(err, buffer) {
if (err) {
throw err
}
map.release()
var image = sharp(buffer, {
raw: {
width: tile.pxWidth,
height: tile.pxHeight,
channels: 4
}
})
image.toFile(name + '.png', function(err) {
if (err) {
throw err
}
})
})
}