From 0512f5e20d449fd49eb314df7280cb3bf7f8cd0f Mon Sep 17 00:00:00 2001 From: Paito Anderson Date: Thu, 6 Jan 2022 10:25:46 -0500 Subject: [PATCH] Add fitToCoordinates --- src/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/index.js b/src/index.js index dab5f226..fd9b9c80 100755 --- a/src/index.js +++ b/src/index.js @@ -37,6 +37,17 @@ class MapView extends Component { center: { lat: coordinates.latitude, lng: coordinates.longitude }, }); } + + fitToCoordinates(coordinates) { + var bounds = new window.google.maps.LatLngBounds(); + for (var i = 0; i < coordinates.length; i++) { + bounds.extend( + new window.google.maps.LatLng(coordinates[i].latitude, coordinates[i].longitude) + ); + } + + this.map.fitBounds(bounds); + } onDragEnd = () => { const { onRegionChangeComplete } = this.props;