Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

379
Views
¿Es posible bloquear el centro de un mapa de capas abiertas?

Quiero bloquear el centro de mi mapa de capas abiertas. Entonces, en la inicialización, centro el mapa, pero después de eso quiero que el mapa permanezca centrado pero permita el zoom. Deshabilité la interacción dragPan pero al hacer zoom en los mapas se acerca a la posición del mouse en lugar del centro del mapa. ¿Es posible cambiar este comportamiento?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Se puede hacer usando una restricción de extensión central de ancho y alto cero:

 <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.9.0/css/ol.css" type="text/css"> <style> html, body, .map { margin: 0; padding: 0; width: 100%; height: 100%; } </style> <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.9.0/build/ol.js"></script> <title>OpenLayers example</title> </head> <body> <div id="map" class="map"></div> <script type="text/javascript"> var center = ol.proj.fromLonLat([37.41, 8.82]); var map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }) ], view: new ol.View({ center: center, zoom: 4, extent: center.concat(center), constrainOnlyCenter: true, smoothExtentConstraint: false }) }); </script> </body> </html>

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!