Closed pbnsilva closed 3 years ago
Platform: node
node
Mapbox SDK version: v5.0.2
v5.0.2
Steps to trigger behavior See below for the code that generates one tile where the problem can be seen.
Note that I am using tile mode and text-allow-overlap and icon-allow-overlap are false.
false
Expected behavior Country labels don't overlap, some might be hidden to avoid it.
Actual behavior
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: 4.8, width: 2051, height: 2051, pxWidth: 593, pxHeight: 593, center: [ 11.39566, -12.602236 ], bearing: 0, pitch: 0, ratio: 0.28913213066796684 } 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 } }) }) }
You need to use the text-overlap style
text-allow-overlap is set to false.
text-allow-overlap
Platform:
node
Mapbox SDK version:
v5.0.2
Steps to trigger behavior See below for the code that generates one tile where the problem can be seen.
Note that I am using tile mode and text-allow-overlap and icon-allow-overlap are
false
.Expected behavior Country labels don't overlap, some might be hidden to avoid it.
Actual behavior![tile1](https://user-images.githubusercontent.com/2334434/93483243-ec6b6980-f900-11ea-931f-41965bf8cf3d.png)
Code