Skip to content

Commit

Permalink
Fixed typescript compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dapriett committed May 5, 2017
1 parent 87120f6 commit 960322c
Show file tree
Hide file tree
Showing 8 changed files with 346 additions and 280 deletions.
10 changes: 5 additions & 5 deletions demo/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"nativescript": {
"id": "org.nativescript.demo",
"tns-ios": {
"version": "3.0.0-rc.2"
},
"tns-android": {
"version": "3.0.0-rc.1"
"version": "3.0.0"
},
"tns-ios": {
"version": "3.0.0"
}
},
"dependencies": {
"nativescript-google-maps-sdk": "file:../",
"tns-core-modules": "^3.0.0-rc.2"
"tns-core-modules": "^3.0.0"
},
"devDependencies": {
"babel-traverse": "6.7.6",
Expand Down
105 changes: 70 additions & 35 deletions map-view-common.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
MapView as IMapView, Position as IPosition, Marker as IMarker,
Shape as IShape, Polyline as IPolyline, Polygon as IPolygon,
Circle as ICircle, Camera, MarkerEventData, ShapeEventData,
CameraEventData, PositionEventData, Bounds as IBounds
} from ".";
MapView, Position, Marker, Shape, Polyline, Polygon,
Circle, Camera, MarkerEventData, ShapeEventData,
CameraEventData, PositionEventData, Bounds, Style
} from "./map-view";
import { View } from "tns-core-modules/ui/core/view";
import { Image } from "tns-core-modules/ui/image";

import { Property, PropertyOptions } from "tns-core-modules/ui/core/properties";
import { Color } from "tns-core-modules/color";

function onMapPropertyChanged(mapView: MapViewBase, oldValue: number, newValue: number) {
if (!mapView.processingCameraEvent) mapView.updateCamera();
Expand All @@ -30,13 +30,14 @@ function paddingValueConverter(value: any) {
}
}

export { Style as StyleBase };

export abstract class MapViewBase extends View implements IMapView {
export abstract class MapViewBase extends View implements MapView {

protected _gMap: any;
protected _markers: Array<MarkerBase> = new Array<MarkerBase>();
protected _shapes: Array<ShapeBase> = new Array<ShapeBase>();
protected _processingCameraEvent: boolean;
public _processingCameraEvent: boolean;
public latitude: number;
public longitude: number;
public bearing: number;
Expand All @@ -63,32 +64,37 @@ export abstract class MapViewBase extends View implements IMapView {
return this._processingCameraEvent;
}

public abstract updateCamera(): void;

public abstract setViewport(b: IBounds, p?: number): void;
public abstract findMarker(callback: (marker: Marker)=>boolean): Marker;

public abstract updatePadding(): void;
public abstract addPolyline(shape: Polyline): void;

public abstract addMarker(marker: IMarker): void;
public abstract addPolygon(shape: Polygon): void;

public abstract removeMarker(marker: IMarker): void;
public abstract addCircle(shape: Circle): void;

public abstract removeAllMarkers(): void;
public abstract removeShape(shape: Shape): void;

public abstract findShape(callback: (shape: Shape) => boolean): Shape;

public abstract addPolyline(shape: PolylineBase): void;
public abstract setStyle(style: Style): boolean;

public abstract addPolygon(shape: PolygonBase): void;
public abstract updateCamera(): void;

public abstract setViewport(b: Bounds, p?: number): void;

public abstract updatePadding(): void;

public abstract addCircle(shape: CircleBase): void;
public abstract addMarker(marker: Marker): void;

public abstract removeShape(shape: ShapeBase): void;
public abstract removeMarker(marker: Marker): void;

public abstract removeAllMarkers(): void;

public abstract removeAllShapes(): void;

public abstract clear(): void;

public abstract setStyle(style: any): void;

public removeAllPolylines() {
this._shapes.forEach(shape => {
if (shape.shape === 'polyline') {
Expand Down Expand Up @@ -117,12 +123,12 @@ export abstract class MapViewBase extends View implements IMapView {
this.notify({ eventName: MapViewBase.mapReadyEvent, object: this, gMap: this.gMap });
}

notifyMarkerEvent(eventName: string, marker: IMarker) {
notifyMarkerEvent(eventName: string, marker: Marker) {
let args: MarkerEventData = { eventName: eventName, object: this, marker: marker };
this.notify(args);
}

notifyShapeEvent(eventName: string, shape: IShape) {
notifyShapeEvent(eventName: string, shape: Shape) {
let args: ShapeEventData = { eventName: eventName, object: this, shape: shape };
this.notify(args);
}
Expand All @@ -147,7 +153,7 @@ export abstract class MapViewBase extends View implements IMapView {
this.notifyMarkerEvent(MapViewBase.markerDragEvent, marker);
}

notifyPositionEvent(eventName: string, position: IPosition) {
notifyPositionEvent(eventName: string, position: Position) {
let args: PositionEventData = { eventName: eventName, object: this, position: position };
this.notify(args);
}
Expand Down Expand Up @@ -176,35 +182,57 @@ tiltProperty.register(MapViewBase);
export const paddingProperty = new Property<MapViewBase, number>(<PropertyOptions<MapViewBase, number>>{ name: 'padding', defaultValue: 0, valueChanged: onPaddingPropertyChanged, valueConverter: paddingValueConverter });
paddingProperty.register(MapViewBase);

export class PositionBase implements IPosition {
export class PositionBase implements Position {
public latitude: number;
public longitude: number;
public ios: any; /* CLLocationCoordinate2D */
public android: any;
}

export class BoundsBase implements IBounds {
public northeast: PositionBase;
public southwest: PositionBase;
export class BoundsBase implements Bounds {
public northeast: Position;
public southwest: Position;
public ios: any; /* GMSCoordinateBounds */
public android: any;
}

export class MarkerBase implements IMarker {
public position: IPosition;
public snippet: string;
export abstract class MarkerBase implements Marker {
public position: Position;
public rotation: number;
public anchor: Array<number>;
public title: string;
public snippet: string;
public icon: Image;
public alpha: number;
public flat: boolean;
public draggable: boolean;
public visible: boolean;
public zIndex: number;
public abstract showInfoWindow(): void;
public userData: any;
public _map: any;
public ios: any;
public android: any;
}

export class ShapeBase implements IShape {
export class ShapeBase implements Shape {
public shape: string;
public visible: boolean;
public zIndex: number;
public userData: any;
public _map: any;
public ios: any;
public android: any;
public clickable: boolean;
}

export abstract class PolylineBase extends ShapeBase implements IPolyline {
export abstract class PolylineBase extends ShapeBase implements Polyline {
public shape: string = 'polyline';
public _map: any;
public _points: Array<PositionBase>;
public width: number;
public color: Color;
public geodesic: boolean;

addPoint(point: PositionBase): void {
this._points.push(point);
Expand Down Expand Up @@ -236,10 +264,13 @@ export abstract class PolylineBase extends ShapeBase implements IPolyline {
public abstract reloadPoints(): void;
}

export abstract class PolygonBase extends ShapeBase implements IPolygon {
export abstract class PolygonBase extends ShapeBase implements Polygon {
public shape: string = 'polygon';
public _map: any;
public _points: Array<PositionBase>;
public strokeWidth: number;
public strokeColor: Color;
public fillColor: Color;

addPoint(point: PositionBase): void {
this._points.push(point);
Expand Down Expand Up @@ -271,8 +302,12 @@ export abstract class PolygonBase extends ShapeBase implements IPolygon {
public abstract reloadPoints(): void;
}

export class CircleBase extends ShapeBase implements ICircle {
export class CircleBase extends ShapeBase implements Circle {
public shape: string = 'circle';
public center: IPosition;
public center: Position;
public _map: any;
}
public radius: number;
public strokeWidth: number;
public strokeColor: Color;
public fillColor: Color;
}
12 changes: 6 additions & 6 deletions map-view.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import application = require("tns-core-modules/application");
import common = require("./map-view-common");

import {
MapViewBase, BoundsBase, CircleBase,
MarkerBase, PolygonBase, PolylineBase,
MapViewBase, BoundsBase, CircleBase,
MarkerBase, PolygonBase, PolylineBase,
PositionBase, ShapeBase, latitudeProperty,
longitudeProperty, bearingProperty, zoomProperty,
tiltProperty
tiltProperty, StyleBase
} from "./map-view-common";
import { Image } from "tns-core-modules/ui/image";
import { Color } from "tns-core-modules/color";
Expand All @@ -19,7 +19,7 @@ declare const android: any;
export class MapView extends MapViewBase {

protected _markers: Array<Marker> = new Array<Marker>();
private _context: any;
public _context: any;
private _pendingCameraUpdate: boolean;
private hasPermissions: boolean;

Expand Down Expand Up @@ -312,7 +312,7 @@ export class MapView extends MapViewBase {
this.gMap.clear();
}

setStyle(style: Style): void {
setStyle(style: StyleBase): boolean {
let styleOptions = new com.google.android.gms.maps.model.MapStyleOptions(JSON.stringify(style));
return this.gMap.setMapStyle(styleOptions);
}
Expand Down Expand Up @@ -347,7 +347,7 @@ export class Position extends PositionBase {
this._android = new com.google.android.gms.maps.model.LatLng(this.latitude, parseFloat(""+longitude));
}

constructor(android?: com.google.android.gms.maps.model.LatLng) {
constructor(android?: any) {
super();
this._android = android || new com.google.android.gms.maps.model.LatLng(0, 0);
}
Expand Down
Loading

0 comments on commit 960322c

Please sign in to comment.