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

211
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
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