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

289
Visualizações
OpenLayers source.getExtent() / view.fit() does not show entire feature

Using OL 6.5.0, the following snippet produces a map where the feature goes outside of the bounds of the map, rather than being completely contained (with a 20px margin) within the bounds of the map.

const extent = layer.getSource().getExtent();

view.fit(extent, {
  size: map.getSize(),
  padding: [20, 20, 20, 20],
});

I tried setting nearest to true / false but the result is the same.

Result (ignore the fuzz):

out of bounds

I expect the entire feature to be within the border of the map, but it is not. Am I missing something?

Expected (or close to it -- again, ignore the fuzz):

in bounds

Here's how I'm instantiating the map:

const map = this.map = maps[mapTargetId] = new ol.Map({
  target: mapTargetId,
  overlays: [overlay],
  layers: await this.getBaseLayers(),
  view: new ol.View({
    projection,
    center: [0, 0],
    zoomFactor: 2,
    zoom: defaultZoom,
    minZoom: 1,
    maxZoom: 12,
  })
});
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