Skip to content

Instantly share code, notes, and snippets.

@sbis04

sbis04/main.dart Secret

Created May 30, 2020 09:16
Show Gist options
  • Save sbis04/ec9402f37dec341dd8401e6fdce3ca26 to your computer and use it in GitHub Desktop.
Save sbis04/ec9402f37dec341dd8401e6fdce3ca26 to your computer and use it in GitHub Desktop.
// Define two position variables
Position _northeastCoordinates;
Position _southwestCoordinates;
// Calculating to check that
// southwest coordinate <= northeast coordinate
if (startCoordinates.latitude <= destinationCoordinates.latitude) {
_southwestCoordinates = startCoordinates;
_northeastCoordinates = destinationCoordinates;
} else {
_southwestCoordinates = destinationCoordinates;
_northeastCoordinates = startCoordinates;
}
// Accommodate the two locations within the
// camera view of the map
mapController.animateCamera(
CameraUpdate.newLatLngBounds(
LatLngBounds(
northeast: LatLng(
_northeastCoordinates.latitude,
_northeastCoordinates.longitude,
),
southwest: LatLng(
_southwestCoordinates.latitude,
_southwestCoordinates.longitude,
),
),
100.0, // padding
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment