Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3rd Party External PBF Vector Source (doc & example?) #866

Closed
canadaka opened this issue Dec 5, 2014 · 6 comments · Fixed by #1046
Closed

3rd Party External PBF Vector Source (doc & example?) #866

canadaka opened this issue Dec 5, 2014 · 6 comments · Fixed by #1046

Comments

@canadaka
Copy link

canadaka commented Dec 5, 2014

I am unable to get MVT/PBF vector tiles working from an external http:// source. I don't see any documentation or examples of this.

The sources docs page only mentions topoJSON and doens't actually give any info or example of using a 3rd party url: https://www.mapbox.com/mapbox-gl-style-spec/#sources

I created a very simple Style JSON file that includes:

"sources": {
    "trailforks": {
      "type": "vector",
      "url": "http://domain.com/{z}/{x}/{y}.pbf",
      "maxzoom": 15
    }
  },

Along with trying to specify a source in the JS

var test = new mapboxgl.Source({
        type: 'vector',
        url: 'http://domain.com/{z}/{x}/{y}.pbf'
    });
    map.addSource('test1', test);

Nothing loads and the Chrome console log has errors:
Line #5433
GET http://domain.com/%7Bz%7D/%7Bx%7D/%7By%7D.pbf net::ERR_NAME_NOT_RESOLVED
Line #2618
Uncaught #

@jfirebaugh
Copy link
Contributor

GET http://domain.com/%7Bz%7D/%7Bx%7D/%7By%7D.pbf net::ERR_NAME_NOT_RESOLVED

net::ERR_NAME_NOT_RESOLVED indicates that DNS resolution failed for the requested domain. Is "domain.com" the actual domain in your style?

@canadaka
Copy link
Author

canadaka commented Dec 6, 2014

no, the actual domain si not domain.com and it resolves, we have some test tiles on http://domain.com/vectiles2/{z}/{x}/{y}.pbf
But that URL in the Console error still contains the {z}/{x}/{y} should that have been converted to actual numbers in the request?
http://domain.com/vectiles2/9/97/192.pbf

@jfirebaugh
Copy link
Contributor

Oh, I see the issue now. If you supply a "url" property in the source it must be a URL to TileJSON. If you want to supply a tile template URL, you need to use the TileJSON "tiles" array property:

    "trailforks": {
      "type": "vector",
      "tiles": ["http://domain.com/{z}/{x}/{y}.pbf"],
      "maxzoom": 15
    }

See https://www.mapbox.com/mapbox-gl-style-spec/#sources

@canadaka
Copy link
Author

canadaka commented Dec 7, 2014

Thanks, that works! That defiantly was not clear from that doc/spec document.

My goal is to try and load pre-generated tiles from a local source (eventually on mobile), rather than http url.

Is it possible to load the tiles from a local source, the most simple being file:// I guess.
But ideally the tiles in some sort of container like a SQLite DB.

@timrobertson100
Copy link

Hi @canadaka - I hit the same issue as you on this.

The call to load the tiles is executing this method: https://github.com/mapbox/mapbox-gl-js/blob/master/js/util/browser/ajax.js#L23

You might want to explore overloading that function to do what you want there?

tristen added a commit that referenced this issue Mar 3, 2015
tristen added a commit that referenced this issue Mar 3, 2015
@MajuSadagopan
Copy link

MajuSadagopan commented Feb 21, 2018

I'm hosting pbf tiles generated using tippecanoe on S3 and I can't seem to get tiles to render. The tiles seem to be loading in the network panel but nothing renders. This tileset works perfectly with OpenLayers 4.

I sometimes get this error when panning around the map but nothing outside of that.
(VM3578 mapbox-gl.js:501)

map.addLayer({
        "id": "soils",
        "type": "fill",
        "source": {
            "type": "vector",
            "tiles": ["https://d2jyc3sz0j3f3j.cloudfront.net/soi151_vectortiles/{z}/{x}/{y}.pbf"],
        },
        "source-layer": "soi151_vectortiles",
        "paint": {
            "fill-color": "rgb(53, 175, 109)",
            "fill-outline-color": "rgb(53, 175, 109)"
        }
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants