Skip to content

Commit f2597c1

Browse files
author
Tim Matthews
committed
Merge commit '7a5083cbb820faec0bb684c010e15c222ce7e533'
* commit '7a5083cbb820faec0bb684c010e15c222ce7e533': (22 commits) Add an options argument Update README with example Add edgePadding example Add default arguments to fitToCoordinates -Set constant for baseMapPadding used in newLatLngBounds calls -Remove extraenous comment -Port fitToCoordinates functionality over to Android Add example Update docs Add fitToCoordinates method Fix list of examples on Android Support Google Maps on iOS (react-native-maps#548) fix react-native-maps#453 Make MAP_TYPES constant, don't pass `none` mapType to iOS Fix some changes missed in rebase renamed the 'url' property to 'urlTemplate' for consistency with ios added support for tile overlays (MKTileOverlay) changed url template to use {x} {y} {z} pattern replacement initial support for tile overlays Updated Mapview onRegionChange events notes Adding support for Android lite mode ...
2 parents d854912 + 7a5083c commit f2597c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2966
-516
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ local.properties
3333
#
3434
node_modules/
3535
npm-debug.log
36+
Pods/
37+
AirMapsExplorer.xcworkspace/

CHANGELOG.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -23,63 +23,63 @@ This error is caused by a @providesModule declaration with the same name accross
2323

2424
### Patches
2525

26-
- [Android] Use latest available (wildcard version) of RN to build Android ([PR #547](https://github.com/lelandrichardson/react-native-maps/pull/547))
27-
- [Android] Use `Activity` to call `MapsInitialier.initialize()` ([PR #449](https://github.com/lelandrichardson/react-native-maps/pull/449))
28-
- [Android] Fix file path for `AirMapModule` ([PR #526](https://github.com/lelandrichardson/react-native-maps/pull/526))
29-
- [Android] Fix path to React Native in `node_modules` ([PR #527](https://github.com/lelandrichardson/react-native-maps/pull/527))
30-
- [Android] Bump Google Play Services dependency to `9.4.0` ([PR #533](https://github.com/lelandrichardson/react-native-maps/pull/533))
31-
- [iOS] Fix a few warnings ([PR #534](https://github.com/lelandrichardson/react-native-maps/pull/534))
32-
- [JS] Fix ESLint violations ([PR #515](https://github.com/lelandrichardson/react-native-maps/pull/515))
26+
- [Android] Use latest available (wildcard version) of RN to build Android ([PR #547](https://github.com/airbnb/react-native-maps/pull/547))
27+
- [Android] Use `Activity` to call `MapsInitialier.initialize()` ([PR #449](https://github.com/airbnb/react-native-maps/pull/449))
28+
- [Android] Fix file path for `AirMapModule` ([PR #526](https://github.com/airbnb/react-native-maps/pull/526))
29+
- [Android] Fix path to React Native in `node_modules` ([PR #527](https://github.com/airbnb/react-native-maps/pull/527))
30+
- [Android] Bump Google Play Services dependency to `9.4.0` ([PR #533](https://github.com/airbnb/react-native-maps/pull/533))
31+
- [iOS] Fix a few warnings ([PR #534](https://github.com/airbnb/react-native-maps/pull/534))
32+
- [JS] Fix ESLint violations ([PR #515](https://github.com/airbnb/react-native-maps/pull/515))
3333

3434
## 0.8.0 (August 30, 2016)
3535

3636
### Breaking Changes
3737

38-
- Upgrade to `react-native@0.32.0`, and update Android code to match ([#502](https://github.com/lelandrichardson/react-native-maps/pull/502))
38+
- Upgrade to `react-native@0.32.0`, and update Android code to match ([#502](https://github.com/airbnb/react-native-maps/pull/502))
3939

4040
### Patches
4141

42-
- [android] Add `showsMyLocationButton` prop ([#382](https://github.com/lelandrichardson/react-native-maps/pull/382))
42+
- [android] Add `showsMyLocationButton` prop ([#382](https://github.com/airbnb/react-native-maps/pull/382))
4343

44-
- Add `fitToSuppliedMarkers()` method ([#386](https://github.com/lelandrichardson/react-native-maps/pull/386))
44+
- Add `fitToSuppliedMarkers()` method ([#386](https://github.com/airbnb/react-native-maps/pull/386))
4545

46-
- [ios] Update AirMapMarker to use loadImageWithURLRequest ([#389](https://github.com/lelandrichardson/react-native-maps/pull/389))
46+
- [ios] Update AirMapMarker to use loadImageWithURLRequest ([#389](https://github.com/airbnb/react-native-maps/pull/389))
4747

48-
- Improvements to watch and copy script ([#445](https://github.com/lelandrichardson/react-native-maps/pull/445))
48+
- Improvements to watch and copy script ([#445](https://github.com/airbnb/react-native-maps/pull/445))
4949

50-
- [ios] Added check on marker class in predicate ([#485](https://github.com/lelandrichardson/react-native-maps/pull/485))
50+
- [ios] Added check on marker class in predicate ([#485](https://github.com/airbnb/react-native-maps/pull/485))
5151

52-
- Use `StyleSheet.absoluteFillObject` where appropriate ([#500](https://github.com/lelandrichardson/react-native-maps/pull/500)) and ([#493](https://github.com/lelandrichardson/react-native-maps/pull/493))
52+
- Use `StyleSheet.absoluteFillObject` where appropriate ([#500](https://github.com/airbnb/react-native-maps/pull/500)) and ([#493](https://github.com/airbnb/react-native-maps/pull/493))
5353

54-
- Add ESLint and fix a number of linting violations ([#501](https://github.com/lelandrichardson/react-native-maps/pull/501))
54+
- Add ESLint and fix a number of linting violations ([#501](https://github.com/airbnb/react-native-maps/pull/501))
5555

56-
- Remove unused `NativeMethodsMixin` for compat with RN 0.32 ([#511](https://github.com/lelandrichardson/react-native-maps/pull/511))
56+
- Remove unused `NativeMethodsMixin` for compat with RN 0.32 ([#511](https://github.com/airbnb/react-native-maps/pull/511))
5757

5858

5959
## 0.7.1 (July 9, 2016)
6060

6161
### Patches
6262

63-
- Fix iOS CocoaPods Issue ([#308](https://github.com/lelandrichardson/react-native-maps/pull/308))
63+
- Fix iOS CocoaPods Issue ([#308](https://github.com/airbnb/react-native-maps/pull/308))
6464

6565

6666

6767
## 0.7.0 (July 9, 2016)
6868

6969
### Breaking Changes
7070

71-
- RN 0.29 compatibility changes ([#363](https://github.com/lelandrichardson/react-native-maps/pull/363) and [#370](https://github.com/lelandrichardson/react-native-maps/pull/370))
71+
- RN 0.29 compatibility changes ([#363](https://github.com/airbnb/react-native-maps/pull/363) and [#370](https://github.com/airbnb/react-native-maps/pull/370))
7272

7373

7474
### Patches
7575

76-
- Fixing scrolling map inside a scrollView ([#343](https://github.com/lelandrichardson/react-native-maps/pull/343))
76+
- Fixing scrolling map inside a scrollView ([#343](https://github.com/airbnb/react-native-maps/pull/343))
7777

78-
- Fix shouldUsePinView ([#344](https://github.com/lelandrichardson/react-native-maps/pull/344))
78+
- Fix shouldUsePinView ([#344](https://github.com/airbnb/react-native-maps/pull/344))
7979

80-
- Not calling setLoadingIndicatorColor when null ([#337](https://github.com/lelandrichardson/react-native-maps/pull/337))
80+
- Not calling setLoadingIndicatorColor when null ([#337](https://github.com/airbnb/react-native-maps/pull/337))
8181

82-
- Fixes `Undefined symbols for architecture x86_64: “std::terminate()”` ([#329](https://github.com/lelandrichardson/react-native-maps/pull/329))
82+
- Fixes `Undefined symbols for architecture x86_64: “std::terminate()”` ([#329](https://github.com/airbnb/react-native-maps/pull/329))
8383

8484

8585

README.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ React Native Map components for iOS + Android
66

77
See [Installation Instructions](docs/installation.md).
88

9+
See [Setup Instructions for the Included Example Project](docs/examples-setup.md).
10+
911
## Compatibility
1012

1113
Due to the rapid changes being made in the React Native ecosystem, we are not officially going to
@@ -240,6 +242,11 @@ Markers are draggable, and emit continuous drag events to update other UI during
240242

241243
![](http://i.giphy.com/l2JImnZxdv1WbpQfC.gif) ![](http://i.giphy.com/l2JIhv4Jx6Ugx1EGI.gif)
242244

245+
### Lite Mode ( Android )
246+
247+
Enable lite mode on Android with `liteMode` prop. Ideal when having multiple maps in a View or ScrollView.
248+
249+
![](http://i.giphy.com/qZ2lAf18s89na.gif)
243250

244251
## Component API
245252

@@ -362,6 +369,12 @@ Pass an array of marker identifiers to have the map re-focus.
362369

363370
![](http://i.giphy.com/3o7qEbOQnO0yoXqKJ2.gif) ![](http://i.giphy.com/l41YdrQZ7m6Dz4h0c.gif)
364371

372+
### Zoom to Specified Coordinates
373+
374+
Pass an array of coordinates to focus a map region on said coordinates.
375+
376+
![](https://cloud.githubusercontent.com/assets/1627824/18609960/da5d9e06-7cdc-11e6-811e-34e255093df9.gif)
377+
365378
### Troubleshooting
366379

367380
#### My map is blank
@@ -417,7 +430,7 @@ License
417430
you may not use this file except in compliance with the License.
418431
You may obtain a copy of the License at
419432

420-
https://raw.githubusercontent.com/lelandrichardson/react-native-maps/master/LICENSE
433+
https://raw.githubusercontent.com/airbnb/react-native-maps/master/LICENSE
421434

422435
Unless required by applicable law or agreed to in writing, software
423436
distributed under the License is distributed on an "AS IS" BASIS,

android/gradle.properties

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ VERSION_NAME=0.8.2
33
GROUP=com.airbnb.android
44

55
POM_DESCRIPTION=React Native Map view component for Android
6-
POM_URL=https://github.com/lelandrichardson/react-native-maps/tree/new-scv
7-
POM_SCM_URL=https://github.com/lelandrichardson/react-native-maps/tree/new-scv
8-
POM_SCM_CONNECTION=scm:git@github.com:lelandrichardson/react-native-maps.git
9-
POM_SCM_DEV_CONNECTION=scm:git@github.com:lelandrichardson/react-native-maps.git
6+
POM_URL=https://github.com/airbnb/react-native-maps/tree/new-scv
7+
POM_SCM_URL=https://github.com/airbnb/react-native-maps/tree/new-scv
8+
POM_SCM_CONNECTION=scm:git@github.com:airbnb/react-native-maps.git
9+
POM_SCM_DEV_CONNECTION=scm:git@github.com:airbnb/react-native-maps.git
1010
POM_LICENSE_NAME=MIT
11-
POM_LICENSE_URL=https://github.com/lelandrichardson/react-native-maps/blob/master/LICENSE
11+
POM_LICENSE_URL=https://github.com/airbnb/react-native-maps/blob/master/LICENSE
1212
POM_LICENSE_DIST=repo
13-
POM_DEVELOPER_ID=lelandrichardson
13+
POM_DEVELOPER_ID=airbnb
1414
POM_DEVELOPER_NAME=Leland Richardson
1515

1616
POM_NAME=ReactNative Maps library
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.airbnb.android.react.maps;
2+
3+
import com.facebook.react.bridge.ReactApplicationContext;
4+
import com.google.android.gms.maps.GoogleMapOptions;
5+
6+
public class AirMapLiteManager extends AirMapManager {
7+
8+
private static final String REACT_CLASS = "AIRMapLite";
9+
10+
@Override
11+
public String getName() {
12+
return REACT_CLASS;
13+
}
14+
15+
public AirMapLiteManager(ReactApplicationContext context) {
16+
super(context);
17+
this.googleMapOptions = new GoogleMapOptions().liteMode(true);
18+
}
19+
20+
}

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

+14-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.facebook.react.uimanager.annotations.ReactProp;
1717
import com.facebook.react.uimanager.events.RCTEventEmitter;
1818
import com.google.android.gms.maps.GoogleMap;
19+
import com.google.android.gms.maps.GoogleMapOptions;
1920
import com.google.android.gms.maps.MapsInitializer;
2021
import com.google.android.gms.maps.model.LatLng;
2122
import com.google.android.gms.maps.model.LatLngBounds;
@@ -31,20 +32,25 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
3132
private static final int ANIMATE_TO_COORDINATE = 2;
3233
private static final int FIT_TO_ELEMENTS = 3;
3334
private static final int FIT_TO_SUPPLIED_MARKERS = 4;
35+
private static final int FIT_TO_COORDINATES = 5;
3436

3537
private final Map<String, Integer> MAP_TYPES = MapBuilder.of(
3638
"standard", GoogleMap.MAP_TYPE_NORMAL,
3739
"satellite", GoogleMap.MAP_TYPE_SATELLITE,
3840
"hybrid", GoogleMap.MAP_TYPE_HYBRID,
39-
"terrain", GoogleMap.MAP_TYPE_TERRAIN
41+
"terrain", GoogleMap.MAP_TYPE_TERRAIN,
42+
"none", GoogleMap.MAP_TYPE_NONE
4043
);
4144

4245
private ReactContext reactContext;
4346

4447
private final ReactApplicationContext appContext;
4548

49+
protected GoogleMapOptions googleMapOptions;
50+
4651
public AirMapManager(ReactApplicationContext context) {
4752
this.appContext = context;
53+
this.googleMapOptions = new GoogleMapOptions();
4854
}
4955

5056
@Override
@@ -57,13 +63,13 @@ protected AirMapView createViewInstance(ThemedReactContext context) {
5763
reactContext = context;
5864

5965
try {
60-
MapsInitializer.initialize(new AirMapModule(this.appContext).getActivity());
66+
MapsInitializer.initialize(this.appContext);
6167
} catch (RuntimeException e) {
6268
e.printStackTrace();
6369
emitMapError("Map initialize error", "map_init_error");
6470
}
6571

66-
return new AirMapView(context, this.appContext, this);
72+
return new AirMapView(context, this.appContext.getCurrentActivity(), this, this.googleMapOptions);
6773
}
6874

6975
@Override
@@ -213,6 +219,9 @@ public void receiveCommand(AirMapView view, int commandId, @Nullable ReadableArr
213219
case FIT_TO_SUPPLIED_MARKERS:
214220
view.fitToSuppliedMarkers(args.getArray(0), args.getBoolean(1));
215221
break;
222+
case FIT_TO_COORDINATES:
223+
view.fitToCoordinates(args.getArray(0), args.getMap(1), args.getBoolean(2));
224+
break;
216225
}
217226
}
218227

@@ -246,7 +255,8 @@ public Map<String, Integer> getCommandsMap() {
246255
"animateToRegion", ANIMATE_TO_REGION,
247256
"animateToCoordinate", ANIMATE_TO_COORDINATE,
248257
"fitToElements", FIT_TO_ELEMENTS,
249-
"fitToSuppliedMarkers", FIT_TO_SUPPLIED_MARKERS
258+
"fitToSuppliedMarkers", FIT_TO_SUPPLIED_MARKERS,
259+
"fitToCoordinates", FIT_TO_COORDINATES
250260
);
251261
}
252262

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

-22
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.airbnb.android.react.maps;
2+
3+
import android.content.Context;
4+
5+
import com.google.android.gms.maps.GoogleMap;
6+
import com.google.android.gms.maps.model.TileOverlay;
7+
import com.google.android.gms.maps.model.TileOverlayOptions;
8+
import com.google.android.gms.maps.model.UrlTileProvider;
9+
10+
import java.net.MalformedURLException;
11+
import java.net.URL;
12+
13+
public class AirMapUrlTile extends AirMapFeature {
14+
15+
class AIRMapUrlTileProvider extends UrlTileProvider
16+
{
17+
private String urlTemplate;
18+
public AIRMapUrlTileProvider(int width, int height, String urlTemplate) {
19+
super(width, height);
20+
this.urlTemplate = urlTemplate;
21+
}
22+
@Override
23+
public synchronized URL getTileUrl(int x, int y, int zoom) {
24+
25+
String s = this.urlTemplate
26+
.replace("{x}", Integer.toString(x))
27+
.replace("{y}", Integer.toString(y))
28+
.replace("{z}", Integer.toString(zoom));
29+
URL url = null;
30+
try {
31+
url = new URL(s);
32+
} catch (MalformedURLException e) {
33+
throw new AssertionError(e);
34+
}
35+
return url;
36+
}
37+
38+
public void setUrlTemplate(String urlTemplate) {
39+
this.urlTemplate = urlTemplate;
40+
}
41+
}
42+
43+
private TileOverlayOptions tileOverlayOptions;
44+
private TileOverlay tileOverlay;
45+
private AIRMapUrlTileProvider tileProvider;
46+
47+
private String urlTemplate;
48+
private float zIndex;
49+
50+
public AirMapUrlTile(Context context) {
51+
super(context);
52+
}
53+
54+
public void setUrlTemplate(String urlTemplate) {
55+
this.urlTemplate = urlTemplate;
56+
if (tileProvider != null) {
57+
tileProvider.setUrlTemplate(urlTemplate);
58+
}
59+
if (tileOverlay != null) {
60+
tileOverlay.clearTileCache();
61+
}
62+
}
63+
64+
public void setZIndex(float zIndex) {
65+
this.zIndex = zIndex;
66+
if (tileOverlay != null) {
67+
tileOverlay.setZIndex(zIndex);
68+
}
69+
}
70+
71+
public TileOverlayOptions getTileOverlayOptions() {
72+
if (tileOverlayOptions == null) {
73+
tileOverlayOptions = createTileOverlayOptions();
74+
}
75+
return tileOverlayOptions;
76+
}
77+
78+
private TileOverlayOptions createTileOverlayOptions() {
79+
TileOverlayOptions options = new TileOverlayOptions();
80+
options.zIndex(zIndex);
81+
this.tileProvider = new AIRMapUrlTileProvider(256, 256, this.urlTemplate);
82+
options.tileProvider(this.tileProvider);
83+
return options;
84+
}
85+
86+
@Override
87+
public Object getFeature() {
88+
return tileOverlay;
89+
}
90+
91+
@Override
92+
public void addToMap(GoogleMap map) {
93+
this.tileOverlay = map.addTileOverlay(getTileOverlayOptions());
94+
}
95+
96+
@Override
97+
public void removeFromMap(GoogleMap map) {
98+
tileOverlay.remove();
99+
}
100+
}

0 commit comments

Comments
 (0)