Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda