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

210
Visualizações
openlayers 6 map getview fit zooms out on every refresh

Im using openlayers 6, on mounted I use map().getView().fit(extent) for some reason on every refresh the zoom level is higher. any tips how to fix this?

Before using .fit(extent) I have to transformExtent to change projection from 5514 to 3857

this.map().setView(new View({
  projection: 'EPSG:3857',
  center: fromLonLat([50.075710, 14.472606]),
  zoom: 10,
  enableRotation: false
}))
extent = transformExtent(extent, 'EPSG:5514', this.map().getView().getProjection().getCode())
this.map().getView().fit(extent)

before refresh: enter image description here

after refresh: enter image description here

my problem is with map.getview.fit here is my code and here are the returned values coordinates after view.fit are a bit different

  console.log(transformedExtent)
  this.map().getView().fit(transformedExtent, this.map().getSize())
  console.log(this.map().getView().calculateExtent(this.map().getSize()))

before fit:

  1. -27186.072153485078
  2. 6701982.491006854
  3. -5136.804165771885
  4. 6724373.669054876

after fit:

  1. -27186.072153485078
  2. 6701493.775314425
  3. -5136.804165771886
  4. 6724862.384747305
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You are using the same variable for the EPSG:5514 and EPSG:3857 extents so presumably corrupting the original EPSG:5514 you want to use. Using a separate variable should solve the problem.

const transformedExtent = transformExtent(extent, 'EPSG:5514', this.map().getView().getProjection().getCode())
this.map().getView().fit(transformedExtent)
about 4 years ago · Juan Pablo Isaza Relatório

0

Asked about this problem directly on openlayers github and it is expected behavior. https://github.com/openlayers/openlayers/issues/13503

about 4 years ago · Juan Pablo Isaza Relatório
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