Skip to content

fix(google-maps): map type missing #309

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
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
5 changes: 4 additions & 1 deletion packages/google-maps/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Color, ImageSource, EventData, View } from '@nativescript/core';
import { JointType, MapViewBase } from './common';
import { JointType, MapType, MapViewBase } from './common';

export type FeatureTypeAdministrative = 'administrative' | 'administrative.country' | 'administrative.land_parcel' | 'administrative.locality' | 'administrative.neighborhood' | 'administrative.province';

Expand Down Expand Up @@ -380,6 +380,8 @@ export interface IGoogleMap {

mapStyle: Style[];

mapType: MapType;

snapshot(): Promise<ImageSource>;

animateCamera(update: CameraUpdate);
Expand Down Expand Up @@ -413,6 +415,7 @@ export interface IGoogleMap {

export class GoogleMap implements IGoogleMap {
mapStyle: Style[];
mapType: MapType;
addTileOverlay(options: TileOverlayOptions): TileOverlay;
removeTileOverlay(overlay: TileOverlay);
buildingsEnabled: boolean;
Expand Down
37 changes: 36 additions & 1 deletion packages/google-maps/index.ios.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Color, EventData, ImageSource, Utils, View } from '@nativescript/core';
import { isNullOrUndefined } from '@nativescript/core/utils/types';
import { ActiveBuildingEvent, ActiveLevelEvent, CameraPositionEvent, CameraPositionStartEvent, CircleOptions, Coordinate, CoordinateBounds, GroundOverlayOptions, GroundOverlayTapEvent, ICameraPosition, ICameraUpdate, ICircle, IGoogleMap, IGroundOverlay, IIndoorBuilding, IIndoorLevel, IMarker, InfoWindowEvent, IPatternItem, IPoi, IPolygon, IPolyline, IProjection, ITileOverlay, ITileProvider, IUISettings, IVisibleRegion, MapTapEvent, MarkerDragEvent, MarkerInfoEvent, MarkerOptions, MarkerTapEvent, PoiTapEvent, PolygonOptions, PolylineOptions, Style, TileOverlayOptions } from '.';
import { bearingProperty, JointType, latProperty, lngProperty, MapViewBase, tiltProperty, zoomProperty } from './common';
import { bearingProperty, JointType, latProperty, lngProperty, MapType, MapViewBase, tiltProperty, zoomProperty } from './common';
import { deserialize, intoNativeCircleOptions, intoNativeGroundOverlayOptions, intoNativeMarkerOptions, intoNativePolygonOptions, intoNativePolylineOptions, serialize } from './utils';

export class CameraUpdate implements ICameraUpdate {
Expand Down Expand Up @@ -820,6 +820,41 @@ export class GoogleMap implements IGoogleMap {
return UISettings.fromNative(this.native.settings);
}

get mapType() {
switch (this.native.mapType) {
case GMSMapViewType.kGMSTypeNone:
return MapType.None;
case GMSMapViewType.kGMSTypeNormal:
return MapType.Normal;
case GMSMapViewType.kGMSTypeSatellite:
return MapType.Satellite;
case GMSMapViewType.kGMSTypeTerrain:
return MapType.Terrain;
case GMSMapViewType.kGMSTypeHybrid:
return MapType.Hybrid;
}
}

set mapType(value: MapType) {
switch (value) {
case MapType.None:
this.native.mapType = GMSMapViewType.kGMSTypeNone;
break;
case MapType.Normal:
this.native.mapType = GMSMapViewType.kGMSTypeNormal;
break;
case MapType.Satellite:
this.native.mapType = GMSMapViewType.kGMSTypeSatellite;
break;
case MapType.Terrain:
this.native.mapType = GMSMapViewType.kGMSTypeTerrain;
break;
case MapType.Hybrid:
this.native.mapType = GMSMapViewType.kGMSTypeHybrid;
break;
}
}

#mapStyle: Style[];
get mapStyle() {
return this.#mapStyle;
Expand Down