Skip to content

Conversation

josuelmm
Copy link

Added the ability to animate the marker to move it from one place to another.

@josuelmm
Copy link
Author

Check @IT-MikeS @ItsChaceD

@Copilot Copilot AI review requested due to automatic review settings July 30, 2025 13:53
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 animateMarker method 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>;
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing spaces after commas in the parameter list. Should be 'markerId: string, lat: number, lng: number, duration?: number'.

Suggested change
animateMarker(markerId: string,lat: number,lng: number,duration?: number): Promise<void>;
animateMarker(markerId: string, lat: number, lng: number, duration?: number): Promise<void>;

Copilot uses AI. Check for mistakes.

enableTouch(args: { id: string }): Promise<void>;
disableTouch(args: { id: string }): Promise<void>;
addMarker(args: AddMarkerArgs): Promise<{ id: string }>;
animateMarker(options: AnimateMarkerOptions): Promise<void>;
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface method uses 'AnimateMarkerOptions' but the implementation uses 'AnimateMarkerArgs'. This inconsistency could cause confusion and type mismatches.

Suggested change
animateMarker(options: AnimateMarkerOptions): Promise<void>;
animateMarker(options: AnimateMarkerArgs): Promise<void>;

Copilot uses AI. Check for mistakes.

return markerHash
}

func animateMarker( markerId: Int, to target: LatLng, duration: Double) throws {
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space after opening parenthesis. Should be 'func animateMarker(markerId: Int, to target: LatLng, duration: Double) throws {'.

Suggested change
func animateMarker( markerId: Int, to target: LatLng, duration: Double) throws {
func animateMarker(markerId: Int, to target: LatLng, duration: Double) throws {

Copilot uses AI. Check for mistakes.

}
}

fun animateMarker(markerId: String,lat: Double,lng: Double,duration: Long, callback: (Result<Unit>) -> Unit
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing spaces after commas in the parameter list. Should have spaces after 'String,', 'Double,', 'Double,', and 'Long,'.

Suggested change
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

Copilot uses AI. Check for mistakes.

Comment on lines +271 to +281
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))
}
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is inconsistent in the animation block. Lines should be properly aligned within the ValueAnimator block.

Suggested change
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))
}

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant