Skip to content

Commit

Permalink
fixed some typescript issues (#2035)
Browse files Browse the repository at this point in the history
* fixed typescript issues

* fixed lint error
  • Loading branch information
AlmirKadric authored and rborn committed Feb 20, 2018
1 parent 42ff69a commit 7c83231
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 7 deletions.
54 changes: 49 additions & 5 deletions index.d.ts
@@ -1,13 +1,14 @@
declare module "react-native-maps" {
import * as React from 'react';

import { Animated } from 'react-native';

export interface Region {
latitude: number
longitude: number
latitudeDelta: number
longitudeDelta: number
}

export interface LatLng {
latitude: number
longitude: number
Expand All @@ -18,6 +19,27 @@ declare module "react-native-maps" {
y: number
}

export class AnimatedRegion extends Animated.AnimatedWithChildren {
latitude: Animated.Value
longitude: Animated.Value
latitudeDelta: Animated.Value
longitudeDelta: Animated.Value

constructor(LatLng);

setValue(value: Region): void;
setOffset(offset: Region): void;
flattenOffset(): void;
__getValue(): Region;
__attach(): void;
__detach(): void;
stopAnimation(callback?: Function): void;
addListener(callback: Function): string;
removeListener(id: string): void;
spring(config: any): any;
timing(config: any): any;
}

export interface MapViewProps {
provider?: 'google';
style: any;
Expand Down Expand Up @@ -72,8 +94,17 @@ declare module "react-native-maps" {
}

export default class MapView extends React.Component<MapViewProps, any> {
static Animated: any;
static AnimatedRegion: any;
animateToRegion(region: Region, duration?: number): void;
animateToCoordinate(latLng: LatLng, duration?: number): void;
animateToBearing(bearing: number, duration?: number): void;
animateToViewingAngle(angle: number, duration?: number): void;
fitToElements(animated: boolean): void;
fitToSuppliedMarkers(markers: string[], animated: boolean): void;
fitToCoordinates(coordinates?: LatLng[], options?:{}): void;
setMapBoundaries(northEast: LatLng, southWest: LatLng): void;
}

export class MapViewAnimated extends React.Component<MapViewProps, any> {
animateToRegion(region: Region, duration?: number): void;
animateToCoordinate(latLng: LatLng, duration?: number): void;
animateToBearing(bearing: number, duration?: number): void;
Expand All @@ -95,7 +126,7 @@ declare module "react-native-maps" {
image?: any;
opacity?: number;
pinColor?: string;
coordinate: { latitude: number; longitude: number };
coordinate: { latitude: number; longitude: number } | AnimatedRegion;
centerOffset?: { x: number; y: number };
calloutOffset?: { x: number; y: number };
anchor?: { x: number; y: number };
Expand Down Expand Up @@ -175,6 +206,11 @@ declare module "react-native-maps" {
zIndex?: number;
}

export interface MapOverlayProps {
image?: any;
bounds: LatLng[];
}

export interface MapCalloutProps {
tooltip?: boolean;
onPress?: Function;
Expand All @@ -191,5 +227,13 @@ declare module "react-native-maps" {
export class Circle extends React.Component<MapCircleProps, any> { }
export class UrlTile extends React.Component<MapUrlTileProps, any> { }
export class LocalTile extends React.Component<MapLocalTileProps, any> { }
export class Overlay extends React.Component<MapOverlayProps, any> { }
export class Callout extends React.Component<MapCalloutProps, any> { }

export class MarkerAnimated extends React.Component<MarkerProps, any> {
showCallout(): void;
hideCallout(): void;
animateMarkerToCoordinate(coordinate: LatLng, duration: number): void;
}
export class OverlayAnimated extends React.Component<MapOverlayProps, any> { }
}
11 changes: 9 additions & 2 deletions index.js
@@ -1,16 +1,23 @@
import MapView from './lib/components/MapView';
import Marker from './lib/components/MapMarker.js';
import Overlay from './lib/components/MapOverlay.js';

export { default as Marker } from './lib/components/MapMarker.js';
export { default as Polyline } from './lib/components/MapPolyline.js';
export { default as Polygon } from './lib/components/MapPolygon.js';
export { default as Circle } from './lib/components/MapCircle.js';
export { default as UrlTile } from './lib/components/MapUrlTile.js';
export { default as LocalTile } from './lib/components/MapLocalTile.js';
export { default as Overlay } from './lib/components/MapOverlay.js';
export { default as Callout } from './lib/components/MapCallout.js';
export { default as AnimatedRegion } from './lib/components/AnimatedRegion.js';
export { Animated, ProviderPropType, MAP_TYPES } from './lib/components/MapView.js';

export { Marker, Overlay };

export const PROVIDER_GOOGLE = MapView.PROVIDER_GOOGLE;
export const PROVIDER_DEFAULT = MapView.PROVIDER_DEFAULT;

export const MarkerAnimated = Marker.Animated;
export const OverlayAnimated = Overlay.Animated;

export default MapView;

0 comments on commit 7c83231

Please sign in to comment.