forked from react-native-maps/react-native-maps
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ...
- Loading branch information
Showing
77 changed files
with
2,966 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,5 @@ local.properties | |
# | ||
node_modules/ | ||
npm-debug.log | ||
Pods/ | ||
AirMapsExplorer.xcworkspace/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
android/src/main/java/com/airbnb/android/react/maps/AirMapLiteManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
android/src/main/java/com/airbnb/android/react/maps/AirMapModule.java
This file was deleted.
Oops, something went wrong.
100 changes: 100 additions & 0 deletions
100
android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.