Skip to content

Instantly share code, notes, and snippets.

@danieljvdm
Created October 10, 2017 15:48
Show Gist options
  • Save danieljvdm/3bbfa185836a4b1ef4cc9abb25c6fd1f to your computer and use it in GitHub Desktop.
Save danieljvdm/3bbfa185836a4b1ef4cc9abb25c6fd1f to your computer and use it in GitHub Desktop.
React Native Maps flow typings
// @flow
// flow-typed signature: 5154a03b2184ac99b551e16ecd09098b
// flow-typed version: <<STUB>>/react-native-maps_v^0.15.3/flow_v0.50.0
declare module 'react-native-maps' {
declare type Region = {|
latitude: number,
longitude: number,
latitudeDelta: number,
longitudeDelta: number,
|};
declare type LatLng = {|
latitude: number,
longitude: number,
|};
declare type MapType = 'standard' | 'satellite' | 'hybrid' | 'terrain';
declare type Point = {|
x: number,
y: number,
|};
declare type EdgePadding = {|
top: number,
right: number,
bottom: number,
left: number,
|};
declare type EdgeInsets = {|
top: number,
left: number,
bottom: number,
right: number,
|};
declare class EventWithCoordinateAndPosition extends Event {
coordinate: LatLng;
position: Point;
}
declare export class InteractWithMapEvent<+T: EventTarget = EventTarget> extends SyntheticEvent<
T,
> {
nativeEvent: EventWithCoordinateAndPosition;
}
declare type MapViewProps = {
provider?: ?'google',
region?: Region,
initialRegion?: Region,
liteMode?: boolean,
mapType?: MapType,
showsUserLocation?: boolean,
followsUserLocation?: boolean,
showsMyLocationButton?: boolean,
showsPointsOfInterest?: boolean,
showsCompass?: boolean,
showsScale?: boolean,
showsBuildings?: boolean,
showsTraffic?: boolean,
showsIndoors?: boolean,
zoomEnabled?: boolean,
rotateEnabled?: boolean,
scrollEnabled?: boolean,
pitchEnabled?: boolean,
toolbarEnabled?: boolean,
cacheEnabled?: boolean,
loadingEnabled?: boolean,
loadingIndicatorColor?: string,
loadingBackgroundColor?: string,
moveOnMarkerPress?: Boolean,
legalLabelInsets?: EdgeInsets,
onRegionChange?: (region: Region) => void,
onRegionChangeComplete?: (region: Region) => void,
onPress?: (event: InteractWithMapEvent<*>) => void,
onPanDrag?: (event: InteractWithMapEvent<*>) => void,
onLongPress?: (event: InteractWithMapEvent<*>) => void,
onMarkerPress?: (event: SyntheticEvent<*>) => void,
onMarkerSelect?: (event: SyntheticEvent<*>) => void,
onMarkerDeselect?: (event: SyntheticEvent<*>) => void,
onCalloutPress?: (event: SyntheticEvent<*>) => void,
onMarkerDragStart?: (event: InteractWithMapEvent<*>) => void,
onMarkerDrag?: (event: InteractWithMapEvent<*>) => void,
onMarkerDragEnd?: (event: InteractWithMapEvent<*>) => void,
};
declare type ImageSourcePropType =
| number
| {
uri: string,
width?: number,
height?: number,
scale?: number,
};
declare type CalloutProps = {
tooltip?: boolean,
onPress?: (event: SyntheticEvent<*>) => void,
};
declare class Callout extends React$Component<CalloutProps> {}
declare type MarkerProps = {
title?: string,
description?: string,
image?: ImageSourcePropType,
pinColor?: string,
coordinate: LatLng,
centerOffset?: Point,
calloutOffset?: Point,
anchor?: Point,
calloutAnchor?: Point,
flat?: Boolean,
identifier?: String,
rotation?: number,
draggable?: ?boolean,
onPress?: (event: InteractWithMapEvent<*>) => void,
onSelect?: (event: InteractWithMapEvent<*>) => void,
onDeselect?: (event: InteractWithMapEvent<*>) => void,
onCalloutPress?: (event: SyntheticEvent<*>) => void,
onDragStart?: (event: InteractWithMapEvent<*>) => void,
onDrag?: (event: InteractWithMapEvent<*>) => void,
onDragEnd?: (event: InteractWithMapEvent<*>) => void,
};
declare class Marker extends React$Component<MarkerProps> {
showCallout: () => void;
hideCallout: () => void;
}
declare type PolygonProps = {
coordinates: LatLng[],
strokeWidth?: number,
strokeColor?: string,
fillColor?: string,
lineCap?: string,
lineJoin?: LatLng[],
miterLimit?: number,
geodesic?: boolean,
lineDashPhase?: number,
lineDashPattern?: number[],
onPress?: (event: SyntheticEvent<*>) => void,
};
declare class Polygon extends React$Component<PolygonProps> {}
declare type PolylineProps = {
coordinates: LatLng[],
strokeWidth?: number,
strokeColor?: string,
lineCap?: string,
lineJoin?: LatLng[],
miterLimit?: number,
geodesic?: boolean,
lineDashPhase?: number,
lineDashPattern?: number[],
onPress?: (event: SyntheticEvent<*>) => void,
};
declare class Polyline extends React$Component<PolylineProps> {}
declare type CircleProps = {
center: LatLng,
radius: number,
strokeWidth?: number,
strokeColor?: string,
fillColor?: string,
zIndex?: number,
lineCap?: string,
lineJoin?: LatLng[],
miterLimit?: number,
geodesic?: boolean,
lineDashPhase?: number,
lineDashPattern?: number[],
};
declare class Circle extends React$Component<CircleProps> {}
declare class MapView extends React$Component<MapViewProps> {
animateToRegion: (region: Region, duration?: number) => void;
animateToCoordinate: (coordinate: LatLng, duration?: number) => void;
fitToElements: (animated: boolean) => void;
fitToSuppliedMarkers: (markerIDs: string[], animated: boolean) => void;
fitToCoordinates: (
coordinates: LatLng[],
options?: {
edgePadding?: EdgePadding,
animated?: boolean,
},
) => void;
}
declare var exports: typeof MapView;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment