Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2019
    Thanked 0 Times in 0 Posts

    How to set higher maxzoom in leafletjs?

    Hi, I'm new to JavaScript so forgive me if this is simple. I'm trying to set the max zoom on a leafletjs map higher than 18 which seems to be the defult maxzoom. This is what I tried so far but the map dosen't display with the minZoom and MaxZoom options
    <div id = "map" style = "width: 900px; height: 580px"></div>
             // Creating map options
             var mapOptions = {
                center: [50.061670, 19.937876],
                zoom: 18
    		minZoom: 5,
            	maxZoom: 20
             // Creating a map object
             var map = new L.map('map', mapOptions);
             // Creating a Layer object
             var layer = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
             // Adding layer to the map
    I would be greatful for any advice

  2. #2
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Keene, NH
    Thanked 516 Times in 503 Posts
    Not familiar with leafletjs, but the first thing I'd suggest is ditching the style="" that has zero business in the markup (since that's presentation), stop setting a fixed width and height and instead set a max-width (in the external stylesheet where it belongs)...

    Oh, and you have a typo. You missed a comma after the zoom: 18... Yeah, that's probably your problem. Add a comma between "18" and "minZoom".
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture

  3. #3
    New to the CF scene
    Join Date
    May 2019
    Thanked 0 Times in 0 Posts
    Thanks for the reply, ops I didn't notice that! Unfortunately, that hasn't solved the problem


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts