Skip to content

Commit c07a062

Browse files
author
Tim Matthews
committed
Merge branch 'master' of github.com:airbnb/react-native-maps
2 parents b96d89b + 12853f0 commit c07a062

27 files changed

+304
-103
lines changed

CHANGELOG.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
# Change Log
22

3+
## 0.11.0 (October 16, 2016)
4+
5+
### Breaking Changes
6+
7+
* Update example app for RN 0.35, fix Gmaps bug for 0.35
8+
[#695](https://github.com/airbnb/react-native-maps/pull/695)
9+
(@spikebrehm)
10+
* Upgraded to RN 0.35
11+
[#680](https://github.com/airbnb/react-native-maps/pull/680)
12+
(@eugenehp)
13+
14+
### Patches
15+
16+
* Update installation.md
17+
[#696](https://github.com/airbnb/react-native-maps/pull/696)
18+
(@securingsincity)
19+
* [android] Fixes crash during Activity onPause()
20+
[#694](https://github.com/airbnb/react-native-maps/pull/694)
21+
(@felipecsl)
22+
* Included MapUrlTile usage in README.md
23+
[#687](https://github.com/airbnb/react-native-maps/pull/687)
24+
(@ochanje210)
25+
* [android] Add parameter to disable the moving on marker press
26+
[#676](https://github.com/airbnb/react-native-maps/pull/676)
27+
(@mlanter)
28+
* Add support for setting zIndex on markers
29+
[#675](https://github.com/airbnb/react-native-maps/pull/675)
30+
(@mlanter)
31+
32+
33+
## 0.10.1 (October 10, 2016)
34+
35+
### Patches
36+
37+
* [android] fix gradle build setup for explorer, bump to gradle 2.2.0
38+
[#666](https://github.com/airbnb/react-native-maps/pull/666)
39+
(@gilbox)
40+
* [android] fix getAirMapName to fix ref-based commands
41+
[#665](https://github.com/airbnb/react-native-maps/pull/665)
42+
(@gilbox)
43+
* Hopefully this release will fix issue [#656](https://github.com/airbnb/react-native-maps/issues/656)
44+
345
## 0.10.0 (October 5, 2016)
446

547
### Breaking Changes

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,30 @@ render() {
135135
</MapView>
136136
```
137137

138+
### Using a custom Tile Overlay
139+
140+
```jsx
141+
<MapView
142+
region={this.state.region}
143+
onRegionChange={this.onRegionChange}
144+
>
145+
<MapView.UrlTile
146+
/**
147+
* The url template of the tile server. The patterns {x} {y} {z} will be replaced at runtime
148+
* For example, http://c.tile.openstreetmap.org/{z}/{x}/{y}.png
149+
*/
150+
urlTemplate={this.state.urlTemplate}
151+
/>
152+
</MapView>
153+
```
154+
155+
For Android: add the following line in your AndroidManifest.xml
156+
```xml
157+
<uses-permission android:name="android.permission.INTERNET" />
158+
```
159+
For IOS: configure [App Transport Security](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33) in your app
160+
161+
138162

139163
## Examples
140164

android/build.gradle

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ buildscript {
99
jcenter()
1010
maven {
1111
// For developing the library outside the context of the example app, expect `react-native`
12-
// to be installed at `./android/node_modules`.
12+
// to be installed at `./node_modules`.
1313
url "$projectDir/../node_modules/react-native/android"
1414
}
1515
maven {
16-
// For developing the example app, expect this library to be installed as a node module
17-
// inside of the example app. So traverse from `./android/example/node_modules/react-native-maps/android`
18-
// to `./android/example/node_modules/react-native/android`.
19-
// react-native should be installed since it's a peer dependency
16+
// For developing the example app.
2017
url "$projectDir/../../react-native/android"
2118
}
2219
}
@@ -29,16 +26,13 @@ allprojects {
2926
repositories {
3027
mavenLocal()
3128
jcenter()
32-
maven {
33-
// For developing the library outside the context of the example app, expect `react-native`
34-
// to be installed at `./android/node_modules`.
35-
url "$projectDir/../node_modules/react-native/android"
36-
}
3729
maven {
38-
// For developing the example app, expect this library to be installed as a node module
39-
// inside of the example app. So traverse from `./android/example/node_modules/react-native-maps/android`
40-
// to `./android/example/node_modules/react-native/android`.
41-
// react-native should be installed since it's a peer dependency
30+
// For developing the library outside the context of the example app, expect `react-native`
31+
// to be installed at `./node_modules`.
32+
url "$projectDir/../node_modules/react-native/android"
33+
}
34+
maven {
35+
// For developing the example app.
4236
url "$projectDir/../../react-native/android"
4337
}
4438
}

android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
VERSION_CODE=2
2-
VERSION_NAME=0.10.0
2+
VERSION_NAME=0.11.0
33
GROUP=com.airbnb.android
44

55
POM_DESCRIPTION=React Native Map view component for Android

android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ protected AirMapView createViewInstance(ThemedReactContext context) {
7272
return new AirMapView(context, this.appContext.getCurrentActivity(), this, this.googleMapOptions);
7373
}
7474

75-
@Override
76-
public void onDropViewInstance(AirMapView view) {
77-
view.doDestroy();
78-
super.onDropViewInstance(view);
79-
}
80-
8175
private void emitMapError(String message, String type) {
8276
WritableMap error = Arguments.createMap();
8377
error.putString("message", message);
@@ -155,22 +149,27 @@ public void setRotateEnabled(AirMapView view, boolean rotateEnabled) {
155149
view.map.getUiSettings().setRotateGesturesEnabled(rotateEnabled);
156150
}
157151

158-
@ReactProp(name="cacheEnabled", defaultBoolean = false)
152+
@ReactProp(name = "cacheEnabled", defaultBoolean = false)
159153
public void setCacheEnabled(AirMapView view, boolean cacheEnabled) {
160154
view.setCacheEnabled(cacheEnabled);
161155
}
162156

163-
@ReactProp(name="loadingEnabled", defaultBoolean = false)
157+
@ReactProp(name = "loadingEnabled", defaultBoolean = false)
164158
public void setLoadingEnabled(AirMapView view, boolean loadingEnabled) {
165159
view.enableMapLoading(loadingEnabled);
166160
}
167161

168-
@ReactProp(name="loadingBackgroundColor", customType="Color")
162+
@ReactProp(name = "moveOnMarkerPress", defaultBoolean = true)
163+
public void setMoveOnMarkerPress(AirMapView view, boolean moveOnPress) {
164+
view.setMoveOnMarkerPress(moveOnPress);
165+
}
166+
167+
@ReactProp(name = "loadingBackgroundColor", customType = "Color")
169168
public void setLoadingBackgroundColor(AirMapView view, @Nullable Integer loadingBackgroundColor) {
170169
view.setLoadingBackgroundColor(loadingBackgroundColor);
171170
}
172171

173-
@ReactProp(name="loadingIndicatorColor", customType="Color")
172+
@ReactProp(name = "loadingIndicatorColor", customType = "Color")
174173
public void setLoadingIndicatorColor(AirMapView view, @Nullable Integer loadingIndicatorColor) {
175174
view.setLoadingIndicatorColor(loadingIndicatorColor);
176175
}

android/src/main/java/com/airbnb/android/react/maps/AirMapMarker.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public class AirMapMarker extends AirMapFeature {
6161
private float rotation = 0.0f;
6262
private boolean flat = false;
6363
private boolean draggable = false;
64+
private int zIndex = 0;
6465

6566
private float calloutAnchorX;
6667
private float calloutAnchorY;
@@ -173,6 +174,14 @@ public void setDraggable(boolean draggable) {
173174
update();
174175
}
175176

177+
public void setZIndex(int zIndex) {
178+
this.zIndex = zIndex;
179+
if (marker != null) {
180+
marker.setZIndex(zIndex);
181+
}
182+
update();
183+
}
184+
176185
public void setMarkerHue(float markerHue) {
177186
this.markerHue = markerHue;
178187
update();
@@ -288,6 +297,7 @@ private MarkerOptions createMarkerOptions() {
288297
options.rotation(rotation);
289298
options.flat(flat);
290299
options.draggable(draggable);
300+
options.zIndex(zIndex);
291301
options.icon(getIcon());
292302
return options;
293303
}

android/src/main/java/com/airbnb/android/react/maps/AirMapMarkerManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ public void setDraggable(AirMapMarker view, boolean draggable) {
116116
view.setDraggable(draggable);
117117
}
118118

119+
@Override
120+
@ReactProp(name = "zIndex", defaultFloat = 0.0f)
121+
public void setZIndex(AirMapMarker view, float zIndex) {
122+
super.setZIndex(view, zIndex);
123+
int integerZIndex = Math.round(zIndex);
124+
view.setZIndex(integerZIndex);
125+
}
126+
119127
@Override
120128
public void addView(AirMapMarker parent, View child, int index) {
121129
// if an <Callout /> component is a child, then it is a callout view, NOT part of the

android/src/main/java/com/airbnb/android/react/maps/AirMapView.java

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import com.google.android.gms.maps.model.LatLng;
4040
import com.google.android.gms.maps.model.LatLngBounds;
4141
import com.google.android.gms.maps.model.Marker;
42-
import com.google.android.gms.maps.model.TileOverlay;
4342

4443
import java.util.ArrayList;
4544
import java.util.Arrays;
@@ -65,6 +64,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
6564
private boolean isMonitoringRegion = false;
6665
private boolean isTouchDown = false;
6766
private boolean handlePanDrag = false;
67+
private boolean moveOnMarkerPress = true;
6868
private boolean cacheEnabled = false;
6969

7070
private static final String[] PERMISSIONS = new String[] {
@@ -75,24 +75,24 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
7575
private final ScaleGestureDetector scaleDetector;
7676
private final GestureDetectorCompat gestureDetector;
7777
private final AirMapManager manager;
78-
private LifecycleEventListener lifecycleListener;
7978
private boolean paused = false;
8079
private final ThemedReactContext context;
8180
private final EventDispatcher eventDispatcher;
8281

83-
public AirMapView(ThemedReactContext context, Context appContext, AirMapManager manager, GoogleMapOptions googleMapOptions) {
82+
public AirMapView(ThemedReactContext reactContext, Context appContext, AirMapManager manager,
83+
GoogleMapOptions googleMapOptions) {
8484
super(appContext, googleMapOptions);
8585

8686
this.manager = manager;
87-
this.context = context;
87+
this.context = reactContext;
8888

8989
super.onCreate(null);
9090
super.onResume();
9191
super.getMapAsync(this);
9292

9393
final AirMapView view = this;
9494
scaleDetector =
95-
new ScaleGestureDetector(context, new ScaleGestureDetector.SimpleOnScaleGestureListener() {
95+
new ScaleGestureDetector(reactContext, new ScaleGestureDetector.SimpleOnScaleGestureListener() {
9696
@Override
9797
public boolean onScaleBegin(ScaleGestureDetector detector) {
9898
view.startMonitoringRegion();
@@ -101,7 +101,7 @@ public boolean onScaleBegin(ScaleGestureDetector detector) {
101101
});
102102

103103
gestureDetector =
104-
new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {
104+
new GestureDetectorCompat(reactContext, new GestureDetector.SimpleOnGestureListener() {
105105
@Override
106106
public boolean onDoubleTap(MotionEvent e) {
107107
view.startMonitoringRegion();
@@ -122,13 +122,13 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
122122
this.addOnLayoutChangeListener(new OnLayoutChangeListener() {
123123
@Override public void onLayoutChange(View v, int left, int top, int right, int bottom,
124124
int oldLeft, int oldTop, int oldRight, int oldBottom) {
125-
if (!AirMapView.this.paused) {
125+
if (!paused) {
126126
AirMapView.this.cacheView();
127127
}
128128
}
129129
});
130130

131-
eventDispatcher = context.getNativeModule(UIManagerModule.class).getEventDispatcher();
131+
eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
132132
}
133133

134134
@Override
@@ -154,7 +154,14 @@ public boolean onMarkerClick(Marker marker) {
154154
event.putString("action", "marker-press");
155155
manager.pushEvent(markerMap.get(marker), "onPress", event);
156156

157-
return false; // returning false opens the callout window, if possible
157+
// Return false to open the callout info window and center on the marker
158+
// https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.OnMarkerClickListener
159+
if (view.moveOnMarkerPress) {
160+
return false;
161+
} else {
162+
marker.showInfoWindow();
163+
return true;
164+
}
158165
}
159166
});
160167

@@ -222,36 +229,32 @@ public void onCameraChange(CameraPosition position) {
222229
// updating location constantly, killing the battery, even though some other location-mgmt
223230
// module may
224231
// desire to shut-down location-services.
225-
lifecycleListener = new LifecycleEventListener() {
226-
@Override
227-
public void onHostResume() {
228-
if (hasPermissions()) {
229-
//noinspection MissingPermission
230-
map.setMyLocationEnabled(showUserLocation);
231-
}
232-
synchronized (AirMapView.this) {
233-
AirMapView.this.onResume();
234-
paused = false;
235-
}
236-
}
232+
LifecycleEventListener lifecycleListener = new LifecycleEventListener() {
233+
@Override
234+
public void onHostResume() {
235+
if (hasPermissions()) {
236+
//noinspection MissingPermission
237+
map.setMyLocationEnabled(showUserLocation);
238+
}
239+
synchronized (AirMapView.this) {
240+
AirMapView.this.onResume();
241+
paused = false;
242+
}
243+
}
237244

238-
@Override
239-
public void onHostPause() {
240-
if (hasPermissions()) {
241-
//noinspection MissingPermission
242-
map.setMyLocationEnabled(false);
243-
}
244-
synchronized (AirMapView.this) {
245-
AirMapView.this.onPause();
246-
paused = true;
247-
}
248-
}
245+
@Override
246+
public void onHostPause() {
247+
if (hasPermissions()) {
248+
//noinspection MissingPermission
249+
map.setMyLocationEnabled(false);
250+
}
251+
paused = true;
252+
}
249253

250-
@Override
251-
public void onHostDestroy() {
252-
AirMapView.this.doDestroy();
253-
}
254-
};
254+
@Override
255+
public void onHostDestroy() {
256+
}
257+
};
255258

256259
context.addLifecycleEventListener(lifecycleListener);
257260
}
@@ -261,20 +264,6 @@ private boolean hasPermissions() {
261264
checkSelfPermission(getContext(), PERMISSIONS[1]) == PackageManager.PERMISSION_GRANTED;
262265
}
263266

264-
/*
265-
onDestroy is final method so I can't override it.
266-
*/
267-
public synchronized void doDestroy() {
268-
if (lifecycleListener != null) {
269-
context.removeLifecycleEventListener(lifecycleListener);
270-
lifecycleListener = null;
271-
}
272-
if (!paused) {
273-
onPause();
274-
}
275-
onDestroy();
276-
}
277-
278267
public void setRegion(ReadableMap region) {
279268
if (region == null) return;
280269

@@ -330,6 +319,10 @@ public void enableMapLoading(boolean loadingEnabled) {
330319
}
331320
}
332321

322+
public void setMoveOnMarkerPress(boolean moveOnPress) {
323+
this.moveOnMarkerPress = moveOnPress;
324+
}
325+
333326
public void setLoadingBackgroundColor(Integer loadingBackgroundColor) {
334327
this.loadingBackgroundColor = loadingBackgroundColor;
335328

0 commit comments

Comments
 (0)