Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
Why can leafletjs use map tiles from a non-CORS server and its plugins cannot?

I have a puzzling problem: I'm using Leaflet on an internal webpage to show a map with some custom layers.

Say, the webpage sits on the internal server showdata.local. The map tiles come from another internal server named maps.local. Leaflet finds the tiles perfectly given the appropriate tile URL http://maps.local/terraintiles/{z}_{x}_{y}.png. - So Leaflet's JavaScript (running in the browser) can clearly retrieve the images from the tile server maps.local. So far so good.

Now I am trying some Leaflet plugins to export on the client (i.e. the browser) the map (with the custom layers) as an image. I tried Leaflet.BigImage and leaflet-image. - But in both plugins, when I try to export the map, I get CORS errors on the tiles URLs. I assume the plugins need to retrieve the tiles again to build a virtual canvas with the map on it.

What I do not understand: Why do I get the CORS error in the plugins, but Leaflet's JavaScript code can load the tiles freely? Shouldn't be both disallowed if the tile server does not allow CORS?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To export the map, the plugin needs to read the image data from the files into JS and generate a new image. This needs permission from CORS.

To display a map tile, Leaflet just needs to place an image element on the page and leave the browser to display it to the user. The image data never touches the JS.

Further reading: XMLHttpRequest cannot load XXX No 'Access-Control-Allow-Origin' header

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda