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

316
Visualizações
Place tiles in leaflet map

I use leafletjs to make a interactive map. I have a fixed list of URLs to use and I can not change the URLs. I want to make a map with those tiles always in the same place and in the place I want them to be.

Tile0 is in (0, 0)

Tile1 is in (0, 1) and so on. How do I decide where each tile goes?

    var i = 0;
    L.TileLayer.CustomUrlLayer = L.TileLayer.extend({
        getTileUrl: function(coords) {
            var x = i;
            var y = i;
            i = i + 1;
            return `https://example.com/${y}-${x}.png`;
        }
    });

    L.tileLayer.myLayer = function(templateUrl, options) {
        return new L.TileLayer.MyLayer(templateUrl, options);
    }

    var map = L.map('map').setView([0, 0], 18);
    L.tileLayer.myLayer('', {
        attribution: 'My Map',
        maxZoom: 18,
        noWrap: true,
        tileSize: 256,
    }).addTo(map);

This snippet show my current leafletjs map. The tiles are placed wherever and it depends on the screen size. It changes if my Google Chrome window is smaller and so on. The correct images are loaded.

Tile0 Tile1 Tile2 Tile3

Tile4 Tile5 Tile6 Tile7

... always regardless of the screen. How?

about 4 years ago · Juan Pablo Isaza
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