Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

315
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!