Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda