Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9199915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:38:53+00:00 2026-06-17T22:38:53+00:00

Im using leaflet to create a photo map, with my own tiles, which works

  • 0

Im using leaflet to create a photo map, with my own tiles, which works as expected.

Im trying to work out how I can prevent the zoom from following this Quadtree type pattern:

  • Zoom Level 0 – Entire map width = 256px;
  • Zoom Level 1 – Entire map width = 512px;
  • Zoom Level 2 – Entire map width = 1024px;
  • And so on…

I would like to be able to zoom in say increments of 25% or 100px.

An example of 100px increments:

  • Zoom Level 0 – Entire map width = 200px;
  • Zoom Level 1 – Entire map width = 300px;
  • Zoom Level 2 – Entire map width = 400px;
  • And so on…

Question:
What is the logic for doing this? If it is at all possible?


My reason for wanting to do this is so that my photo map (which doesnt wrap like a normal map) can be more responsive and fit the users screen size nicely.

I made a demonstration of my issue which can be seen here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:38:54+00:00Added an answer on June 17, 2026 at 10:38 pm

    The short answer is that you can only show zoom levels for which you have pre-rendered tiles. Leaflet won’t create intermediary zoom levels for you.

    The long answer is that in order to use do this, you need to define your own CRS scale method and pass it to your map, for example:

    L.CRS.CustomZoom = L.extend({}, L.CRS.Simple, {
        scale: function (zoom) {
            // This method should return the tile grid size
            // (which is always square) for a specific zoom
            // We want 0 = 200px = 2 tiles @ 100x100px,
            // 1 = 300px = 3 tiles @ 100x100px, etc.
            // Ie.: (200 + zoom*100)/100 => 2 + zoom
    
            return 2 + zoom;
        }
    });
    
    var map = L.map('map', { crs: L.CRS.CustomZoom }).setView([0, 0], 0);
    

    In this example, I’ve extended L.CRS.Simple, but you can of course extend any CRS from the API you’d like, or even create your own from scratch.

    Using a zoom factor which results in a map pixel size that is not a multiple of your tilesize, means your right/bottom edge tiles will only be partially filled with map data. This can be fixed by making the non-map part of such tiles 100% transparent (or same the colour as your background).

    However, it is, in my opinion, a much better idea to set the tilesize to match the lowest common denominator, in this case 100px. Remember to reflect this by using the tileSize option in your tile layer. And, of course, you will need to re-render your image into 100×100 pixels tiles instead of the 256×256 tiles you are using currently.

    One caveat, the current version of LeafletJS (0.5) has a bug that prevents a custom scale() method from working, due to the TileLayer class being hardcoded to use power-of-2 zoom scaling. However, the change you need to do is minor and hopefully this will be addressed in a future release of Leaflet. Simply change TileLayer._getWrapTileNum() from:

    _getWrapTileNum: function () {
        // TODO refactor, limit is not valid for non-standard projections
        return Math.pow(2, this._getZoomForUrl());
    },
    

    To:

    _getWrapTileNum: function () {
        return this._map.options.crs.scale(this._getZoomForUrl());
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a map application using leaflet.js and I can not
I would like to create a map with some pins on it (using leaflet).
I want to create something like a leaflet/magazine using Latex. Is it possible to
I'm using Leaflet to draw a map, within the popups I've added a link
I have started using leaflet as an open source map, http://leaflet.cloudmade.com/ The following jQuery
I am using cloudmade leaflet for my map library. I am not sure how
I've created a simple js project which plots a series of points using leaflet.js.
I'm trying to get the weather icon to show in a map marker using
Using CSS, how can I create a partial border as per image below I
I am using maps and backbone.js together. Map JS library used is Leaflet, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.