Skip to content

Commit

Permalink
feat: Added newLatLngBounds
Browse files Browse the repository at this point in the history
newLatLngBounds was added to the PlatformMapsController.
Closes #27.
  • Loading branch information
LuisThein committed Mar 28, 2021
1 parent b96fe62 commit 1b36d5d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/src/camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class CameraPosition {
class CameraUpdate {
CameraUpdate._(this._json);

/// Returns a camera update that moves the camera to the specified position.
static newCameraPosition(CameraPosition cameraPosition) {
if (Platform.isIOS) {
return appleMaps.CameraUpdate.newCameraPosition(
Expand All @@ -89,6 +90,7 @@ class CameraUpdate {
}
}

/// Returns a camera update that moves the camera target to the specified geographical location.
static newLatLng(LatLng latLng) {
if (Platform.isIOS) {
return appleMaps.CameraUpdate.newLatLng(latLng.appleLatLng);
Expand All @@ -97,6 +99,7 @@ class CameraUpdate {
}
}

/// Returns a camera update that moves the camera target to the specified geographical location and zoom level.
static newLatLngZoom(LatLng latLng, double zoom) {
if (Platform.isIOS) {
return appleMaps.CameraUpdate.newLatLngZoom(latLng.appleLatLng, zoom);
Expand All @@ -105,6 +108,24 @@ class CameraUpdate {
}
}

/// Returns a camera update that transforms the camera so that
/// the specified geographical bounding box is centered in the map
/// view at the greatest possible zoom level.
/// A non-zero [padding] insets the bounding box from the map view's edges.
/// The camera's new tilt and bearing will both be 0.0.
static newLatLngBounds(LatLngBounds bounds, double padding) {
if (Platform.isIOS) {
return appleMaps.CameraUpdate.newLatLngBounds(
bounds.appleLatLngBounds, padding);
} else if (Platform.isAndroid) {
return googleMaps.CameraUpdate.newLatLngBounds(
bounds.googleLatLngBounds, padding);
}
}

/// Returns a camera update that modifies the camera zoom level by the specified amount.
/// The optional [focus] is a screen point whose underlying geographical location
/// should be invariant, if possible, by the movement.
static zoomBy(double amount) {
if (Platform.isIOS) {
return appleMaps.CameraUpdate.zoomBy(amount);
Expand All @@ -113,6 +134,10 @@ class CameraUpdate {
}
}

/// Returns a camera update that zooms the camera in,
/// bringing the camera closer to the surface of the Earth.
///
/// Equivalent to the result of calling zoomBy(1.0).
static zoomIn() {
if (Platform.isIOS) {
return appleMaps.CameraUpdate.zoomIn();
Expand All @@ -121,6 +146,10 @@ class CameraUpdate {
}
}

/// Returns a camera update that zooms the camera out,
/// bringing the camera further away from the surface of the Earth.
///
/// Equivalent to the result of calling zoomBy(-1.0).
static zoomOut() {
if (Platform.isIOS) {
return appleMaps.CameraUpdate.zoomOut();
Expand All @@ -129,6 +158,7 @@ class CameraUpdate {
}
}

/// Returns a camera update that sets the camera zoom level.
static zoomTo(double zoom) {
if (Platform.isIOS) {
return appleMaps.CameraUpdate.zoomTo(zoom);
Expand Down
10 changes: 10 additions & 0 deletions lib/src/cap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@
part of platform_maps_flutter;

enum Cap {
/// Cap that is squared off exactly at the start or end vertex of a [Polyline] with solid stroke pattern,
/// equivalent to having no additional cap beyond the start or end vertex.
///
/// This is the default cap type at start and end vertices of Polylines with solid stroke pattern.
buttCap,

/// Cap that is a semicircle with radius equal to half the stroke width, centered at
/// the start or end vertex of a [Polyline] with solid stroke pattern.
roundCap,

/// Cap that is squared off after extending half the stroke width beyond the start
/// or end vertex of a [Polyline] with solid stroke pattern.
squareCap,
}

Expand Down

0 comments on commit 1b36d5d

Please sign in to comment.