react-native-maps 0.29.4 → 0.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/index.d.ts +25 -10
- package/index.js +1 -3
- package/lib/android/build.gradle +3 -1
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapTileProvider.java +515 -0
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapTileWorker.java +122 -0
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTile.java +124 -55
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTileManager.java +34 -0
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +6 -1
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapWMSTile.java +31 -87
- package/lib/android/src/main/java/com/airbnb/android/react/maps/AirMapWMSTileManager.java +22 -2
- package/lib/components/AnimatedRegion.js +67 -101
- package/lib/components/Geojson.js +67 -40
- package/lib/components/MapCallout.js +3 -5
- package/lib/components/MapCalloutSubview.js +3 -5
- package/lib/components/MapCircle.js +6 -6
- package/lib/components/MapHeatmap.js +5 -7
- package/lib/components/MapLocalTile.js +2 -6
- package/lib/components/MapMarker.js +9 -9
- package/lib/components/MapOverlay.js +3 -2
- package/lib/components/MapPolygon.js +6 -6
- package/lib/components/MapPolyline.js +6 -6
- package/lib/components/MapUrlTile.js +56 -8
- package/lib/components/MapView.js +12 -14
- package/lib/components/MapWMSTile.js +51 -8
- package/lib/components/decorateMapComponent.js +1 -1
- package/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.h +1 -0
- package/lib/ios/AirGoogleMaps/AIRGoogleMapMarker.m +8 -0
- package/lib/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +1 -0
- package/lib/ios/AirMaps/AIRMapManager.m +6 -1
- package/lib/ios/AirMaps/AIRMapMarkerManager.m +1 -0
- package/lib/ios/AirMaps/AIRMapUrlTile.h +22 -4
- package/lib/ios/AirMaps/AIRMapUrlTile.m +124 -34
- package/lib/ios/AirMaps/AIRMapUrlTileCachedOverlay.h +17 -0
- package/lib/ios/AirMaps/AIRMapUrlTileCachedOverlay.m +235 -0
- package/lib/ios/AirMaps/AIRMapUrlTileManager.m +6 -1
- package/lib/ios/AirMaps/AIRMapWMSTile.h +10 -16
- package/lib/ios/AirMaps/AIRMapWMSTile.m +68 -101
- package/lib/ios/AirMaps/AIRMapWMSTileManager.m +6 -1
- package/lib/ios/AirMaps.xcodeproj/project.pbxproj +7 -1
- package/package.json +43 -6
- package/react-native-google-maps.podspec +2 -2
- package/.eslintrc +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -111
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -32
- package/.github/ISSUE_TEMPLATE.md +0 -5
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -53
- package/.github/stale.yml +0 -17
- package/.github/workflows/base.yml +0 -21
- package/.prettierrc +0 -4
- package/CHANGELOG.md +0 -761
- package/docs/callout.md +0 -38
- package/docs/circle.md +0 -28
- package/docs/examples-setup.md +0 -17
- package/docs/geojson.md +0 -50
- package/docs/heatmap.md +0 -32
- package/docs/installation.md +0 -347
- package/docs/mapview.md +0 -252
- package/docs/marker.md +0 -84
- package/docs/overlay.md +0 -27
- package/docs/polygon.md +0 -34
- package/docs/polyline.md +0 -65
- package/enable-google-maps +0 -15
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
package com.airbnb.android.react.maps;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
|
|
7
|
+
import androidx.annotation.NonNull;
|
|
8
|
+
import androidx.work.Worker;
|
|
9
|
+
import androidx.work.WorkerParameters;
|
|
10
|
+
|
|
11
|
+
import java.io.ByteArrayOutputStream;
|
|
12
|
+
import java.io.File;
|
|
13
|
+
import java.io.FileInputStream;
|
|
14
|
+
import java.io.FileOutputStream;
|
|
15
|
+
import java.io.InputStream;
|
|
16
|
+
import java.io.OutputStream;
|
|
17
|
+
import java.io.IOException;
|
|
18
|
+
|
|
19
|
+
import java.net.MalformedURLException;
|
|
20
|
+
import java.net.URL;
|
|
21
|
+
|
|
22
|
+
public class AirMapTileWorker extends Worker {
|
|
23
|
+
private static final int BUFFER_SIZE = 16 * 1024;
|
|
24
|
+
|
|
25
|
+
public AirMapTileWorker(
|
|
26
|
+
@NonNull Context context,
|
|
27
|
+
@NonNull WorkerParameters params) {
|
|
28
|
+
super(context, params);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Override
|
|
32
|
+
public Result doWork() {
|
|
33
|
+
byte[] image = null;
|
|
34
|
+
URL url = null;
|
|
35
|
+
String fileName = getInputData().getString("filename");
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
int tileCacheMaxAge = getInputData().getInt("maxAge", 0);
|
|
39
|
+
if (tileCacheMaxAge >= 0) {
|
|
40
|
+
File file = new File(fileName);
|
|
41
|
+
long lastModified = file.lastModified();
|
|
42
|
+
long now = System.currentTimeMillis();
|
|
43
|
+
if ((now - lastModified) / 1000 < tileCacheMaxAge) return Result.failure();
|
|
44
|
+
}
|
|
45
|
+
} catch (Error e) {
|
|
46
|
+
return Result.failure();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
url = new URL(getInputData().getString("url"));
|
|
51
|
+
} catch (MalformedURLException e) {
|
|
52
|
+
throw new AssertionError(e);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
image = fetchTile(url);
|
|
56
|
+
if (image != null) {
|
|
57
|
+
boolean success = writeTileImage(image, fileName);
|
|
58
|
+
if (!success) {
|
|
59
|
+
return Result.failure();
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
return Result.retry();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Indicate whether the work finished successfully with the Result
|
|
66
|
+
Log.d("urlTile", "Worker fetched " + fileName);
|
|
67
|
+
return Result.success();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private byte[] fetchTile(URL url) {
|
|
71
|
+
ByteArrayOutputStream buffer = null;
|
|
72
|
+
InputStream in = null;
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
in = url.openStream();
|
|
76
|
+
buffer = new ByteArrayOutputStream();
|
|
77
|
+
|
|
78
|
+
int nRead;
|
|
79
|
+
byte[] data = new byte[BUFFER_SIZE];
|
|
80
|
+
|
|
81
|
+
while ((nRead = in.read(data, 0, BUFFER_SIZE)) != -1) {
|
|
82
|
+
buffer.write(data, 0, nRead);
|
|
83
|
+
}
|
|
84
|
+
buffer.flush();
|
|
85
|
+
|
|
86
|
+
return buffer.toByteArray();
|
|
87
|
+
} catch (IOException e) {
|
|
88
|
+
e.printStackTrace();
|
|
89
|
+
return null;
|
|
90
|
+
} catch (OutOfMemoryError e) {
|
|
91
|
+
e.printStackTrace();
|
|
92
|
+
return null;
|
|
93
|
+
} finally {
|
|
94
|
+
if (in != null) try { in.close(); } catch (Exception ignored) {}
|
|
95
|
+
if (buffer != null) try { buffer.close(); } catch (Exception ignored) {}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private boolean writeTileImage(byte[] image, String fileName) {
|
|
100
|
+
OutputStream out = null;
|
|
101
|
+
if (fileName == null) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
File file = new File(fileName);
|
|
107
|
+
file.getParentFile().mkdirs();
|
|
108
|
+
out = new FileOutputStream(file);
|
|
109
|
+
out.write(image);
|
|
110
|
+
|
|
111
|
+
return true;
|
|
112
|
+
} catch (IOException e) {
|
|
113
|
+
e.printStackTrace();
|
|
114
|
+
return false;
|
|
115
|
+
} catch (OutOfMemoryError e) {
|
|
116
|
+
e.printStackTrace();
|
|
117
|
+
return false;
|
|
118
|
+
} finally {
|
|
119
|
+
if (out != null) try { out.close(); } catch (Exception ignored) {}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -1,71 +1,39 @@
|
|
|
1
1
|
package com.airbnb.android.react.maps;
|
|
2
2
|
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
3
5
|
import android.content.Context;
|
|
4
6
|
|
|
5
7
|
import com.google.android.gms.maps.GoogleMap;
|
|
6
8
|
import com.google.android.gms.maps.model.TileOverlay;
|
|
7
9
|
import com.google.android.gms.maps.model.TileOverlayOptions;
|
|
8
|
-
import com.google.android.gms.maps.model.UrlTileProvider;
|
|
9
10
|
|
|
10
11
|
import java.net.MalformedURLException;
|
|
11
12
|
import java.net.URL;
|
|
12
13
|
|
|
13
14
|
public class AirMapUrlTile extends AirMapFeature {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.replace("{y}", Integer.toString(y))
|
|
33
|
-
.replace("{z}", Integer.toString(zoom));
|
|
34
|
-
URL url = null;
|
|
35
|
-
|
|
36
|
-
if(AirMapUrlTile.this.maximumZ > 0 && zoom > maximumZ) {
|
|
37
|
-
return url;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if(AirMapUrlTile.this.minimumZ > 0 && zoom < minimumZ) {
|
|
41
|
-
return url;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
url = new URL(s);
|
|
46
|
-
} catch (MalformedURLException e) {
|
|
47
|
-
throw new AssertionError(e);
|
|
48
|
-
}
|
|
49
|
-
return url;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public void setUrlTemplate(String urlTemplate) {
|
|
53
|
-
this.urlTemplate = urlTemplate;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private TileOverlayOptions tileOverlayOptions;
|
|
58
|
-
private TileOverlay tileOverlay;
|
|
59
|
-
private AIRMapUrlTileProvider tileProvider;
|
|
60
|
-
|
|
61
|
-
private String urlTemplate;
|
|
62
|
-
private float zIndex;
|
|
63
|
-
private float maximumZ;
|
|
64
|
-
private float minimumZ;
|
|
65
|
-
private boolean flipY;
|
|
15
|
+
protected TileOverlayOptions tileOverlayOptions;
|
|
16
|
+
protected TileOverlay tileOverlay;
|
|
17
|
+
protected AirMapTileProvider tileProvider;
|
|
18
|
+
|
|
19
|
+
protected String urlTemplate;
|
|
20
|
+
protected float zIndex;
|
|
21
|
+
protected float maximumZ;
|
|
22
|
+
protected float maximumNativeZ = 100;
|
|
23
|
+
protected float minimumZ;
|
|
24
|
+
protected boolean flipY = false;
|
|
25
|
+
protected float tileSize = 256;
|
|
26
|
+
protected boolean doubleTileSize = false;
|
|
27
|
+
protected String tileCachePath;
|
|
28
|
+
protected float tileCacheMaxAge;
|
|
29
|
+
protected boolean offlineMode = false;
|
|
30
|
+
protected float opacity = 1;
|
|
31
|
+
protected Context context;
|
|
32
|
+
protected boolean customTileProviderNeeded = false;
|
|
66
33
|
|
|
67
34
|
public AirMapUrlTile(Context context) {
|
|
68
35
|
super(context);
|
|
36
|
+
this.context = context;
|
|
69
37
|
}
|
|
70
38
|
|
|
71
39
|
public void setUrlTemplate(String urlTemplate) {
|
|
@@ -87,6 +55,20 @@ public class AirMapUrlTile extends AirMapFeature {
|
|
|
87
55
|
|
|
88
56
|
public void setMaximumZ(float maximumZ) {
|
|
89
57
|
this.maximumZ = maximumZ;
|
|
58
|
+
if (tileProvider != null) {
|
|
59
|
+
tileProvider.setMaximumZ((int)maximumZ);
|
|
60
|
+
}
|
|
61
|
+
if (tileOverlay != null) {
|
|
62
|
+
tileOverlay.clearTileCache();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public void setMaximumNativeZ(float maximumNativeZ) {
|
|
67
|
+
this.maximumNativeZ = maximumNativeZ;
|
|
68
|
+
if (tileProvider != null) {
|
|
69
|
+
tileProvider.setMaximumNativeZ((int)maximumNativeZ);
|
|
70
|
+
}
|
|
71
|
+
setCustomTileProviderMode();
|
|
90
72
|
if (tileOverlay != null) {
|
|
91
73
|
tileOverlay.clearTileCache();
|
|
92
74
|
}
|
|
@@ -94,6 +76,9 @@ public class AirMapUrlTile extends AirMapFeature {
|
|
|
94
76
|
|
|
95
77
|
public void setMinimumZ(float minimumZ) {
|
|
96
78
|
this.minimumZ = minimumZ;
|
|
79
|
+
if (tileProvider != null) {
|
|
80
|
+
tileProvider.setMinimumZ((int)minimumZ);
|
|
81
|
+
}
|
|
97
82
|
if (tileOverlay != null) {
|
|
98
83
|
tileOverlay.clearTileCache();
|
|
99
84
|
}
|
|
@@ -101,11 +86,83 @@ public class AirMapUrlTile extends AirMapFeature {
|
|
|
101
86
|
|
|
102
87
|
public void setFlipY(boolean flipY) {
|
|
103
88
|
this.flipY = flipY;
|
|
89
|
+
if (tileProvider != null) {
|
|
90
|
+
tileProvider.setFlipY((boolean)flipY);
|
|
91
|
+
}
|
|
104
92
|
if (tileOverlay != null) {
|
|
105
93
|
tileOverlay.clearTileCache();
|
|
106
94
|
}
|
|
107
95
|
}
|
|
108
96
|
|
|
97
|
+
public void setDoubleTileSize(boolean doubleTileSize) {
|
|
98
|
+
this.doubleTileSize = doubleTileSize;
|
|
99
|
+
if (tileProvider != null) {
|
|
100
|
+
tileProvider.setDoubleTileSize((boolean)doubleTileSize);
|
|
101
|
+
}
|
|
102
|
+
setCustomTileProviderMode();
|
|
103
|
+
if (tileOverlay != null) {
|
|
104
|
+
tileOverlay.clearTileCache();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public void setTileSize(float tileSize) {
|
|
109
|
+
this.tileSize = tileSize;
|
|
110
|
+
if (tileProvider != null) {
|
|
111
|
+
tileProvider.setTileSize((int)tileSize);
|
|
112
|
+
}
|
|
113
|
+
if (tileOverlay != null) {
|
|
114
|
+
tileOverlay.clearTileCache();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public void setTileCachePath(String tileCachePath) {
|
|
119
|
+
if (tileCachePath == null || tileCachePath.isEmpty()) return;
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
URL url = new URL(tileCachePath);
|
|
123
|
+
this.tileCachePath = url.getPath();
|
|
124
|
+
} catch (MalformedURLException e) {
|
|
125
|
+
this.tileCachePath = tileCachePath;
|
|
126
|
+
} catch (Exception e) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (tileProvider != null) {
|
|
131
|
+
tileProvider.setTileCachePath(tileCachePath);
|
|
132
|
+
}
|
|
133
|
+
setCustomTileProviderMode();
|
|
134
|
+
if (tileOverlay != null) {
|
|
135
|
+
tileOverlay.clearTileCache();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public void setTileCacheMaxAge(float tileCacheMaxAge) {
|
|
140
|
+
this.tileCacheMaxAge = tileCacheMaxAge;
|
|
141
|
+
if (tileProvider != null) {
|
|
142
|
+
tileProvider.setTileCacheMaxAge((int)tileCacheMaxAge);
|
|
143
|
+
}
|
|
144
|
+
if (tileOverlay != null) {
|
|
145
|
+
tileOverlay.clearTileCache();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public void setOfflineMode(boolean offlineMode) {
|
|
150
|
+
this.offlineMode = offlineMode;
|
|
151
|
+
if (tileProvider != null) {
|
|
152
|
+
tileProvider.setOfflineMode((boolean)offlineMode);
|
|
153
|
+
}
|
|
154
|
+
if (tileOverlay != null) {
|
|
155
|
+
tileOverlay.clearTileCache();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public void setOpacity(float opacity) {
|
|
160
|
+
this.opacity = opacity;
|
|
161
|
+
if (tileOverlay != null) {
|
|
162
|
+
tileOverlay.setTransparency(1 - opacity);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
109
166
|
public TileOverlayOptions getTileOverlayOptions() {
|
|
110
167
|
if (tileOverlayOptions == null) {
|
|
111
168
|
tileOverlayOptions = createTileOverlayOptions();
|
|
@@ -113,10 +170,22 @@ public class AirMapUrlTile extends AirMapFeature {
|
|
|
113
170
|
return tileOverlayOptions;
|
|
114
171
|
}
|
|
115
172
|
|
|
116
|
-
|
|
173
|
+
protected void setCustomTileProviderMode() {
|
|
174
|
+
Log.d("urlTile ", "creating new mode TileProvider");
|
|
175
|
+
this.customTileProviderNeeded = true;
|
|
176
|
+
if (tileProvider != null) {
|
|
177
|
+
tileProvider.setCustomMode();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
protected TileOverlayOptions createTileOverlayOptions() {
|
|
182
|
+
Log.d("urlTile ", "creating TileProvider");
|
|
117
183
|
TileOverlayOptions options = new TileOverlayOptions();
|
|
118
184
|
options.zIndex(zIndex);
|
|
119
|
-
|
|
185
|
+
options.transparency(1 - this.opacity);
|
|
186
|
+
this.tileProvider = new AirMapTileProvider((int)this.tileSize, this.doubleTileSize, this.urlTemplate,
|
|
187
|
+
(int)this.maximumZ, (int)this.maximumNativeZ, (int)this.minimumZ, this.flipY, this.tileCachePath,
|
|
188
|
+
(int)this.tileCacheMaxAge, this.offlineMode, this.context, this.customTileProviderNeeded);
|
|
120
189
|
options.tileProvider(this.tileProvider);
|
|
121
190
|
return options;
|
|
122
191
|
}
|
|
@@ -55,9 +55,43 @@ public class AirMapUrlTileManager extends ViewGroupManager<AirMapUrlTile> {
|
|
|
55
55
|
view.setMaximumZ(maximumZ);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
@ReactProp(name = "maximumNativeZ", defaultFloat = 100.0f)
|
|
59
|
+
public void setMaximumNativeZ(AirMapUrlTile view, float maximumNativeZ) {
|
|
60
|
+
view.setMaximumNativeZ(maximumNativeZ);
|
|
61
|
+
}
|
|
62
|
+
|
|
58
63
|
@ReactProp(name = "flipY", defaultBoolean = false)
|
|
59
64
|
public void setFlipY(AirMapUrlTile view, boolean flipY) {
|
|
60
65
|
view.setFlipY(flipY);
|
|
61
66
|
}
|
|
62
67
|
|
|
68
|
+
@ReactProp(name = "tileSize", defaultFloat = 256.0f)
|
|
69
|
+
public void setTileSize(AirMapUrlTile view, float tileSize) {
|
|
70
|
+
view.setTileSize(tileSize);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@ReactProp(name = "doubleTileSize", defaultBoolean = false)
|
|
74
|
+
public void setDoubleTileSize(AirMapUrlTile view, boolean doubleTileSize) {
|
|
75
|
+
view.setDoubleTileSize(doubleTileSize);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@ReactProp(name = "tileCachePath")
|
|
79
|
+
public void setTileCachePath(AirMapUrlTile view, String tileCachePath) {
|
|
80
|
+
view.setTileCachePath(tileCachePath);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@ReactProp(name = "tileCacheMaxAge", defaultFloat = 0.0f)
|
|
84
|
+
public void setTileCacheMaxAge(AirMapUrlTile view, float tileCacheMaxAge) {
|
|
85
|
+
view.setTileCacheMaxAge(tileCacheMaxAge);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@ReactProp(name = "offlineMode", defaultBoolean = false)
|
|
89
|
+
public void setOfflineMode(AirMapUrlTile view, boolean offlineMode) {
|
|
90
|
+
view.setOfflineMode(offlineMode);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@ReactProp(name = "opacity", defaultFloat = 1.0f)
|
|
94
|
+
public void setOpacity(AirMapUrlTile view, float opacity) {
|
|
95
|
+
view.setOpacity(opacity);
|
|
96
|
+
}
|
|
63
97
|
}
|
|
@@ -116,6 +116,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
116
116
|
private FusedLocationSource fusedLocationSource;
|
|
117
117
|
|
|
118
118
|
private ViewAttacherGroup attacherGroup;
|
|
119
|
+
private LatLng tapLocation;
|
|
119
120
|
|
|
120
121
|
private static boolean contextHasBug(Context context) {
|
|
121
122
|
return context == null ||
|
|
@@ -276,7 +277,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
276
277
|
map.setOnPolygonClickListener(new GoogleMap.OnPolygonClickListener() {
|
|
277
278
|
@Override
|
|
278
279
|
public void onPolygonClick(Polygon polygon) {
|
|
279
|
-
WritableMap event = makeClickEventData(
|
|
280
|
+
WritableMap event = makeClickEventData(tapLocation);
|
|
280
281
|
event.putString("action", "polygon-press");
|
|
281
282
|
manager.pushEvent(context, polygonMap.get(polygon), "onPress", event);
|
|
282
283
|
}
|
|
@@ -1008,6 +1009,10 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
1008
1009
|
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
1009
1010
|
gestureDetector.onTouchEvent(ev);
|
|
1010
1011
|
|
|
1012
|
+
int X = (int)ev.getX();
|
|
1013
|
+
int Y = (int)ev.getY();
|
|
1014
|
+
tapLocation = map.getProjection().fromScreenLocation(new Point(X,Y));
|
|
1015
|
+
|
|
1011
1016
|
int action = MotionEventCompat.getActionMasked(ev);
|
|
1012
1017
|
|
|
1013
1018
|
switch (action) {
|
|
@@ -2,6 +2,8 @@ package com.airbnb.android.react.maps;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
|
|
5
7
|
import com.google.android.gms.maps.GoogleMap;
|
|
6
8
|
import com.google.android.gms.maps.model.TileOverlay;
|
|
7
9
|
import com.google.android.gms.maps.model.TileOverlayOptions;
|
|
@@ -10,38 +12,42 @@ import com.google.android.gms.maps.model.UrlTileProvider;
|
|
|
10
12
|
import java.net.MalformedURLException;
|
|
11
13
|
import java.net.URL;
|
|
12
14
|
|
|
13
|
-
public class AirMapWMSTile extends
|
|
15
|
+
public class AirMapWMSTile extends AirMapUrlTile {
|
|
14
16
|
private static final double[] mapBound = {-20037508.34789244, 20037508.34789244};
|
|
15
17
|
private static final double FULL = 20037508.34789244 * 2;
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
class AIRMapGSUrlTileProvider extends AirMapTileProvider {
|
|
20
|
+
|
|
21
|
+
class AIRMapWMSTileProvider extends UrlTileProvider {
|
|
18
22
|
private String urlTemplate;
|
|
19
|
-
private int
|
|
20
|
-
|
|
21
|
-
public
|
|
23
|
+
private int tileSize;
|
|
24
|
+
|
|
25
|
+
public AIRMapWMSTileProvider(int width, int height, String urlTemplate) {
|
|
22
26
|
super(width, height);
|
|
23
27
|
this.urlTemplate = urlTemplate;
|
|
24
|
-
this.
|
|
25
|
-
this.height = height;
|
|
28
|
+
this.tileSize = width;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
@Override
|
|
29
|
-
public
|
|
32
|
+
public URL getTileUrl(int x, int y, int zoom) {
|
|
30
33
|
if(AirMapWMSTile.this.maximumZ > 0 && zoom > maximumZ) {
|
|
31
34
|
return null;
|
|
32
35
|
}
|
|
36
|
+
|
|
33
37
|
if(AirMapWMSTile.this.minimumZ > 0 && zoom < minimumZ) {
|
|
34
38
|
return null;
|
|
35
39
|
}
|
|
40
|
+
|
|
36
41
|
double[] bb = getBoundingBox(x, y, zoom);
|
|
37
42
|
String s = this.urlTemplate
|
|
38
43
|
.replace("{minX}", Double.toString(bb[0]))
|
|
39
44
|
.replace("{minY}", Double.toString(bb[1]))
|
|
40
45
|
.replace("{maxX}", Double.toString(bb[2]))
|
|
41
46
|
.replace("{maxY}", Double.toString(bb[3]))
|
|
42
|
-
.replace("{width}", Integer.toString(
|
|
43
|
-
.replace("{height}", Integer.toString(
|
|
47
|
+
.replace("{width}", Integer.toString(this.tileSize))
|
|
48
|
+
.replace("{height}", Integer.toString(this.tileSize));
|
|
44
49
|
URL url = null;
|
|
50
|
+
|
|
45
51
|
try {
|
|
46
52
|
url = new URL(s);
|
|
47
53
|
} catch (MalformedURLException e) {
|
|
@@ -65,92 +71,30 @@ public class AirMapWMSTile extends AirMapFeature {
|
|
|
65
71
|
}
|
|
66
72
|
}
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
private float maximumZ;
|
|
75
|
-
private float minimumZ;
|
|
76
|
-
private int tileSize;
|
|
77
|
-
private float opacity;
|
|
78
|
-
|
|
79
|
-
public AirMapWMSTile(Context context) {
|
|
80
|
-
super(context);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public void setUrlTemplate(String urlTemplate) {
|
|
84
|
-
this.urlTemplate = urlTemplate;
|
|
85
|
-
if (tileProvider != null) {
|
|
86
|
-
tileProvider.setUrlTemplate(urlTemplate);
|
|
87
|
-
}
|
|
88
|
-
if (tileOverlay != null) {
|
|
89
|
-
tileOverlay.clearTileCache();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public void setZIndex(float zIndex) {
|
|
94
|
-
this.zIndex = zIndex;
|
|
95
|
-
if (tileOverlay != null) {
|
|
96
|
-
tileOverlay.setZIndex(zIndex);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public void setMaximumZ(float maximumZ) {
|
|
101
|
-
this.maximumZ = maximumZ;
|
|
102
|
-
if (tileOverlay != null) {
|
|
103
|
-
tileOverlay.clearTileCache();
|
|
74
|
+
public AIRMapGSUrlTileProvider(int tileSizet, String urlTemplate,
|
|
75
|
+
int maximumZ, int maximumNativeZ, int minimumZ, String tileCachePath,
|
|
76
|
+
int tileCacheMaxAge, boolean offlineMode, Context context, boolean customMode) {
|
|
77
|
+
super(tileSizet, false, urlTemplate, maximumZ, maximumNativeZ, minimumZ, false,
|
|
78
|
+
tileCachePath, tileCacheMaxAge, offlineMode, context, customMode);
|
|
79
|
+
this.tileProvider = new AIRMapWMSTileProvider(tileSizet, tileSizet, urlTemplate);
|
|
104
80
|
}
|
|
105
81
|
}
|
|
106
82
|
|
|
107
|
-
|
|
108
|
-
this.minimumZ = minimumZ;
|
|
109
|
-
if (tileOverlay != null) {
|
|
110
|
-
tileOverlay.clearTileCache();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
public void setTileSize(int tileSize) {
|
|
114
|
-
this.tileSize = tileSize;
|
|
115
|
-
if (tileOverlay != null) {
|
|
116
|
-
tileOverlay.clearTileCache();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
public void setOpacity(float opacity) {
|
|
120
|
-
this.opacity = opacity;
|
|
121
|
-
if (tileOverlay != null) {
|
|
122
|
-
tileOverlay.setTransparency(1-opacity);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
83
|
+
private AIRMapGSUrlTileProvider tileProvider;
|
|
125
84
|
|
|
126
|
-
public
|
|
127
|
-
|
|
128
|
-
tileOverlayOptions = createTileOverlayOptions();
|
|
129
|
-
}
|
|
130
|
-
return tileOverlayOptions;
|
|
85
|
+
public AirMapWMSTile(Context context) {
|
|
86
|
+
super(context);
|
|
131
87
|
}
|
|
132
88
|
|
|
133
|
-
|
|
89
|
+
@Override
|
|
90
|
+
protected TileOverlayOptions createTileOverlayOptions() {
|
|
134
91
|
TileOverlayOptions options = new TileOverlayOptions();
|
|
135
92
|
options.zIndex(zIndex);
|
|
136
|
-
options.transparency(1-opacity);
|
|
137
|
-
this.tileProvider = new AIRMapGSUrlTileProvider(this.tileSize, this.
|
|
93
|
+
options.transparency(1 - this.opacity);
|
|
94
|
+
this.tileProvider = new AIRMapGSUrlTileProvider((int)this.tileSize, this.urlTemplate,
|
|
95
|
+
(int)this.maximumZ, (int)this.maximumNativeZ, (int)this.minimumZ, this.tileCachePath,
|
|
96
|
+
(int)this.tileCacheMaxAge, this.offlineMode, this.context, this.customTileProviderNeeded);
|
|
138
97
|
options.tileProvider(this.tileProvider);
|
|
139
98
|
return options;
|
|
140
99
|
}
|
|
141
|
-
|
|
142
|
-
@Override
|
|
143
|
-
public Object getFeature() {
|
|
144
|
-
return tileOverlay;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
@Override
|
|
148
|
-
public void addToMap(GoogleMap map) {
|
|
149
|
-
this.tileOverlay = map.addTileOverlay(getTileOverlayOptions());
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
@Override
|
|
153
|
-
public void removeFromMap(GoogleMap map) {
|
|
154
|
-
tileOverlay.remove();
|
|
155
|
-
}
|
|
156
100
|
}
|
|
@@ -55,11 +55,31 @@ public class AirMapWMSTileManager extends ViewGroupManager<AirMapWMSTile> {
|
|
|
55
55
|
view.setMaximumZ(maximumZ);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
@ReactProp(name = "
|
|
59
|
-
public void
|
|
58
|
+
@ReactProp(name = "maximumNativeZ", defaultFloat = 100.0f)
|
|
59
|
+
public void setMaximumNativeZ(AirMapWMSTile view, float maximumNativeZ) {
|
|
60
|
+
view.setMaximumNativeZ(maximumNativeZ);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@ReactProp(name = "tileSize", defaultFloat = 256.0f)
|
|
64
|
+
public void setTileSize(AirMapWMSTile view, float tileSize) {
|
|
60
65
|
view.setTileSize(tileSize);
|
|
61
66
|
}
|
|
62
67
|
|
|
68
|
+
@ReactProp(name = "tileCachePath")
|
|
69
|
+
public void setTileCachePath(AirMapWMSTile view, String tileCachePath) {
|
|
70
|
+
view.setTileCachePath(tileCachePath);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@ReactProp(name = "tileCacheMaxAge", defaultFloat = 0.0f)
|
|
74
|
+
public void setTileCacheMaxAge(AirMapWMSTile view, float tileCacheMaxAge) {
|
|
75
|
+
view.setTileCacheMaxAge(tileCacheMaxAge);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@ReactProp(name = "offlineMode", defaultBoolean = false)
|
|
79
|
+
public void setOfflineMode(AirMapWMSTile view, boolean offlineMode) {
|
|
80
|
+
view.setOfflineMode(offlineMode);
|
|
81
|
+
}
|
|
82
|
+
|
|
63
83
|
@ReactProp(name = "opacity", defaultFloat = 1.0f)
|
|
64
84
|
public void setOpacity(AirMapWMSTile view, float opacity) {
|
|
65
85
|
view.setOpacity(opacity);
|