Skip to content

Fix/google maps ground overlay #303

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

Merged
merged 3 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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