Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda