From 535d95fd8d8b135a7b805f0ddd723539b93b6c1a Mon Sep 17 00:00:00 2001 From: tomma_g <38555316+tommag21@users.noreply.github.com> Date: Fri, 15 Jul 2022 18:35:58 +0200 Subject: [PATCH] fix(google-maps): ground overlay (#303) * fixes android ground overlay from position * adds ground overlay from bounds * fixes map style --- packages/google-maps/index.d.ts | 6 ++++-- packages/google-maps/utils/index.android.ts | 17 ++++++++++++----- packages/google-maps/utils/index.ios.ts | 7 +++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/packages/google-maps/index.d.ts b/packages/google-maps/index.d.ts index b3176dcf..2b761d0c 100644 --- a/packages/google-maps/index.d.ts +++ b/packages/google-maps/index.d.ts @@ -17,13 +17,15 @@ export type ElementTypeGeometry = 'geometry' | 'geometry.fill' | 'geometry.strok export type ElementTypeLabels = 'labels' | 'labels.icon' | 'labels.text' | 'labels.text.fill' | 'labels.text.stroke'; +export type StylersVisibility = 'on' | 'off' | 'simplified'; + export interface Stylers { hue?: string; lightness?: number; saturation?: number; gamma?: number; invert_lightness?: boolean; - visibility?: boolean; + visibility?: StylersVisibility; color?: string; weight?: number; } @@ -410,7 +412,7 @@ export interface IGoogleMap { } export class GoogleMap implements IGoogleMap { - mapStyle: Style; + mapStyle: Style[]; addTileOverlay(options: TileOverlayOptions): TileOverlay; removeTileOverlay(overlay: TileOverlay); buildingsEnabled: boolean; diff --git a/packages/google-maps/utils/index.android.ts b/packages/google-maps/utils/index.android.ts index 5ccd656f..122fb99c 100644 --- a/packages/google-maps/utils/index.android.ts +++ b/packages/google-maps/utils/index.android.ts @@ -253,6 +253,11 @@ export function intoNativePolylineOptions(options: PolylineOptions) { export function intoNativeGroundOverlayOptions(options: GroundOverlayOptions) { const opts = new com.google.android.gms.maps.model.GroundOverlayOptions(); + if (options?.position) { + const coords = options.position; + opts.position(new com.google.android.gms.maps.model.LatLng(coords.lat, coords.lng), options.width); + } + if (typeof options?.width === 'number') { opts.position(opts.getLocation(), options.width); } @@ -261,6 +266,13 @@ export function intoNativeGroundOverlayOptions(options: GroundOverlayOptions) { opts.position(opts.getLocation(), opts.getWidth(), options.height); } + if (options?.bounds) { + opts.positionFromBounds(new com.google.android.gms.maps.model.LatLngBounds( + new com.google.android.gms.maps.model.LatLng(options.bounds.southwest.lat, options.bounds.southwest.lng), + new com.google.android.gms.maps.model.LatLng(options.bounds.northeast.lat, options.bounds.northeast.lng) + )); + } + if (typeof options?.transparency) { opts.transparency(options.transparency); } @@ -273,11 +285,6 @@ export function intoNativeGroundOverlayOptions(options: GroundOverlayOptions) { opts.clickable(options.tappable); } - if (options?.position) { - const coords = options.position; - opts.position(new com.google.android.gms.maps.model.LatLng(coords.lat, coords.lng), opts.getWidth()); - } - if (typeof options?.tappable === 'boolean') { opts.clickable(options.tappable); } diff --git a/packages/google-maps/utils/index.ios.ts b/packages/google-maps/utils/index.ios.ts index 5d18056b..a3b6eaf1 100644 --- a/packages/google-maps/utils/index.ios.ts +++ b/packages/google-maps/utils/index.ios.ts @@ -259,6 +259,13 @@ export function intoNativeGroundOverlayOptions(options: GroundOverlayOptions) { // TODO } + if (options?.bounds) { + opts.bounds = new GMSCoordinateBounds({ + coordinate: CLLocationCoordinate2DMake(options.bounds.southwest.lat, options.bounds.southwest.lng), + coordinate2: CLLocationCoordinate2DMake(options.bounds.northeast.lat, options.bounds.northeast.lng) + }); + } + if (typeof options?.anchorU === 'number' || typeof options?.anchorV === 'number') { opts.anchor = CGPointMake(options?.anchorU ?? opts.anchor.x, options?.anchorV ?? opts.anchor.y); }