Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(google-maps): Support marker rotation #1820

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -769,6 +769,7 @@ class CapacitorGoogleMap(
markerOptions.title(marker.title)
markerOptions.snippet(marker.snippet)
markerOptions.alpha(marker.opacity)
markerOptions.rotation(marker.rotation)
markerOptions.flat(marker.isFlat)
markerOptions.draggable(marker.draggable)
markerOptions.zIndex(marker.zIndex)
Expand Down
Expand Up @@ -11,6 +11,7 @@ import org.json.JSONObject
class CapacitorGoogleMapMarker(fromJSONObject: JSONObject): ClusterItem {
var coordinate: LatLng = LatLng(0.0, 0.0)
var opacity: Float = 1.0f
var rotation: Float = 1.0f
private var title: String
private var snippet: String
private var zIndex: Float = 0.0f
Expand All @@ -36,6 +37,7 @@ class CapacitorGoogleMapMarker(fromJSONObject: JSONObject): ClusterItem {
coordinate = LatLng(latLngObj.getDouble("lat"), latLngObj.getDouble("lng"))
title = fromJSONObject.optString("title")
opacity = fromJSONObject.optDouble("opacity", 1.0).toFloat()
rotation = fromJSONObject.optDouble("rotation", 0.0).toFloat()
snippet = fromJSONObject.optString("snippet")
isFlat = fromJSONObject.optBoolean("isFlat", false)
iconUrl = fromJSONObject.optString("iconUrl")
Expand Down
2 changes: 2 additions & 0 deletions google-maps/ios/Plugin/Marker.swift
Expand Up @@ -4,6 +4,7 @@ import Capacitor
public struct Marker {
let coordinate: LatLng
let opacity: Float?
let rotation: Float?
let title: String?
let snippet: String?
let isFlat: Bool?
Expand Down Expand Up @@ -55,6 +56,7 @@ public struct Marker {

self.coordinate = LatLng(lat: lat, lng: lng)
self.opacity = fromJSObject["opacity"] as? Float
self.rotation = fromJSObject["rotation"] as? Float
self.title = fromJSObject["title"] as? String
self.snippet = fromJSObject["snippet"] as? String
self.isFlat = fromJSObject["isFlat"] as? Bool
Expand Down
6 changes: 6 additions & 0 deletions google-maps/src/definitions.ts
Expand Up @@ -279,6 +279,12 @@ export interface Marker {
* @default 1
*/
opacity?: number;
/**
* The angle by which to rotate the marker, expressed clockwise in degrees
*
* @default 0
*/
rotation?: number;
/**
* Title, a short description of the overlay.
*/
Expand Down