Skip to content

Commit

Permalink
Merge pull request #45 from maltaesousa/fit
Browse files Browse the repository at this point in the history
use fit instead of setCenter
  • Loading branch information
maltaesousa authored Jan 20, 2022
2 parents 57c5e3e + 19e5940 commit 2d46180
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h3>Exemple 2</h3>
</div>
</div>
<div class="col">
<button id="map2-center" class="btn btn-dark mb-2" type="button">Obtenir le centre</button>
<button id="map2-center" class="btn btn-dark mb-2" type="button">Obtenir le centre des objets dessinés</button>
<label class="mb-2"><span class="badge" id="getcoorde2"></span> <span class="badge badge-secondary"
id="getcoordn2"></span></label>
</div>
Expand Down Expand Up @@ -217,7 +217,7 @@ <h3>Exemple 4</h3>
<button id="map5-upd-marker" class="btn btn-info">Mettre à jour</button>
<button class="btn btn-danger" onclick="map4.removeMarker()">Supprimer</button>
<button id="map5-recenter" class="btn btn-dark">Recentrer la carte</button>
<button id="map5-get-center" class="btn btn-dark">Obtenir le centre</button>
<button id="map5-get-center" class="btn btn-dark">Obtenir le centre des objets dessinés</button>
<label><span class="badge" id="getcoorde"></span> <span class="badge badge-secondary"
id="getcoordn"></span></label>
</div>
Expand Down
4 changes: 2 additions & 2 deletions js/sitnlayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@
sitnLayers.recenterMap = function (coordinates, zoomLevel) {
if (_map) {
const view = _map.getView();
view.setCenter(coordinates);
view.setZoom(zoomLevel);
const point = new ol.geom.Point(coordinates);
view.fit(point, { maxZoom: zoomLevel });
}
};

Expand Down

0 comments on commit 2d46180

Please sign in to comment.