Compensate resolution change with size of features in MapBox static API

608 views Asked by At

I'm using MapBox's static API in a project. I have managed to load maps with the same width and height in terms of latitude and longitude regardless of the resolution. This is so that users see the same area regardless of their screen resolution, for example. The problem is that on larger resolutions features and —especially, text appear much smaller, relatively. For example, these two maps look very similar, except for the size of text (and some other details, like the thickness of lines):

https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,14.3/540x285@2x?access_token=ACCESS_TOKEN

enter image description here

https://api.mapbox.com/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,13.15/240x126@2x?access_token=ACCESS_TOKEN

enter image description here

Is there a way to compensate for this and have the text on the larger image print larger, and have thicker lines? (in pixel terms). The result being that, say, two 6 inch screens print text in the same real-world size (centimeters) regardless of their pixel count.

I have looked into layers and filters, but it does not seem like there is a straightforward way of achieving this. It looks like maybe designing new maps would be the way to go, but I'm using the default ones and I would not know where to start.

THank you

1

There are 1 answers

1
riastrad On

I'm a bit confused by the premise of your question here. The API's @2x parameter is meant to toggle resolution and should serve exactly the purpose you describe. The reason for different amounts of label information being included in the images you've shared is because you've used different zoom values (13.15 vs. 14.3) and the labels in Mapbox core styles are zoom-dependent, meaning they change based on the zoom value used to generate the map.

With a fixed image width, and no @2x parameter:

/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,14.3/540x285?access_token=ACCESS_TOKEN

yields

With a fixed image width, and a @2x parameter:

yields

/styles/v1/mapbox/outdoors-v11/static/0.63189425,46.195750258333334,14.3/540x285@2x?access_token=ACCESS_TOKEN

⚠️ Disclaimer: I currently work for Mapbox ⚠️