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

165
Views
Full width imageOverlay on Leaflet js

I would like to set the width to be always 100% of the screen size when clicking on zoom out on the imageOverlay on leaflet.js, I have set all the options for maxBounds and minZoom but on large sizes of screen when zooming out of the image, the bounds appear like on the image below. could some assist me on where i am going wrong?

var secondaryMap = L.map("secondaryMap", {
    minZoom: -0.15,
    maxZoom: 1,
    center: L.latLng(-1165.5, 1032),
    zoom: 0,
    zoomSnap: 0.25,
    zoomDelta: 0.25,
    crs: L.CRS.Simple,
    scrollWheelZoom: false,
    maxBoundsViscosity: 1.0,
    interactive: true,
    doubleClickZoom: false,
    touchZoom: false,
    tap: true,
    tapTolerance: 50,
    bounceAtZoomLimits: false,
    attributionControl: false,
    zoomControl: false,
});

// dimensions of the image
var w = 2200,
    h = 1778,
    url = $('#secondaryMap').attr('src');

// calculate the edges of the image, in coordinate space
var southWest = secondaryMap.unproject([0, h], secondaryMap.getMinZoom());
var northEast = secondaryMap.unproject([w, 0], secondaryMap.getMinZoom());
var bounds = new L.LatLngBounds(southWest, northEast);
var layer = L.imageOverlay(url, bounds).addTo(secondaryMap);
secondaryMap.fitBounds(bounds);
secondaryMap.setMaxBounds(bounds);

enter image description here

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!