Skip to content

Commit

Permalink
Fix/google maps ground overlay (#303)
Browse files Browse the repository at this point in the history
* fixes android ground overlay from position

* adds ground overlay from bounds

* fixes map style
  • Loading branch information
tommag21 authored Jul 15, 2022
1 parent 5616f22 commit 0413bac
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
6 changes: 4 additions & 2 deletions packages/google-maps/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 12 additions & 5 deletions packages/google-maps/utils/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <Coordinate>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);
}
Expand All @@ -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);
}
Expand All @@ -273,11 +285,6 @@ export function intoNativeGroundOverlayOptions(options: GroundOverlayOptions) {
opts.clickable(options.tappable);
}

if (options?.position) {
const coords = <Coordinate>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);
}
Expand Down
7 changes: 7 additions & 0 deletions packages/google-maps/utils/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 0413bac

Please sign in to comment.