Skip to content

Commit

Permalink
Merge commit '7a5083cbb820faec0bb684c010e15c222ce7e533'
Browse files Browse the repository at this point in the history
* 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
  ...
  • Loading branch information
Tim Matthews committed Sep 26, 2016
2 parents d854912 + 7a5083c commit f2597c1
Show file tree
Hide file tree
Showing 77 changed files with 2,966 additions and 516 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ local.properties
#
node_modules/
npm-debug.log
Pods/
AirMapsExplorer.xcworkspace/
44 changes: 22 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,63 +23,63 @@ This error is caused by a @providesModule declaration with the same name accross

### Patches

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

## 0.8.0 (August 30, 2016)

### Breaking Changes

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

### Patches

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

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

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

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

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

- 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))
- 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))

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

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


## 0.7.1 (July 9, 2016)

### Patches

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



## 0.7.0 (July 9, 2016)

### Breaking Changes

- 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))
- 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))


### Patches

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

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

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

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



Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ React Native Map components for iOS + Android

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

See [Setup Instructions for the Included Example Project](docs/examples-setup.md).

## Compatibility

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

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

### Lite Mode ( Android )

Enable lite mode on Android with `liteMode` prop. Ideal when having multiple maps in a View or ScrollView.

![](http://i.giphy.com/qZ2lAf18s89na.gif)

## Component API

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

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

### Zoom to Specified Coordinates

Pass an array of coordinates to focus a map region on said coordinates.

![](https://cloud.githubusercontent.com/assets/1627824/18609960/da5d9e06-7cdc-11e6-811e-34e255093df9.gif)

### Troubleshooting

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

https://raw.githubusercontent.com/lelandrichardson/react-native-maps/master/LICENSE
https://raw.githubusercontent.com/airbnb/react-native-maps/master/LICENSE

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
12 changes: 6 additions & 6 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ VERSION_NAME=0.8.2
GROUP=com.airbnb.android

POM_DESCRIPTION=React Native Map view component for Android
POM_URL=https://github.com/lelandrichardson/react-native-maps/tree/new-scv
POM_SCM_URL=https://github.com/lelandrichardson/react-native-maps/tree/new-scv
POM_SCM_CONNECTION=scm:git@github.com:lelandrichardson/react-native-maps.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:lelandrichardson/react-native-maps.git
POM_URL=https://github.com/airbnb/react-native-maps/tree/new-scv
POM_SCM_URL=https://github.com/airbnb/react-native-maps/tree/new-scv
POM_SCM_CONNECTION=scm:git@github.com:airbnb/react-native-maps.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:airbnb/react-native-maps.git
POM_LICENSE_NAME=MIT
POM_LICENSE_URL=https://github.com/lelandrichardson/react-native-maps/blob/master/LICENSE
POM_LICENSE_URL=https://github.com/airbnb/react-native-maps/blob/master/LICENSE
POM_LICENSE_DIST=repo
POM_DEVELOPER_ID=lelandrichardson
POM_DEVELOPER_ID=airbnb
POM_DEVELOPER_NAME=Leland Richardson

POM_NAME=ReactNative Maps library
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.airbnb.android.react.maps;

import com.facebook.react.bridge.ReactApplicationContext;
import com.google.android.gms.maps.GoogleMapOptions;

public class AirMapLiteManager extends AirMapManager {

private static final String REACT_CLASS = "AIRMapLite";

@Override
public String getName() {
return REACT_CLASS;
}

public AirMapLiteManager(ReactApplicationContext context) {
super(context);
this.googleMapOptions = new GoogleMapOptions().liteMode(true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMapOptions;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
Expand All @@ -31,20 +32,25 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
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 final Map<String, Integer> MAP_TYPES = MapBuilder.of(
"standard", GoogleMap.MAP_TYPE_NORMAL,
"satellite", GoogleMap.MAP_TYPE_SATELLITE,
"hybrid", GoogleMap.MAP_TYPE_HYBRID,
"terrain", GoogleMap.MAP_TYPE_TERRAIN
"terrain", GoogleMap.MAP_TYPE_TERRAIN,
"none", GoogleMap.MAP_TYPE_NONE
);

private ReactContext reactContext;

private final ReactApplicationContext appContext;

protected GoogleMapOptions googleMapOptions;

public AirMapManager(ReactApplicationContext context) {
this.appContext = context;
this.googleMapOptions = new GoogleMapOptions();
}

@Override
Expand All @@ -57,13 +63,13 @@ protected AirMapView createViewInstance(ThemedReactContext context) {
reactContext = context;

try {
MapsInitializer.initialize(new AirMapModule(this.appContext).getActivity());
MapsInitializer.initialize(this.appContext);
} catch (RuntimeException e) {
e.printStackTrace();
emitMapError("Map initialize error", "map_init_error");
}

return new AirMapView(context, this.appContext, this);
return new AirMapView(context, this.appContext.getCurrentActivity(), this, this.googleMapOptions);
}

@Override
Expand Down Expand Up @@ -213,6 +219,9 @@ public void receiveCommand(AirMapView view, int commandId, @Nullable ReadableArr
case FIT_TO_SUPPLIED_MARKERS:
view.fitToSuppliedMarkers(args.getArray(0), args.getBoolean(1));
break;
case FIT_TO_COORDINATES:
view.fitToCoordinates(args.getArray(0), args.getMap(1), args.getBoolean(2));
break;
}
}

Expand Down Expand Up @@ -246,7 +255,8 @@ public Map<String, Integer> getCommandsMap() {
"animateToRegion", ANIMATE_TO_REGION,
"animateToCoordinate", ANIMATE_TO_COORDINATE,
"fitToElements", FIT_TO_ELEMENTS,
"fitToSuppliedMarkers", FIT_TO_SUPPLIED_MARKERS
"fitToSuppliedMarkers", FIT_TO_SUPPLIED_MARKERS,
"fitToCoordinates", FIT_TO_COORDINATES
);
}

Expand Down

This file was deleted.

100 changes: 100 additions & 0 deletions android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package com.airbnb.android.react.maps;

import android.content.Context;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.TileOverlay;
import com.google.android.gms.maps.model.TileOverlayOptions;
import com.google.android.gms.maps.model.UrlTileProvider;

import java.net.MalformedURLException;
import java.net.URL;

public class AirMapUrlTile extends AirMapFeature {

class AIRMapUrlTileProvider extends UrlTileProvider
{
private String urlTemplate;
public AIRMapUrlTileProvider(int width, int height, String urlTemplate) {
super(width, height);
this.urlTemplate = urlTemplate;
}
@Override
public synchronized URL getTileUrl(int x, int y, int zoom) {

String s = this.urlTemplate
.replace("{x}", Integer.toString(x))
.replace("{y}", Integer.toString(y))
.replace("{z}", Integer.toString(zoom));
URL url = null;
try {
url = new URL(s);
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
return url;
}

public void setUrlTemplate(String urlTemplate) {
this.urlTemplate = urlTemplate;
}
}

private TileOverlayOptions tileOverlayOptions;
private TileOverlay tileOverlay;
private AIRMapUrlTileProvider tileProvider;

private String urlTemplate;
private float zIndex;

public AirMapUrlTile(Context context) {
super(context);
}

public void setUrlTemplate(String urlTemplate) {
this.urlTemplate = urlTemplate;
if (tileProvider != null) {
tileProvider.setUrlTemplate(urlTemplate);
}
if (tileOverlay != null) {
tileOverlay.clearTileCache();
}
}

public void setZIndex(float zIndex) {
this.zIndex = zIndex;
if (tileOverlay != null) {
tileOverlay.setZIndex(zIndex);
}
}

public TileOverlayOptions getTileOverlayOptions() {
if (tileOverlayOptions == null) {
tileOverlayOptions = createTileOverlayOptions();
}
return tileOverlayOptions;
}

private TileOverlayOptions createTileOverlayOptions() {
TileOverlayOptions options = new TileOverlayOptions();
options.zIndex(zIndex);
this.tileProvider = new AIRMapUrlTileProvider(256, 256, this.urlTemplate);
options.tileProvider(this.tileProvider);
return options;
}

@Override
public Object getFeature() {
return tileOverlay;
}

@Override
public void addToMap(GoogleMap map) {
this.tileOverlay = map.addTileOverlay(getTileOverlayOptions());
}

@Override
public void removeFromMap(GoogleMap map) {
tileOverlay.remove();
}
}
Loading

0 comments on commit f2597c1

Please sign in to comment.