Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions android/src/main/java/com/luggmaps/LuggMapView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,15 @@ class LuggMapView(private val reactContext: ThemedReactContext) :
provider?.setTheme(value)
}

fun setEdgeInsets(top: Int, left: Int, bottom: Int, right: Int) {
fun setEdgeInsets(
top: Int,
left: Int,
bottom: Int,
right: Int,
duration: Int = 0
) {
edgeInsets = EdgeInsets(top, left, bottom, right)
provider?.setEdgeInsets(edgeInsets)
provider?.setEdgeInsets(edgeInsets, duration)
}

// endregion
Expand Down
17 changes: 17 additions & 0 deletions android/src/main/java/com/luggmaps/LuggMapViewManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,23 @@ class LuggMapViewManager :
view.moveCamera(latitude, longitude, zoom, duration.toInt())
}

override fun setEdgeInsets(
view: LuggMapView,
top: Double,
left: Double,
bottom: Double,
right: Double,
duration: Double
) {
view.setEdgeInsets(
top.toFloat().dpToPx().toInt(),
left.toFloat().dpToPx().toInt(),
bottom.toFloat().dpToPx().toInt(),
right.toFloat().dpToPx().toInt(),
duration.toInt()
)
}

override fun fitCoordinates(
view: LuggMapView,
coordinates: ReadableArray?,
Expand Down
19 changes: 18 additions & 1 deletion android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,31 @@ class GoogleMapProvider(private val context: Context) :
}

override fun setEdgeInsets(edgeInsets: EdgeInsets) {
val oldInsets = this.edgeInsets
this.edgeInsets = edgeInsets
applyEdgeInsets()

val map = googleMap
if (map != null && oldInsets != edgeInsets) {
mapView?.post {
setEdgeInsets(edgeInsets, 0)
}
}
}

override fun setEdgeInsets(edgeInsets: EdgeInsets, duration: Int) {
val map = googleMap
val oldInsets = this.edgeInsets
this.edgeInsets = edgeInsets

if (map != null && oldInsets != edgeInsets) {
val cameraUpdate = CameraUpdateFactory.newCameraPosition(map.cameraPosition)
applyEdgeInsets()
map.moveCamera(cameraUpdate)
when {
duration < 0 -> map.animateCamera(cameraUpdate)
duration > 0 -> map.animateCamera(cameraUpdate, duration, null)
else -> map.moveCamera(cameraUpdate)
}
} else {
applyEdgeInsets()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface MapProvider {
fun setMinZoom(zoom: Double)
fun setMaxZoom(zoom: Double)
fun setEdgeInsets(edgeInsets: EdgeInsets)
fun setEdgeInsets(edgeInsets: EdgeInsets, duration: Int)

// Children
fun addMarkerView(markerView: LuggMarkerView)
Expand Down
22 changes: 20 additions & 2 deletions docs/MAPVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ mapRef.current?.fitCoordinates(
{ latitude: 37.7749, longitude: -122.4194 },
{ latitude: 37.8049, longitude: -122.4094 },
],
{ edgeInsets: { top: 50, left: 50, bottom: 50, right: 50 }, duration: 500 }
{ padding: { top: 50, left: 50, bottom: 50, right: 50 }, duration: 500 }
);

// Set edge insets with animation
mapRef.current?.setEdgeInsets(
{ top: 0, left: 0, bottom: 200, right: 0 },
{ duration: 300 }
);
```

Expand All @@ -81,11 +87,23 @@ Fit multiple coordinates in the visible map area.
fitCoordinates(coordinates: Coordinate[], options?: FitCoordinatesOptions): void

interface FitCoordinatesOptions {
edgeInsets?: EdgeInsets;
padding?: EdgeInsets;
duration?: number; // milliseconds, -1 for default
}
```

### setEdgeInsets

Programmatically update the map's edge insets with optional animation.

```ts
setEdgeInsets(edgeInsets: EdgeInsets, options?: SetEdgeInsetsOptions): void

interface SetEdgeInsetsOptions {
duration?: number; // milliseconds, -1 for default animation, 0 for instant
}
```

## Events

### onCameraMove
Expand Down
23 changes: 23 additions & 0 deletions docs/POLYLINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ import { MapView, Polyline } from '@lugg/maps';
| `coordinates` | `Coordinate[]` | **required** | Array of coordinates |
| `strokeWidth` | `number` | - | Line width in points |
| `strokeColors` | `ColorValue[]` | - | Gradient colors along the line |
| `animated` | `boolean` | `false` | Animate the polyline with a snake effect |
| `animatedOptions` | `PolylineAnimatedOptions` | - | Animation configuration options |
| `zIndex` | `number` | - | Z-index for layering polylines |

## Animated Options

```ts
interface PolylineAnimatedOptions {
duration?: number; // milliseconds, default 2150
easing?: 'linear' | 'easeIn' | 'easeOut' | 'easeInOut'; // default 'linear'
trailLength?: number; // 0-1, default 1.0 (full snake effect)
delay?: number; // milliseconds, default 0
}
```

```tsx
<Polyline
coordinates={coordinates}
strokeWidth={4}
animated
animatedOptions={{ duration: 3000, easing: 'easeOut', trailLength: 0.5 }}
/>
```

## Gradient Colors

Expand Down
4 changes: 2 additions & 2 deletions example/bare/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PODS:
- hermes-engine (0.14.0):
- hermes-engine/Pre-built (= 0.14.0)
- hermes-engine/Pre-built (0.14.0)
- LuggMaps (0.2.0-alpha.24):
- LuggMaps (0.2.0-alpha.27):
- boost
- DoubleConversion
- fast_float
Expand Down Expand Up @@ -3050,7 +3050,7 @@ SPEC CHECKSUMS:
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
GoogleMaps: 0608099d4870cac8754bdba9b6953db543432438
hermes-engine: 3515eff1a2de44b79dfa94a03d1adeed40f0dafe
LuggMaps: decd48fedf38073fcd53a74394624d5eaa763b2b
LuggMaps: 52b43077d9f8ca87c7c9c22771aa61fd93df5ae3
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
RCTDeprecation: 2b70c6e3abe00396cefd8913efbf6a2db01a2b36
RCTRequired: f3540eee8094231581d40c5c6d41b0f170237a81
Expand Down
Loading