Skip to content
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

fixed some typescript issues #2035

Merged
merged 3 commits into from Feb 20, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;