Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into upstream-update

* 'master' of https://github.com/airbnb/react-native-maps:
  v0.17.0
  Update index.d.ts
  v0.16.4
  [MapMarker] fix android release crash on custom marker (react-native-maps#1643)
  Add support for animateToViewingAngle and animateToBearing for Android
  Bump 0.16.3
  Revert "[MapView] revert initialRegion change (react-native-maps#1613)"
  [MapView] revert initialRegion change (react-native-maps#1613)
  Added missing satellite option for iOS Google Maps (react-native-maps#1603)
  Remove legalNotice from android AirMapModule As per https://developers.google.com/android/reference/com/google/android/gms/common/GooglePlayServicesUtil this information does not need to be displayed in app.
  Set initial region on view (react-native-maps#1579)
  Added Typescript Definitions
  Updated "showsIndoorLevelPicker" documentation.
  Added [iOS / Google Maps] support for showsIndoorLevelPicker.
  Fall back to View.propTypes if ViewPropTypes is not available (react-native-maps#1473) (react-native-maps#1474)
  fixe mistakes on circle.md (react-native-maps#1584)
  Add support for AirMap (Native IOS Maps) as suggested on the PR comments.
  Adds support to animateToBearing and animateToViewingAngle functions on IOS.
  fix rare android crashes when map size is 0
  Remove caret from "react": "^16.0.0-alpha.12"
  • Loading branch information
Rodrigo Solis committed Oct 23, 2017
2 parents f11208e + 8f0b21e commit 7c7b8c2
Show file tree
Hide file tree
Showing 17 changed files with 375 additions and 24 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Change Log

## 0.17.0 (October 11, 2017)
* iOS: [#1527](https://github.com/airbnb/react-native-maps/pull/1527) Added [iOS / Google Maps] support for showsIndoorLevelPicker
* iOS/Android: [#1544](https://github.com/airbnb/react-native-maps/pull/1544) Adds support to animateToBearing and animateToViewingAngle ( IOS + Android )
* JS: [#1503](https://github.com/airbnb/react-native-maps/pull/1503) Remove caret from "react": "^16.0.0-alpha.12
* Android: [#1521](https://github.com/airbnb/react-native-maps/pull/1521) Fix rare android crashes when map size is 0
* Common: [#1610](https://github.com/airbnb/react-native-maps/pull/1610) Added Typescript Definitions
* Android: [#1612](https://github.com/airbnb/react-native-maps/pull/1612) Remove legalNotice from android AirMapModule

## 0.16.4 (September 13, 2017)
* Android: [#1643](https://github.com/airbnb/react-native-maps/pull/1643) [MapMarker] fix android release crash on custom marker

## 0.16.3 (September 2, 2017)
* iOS: [#1603](https://github.com/airbnb/react-native-maps/pull/1603) Added missing satellite option for iOS Google Maps
* iOS: [#1579](https://github.com/airbnb/react-native-maps/pull/1579) Set initial region on view

## 0.16.2 (August 17, 2017)
* Android: [#1563](https://github.com/airbnb/react-native-maps/pull/#1563) Add missing native method for setting initial region
* iOS: [#1187](https://github.com/airbnb/react-native-maps/pull/1187) Reverted due to build issues
Expand Down
4 changes: 2 additions & 2 deletions docs/circle.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
| `strokeColor` | `String` | `#000`, `rgba(r,g,b,0.5)` | The stroke color to use for the path.
| `fillColor` | `String` | `#000`, `rgba(r,g,b,0.5)` | The fill color to use for the path.
| `zIndex` | `Number` | 0 | The order in which this tile overlay is drawn with respect to other overlays. An overlay with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays with the same z-index is arbitrary. The default zIndex is 0. (Android Only)
| `lineCap` | `String` | `round` | The line cap style to apply to the open ends of the path.
| `lineJoin` | `Array<LatLng>` | | The line join style to apply to corners of the path.
| `lineCap` | `String` | `round` | The line cap style to apply to the open ends of the path. Other values : `butt`, `square`
| `lineJoin` | `String` | | The line join style to apply to corners of the path. possible value: `miter`, `round`, `bevel`
| `miterLimit` | `Number` | | The limiting value that helps avoid spikes at junctions between connected line segments. The miter limit helps you avoid spikes in paths that use the `miter` `lineJoin` style. If the ratio of the miter length—that is, the diagonal length of the miter join—to the line thickness exceeds the miter limit, the joint is converted to a bevel join. The default miter limit is 10, which results in the conversion of miters whose angle at the joint is less than 11 degrees.
| `geodesic` | `Boolean` | | Boolean to indicate whether to draw each segment of the line as a geodesic as opposed to straight lines on the Mercator projection. A geodesic is the shortest path between two points on the Earth's surface. The geodesic curve is constructed assuming the Earth is a sphere.
| `lineDashPhase` | `Number` | `0` | (iOS only) The offset (in points) at which to start drawing the dash pattern. Use this property to start drawing a dashed line partway through a segment or gap. For example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the middle of the first gap.
Expand Down
4 changes: 3 additions & 1 deletion docs/mapview.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
| `showsBuildings` | `Boolean` | `true` | A Boolean indicating whether the map displays extruded building information.
| `showsTraffic` | `Boolean` | `true` | A Boolean value indicating whether the map displays traffic information.
| `showsIndoors` | `Boolean` | `true` | A Boolean indicating whether indoor maps should be enabled.
| `showsIndoorLevelPicker` | `Boolean` | `false` | A Boolean indicating whether indoor level picker should be enabled. **Note:** Android only.
| `showsIndoorLevelPicker` | `Boolean` | `false` | A Boolean indicating whether indoor level picker should be enabled. **Note:** Google Maps only (either Android or iOS with `PROVIDER_GOOGLE`).
| `zoomEnabled` | `Boolean` | `true` | If `false` the user won't be able to pinch/zoom the map.
| `minZoomLevel` | `Number` | `0` | Minimum zoom value for the map, must be between 0 and 20
| `maxZoomLevel` | `Number` | `20` | Maximum zoom value for the map, must be between 0 and 20
Expand Down Expand Up @@ -64,6 +64,8 @@ To access event data, you will need to use `e.nativeEvent`. For example, `onPres
|---|---|---|
| `animateToRegion` | `region: Region`, `duration: Number` |
| `animateToCoordinate` | `coordinate: LatLng`, `duration: Number` |
| `animateToBearing` | `bearing: Number`, `duration: Number` |
| `animateToViewingAngle` | `angle: Number`, `duration: Number` |
| `fitToElements` | `animated: Boolean` |
| `fitToSuppliedMarkers` | `markerIDs: String[]`, `animated: Boolean` | If you need to use this in `ComponentDidMount`, make sure you put it in a timeout or it will cause performance problems.
| `fitToCoordinates` | `coordinates: Array<LatLng>, options: { edgePadding: EdgePadding, animated: Boolean }` | If called in `ComponentDidMount` in android, it will cause an exception. It is recommended to call it from the MapView `onLayout` event.
Expand Down
24 changes: 24 additions & 0 deletions example/examples/DisplayLatLng.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ class DisplayLatLng extends React.Component {
this.map.animateToCoordinate(this.randomCoordinate());
}

animateToRandomBearing() {
this.map.animateToBearing(this.getRandomFloat(-360, 360));
}

animateToRandomViewingAngle() {
this.map.animateToViewingAngle(this.getRandomFloat(0, 90));
}

getRandomFloat(min, max) {
return (Math.random() * (max - min)) + min;
}

randomCoordinate() {
const region = this.state.region;
return {
Expand Down Expand Up @@ -98,6 +110,18 @@ class DisplayLatLng extends React.Component {
>
<Text style={styles.buttonText}>Animate (Coordinate)</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => this.animateToRandomBearing()}
style={[styles.bubble, styles.button]}
>
<Text style={styles.buttonText}>Animate (Bearing)</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => this.animateToRandomViewingAngle()}
style={[styles.bubble, styles.button]}
>
<Text style={styles.buttonText}>Animate (View Angle)</Text>
</TouchableOpacity>
</View>
</View>
);
Expand Down
156 changes: 156 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import * as React from 'react';

interface MapViewProps {
provider?: 'google';
style: any;
customMapStyle?: any[];
customMapStyleString?: string;
showsUserLocation?: boolean;
userLocationAnnotationTitle?: string;
showsMyLocationButton?: boolean;
followsUserLocation?: boolean;
showsPointsOfInterest?: boolean;
showsCompass?: boolean;
zoomEnabled?: boolean;
rotateEnabled?: boolean;
cacheEnabled?: boolean;
loadingEnabled?: boolean;
loadingBackgroundColor?: any;
loadingIndicatorColor?: any;
scrollEnabled?: boolean;
pitchEnabled?: boolean;
toolbarEnabled?: boolean;
moveOnMarkerPress?: boolean;
showsScale?: boolean;
showsBuildings?: boolean;
showsTraffic?: boolean;
showsIndoors?: boolean;
showsIndoorLevelPicker?: boolean;
mapType?: 'standard' | 'satellite' | 'hybrid' | 'terrain' | 'none';
region?: { latitude: number; longitude: number; latitudeDelta: number; longitudeDelta: number; };
initialRegion?: { latitude: number; longitude: number; latitudeDelta: number; longitudeDelta: number; };
liteMode?: boolean;
maxDelta?: number;
minDelta?: number;
legalLabelInsets?: any;
onChange?: Function;
onMapReady?: Function;
onRegionChange?: Function;
onRegionChangeComplete?: Function;
onPress?: Function;
onLayout?: Function;
onLongPress?: Function;
onPanDrag?: Function;
onMarkerPress?: Function;
onMarkerSelect?: Function;
onMarkerDeselect?: Function;
onCalloutPress?: Function;
onMarkerDragStart?: Function;
onMarkerDrag?: Function;
onMarkerDragEnd?: Function;
minZoomLevel?: number;
maxZoomLevel?: number;
}

declare class MapView extends React.Component<MapViewProps, any> {
static Animated: any;
static AnimatedRegion: any;
}

declare namespace MapView {

type LineCapType = 'butt' | 'round' | 'square';
type LineJoinType = 'miter' | 'round' | 'bevel';

interface MarkerProps {
identifier?: string;
reuseIdentifier?: string;
title?: string;
description?: string;
image?: any;
opacity?: number;
pinColor?: string;
coordinate: { latitude: number; longitude: number };
centerOffset?: { x: number; y: number };
calloutOffset?: { x: number; y: number };
anchor?: { x: number; y: number };
calloutAnchor?: { x: number; y: number };
flat?: boolean;
draggable?: boolean;
onPress?: Function;
onSelect?: Function;
onDeselect?: Function;
onCalloutPress?: Function;
onDragStart?: Function;
onDrag?: Function;
onDragEnd?: Function;
zIndex?: number;
}

interface MapPolylineProps {
coordinates?: { latitude: number; longitude: number; }[];
onPress?: Function;
tappable?: boolean;
fillColor?: string;
strokeWidth?: number;
strokeColor?: string;
zIndex?: number;
lineCap?: LineCapType;
lineJoin?: LineJoinType;
miterLimit?: number;
geodesic?: boolean;
lineDashPhase?: number;
lineDashPattern?: number[];
}

interface MapPolygonProps {
coordinates?: { latitude: number; longitude: number; }[];
holes?: { latitude: number; longitude: number; }[][];
onPress?: Function;
tappable?: boolean;
strokeWidth?: number;
strokeColor?: string;
fillColor?: string;
zIndex?: number;
lineCap?: LineCapType;
lineJoin?: LineJoinType;
miterLimit?: number;
geodesic?: boolean;
lineDashPhase?: number;
lineDashPattern?: number[];
}

interface MapCircleProps {
center: { latitude: number; longitude: number };
radius: number;
onPress?: Function;
strokeWidth?: number;
strokeColor?: string;
fillColor?: string;
zIndex?: number;
lineCap?: LineCapType;
lineJoin?: LineJoinType;
miterLimit?: number;
lineDashPhase?: number;
lineDashPattern?: number[];
}

interface MapUrlTitleProps {
urlTemplate: string;
zIndex?: number;
}

interface MapCalloutProps {
tooltip?: boolean;
onPress?: Function;
}

export class Marker extends React.Component<MarkerProps, any> {}
export class Polyline extends React.Component<MapPolylineProps, any> {}
export class Polygon extends React.Component<MapPolygonProps, any> {}
export class Circle extends React.Component<MapCircleProps, any> {}
export class UrlTile extends React.Component<MapUrlTitleProps, any> {}
export class Callout extends React.Component<MapCalloutProps, any> {}
}

export = MapView;
2 changes: 1 addition & 1 deletion lib/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_CODE=4
VERSION_NAME=0.16.2
VERSION_NAME=0.17.0
GROUP=com.airbnb.android

POM_DESCRIPTION=React Native Map view component for Android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
private static final String REACT_CLASS = "AIRMap";
private static final int ANIMATE_TO_REGION = 1;
private static final int ANIMATE_TO_COORDINATE = 2;
private static final int FIT_TO_ELEMENTS = 3;
private static final int FIT_TO_SUPPLIED_MARKERS = 4;
private static final int FIT_TO_COORDINATES = 5;
private static final int ANIMATE_TO_VIEWING_ANGLE = 3;
private static final int ANIMATE_TO_BEARING = 4;
private static final int FIT_TO_ELEMENTS = 5;
private static final int FIT_TO_SUPPLIED_MARKERS = 6;
private static final int FIT_TO_COORDINATES = 7;

private final Map<String, Integer> MAP_TYPES = MapBuilder.of(
"standard", GoogleMap.MAP_TYPE_NORMAL,
Expand Down Expand Up @@ -200,6 +202,8 @@ public void receiveCommand(AirMapView view, int commandId, @Nullable ReadableArr
Double lng;
Double lngDelta;
Double latDelta;
float bearing;
float angle;
ReadableMap region;

switch (commandId) {
Expand All @@ -225,6 +229,18 @@ public void receiveCommand(AirMapView view, int commandId, @Nullable ReadableArr
view.animateToCoordinate(new LatLng(lat, lng), duration);
break;

case ANIMATE_TO_VIEWING_ANGLE:
angle = (float)args.getDouble(0);
duration = args.getInt(1);
view.animateToViewingAngle(angle, duration);
break;

case ANIMATE_TO_BEARING:
bearing = (float)args.getDouble(0);
duration = args.getInt(1);
view.animateToBearing(bearing, duration);
break;

case FIT_TO_ELEMENTS:
view.fitToElements(args.getBoolean(0));
break;
Expand Down Expand Up @@ -267,6 +283,8 @@ public Map<String, Integer> getCommandsMap() {
return MapBuilder.of(
"animateToRegion", ANIMATE_TO_REGION,
"animateToCoordinate", ANIMATE_TO_COORDINATE,
"animateToViewingAngle", ANIMATE_TO_VIEWING_ANGLE,
"animateToBearing", ANIMATE_TO_BEARING,
"fitToElements", FIT_TO_ELEMENTS,
"fitToSuppliedMarkers", FIT_TO_SUPPLIED_MARKERS,
"fitToCoordinates", FIT_TO_COORDINATES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Animatable;
import android.net.Uri;
Expand Down Expand Up @@ -236,6 +237,9 @@ public void setImage(String uri) {
logoHolder.setController(controller);
} else {
iconBitmapDescriptor = getBitmapDescriptorByName(uri);
if (iconBitmapDescriptor != null) {
iconBitmap = BitmapFactory.decodeResource(getResources(), getDrawableResourceByName(uri));
}
update();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public String getName() {
@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
constants.put("legalNotice", GoogleApiAvailability.getInstance().getOpenSourceSoftwareLicenseInfo(getReactApplicationContext()));
constants.put("legalNotice", "This license information is displayed in Settings > Google > Open Source on any device running Google Play services.");
return constants;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,16 +563,17 @@ public void updateExtraData(Object extraData) {
// a proper camera move
if (boundsToMove != null) {
HashMap<String, Float> data = (HashMap<String, Float>) extraData;
float width = data.get("width");
float height = data.get("height");
map.moveCamera(
CameraUpdateFactory.newLatLngBounds(
boundsToMove,
(int) width,
(int) height,
0
)
);
int width = data.get("width") == null ? 0 : data.get("width").intValue();
int height = data.get("height") == null ? 0 : data.get("height").intValue();

//fix for https://github.com/airbnb/react-native-maps/issues/245,
//it's not guaranteed the passed-in height and width would be greater than 0.
if (width <= 0 || height <= 0) {
map.moveCamera(CameraUpdateFactory.newLatLngBounds(boundsToMove, 0));
} else {
map.moveCamera(CameraUpdateFactory.newLatLngBounds(boundsToMove, width, height, 0));
}

boundsToMove = null;
}
}
Expand All @@ -584,6 +585,26 @@ public void animateToRegion(LatLngBounds bounds, int duration) {
}
}

public void animateToViewingAngle(float angle, int duration) {
if (map != null) {
startMonitoringRegion();
CameraPosition cameraPosition = new CameraPosition.Builder(map.getCameraPosition())
.tilt(angle)
.build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), duration, null);
}
}

public void animateToBearing(float bearing, int duration) {
if (map != null) {
startMonitoringRegion();
CameraPosition cameraPosition = new CameraPosition.Builder(map.getCameraPosition())
.bearing(bearing)
.build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), duration, null);
}
}

public void animateToCoordinate(LatLng coordinate, int duration) {
if (map != null) {
startMonitoringRegion();
Expand Down
Loading

0 comments on commit 7c7b8c2

Please sign in to comment.