3

I'm using the CartoDB static Maps API. I need to change the font size of the street names. E.g. in the image below the street name "Stanhope Road" needs to be bigger.

Here's what my Json config file looks like so far. I've just been guessing how to set the cartocss property, and so far it hasn't worked.

{
  "version": "1.0.1",
  "name": "map",
  "layers": [
    {
        "type": "http",
        "options": {
            "urlTemplate": "http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",
            "cartocss_version": "2.3.0",
            "cartocss": "#road_label {  text-size: 24;  }"
        }
    },

sample map

2 Answers 2

4

Basemaps tiles are rendered server-side according a to a set of rules that you cannot change in a client side app.

Our basemaps are hosted on dedicated accounts that serve the same tiles for everyone.

That cartoCSS option does not work with http layers, as tiles are already rendered and cached, not instantiated as a result of your request.

Also, font-size has been evaluated along with many other features to create a well-balanced basemap that allows quality data visualization. It took a lot of work to find a correct size for the fonts at each zoom level. Changing it randomly will probably cause a bad experience visualising data over them.

1
  • I found this answer when trying to create a map usable by those with visual impairments (>60% of the US population atm) Oct 10, 2022 at 9:57
1

Since it's not possible to specify the road label font size (see Ernesto's answer - he works for CartoDB), I decided to get my image from one zoom level further out (e.g. zoom 18 instead of 19), and then stretch the .jpeg image from 320x240 to 640x480. It's crude, and there's more compression noise around the street numbers, but the street name becomes legible, as seen below.

stretched image

Interestingly, the font sizes seem to work differently in the static maps API than they do in the CartoDB UI. Compare the font size in the following image (captured from the CartoDB UI) with the one from my original question (directly from the static maps API).

CartoDB UI font size

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.