Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Pass custom parameters to styleURL #5485

Closed
ambientlight opened this issue Jun 27, 2016 · 4 comments · Fixed by #5628
Closed

Pass custom parameters to styleURL #5485

ambientlight opened this issue Jun 27, 2016 · 4 comments · Fixed by #5628

Comments

@ambientlight
Copy link

I need to integrate the Bing Maps datasource into the styleURL, however instead of /z/x/y.png it uses quadKey indexing, where quadKey can be defined as:

_quadKey: function (x, y, z) {
    var quadKey = [];
    for (var i = z; i > 0; i--) {
        var digit = '0';
        var mask = 1 << (i - 1);
        if ((x & mask) != 0) {
            digit++;
        }
        if ((y & mask) != 0) {
            digit++;
            digit++;
        }
        quadKey.push(digit);
    }
    return quadKey.join('');
}

How can I make the styleURL eat a custom parameter in iOS and Android SDK? say for example something like:
https://somedatasource.com/{quadKey}.png

@1ec5
Copy link
Contributor

1ec5 commented Jun 27, 2016

The styleURL property takes a URL to a Mapbox GL stylesheet, not a tile URL template. It is possible to craft a stylesheet that includes a raster tile layer, but raster tile layers currently only support a limited set of tokens such as {x}, {y}, and {z}. There’s no API for extending that tokenization – the relevant code lives deep down in src/mbgl/util/mapbox.cpp.

@ambientlight
Copy link
Author

@1ec5 Thank you.

Ok I guess I therefore need to setup the apache server with request redirecting...

@1ec5
Copy link
Contributor

1ec5 commented Jun 30, 2016

mapbox/mapbox-gl-js#2805 proposes adding support for {quadkey} specifically in Mapbox GL JS. I don’t know whether or not that’s the right approach, but the equivalent code in the mapbox-gl-native codebase would be located in Resource::tile().

@1ec5
Copy link
Contributor

1ec5 commented Jul 9, 2016

#5628 implements {quadkey} support in tile URLs, as requested.

1ec5 added a commit that referenced this issue Jul 12, 2016
1ec5 added a commit that referenced this issue Jul 12, 2016
* [core] Quadkey tokens in tile URL templates

Fixes #5485.

* [core] WMS tokens in tile URL templates

Fixes #822.

* [macos] Added WMS debug style

Added a style to the macosapp resource bundle that can be used to test WMS support. To use it, zoom in to somewhere in New Jersey, then go to View ‣ Custom Style and enter “wms.json”.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants