I have tiles that are not available for the whole map. How can I stop Leaflet.js/Mapbox.js from making requests to these tiles? There are dozens of HTTP 404's that I'd really like to get rid of.
1 Answer
Try researching that link.
Also: Tile Layer Bounding Box Example
Or modify errorTileUrl to help your cause. Perhaps try errorTileUrl: ""
-
thanks, i'll look into tileBounds especially. Won't errorTileUrl only fire after a 404 though? I'd like to limit the XMLHttpRequests as much as posssible - I'm generating hundreds of 404's...– knutoleJan 3, 2014 at 17:13
-
1I added a third link: the Tile Layer Bounding Box Example link. That guy lays out the code for you.– BarrettJan 3, 2014 at 17:14
-
Yeah, looks great. Do you know if it's possible to embed this information in the Layer itself? (That it's self-aware of its bounds?)– knutoleJan 3, 2014 at 17:15
-
1Also, not sure about embedding the bounds info into the layer. Perhaps the best thing you can do (hacky) is a listen event to remove the layer, and then re-add with updated bounds. I don't think there is a way to .setOptions on the tileLayer– BarrettJan 3, 2014 at 17:40
-
1Also, is it possible to request the bounds from the layer service? If you could get that info at the beginning, you could set it once and be done. Please accept the answer if this works for ya. - B– BarrettJan 3, 2014 at 18:03