0

I'm having trouble getting a mapbox XYZ layer to work with the Geoserver Print plugin - I just get the following error:

spec.layers[0].baseURL has an invalid value

and a bit further down:

Illegal character in path at index 79

My URL is like as so (some parts redacted for privacy): https://api.mapbox.com/styles/v1/*********/*************************/tiles/256/{z}/{x}/{y}?access_token=ACCESS_TOKEN

I assumed that the illegal character might be the curly brace, but of course this is required in the URL.

If I remove this layer, the print works correctly.

The layer is added to the spec using this object:

 {
    type: "XYZ",
    baseURL: XYZ, //the url shown above
    extension: "png",
    maxExtent: [0, 0, 700000, 1300000],
    tileSize: 256,
    resolutions: [resolutions], //current map resolution, i.e [40]
    path_format: '${z}/${x}/${y}'
  }

I have also added the host to the whitelist in the yaml config:

hosts:
- !dnsMatch
  host: api.mapbox.com

Geoserver Version: 2.13.0

Has anyone had any success getting this to work?

1 Answer 1

3

I had constructed my URL incorrectly, the base URL can't contain the z/x/y and the access token needs to be added as a custom param, for example:

 {
    type: "XYZ",
    baseURL: 'https://api.mapbox.com/styles/v1/***/***/tiles/256/',
    customParams: {
      access_token: ACCESS_TOKEN
    },
    extension: "",
    maxExtent: map.getExtent(),
    tileSize: [256, 256],
    resolutions: resolutions,
    path_format: '/${z}/${x}/${y}',
  }
0

Your Answer

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

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