2

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.

3

tileBounds

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... – knutole Jan 3 '14 at 17:13
  • 1
    I added a third link: the Tile Layer Bounding Box Example link. That guy lays out the code for you. – Barrett Jan 3 '14 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?) – knutole Jan 3 '14 at 17:15
  • 1
    Also, 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 – Barrett Jan 3 '14 at 17:40
  • 1
    Also, 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 – Barrett Jan 3 '14 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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