Conversation
|
Check @IT-MikeS @ItsChaceD |
There was a problem hiding this comment.
Pull Request Overview
This PR adds the ability to animate markers on Google Maps by smoothly transitioning them from one position to another. The animation functionality is implemented across all supported platforms (web, iOS, and Android) with configurable duration.
Key changes:
- Adds
animateMarkermethod to the public API interface - Implements platform-specific animation logic using native animation frameworks
- Updates documentation to include the new method
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| plugin/src/web.ts | Implements web animation using requestAnimationFrame with linear interpolation |
| plugin/src/map.ts | Adds public API method for marker animation |
| plugin/src/implementation.ts | Defines plugin interface and argument types for animation |
| plugin/src/definitions.ts | Defines TypeScript interface for animation options |
| plugin/ios/Plugin/Map.swift | Implements iOS animation using Core Animation transactions |
| plugin/ios/Plugin/CapacitorGoogleMapsPlugin.swift | Adds iOS plugin method handler for marker animation |
| plugin/ios/Plugin/CapacitorGoogleMapsPlugin.m | Registers the new plugin method in Objective-C |
| plugin/android/src/main/java/com/capacitorjs/plugins/googlemaps/CapacitorGoogleMapsPlugin.kt | Adds Android plugin method handler |
| plugin/android/src/main/java/com/capacitorjs/plugins/googlemaps/CapacitorGoogleMap.kt | Implements Android animation using ValueAnimator |
| plugin/README.md | Updates documentation with new method details |
| README.md | Updates root documentation with new method details |
| ): Promise<void>; | ||
| disableClustering(): Promise<void>; | ||
| addMarker(marker: Marker): Promise<string>; | ||
| animateMarker(markerId: string,lat: number,lng: number,duration?: number): Promise<void>; |
There was a problem hiding this comment.
Missing spaces after commas in the parameter list. Should be 'markerId: string, lat: number, lng: number, duration?: number'.
| animateMarker(markerId: string,lat: number,lng: number,duration?: number): Promise<void>; | |
| animateMarker(markerId: string, lat: number, lng: number, duration?: number): Promise<void>; |
| enableTouch(args: { id: string }): Promise<void>; | ||
| disableTouch(args: { id: string }): Promise<void>; | ||
| addMarker(args: AddMarkerArgs): Promise<{ id: string }>; | ||
| animateMarker(options: AnimateMarkerOptions): Promise<void>; |
There was a problem hiding this comment.
The interface method uses 'AnimateMarkerOptions' but the implementation uses 'AnimateMarkerArgs'. This inconsistency could cause confusion and type mismatches.
| animateMarker(options: AnimateMarkerOptions): Promise<void>; | |
| animateMarker(options: AnimateMarkerArgs): Promise<void>; |
| return markerHash | ||
| } | ||
|
|
||
| func animateMarker( markerId: Int, to target: LatLng, duration: Double) throws { |
There was a problem hiding this comment.
Extra space after opening parenthesis. Should be 'func animateMarker(markerId: Int, to target: LatLng, duration: Double) throws {'.
| func animateMarker( markerId: Int, to target: LatLng, duration: Double) throws { | |
| func animateMarker(markerId: Int, to target: LatLng, duration: Double) throws { |
| } | ||
| } | ||
|
|
||
| fun animateMarker(markerId: String,lat: Double,lng: Double,duration: Long, callback: (Result<Unit>) -> Unit |
There was a problem hiding this comment.
Missing spaces after commas in the parameter list. Should have spaces after 'String,', 'Double,', 'Double,', and 'Long,'.
| fun animateMarker(markerId: String,lat: Double,lng: Double,duration: Long, callback: (Result<Unit>) -> Unit | |
| fun animateMarker(markerId: String, lat: Double, lng: Double, duration: Long, callback: (Result<Unit>) -> Unit |
| val fraction = anim.animatedValue as Float | ||
| val newLat = startPos.latitude + | ||
| fraction * (endPos.latitude - startPos.latitude) | ||
| val newLng = startPos.longitude + | ||
| fraction * (endPos.longitude - startPos.longitude) | ||
| marker.position = LatLng(newLat, newLng) | ||
| } | ||
| addListener(object : AnimatorListenerAdapter() { | ||
| override fun onAnimationEnd(animation: Animator) { | ||
| callback(Result.success(Unit)) | ||
| } |
There was a problem hiding this comment.
The indentation is inconsistent in the animation block. Lines should be properly aligned within the ValueAnimator block.
| val fraction = anim.animatedValue as Float | |
| val newLat = startPos.latitude + | |
| fraction * (endPos.latitude - startPos.latitude) | |
| val newLng = startPos.longitude + | |
| fraction * (endPos.longitude - startPos.longitude) | |
| marker.position = LatLng(newLat, newLng) | |
| } | |
| addListener(object : AnimatorListenerAdapter() { | |
| override fun onAnimationEnd(animation: Animator) { | |
| callback(Result.success(Unit)) | |
| } | |
| val fraction = anim.animatedValue as Float | |
| val newLat = startPos.latitude + | |
| fraction * (endPos.latitude - startPos.latitude) | |
| val newLng = startPos.longitude + | |
| fraction * (endPos.longitude - startPos.longitude) | |
| marker.position = LatLng(newLat, newLng) | |
| } | |
| addListener(object : AnimatorListenerAdapter() { | |
| override fun onAnimationEnd(animation: Animator) { | |
| callback(Result.success(Unit)) | |
| } |
Added the ability to animate the marker to move it from one place to another.