react-native-maps 1.1.1-beta.1 → 1.2.0
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/android/src/main/java/com/airbnb/android/react/maps/AirMapCircleManager.java +4 -9
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapGradientPolyline.java +2 -4
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapGradientPolylineManager.java +4 -9
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapHeatmap.java +2 -2
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTile.java +2 -6
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapLocalTileManager.java +4 -10
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapManager.java +7 -12
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapMarker.java +11 -22
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapMarkerManager.java +2 -2
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapOverlay.java +0 -5
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapOverlayManager.java +4 -10
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapPolygonManager.java +4 -9
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapPolyline.java +1 -1
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapPolylineManager.java +4 -9
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapTileProvider.java +42 -67
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapTileWorker.java +4 -11
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTile.java +3 -3
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapUrlTileManager.java +4 -10
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapView.java +22 -47
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapWMSTile.java +5 -11
- package/android/src/main/java/com/airbnb/android/react/maps/AirMapWMSTileManager.java +4 -10
- package/android/src/main/java/com/airbnb/android/react/maps/FileUtil.java +2 -5
- package/android/src/main/java/com/airbnb/android/react/maps/ImageReader.java +4 -6
- package/android/src/main/java/com/airbnb/android/react/maps/ViewAttacherGroup.java +1 -6
- package/android/src/main/java/com/airbnb/android/react/maps/ViewChangesTracker.java +4 -4
- package/lib/Geojson.d.ts +11 -0
- package/lib/Geojson.js +3 -2
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@ package com.airbnb.android.react.maps;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.graphics.Color;
|
|
5
|
-
import android.os.Build;
|
|
6
5
|
import android.util.DisplayMetrics;
|
|
7
6
|
import android.view.WindowManager;
|
|
8
7
|
|
|
@@ -18,14 +17,10 @@ public class AirMapCircleManager extends ViewGroupManager<AirMapCircle> {
|
|
|
18
17
|
|
|
19
18
|
public AirMapCircleManager(ReactApplicationContext reactContext) {
|
|
20
19
|
super();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.getRealMetrics(metrics);
|
|
26
|
-
} else {
|
|
27
|
-
metrics = reactContext.getResources().getDisplayMetrics();
|
|
28
|
-
}
|
|
20
|
+
metrics = new DisplayMetrics();
|
|
21
|
+
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
|
|
22
|
+
.getDefaultDisplay()
|
|
23
|
+
.getRealMetrics(metrics);
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
@Override
|
|
@@ -38,9 +38,7 @@ public class AirMapGradientPolyline extends AirMapFeature {
|
|
|
38
38
|
|
|
39
39
|
private GoogleMap map;
|
|
40
40
|
|
|
41
|
-
private TileOverlayOptions tileOverlayOptions;
|
|
42
41
|
private TileOverlay tileOverlay;
|
|
43
|
-
private AirMapGradientPolylineProvider tileProvider;
|
|
44
42
|
protected final Context context;
|
|
45
43
|
|
|
46
44
|
public AirMapGradientPolyline(Context context) {
|
|
@@ -88,8 +86,8 @@ public class AirMapGradientPolyline extends AirMapFeature {
|
|
|
88
86
|
private TileOverlayOptions createTileOverlayOptions() {
|
|
89
87
|
TileOverlayOptions options = new TileOverlayOptions();
|
|
90
88
|
options.zIndex(zIndex);
|
|
91
|
-
|
|
92
|
-
options.tileProvider(
|
|
89
|
+
AirMapGradientPolylineProvider tileProvider = new AirMapGradientPolylineProvider(context, points, colors, width);
|
|
90
|
+
options.tileProvider(tileProvider);
|
|
93
91
|
return options;
|
|
94
92
|
}
|
|
95
93
|
|
package/android/src/main/java/com/airbnb/android/react/maps/AirMapGradientPolylineManager.java
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.airbnb.android.react.maps;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
-
import android.os.Build;
|
|
5
4
|
import android.util.DisplayMetrics;
|
|
6
5
|
import android.view.WindowManager;
|
|
7
6
|
|
|
@@ -21,14 +20,10 @@ public class AirMapGradientPolylineManager extends ViewGroupManager<AirMapGradie
|
|
|
21
20
|
|
|
22
21
|
public AirMapGradientPolylineManager(ReactApplicationContext reactContext) {
|
|
23
22
|
super();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.getRealMetrics(metrics);
|
|
29
|
-
} else {
|
|
30
|
-
metrics = reactContext.getResources().getDisplayMetrics();
|
|
31
|
-
}
|
|
23
|
+
metrics = new DisplayMetrics();
|
|
24
|
+
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
|
|
25
|
+
.getDefaultDisplay()
|
|
26
|
+
.getRealMetrics(metrics);
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
@Override
|
|
@@ -49,7 +49,7 @@ public class AirMapHeatmap extends AirMapFeature {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
public void setOpacity(double opacity) {
|
|
52
|
-
this.opacity =
|
|
52
|
+
this.opacity = opacity;
|
|
53
53
|
if (heatmapTileProvider != null) {
|
|
54
54
|
heatmapTileProvider.setOpacity(opacity);
|
|
55
55
|
}
|
|
@@ -59,7 +59,7 @@ public class AirMapHeatmap extends AirMapFeature {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
public void setRadius(int radius) {
|
|
62
|
-
this.radius =
|
|
62
|
+
this.radius = radius;
|
|
63
63
|
if (heatmapTileProvider != null) {
|
|
64
64
|
heatmapTileProvider.setRadius(radius);
|
|
65
65
|
}
|
|
@@ -9,7 +9,6 @@ import com.google.android.gms.maps.model.TileOverlayOptions;
|
|
|
9
9
|
import com.google.android.gms.maps.model.TileProvider;
|
|
10
10
|
|
|
11
11
|
import java.io.ByteArrayOutputStream;
|
|
12
|
-
import java.io.File;
|
|
13
12
|
import java.io.FileInputStream;
|
|
14
13
|
import java.io.IOException;
|
|
15
14
|
import java.io.InputStream;
|
|
@@ -20,7 +19,7 @@ public class AirMapLocalTile extends AirMapFeature {
|
|
|
20
19
|
private static final int BUFFER_SIZE = 16 * 1024;
|
|
21
20
|
private int tileSize;
|
|
22
21
|
private String pathTemplate;
|
|
23
|
-
private boolean useAssets;
|
|
22
|
+
private final boolean useAssets;
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
public AIRMapLocalTileProvider(int tileSizet, String pathTemplate, boolean useAssets) {
|
|
@@ -61,10 +60,7 @@ public class AirMapLocalTile extends AirMapFeature {
|
|
|
61
60
|
buffer.flush();
|
|
62
61
|
|
|
63
62
|
return buffer.toByteArray();
|
|
64
|
-
} catch (IOException e) {
|
|
65
|
-
e.printStackTrace();
|
|
66
|
-
return null;
|
|
67
|
-
} catch (OutOfMemoryError e) {
|
|
63
|
+
} catch (IOException | OutOfMemoryError e) {
|
|
68
64
|
e.printStackTrace();
|
|
69
65
|
return null;
|
|
70
66
|
} finally {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.airbnb.android.react.maps;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
-
import android.os.Build;
|
|
5
4
|
import android.util.DisplayMetrics;
|
|
6
5
|
import android.view.WindowManager;
|
|
7
6
|
|
|
@@ -14,18 +13,13 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
|
|
14
13
|
* Created by zavadpe on 30/11/2017.
|
|
15
14
|
*/
|
|
16
15
|
public class AirMapLocalTileManager extends ViewGroupManager<AirMapLocalTile> {
|
|
17
|
-
private DisplayMetrics metrics;
|
|
18
16
|
|
|
19
17
|
public AirMapLocalTileManager(ReactApplicationContext reactContext) {
|
|
20
18
|
super();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.getRealMetrics(metrics);
|
|
26
|
-
} else {
|
|
27
|
-
metrics = reactContext.getResources().getDisplayMetrics();
|
|
28
|
-
}
|
|
19
|
+
DisplayMetrics metrics = new DisplayMetrics();
|
|
20
|
+
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
|
|
21
|
+
.getDefaultDisplay()
|
|
22
|
+
.getRealMetrics(metrics);
|
|
29
23
|
}
|
|
30
24
|
|
|
31
25
|
@Override
|
|
@@ -21,7 +21,6 @@ import com.google.android.gms.maps.GoogleMap;
|
|
|
21
21
|
import com.google.android.gms.maps.GoogleMapOptions;
|
|
22
22
|
import com.google.android.gms.maps.model.LatLng;
|
|
23
23
|
import com.google.android.gms.maps.model.LatLngBounds;
|
|
24
|
-
import com.google.android.gms.maps.model.MapStyleOptions;
|
|
25
24
|
|
|
26
25
|
import java.util.HashMap;
|
|
27
26
|
import java.util.Map;
|
|
@@ -30,17 +29,13 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
|
|
|
30
29
|
|
|
31
30
|
private static final String REACT_CLASS = "AIRMap";
|
|
32
31
|
private static final int ANIMATE_TO_REGION = 1;
|
|
33
|
-
private static final int
|
|
34
|
-
private static final int
|
|
35
|
-
private static final int
|
|
36
|
-
private static final int
|
|
37
|
-
private static final int
|
|
38
|
-
private static final int
|
|
39
|
-
private static final int
|
|
40
|
-
private static final int ANIMATE_TO_NAVIGATION = 9;
|
|
41
|
-
private static final int SET_INDOOR_ACTIVE_LEVEL_INDEX = 10;
|
|
42
|
-
private static final int SET_CAMERA = 11;
|
|
43
|
-
private static final int ANIMATE_CAMERA = 12;
|
|
32
|
+
private static final int FIT_TO_ELEMENTS = 2;
|
|
33
|
+
private static final int FIT_TO_SUPPLIED_MARKERS = 3;
|
|
34
|
+
private static final int FIT_TO_COORDINATES = 4;
|
|
35
|
+
private static final int SET_MAP_BOUNDARIES = 5;
|
|
36
|
+
private static final int SET_INDOOR_ACTIVE_LEVEL_INDEX = 6;
|
|
37
|
+
private static final int SET_CAMERA = 7;
|
|
38
|
+
private static final int ANIMATE_CAMERA = 8;
|
|
44
39
|
|
|
45
40
|
|
|
46
41
|
private final Map<String, Integer> MAP_TYPES = MapBuilder.of(
|
|
@@ -76,7 +76,6 @@ public class AirMapMarker extends AirMapFeature {
|
|
|
76
76
|
|
|
77
77
|
private boolean tracksViewChanges = true;
|
|
78
78
|
private boolean tracksViewChangesActive = false;
|
|
79
|
-
private boolean hasViewChanges = true;
|
|
80
79
|
|
|
81
80
|
private boolean hasCustomMarkerView = false;
|
|
82
81
|
private final AirMapMarkerManager markerManager;
|
|
@@ -96,7 +95,7 @@ public class AirMapMarker extends AirMapFeature {
|
|
|
96
95
|
imageReference = dataSource.getResult();
|
|
97
96
|
if (imageReference != null) {
|
|
98
97
|
CloseableImage image = imageReference.get();
|
|
99
|
-
if (image
|
|
98
|
+
if (image instanceof CloseableStaticBitmap) {
|
|
100
99
|
CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
|
|
101
100
|
Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
|
|
102
101
|
if (bitmap != null) {
|
|
@@ -289,13 +288,7 @@ public class AirMapMarker extends AirMapFeature {
|
|
|
289
288
|
public void updateMarkerIcon() {
|
|
290
289
|
if (marker == null) return;
|
|
291
290
|
|
|
292
|
-
|
|
293
|
-
// No more updates for this, as it's a simple icon
|
|
294
|
-
hasViewChanges = false;
|
|
295
|
-
}
|
|
296
|
-
if (marker != null) {
|
|
297
|
-
marker.setIcon(getIcon());
|
|
298
|
-
}
|
|
291
|
+
marker.setIcon(getIcon());
|
|
299
292
|
}
|
|
300
293
|
|
|
301
294
|
public LatLng interpolate(float fraction, LatLng a, LatLng b) {
|
|
@@ -322,7 +315,6 @@ public class AirMapMarker extends AirMapFeature {
|
|
|
322
315
|
}
|
|
323
316
|
|
|
324
317
|
public void setImage(String uri) {
|
|
325
|
-
hasViewChanges = true;
|
|
326
318
|
|
|
327
319
|
boolean shouldLoadImage = true;
|
|
328
320
|
|
|
@@ -368,18 +360,16 @@ public class AirMapMarker extends AirMapFeature {
|
|
|
368
360
|
logoHolder.setController(controller);
|
|
369
361
|
} else {
|
|
370
362
|
iconBitmapDescriptor = getBitmapDescriptorByName(uri);
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
drawable.draw(canvas);
|
|
380
|
-
}
|
|
363
|
+
int drawableId = getDrawableResourceByName(uri);
|
|
364
|
+
iconBitmap = BitmapFactory.decodeResource(getResources(), drawableId);
|
|
365
|
+
if (iconBitmap == null) { // VectorDrawable or similar
|
|
366
|
+
Drawable drawable = getResources().getDrawable(drawableId);
|
|
367
|
+
iconBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
|
368
|
+
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
|
369
|
+
Canvas canvas = new Canvas(iconBitmap);
|
|
370
|
+
drawable.draw(canvas);
|
|
381
371
|
}
|
|
382
|
-
if (this.markerManager != null
|
|
372
|
+
if (this.markerManager != null) {
|
|
383
373
|
this.markerManager.getSharedIcon(uri).updateIcon(iconBitmapDescriptor, iconBitmap);
|
|
384
374
|
}
|
|
385
375
|
update(true);
|
|
@@ -389,7 +379,6 @@ public class AirMapMarker extends AirMapFeature {
|
|
|
389
379
|
public void setIconBitmapDescriptor(BitmapDescriptor bitmapDescriptor, Bitmap bitmap) {
|
|
390
380
|
this.iconBitmapDescriptor = bitmapDescriptor;
|
|
391
381
|
this.iconBitmap = bitmap;
|
|
392
|
-
this.hasViewChanges = true;
|
|
393
382
|
this.update(true);
|
|
394
383
|
}
|
|
395
384
|
|
|
@@ -32,7 +32,7 @@ public class AirMapMarkerManager extends ViewGroupManager<AirMapMarker> {
|
|
|
32
32
|
public static class AirMapMarkerSharedIcon {
|
|
33
33
|
private BitmapDescriptor iconBitmapDescriptor;
|
|
34
34
|
private Bitmap bitmap;
|
|
35
|
-
private Map<AirMapMarker, Boolean> markers;
|
|
35
|
+
private final Map<AirMapMarker, Boolean> markers;
|
|
36
36
|
private boolean loadImageStarted;
|
|
37
37
|
|
|
38
38
|
public AirMapMarkerSharedIcon(){
|
|
@@ -113,7 +113,7 @@ public class AirMapMarkerManager extends ViewGroupManager<AirMapMarker> {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
private Map<String, AirMapMarkerSharedIcon> sharedIcons = new ConcurrentHashMap<>();
|
|
116
|
+
private final Map<String, AirMapMarkerSharedIcon> sharedIcons = new ConcurrentHashMap<>();
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* get the shared icon object, if not existed, create a new one and store it.
|
|
@@ -4,7 +4,6 @@ import android.content.Context;
|
|
|
4
4
|
import android.graphics.Bitmap;
|
|
5
5
|
|
|
6
6
|
import com.facebook.react.bridge.ReadableArray;
|
|
7
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
8
7
|
import com.google.android.gms.maps.GoogleMap;
|
|
9
8
|
import com.google.android.gms.maps.model.BitmapDescriptor;
|
|
10
9
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
|
@@ -13,8 +12,6 @@ import com.google.android.gms.maps.model.GroundOverlayOptions;
|
|
|
13
12
|
import com.google.android.gms.maps.model.LatLng;
|
|
14
13
|
import com.google.android.gms.maps.model.LatLngBounds;
|
|
15
14
|
|
|
16
|
-
import java.util.ArrayList;
|
|
17
|
-
|
|
18
15
|
public class AirMapOverlay extends AirMapFeature implements ImageReadable {
|
|
19
16
|
|
|
20
17
|
private GroundOverlayOptions groundOverlayOptions;
|
|
@@ -22,7 +19,6 @@ public class AirMapOverlay extends AirMapFeature implements ImageReadable {
|
|
|
22
19
|
private LatLngBounds bounds;
|
|
23
20
|
private float bearing;
|
|
24
21
|
private BitmapDescriptor iconBitmapDescriptor;
|
|
25
|
-
private Bitmap iconBitmap;
|
|
26
22
|
private boolean tappable;
|
|
27
23
|
private float zIndex;
|
|
28
24
|
private float transparency;
|
|
@@ -133,7 +129,6 @@ public class AirMapOverlay extends AirMapFeature implements ImageReadable {
|
|
|
133
129
|
|
|
134
130
|
@Override
|
|
135
131
|
public void setIconBitmap(Bitmap bitmap) {
|
|
136
|
-
this.iconBitmap = bitmap;
|
|
137
132
|
}
|
|
138
133
|
|
|
139
134
|
@Override
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.airbnb.android.react.maps;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
-
import android.os.Build;
|
|
5
4
|
import android.util.DisplayMetrics;
|
|
6
5
|
import android.view.WindowManager;
|
|
7
6
|
|
|
@@ -17,18 +16,13 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
|
|
17
16
|
import java.util.Map;
|
|
18
17
|
|
|
19
18
|
public class AirMapOverlayManager extends ViewGroupManager<AirMapOverlay> {
|
|
20
|
-
private final DisplayMetrics metrics;
|
|
21
19
|
|
|
22
20
|
public AirMapOverlayManager(ReactApplicationContext reactContext) {
|
|
23
21
|
super();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.getRealMetrics(metrics);
|
|
29
|
-
} else {
|
|
30
|
-
metrics = reactContext.getResources().getDisplayMetrics();
|
|
31
|
-
}
|
|
22
|
+
DisplayMetrics metrics = new DisplayMetrics();
|
|
23
|
+
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
|
|
24
|
+
.getDefaultDisplay()
|
|
25
|
+
.getRealMetrics(metrics);
|
|
32
26
|
}
|
|
33
27
|
|
|
34
28
|
@Override
|
|
@@ -2,7 +2,6 @@ package com.airbnb.android.react.maps;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.graphics.Color;
|
|
5
|
-
import android.os.Build;
|
|
6
5
|
import android.util.DisplayMetrics;
|
|
7
6
|
import android.view.WindowManager;
|
|
8
7
|
|
|
@@ -22,14 +21,10 @@ public class AirMapPolygonManager extends ViewGroupManager<AirMapPolygon> {
|
|
|
22
21
|
|
|
23
22
|
public AirMapPolygonManager(ReactApplicationContext reactContext) {
|
|
24
23
|
super();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.getRealMetrics(metrics);
|
|
30
|
-
} else {
|
|
31
|
-
metrics = reactContext.getResources().getDisplayMetrics();
|
|
32
|
-
}
|
|
24
|
+
metrics = new DisplayMetrics();
|
|
25
|
+
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
|
|
26
|
+
.getDefaultDisplay()
|
|
27
|
+
.getRealMetrics(metrics);
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
@Override
|
|
@@ -109,7 +109,7 @@ public class AirMapPolyline extends AirMapFeature {
|
|
|
109
109
|
if(isGap) {
|
|
110
110
|
this.pattern.add(new Gap(patternValue));
|
|
111
111
|
}else {
|
|
112
|
-
PatternItem patternItem
|
|
112
|
+
PatternItem patternItem;
|
|
113
113
|
boolean isLineCapRound = this.lineCap instanceof RoundCap;
|
|
114
114
|
if(isLineCapRound) {
|
|
115
115
|
patternItem = new Dot();
|
|
@@ -2,7 +2,6 @@ package com.airbnb.android.react.maps;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.graphics.Color;
|
|
5
|
-
import android.os.Build;
|
|
6
5
|
import android.util.DisplayMetrics;
|
|
7
6
|
import android.view.WindowManager;
|
|
8
7
|
|
|
@@ -26,14 +25,10 @@ public class AirMapPolylineManager extends ViewGroupManager<AirMapPolyline> {
|
|
|
26
25
|
|
|
27
26
|
public AirMapPolylineManager(ReactApplicationContext reactContext) {
|
|
28
27
|
super();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.getRealMetrics(metrics);
|
|
34
|
-
} else {
|
|
35
|
-
metrics = reactContext.getResources().getDisplayMetrics();
|
|
36
|
-
}
|
|
28
|
+
metrics = new DisplayMetrics();
|
|
29
|
+
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
|
|
30
|
+
.getDefaultDisplay()
|
|
31
|
+
.getRealMetrics(metrics);
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
@Override
|
|
@@ -14,12 +14,8 @@ import android.graphics.Color;
|
|
|
14
14
|
import android.graphics.Paint;
|
|
15
15
|
import android.graphics.Rect;
|
|
16
16
|
|
|
17
|
-
import androidx.annotation.NonNull;
|
|
18
17
|
import androidx.work.OneTimeWorkRequest;
|
|
19
18
|
import androidx.work.WorkManager;
|
|
20
|
-
import androidx.work.WorkRequest;
|
|
21
|
-
import androidx.work.Worker;
|
|
22
|
-
import androidx.work.WorkerParameters;
|
|
23
19
|
import androidx.work.Data;
|
|
24
20
|
import androidx.work.Constraints;
|
|
25
21
|
import androidx.work.NetworkType;
|
|
@@ -27,10 +23,7 @@ import androidx.work.ExistingWorkPolicy;
|
|
|
27
23
|
import androidx.work.Operation;
|
|
28
24
|
import androidx.work.WorkInfo;
|
|
29
25
|
|
|
30
|
-
import com.google.android.gms.maps.GoogleMap;
|
|
31
26
|
import com.google.android.gms.maps.model.Tile;
|
|
32
|
-
import com.google.android.gms.maps.model.TileOverlay;
|
|
33
|
-
import com.google.android.gms.maps.model.TileOverlayOptions;
|
|
34
27
|
import com.google.android.gms.maps.model.TileProvider;
|
|
35
28
|
import com.google.android.gms.maps.model.UrlTileProvider;
|
|
36
29
|
|
|
@@ -61,7 +54,7 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
61
54
|
@Override
|
|
62
55
|
public URL getTileUrl(int x, int y, int zoom) {
|
|
63
56
|
|
|
64
|
-
if (AirMapTileProvider.this.flipY
|
|
57
|
+
if (AirMapTileProvider.this.flipY) {
|
|
65
58
|
y = (1 << zoom) - y - 1;
|
|
66
59
|
}
|
|
67
60
|
|
|
@@ -69,14 +62,14 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
69
62
|
.replace("{x}", Integer.toString(x))
|
|
70
63
|
.replace("{y}", Integer.toString(y))
|
|
71
64
|
.replace("{z}", Integer.toString(zoom));
|
|
72
|
-
URL url
|
|
65
|
+
URL url;
|
|
73
66
|
|
|
74
67
|
if(AirMapTileProvider.this.maximumZ > 0 && zoom > AirMapTileProvider.this.maximumZ) {
|
|
75
|
-
return
|
|
68
|
+
return null;
|
|
76
69
|
}
|
|
77
70
|
|
|
78
71
|
if(AirMapTileProvider.this.minimumZ > 0 && zoom < AirMapTileProvider.this.minimumZ) {
|
|
79
|
-
return
|
|
72
|
+
return null;
|
|
80
73
|
}
|
|
81
74
|
|
|
82
75
|
try {
|
|
@@ -152,7 +145,7 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
152
145
|
if (image == null && this.tileCachePath != null && this.offlineMode) {
|
|
153
146
|
Log.d("urlTile", "findLowerZoomTileForScaling");
|
|
154
147
|
int zoomLevelToStart = (zoom > this.maximumNativeZ) ? this.maximumNativeZ - 1 : zoom - 1;
|
|
155
|
-
int minimumZoomToSearch =
|
|
148
|
+
int minimumZoomToSearch = Math.max(this.minimumZ, zoom - 3);
|
|
156
149
|
for (int tryZoom = zoomLevelToStart; tryZoom >= minimumZoomToSearch; tryZoom--) {
|
|
157
150
|
image = scaleLowerZoomTile(x, y, zoom, tryZoom);
|
|
158
151
|
if (image != null) {
|
|
@@ -166,16 +159,15 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
166
159
|
|
|
167
160
|
byte[] getTileImage(int x, int y, int zoom) {
|
|
168
161
|
byte[] image = null;
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
|
|
171
163
|
if (this.tileCachePath != null) {
|
|
172
164
|
image = readTileImage(x, y, zoom);
|
|
173
165
|
if (image != null) {
|
|
174
|
-
Log.d("urlTile", "tile cache HIT for " +
|
|
175
|
-
"/" +
|
|
166
|
+
Log.d("urlTile", "tile cache HIT for " + zoom +
|
|
167
|
+
"/" + x + "/" + y);
|
|
176
168
|
} else {
|
|
177
|
-
Log.d("urlTile", "tile cache MISS for " +
|
|
178
|
-
"/" +
|
|
169
|
+
Log.d("urlTile", "tile cache MISS for " + zoom +
|
|
170
|
+
"/" + x + "/" + y);
|
|
179
171
|
}
|
|
180
172
|
if (image != null && !this.offlineMode) {
|
|
181
173
|
checkForRefresh(x, y, zoom);
|
|
@@ -198,39 +190,35 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
198
190
|
.build()
|
|
199
191
|
)
|
|
200
192
|
.build();
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
"/" + Integer.toString(x) + "/" + Integer.toString(y));
|
|
220
|
-
}
|
|
193
|
+
WorkManager workManager = WorkManager.getInstance(this.context.getApplicationContext());
|
|
194
|
+
Operation fetchOperation = workManager
|
|
195
|
+
.enqueueUniqueWork(fileName, ExistingWorkPolicy.KEEP, tileRefreshWorkRequest);
|
|
196
|
+
Future<Operation.State.SUCCESS> operationFuture = fetchOperation.getResult();
|
|
197
|
+
try {
|
|
198
|
+
operationFuture.get(1L, TimeUnit.SECONDS);
|
|
199
|
+
Thread.sleep(500);
|
|
200
|
+
Future<List<WorkInfo>> fetchFuture = workManager.getWorkInfosByTag(fileName);
|
|
201
|
+
List<WorkInfo> workInfo = fetchFuture.get(1L, TimeUnit.SECONDS);
|
|
202
|
+
Log.d("urlTile: ", workInfo.get(0).toString());
|
|
203
|
+
if (this.tileCachePath != null) {
|
|
204
|
+
image = readTileImage(x, y, zoom);
|
|
205
|
+
if (image != null) {
|
|
206
|
+
Log.d("urlTile","tile cache fetch HIT for " + zoom +
|
|
207
|
+
"/" + x + "/" + y);
|
|
208
|
+
} else {
|
|
209
|
+
Log.d("urlTile","tile cache fetch MISS for " + zoom +
|
|
210
|
+
"/" + x + "/" + y);
|
|
221
211
|
}
|
|
222
|
-
} catch (Exception e) {
|
|
223
|
-
e.printStackTrace();
|
|
224
212
|
}
|
|
225
|
-
}
|
|
226
|
-
|
|
213
|
+
} catch (Exception e) {
|
|
214
|
+
e.printStackTrace();
|
|
227
215
|
}
|
|
228
|
-
} else if (
|
|
216
|
+
} else if (image == null && !this.offlineMode) {
|
|
229
217
|
Log.d("urlTile", "Normal fetch");
|
|
230
218
|
image = fetchTile(x, y, zoom);
|
|
231
219
|
if (image == null) {
|
|
232
|
-
Log.d("urlTile", "tile fetch TIMEOUT / FAIL for " +
|
|
233
|
-
"/" +
|
|
220
|
+
Log.d("urlTile", "tile fetch TIMEOUT / FAIL for " + zoom +
|
|
221
|
+
"/" + x + "/" + y);
|
|
234
222
|
}
|
|
235
223
|
}
|
|
236
224
|
|
|
@@ -304,7 +292,7 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
304
292
|
int yParent = y >> overZoomLevel;
|
|
305
293
|
int zoomParent = zoom - overZoomLevel;
|
|
306
294
|
|
|
307
|
-
int xOffset = x % zoomFactor
|
|
295
|
+
int xOffset = x % zoomFactor;
|
|
308
296
|
int yOffset = y % zoomFactor;
|
|
309
297
|
|
|
310
298
|
byte[] data;
|
|
@@ -351,11 +339,9 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
351
339
|
.build()
|
|
352
340
|
)
|
|
353
341
|
.build();
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
}
|
|
342
|
+
WorkManager.getInstance(this.context.getApplicationContext())
|
|
343
|
+
.enqueueUniqueWork(fileName, ExistingWorkPolicy.KEEP, tileRefreshWorkRequest);
|
|
344
|
+
}
|
|
359
345
|
}
|
|
360
346
|
|
|
361
347
|
byte[] fetchTile(int x, int y, int zoom) {
|
|
@@ -377,10 +363,7 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
377
363
|
buffer.flush();
|
|
378
364
|
|
|
379
365
|
return buffer.toByteArray();
|
|
380
|
-
} catch (IOException e) {
|
|
381
|
-
e.printStackTrace();
|
|
382
|
-
return null;
|
|
383
|
-
} catch (OutOfMemoryError e) {
|
|
366
|
+
} catch (IOException | OutOfMemoryError e) {
|
|
384
367
|
e.printStackTrace();
|
|
385
368
|
return null;
|
|
386
369
|
} finally {
|
|
@@ -416,10 +399,7 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
416
399
|
}
|
|
417
400
|
|
|
418
401
|
return buffer.toByteArray();
|
|
419
|
-
} catch (IOException e) {
|
|
420
|
-
e.printStackTrace();
|
|
421
|
-
return null;
|
|
422
|
-
} catch (OutOfMemoryError e) {
|
|
402
|
+
} catch (IOException | OutOfMemoryError e) {
|
|
423
403
|
e.printStackTrace();
|
|
424
404
|
return null;
|
|
425
405
|
} finally {
|
|
@@ -442,10 +422,7 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
442
422
|
out.write(image);
|
|
443
423
|
|
|
444
424
|
return true;
|
|
445
|
-
} catch (IOException e) {
|
|
446
|
-
e.printStackTrace();
|
|
447
|
-
return false;
|
|
448
|
-
} catch (OutOfMemoryError e) {
|
|
425
|
+
} catch (IOException | OutOfMemoryError e) {
|
|
449
426
|
e.printStackTrace();
|
|
450
427
|
return false;
|
|
451
428
|
} finally {
|
|
@@ -457,9 +434,8 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
457
434
|
if (this.tileCachePath == null) {
|
|
458
435
|
return null;
|
|
459
436
|
}
|
|
460
|
-
|
|
461
|
-
"/" +
|
|
462
|
-
return s;
|
|
437
|
+
return this.tileCachePath + '/' + zoom +
|
|
438
|
+
"/" + x + "/" + y;
|
|
463
439
|
}
|
|
464
440
|
|
|
465
441
|
protected URL getTileUrl(int x, int y, int zoom) {
|
|
@@ -510,6 +486,5 @@ public class AirMapTileProvider implements TileProvider {
|
|
|
510
486
|
}
|
|
511
487
|
|
|
512
488
|
public void setCustomMode() {
|
|
513
|
-
this.customMode = customMode;
|
|
514
489
|
}
|
|
515
490
|
}
|
|
@@ -10,7 +10,6 @@ import androidx.work.WorkerParameters;
|
|
|
10
10
|
|
|
11
11
|
import java.io.ByteArrayOutputStream;
|
|
12
12
|
import java.io.File;
|
|
13
|
-
import java.io.FileInputStream;
|
|
14
13
|
import java.io.FileOutputStream;
|
|
15
14
|
import java.io.InputStream;
|
|
16
15
|
import java.io.OutputStream;
|
|
@@ -30,8 +29,8 @@ public class AirMapTileWorker extends Worker {
|
|
|
30
29
|
|
|
31
30
|
@Override
|
|
32
31
|
public Result doWork() {
|
|
33
|
-
byte[] image
|
|
34
|
-
URL url
|
|
32
|
+
byte[] image;
|
|
33
|
+
URL url;
|
|
35
34
|
String fileName = getInputData().getString("filename");
|
|
36
35
|
|
|
37
36
|
try {
|
|
@@ -84,10 +83,7 @@ public class AirMapTileWorker extends Worker {
|
|
|
84
83
|
buffer.flush();
|
|
85
84
|
|
|
86
85
|
return buffer.toByteArray();
|
|
87
|
-
} catch (IOException e) {
|
|
88
|
-
e.printStackTrace();
|
|
89
|
-
return null;
|
|
90
|
-
} catch (OutOfMemoryError e) {
|
|
86
|
+
} catch (IOException | OutOfMemoryError e) {
|
|
91
87
|
e.printStackTrace();
|
|
92
88
|
return null;
|
|
93
89
|
} finally {
|
|
@@ -109,10 +105,7 @@ public class AirMapTileWorker extends Worker {
|
|
|
109
105
|
out.write(image);
|
|
110
106
|
|
|
111
107
|
return true;
|
|
112
|
-
} catch (IOException e) {
|
|
113
|
-
e.printStackTrace();
|
|
114
|
-
return false;
|
|
115
|
-
} catch (OutOfMemoryError e) {
|
|
108
|
+
} catch (IOException | OutOfMemoryError e) {
|
|
116
109
|
e.printStackTrace();
|
|
117
110
|
return false;
|
|
118
111
|
} finally {
|
|
@@ -87,7 +87,7 @@ public class AirMapUrlTile extends AirMapFeature {
|
|
|
87
87
|
public void setFlipY(boolean flipY) {
|
|
88
88
|
this.flipY = flipY;
|
|
89
89
|
if (tileProvider != null) {
|
|
90
|
-
tileProvider.setFlipY(
|
|
90
|
+
tileProvider.setFlipY(flipY);
|
|
91
91
|
}
|
|
92
92
|
if (tileOverlay != null) {
|
|
93
93
|
tileOverlay.clearTileCache();
|
|
@@ -97,7 +97,7 @@ public class AirMapUrlTile extends AirMapFeature {
|
|
|
97
97
|
public void setDoubleTileSize(boolean doubleTileSize) {
|
|
98
98
|
this.doubleTileSize = doubleTileSize;
|
|
99
99
|
if (tileProvider != null) {
|
|
100
|
-
tileProvider.setDoubleTileSize(
|
|
100
|
+
tileProvider.setDoubleTileSize(doubleTileSize);
|
|
101
101
|
}
|
|
102
102
|
setCustomTileProviderMode();
|
|
103
103
|
if (tileOverlay != null) {
|
|
@@ -149,7 +149,7 @@ public class AirMapUrlTile extends AirMapFeature {
|
|
|
149
149
|
public void setOfflineMode(boolean offlineMode) {
|
|
150
150
|
this.offlineMode = offlineMode;
|
|
151
151
|
if (tileProvider != null) {
|
|
152
|
-
tileProvider.setOfflineMode(
|
|
152
|
+
tileProvider.setOfflineMode(offlineMode);
|
|
153
153
|
}
|
|
154
154
|
if (tileOverlay != null) {
|
|
155
155
|
tileOverlay.clearTileCache();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.airbnb.android.react.maps;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
-
import android.os.Build;
|
|
5
4
|
import android.util.DisplayMetrics;
|
|
6
5
|
import android.view.WindowManager;
|
|
7
6
|
|
|
@@ -11,18 +10,13 @@ import com.facebook.react.uimanager.ViewGroupManager;
|
|
|
11
10
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
12
11
|
|
|
13
12
|
public class AirMapUrlTileManager extends ViewGroupManager<AirMapUrlTile> {
|
|
14
|
-
private DisplayMetrics metrics;
|
|
15
13
|
|
|
16
14
|
public AirMapUrlTileManager(ReactApplicationContext reactContext) {
|
|
17
15
|
super();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.getRealMetrics(metrics);
|
|
23
|
-
} else {
|
|
24
|
-
metrics = reactContext.getResources().getDisplayMetrics();
|
|
25
|
-
}
|
|
16
|
+
DisplayMetrics metrics = new DisplayMetrics();
|
|
17
|
+
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
|
|
18
|
+
.getDefaultDisplay()
|
|
19
|
+
.getRealMetrics(metrics);
|
|
26
20
|
}
|
|
27
21
|
|
|
28
22
|
@Override
|
|
@@ -5,10 +5,8 @@ import android.content.res.ColorStateList;
|
|
|
5
5
|
import android.graphics.Bitmap;
|
|
6
6
|
import android.graphics.Color;
|
|
7
7
|
import android.graphics.Point;
|
|
8
|
-
import android.graphics.PorterDuff;
|
|
9
|
-
import android.graphics.Rect;
|
|
10
|
-
import android.os.Build;
|
|
11
8
|
|
|
9
|
+
import androidx.annotation.NonNull;
|
|
12
10
|
import androidx.annotation.Nullable;
|
|
13
11
|
import androidx.core.content.PermissionChecker;
|
|
14
12
|
import androidx.core.view.GestureDetectorCompat;
|
|
@@ -33,7 +31,6 @@ import com.facebook.react.bridge.WritableNativeMap;
|
|
|
33
31
|
import com.facebook.react.bridge.Arguments;
|
|
34
32
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
35
33
|
import com.facebook.react.uimanager.UIManagerModule;
|
|
36
|
-
import com.facebook.react.uimanager.ViewProps;
|
|
37
34
|
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
38
35
|
import com.google.android.gms.maps.CameraUpdate;
|
|
39
36
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
|
@@ -54,7 +51,6 @@ import com.google.android.gms.maps.model.PointOfInterest;
|
|
|
54
51
|
import com.google.android.gms.maps.model.Polygon;
|
|
55
52
|
import com.google.android.gms.maps.model.Polyline;
|
|
56
53
|
import com.google.android.gms.maps.model.TileOverlay;
|
|
57
|
-
import com.google.android.gms.maps.model.VisibleRegion;
|
|
58
54
|
import com.google.android.gms.maps.model.IndoorBuilding;
|
|
59
55
|
import com.google.android.gms.maps.model.IndoorLevel;
|
|
60
56
|
import com.google.maps.android.data.kml.KmlContainer;
|
|
@@ -78,7 +74,6 @@ import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
|
|
78
74
|
public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
79
75
|
GoogleMap.OnMarkerDragListener, OnMapReadyCallback, GoogleMap.OnPoiClickListener, GoogleMap.OnIndoorStateChangeListener {
|
|
80
76
|
public GoogleMap map;
|
|
81
|
-
private KmlLayer kmlLayer;
|
|
82
77
|
private ProgressBar mapLoadingProgressBar;
|
|
83
78
|
private RelativeLayout mapLoadingLayout;
|
|
84
79
|
private ImageView cacheImageView;
|
|
@@ -118,9 +113,9 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
118
113
|
private boolean destroyed = false;
|
|
119
114
|
private final ThemedReactContext context;
|
|
120
115
|
private final EventDispatcher eventDispatcher;
|
|
121
|
-
private FusedLocationSource fusedLocationSource;
|
|
116
|
+
private final FusedLocationSource fusedLocationSource;
|
|
122
117
|
|
|
123
|
-
private ViewAttacherGroup attacherGroup;
|
|
118
|
+
private final ViewAttacherGroup attacherGroup;
|
|
124
119
|
private LatLng tapLocation;
|
|
125
120
|
|
|
126
121
|
private static boolean contextHasBug(Context context) {
|
|
@@ -147,9 +142,8 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
147
142
|
superContext = reactContext.getCurrentActivity();
|
|
148
143
|
} else if (!contextHasBug(reactContext.getApplicationContext())) {
|
|
149
144
|
superContext = reactContext.getApplicationContext();
|
|
150
|
-
} else {
|
|
151
|
-
// ¯\_(ツ)_/¯
|
|
152
145
|
}
|
|
146
|
+
|
|
153
147
|
}
|
|
154
148
|
return superContext;
|
|
155
149
|
}
|
|
@@ -214,7 +208,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
214
208
|
}
|
|
215
209
|
|
|
216
210
|
@Override
|
|
217
|
-
public void onMapReady(final GoogleMap map) {
|
|
211
|
+
public void onMapReady(@NonNull final GoogleMap map) {
|
|
218
212
|
if (destroyed) {
|
|
219
213
|
return;
|
|
220
214
|
}
|
|
@@ -243,9 +237,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
243
237
|
coordinate.putDouble("accuracy", location.getAccuracy());
|
|
244
238
|
coordinate.putDouble("speed", location.getSpeed());
|
|
245
239
|
coordinate.putDouble("heading", location.getBearing());
|
|
246
|
-
if(android.os.Build.VERSION.SDK_INT >= 18){
|
|
247
240
|
coordinate.putBoolean("isFromMockProvider", location.isFromMockProvider());
|
|
248
|
-
}
|
|
249
241
|
|
|
250
242
|
event.putMap("coordinate", coordinate);
|
|
251
243
|
|
|
@@ -531,8 +523,8 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
531
523
|
|
|
532
524
|
ReadableMap center = camera.getMap("center");
|
|
533
525
|
if (center != null) {
|
|
534
|
-
|
|
535
|
-
|
|
526
|
+
double lng = center.getDouble("longitude");
|
|
527
|
+
double lat = center.getDouble("latitude");
|
|
536
528
|
builder.target(new LatLng(lat, lng));
|
|
537
529
|
}
|
|
538
530
|
|
|
@@ -628,24 +620,13 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
628
620
|
color = Color.parseColor("#606060");
|
|
629
621
|
}
|
|
630
622
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
ColorStateList indeterminateTintList = ColorStateList.valueOf(loadingIndicatorColor);
|
|
623
|
+
ColorStateList progressTintList = ColorStateList.valueOf(loadingIndicatorColor);
|
|
624
|
+
ColorStateList secondaryProgressTintList = ColorStateList.valueOf(loadingIndicatorColor);
|
|
625
|
+
ColorStateList indeterminateTintList = ColorStateList.valueOf(loadingIndicatorColor);
|
|
635
626
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
} else {
|
|
640
|
-
PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
|
|
641
|
-
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
|
|
642
|
-
mode = PorterDuff.Mode.MULTIPLY;
|
|
643
|
-
}
|
|
644
|
-
if (this.mapLoadingProgressBar.getIndeterminateDrawable() != null)
|
|
645
|
-
this.mapLoadingProgressBar.getIndeterminateDrawable().setColorFilter(color, mode);
|
|
646
|
-
if (this.mapLoadingProgressBar.getProgressDrawable() != null)
|
|
647
|
-
this.mapLoadingProgressBar.getProgressDrawable().setColorFilter(color, mode);
|
|
648
|
-
}
|
|
627
|
+
this.mapLoadingProgressBar.setProgressTintList(progressTintList);
|
|
628
|
+
this.mapLoadingProgressBar.setSecondaryProgressTintList(secondaryProgressTintList);
|
|
629
|
+
this.mapLoadingProgressBar.setIndeterminateTintList(indeterminateTintList);
|
|
649
630
|
}
|
|
650
631
|
}
|
|
651
632
|
|
|
@@ -931,8 +912,8 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
931
912
|
|
|
932
913
|
for (int i = 0; i < coordinatesArray.size(); i++) {
|
|
933
914
|
ReadableMap latLng = coordinatesArray.getMap(i);
|
|
934
|
-
|
|
935
|
-
|
|
915
|
+
double lat = latLng.getDouble("latitude");
|
|
916
|
+
double lng = latLng.getDouble("longitude");
|
|
936
917
|
builder.include(new LatLng(lat, lng));
|
|
937
918
|
}
|
|
938
919
|
|
|
@@ -986,12 +967,12 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
986
967
|
|
|
987
968
|
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
|
988
969
|
|
|
989
|
-
|
|
990
|
-
|
|
970
|
+
double latNE = northEast.getDouble("latitude");
|
|
971
|
+
double lngNE = northEast.getDouble("longitude");
|
|
991
972
|
builder.include(new LatLng(latNE, lngNE));
|
|
992
973
|
|
|
993
|
-
|
|
994
|
-
|
|
974
|
+
double latSW = southWest.getDouble("latitude");
|
|
975
|
+
double lngSW = southWest.getDouble("longitude");
|
|
995
976
|
builder.include(new LatLng(latSW, lngSW));
|
|
996
977
|
|
|
997
978
|
LatLngBounds bounds = builder.build();
|
|
@@ -1188,7 +1169,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
1188
1169
|
return;
|
|
1189
1170
|
}
|
|
1190
1171
|
|
|
1191
|
-
kmlLayer = new KmlLayer(map, kmlStream, context);
|
|
1172
|
+
KmlLayer kmlLayer = new KmlLayer(map, kmlStream, context);
|
|
1192
1173
|
kmlLayer.addLayerToMap();
|
|
1193
1174
|
|
|
1194
1175
|
WritableMap pointers = new WritableNativeMap();
|
|
@@ -1211,7 +1192,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
1211
1192
|
container = container.getContainers().iterator().next();
|
|
1212
1193
|
}
|
|
1213
1194
|
|
|
1214
|
-
|
|
1195
|
+
int index = 0;
|
|
1215
1196
|
for (KmlPlacemark placemark : container.getPlacemarks()) {
|
|
1216
1197
|
MarkerOptions options = new MarkerOptions();
|
|
1217
1198
|
|
|
@@ -1265,13 +1246,7 @@ public class AirMapView extends MapView implements GoogleMap.InfoWindowAdapter,
|
|
|
1265
1246
|
|
|
1266
1247
|
manager.pushEvent(context, this, "onKmlReady", pointers);
|
|
1267
1248
|
|
|
1268
|
-
} catch (XmlPullParserException e) {
|
|
1269
|
-
e.printStackTrace();
|
|
1270
|
-
} catch (IOException e) {
|
|
1271
|
-
e.printStackTrace();
|
|
1272
|
-
} catch (InterruptedException e) {
|
|
1273
|
-
e.printStackTrace();
|
|
1274
|
-
} catch (ExecutionException e) {
|
|
1249
|
+
} catch (XmlPullParserException | IOException | InterruptedException | ExecutionException e) {
|
|
1275
1250
|
e.printStackTrace();
|
|
1276
1251
|
}
|
|
1277
1252
|
}
|
|
@@ -2,10 +2,6 @@ package com.airbnb.android.react.maps;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
|
|
5
|
-
import android.util.Log;
|
|
6
|
-
|
|
7
|
-
import com.google.android.gms.maps.GoogleMap;
|
|
8
|
-
import com.google.android.gms.maps.model.TileOverlay;
|
|
9
5
|
import com.google.android.gms.maps.model.TileOverlayOptions;
|
|
10
6
|
import com.google.android.gms.maps.model.UrlTileProvider;
|
|
11
7
|
|
|
@@ -20,7 +16,7 @@ public class AirMapWMSTile extends AirMapUrlTile {
|
|
|
20
16
|
|
|
21
17
|
class AIRMapWMSTileProvider extends UrlTileProvider {
|
|
22
18
|
private String urlTemplate;
|
|
23
|
-
private int tileSize;
|
|
19
|
+
private final int tileSize;
|
|
24
20
|
|
|
25
21
|
public AIRMapWMSTileProvider(int width, int height, String urlTemplate) {
|
|
26
22
|
super(width, height);
|
|
@@ -80,8 +76,6 @@ public class AirMapWMSTile extends AirMapUrlTile {
|
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
78
|
|
|
83
|
-
private AIRMapGSUrlTileProvider tileProvider;
|
|
84
|
-
|
|
85
79
|
public AirMapWMSTile(Context context) {
|
|
86
80
|
super(context);
|
|
87
81
|
}
|
|
@@ -91,10 +85,10 @@ public class AirMapWMSTile extends AirMapUrlTile {
|
|
|
91
85
|
TileOverlayOptions options = new TileOverlayOptions();
|
|
92
86
|
options.zIndex(zIndex);
|
|
93
87
|
options.transparency(1 - this.opacity);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
options.tileProvider(
|
|
88
|
+
AIRMapGSUrlTileProvider tileProvider = new AIRMapGSUrlTileProvider((int) this.tileSize, this.urlTemplate,
|
|
89
|
+
(int) this.maximumZ, (int) this.maximumNativeZ, (int) this.minimumZ, this.tileCachePath,
|
|
90
|
+
(int) this.tileCacheMaxAge, this.offlineMode, this.context, this.customTileProviderNeeded);
|
|
91
|
+
options.tileProvider(tileProvider);
|
|
98
92
|
return options;
|
|
99
93
|
}
|
|
100
94
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.airbnb.android.react.maps;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
-
import android.os.Build;
|
|
5
4
|
import android.util.DisplayMetrics;
|
|
6
5
|
import android.view.WindowManager;
|
|
7
6
|
|
|
@@ -11,18 +10,13 @@ import com.facebook.react.uimanager.ViewGroupManager;
|
|
|
11
10
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
12
11
|
|
|
13
12
|
public class AirMapWMSTileManager extends ViewGroupManager<AirMapWMSTile> {
|
|
14
|
-
private DisplayMetrics metrics;
|
|
15
13
|
|
|
16
14
|
public AirMapWMSTileManager(ReactApplicationContext reactContext) {
|
|
17
15
|
super();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.getRealMetrics(metrics);
|
|
23
|
-
} else {
|
|
24
|
-
metrics = reactContext.getResources().getDisplayMetrics();
|
|
25
|
-
}
|
|
16
|
+
DisplayMetrics metrics = new DisplayMetrics();
|
|
17
|
+
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE))
|
|
18
|
+
.getDefaultDisplay()
|
|
19
|
+
.getRealMetrics(metrics);
|
|
26
20
|
}
|
|
27
21
|
|
|
28
22
|
@Override
|
|
@@ -18,10 +18,6 @@ import java.nio.channels.ReadableByteChannel;
|
|
|
18
18
|
|
|
19
19
|
public class FileUtil extends AsyncTask<String, Void, InputStream> {
|
|
20
20
|
|
|
21
|
-
private final String NAME = "FileUtil";
|
|
22
|
-
private final String TEMP_FILE_SUFFIX = "temp";
|
|
23
|
-
|
|
24
|
-
private Exception exception;
|
|
25
21
|
private Context context;
|
|
26
22
|
|
|
27
23
|
public FileUtil(Context context) {
|
|
@@ -39,7 +35,6 @@ public class FileUtil extends AsyncTask<String, Void, InputStream> {
|
|
|
39
35
|
}
|
|
40
36
|
return context.getContentResolver().openInputStream(fileContentUri);
|
|
41
37
|
} catch (Exception e) {
|
|
42
|
-
this.exception = e;
|
|
43
38
|
FLog.e(
|
|
44
39
|
ReactConstants.TAG,
|
|
45
40
|
"Could not retrieve file for contentUri " + urls[0],
|
|
@@ -51,6 +46,8 @@ public class FileUtil extends AsyncTask<String, Void, InputStream> {
|
|
|
51
46
|
private InputStream getDownloadFileInputStream(Context context, Uri uri)
|
|
52
47
|
throws IOException {
|
|
53
48
|
final File outputDir = context.getApplicationContext().getCacheDir();
|
|
49
|
+
String NAME = "FileUtil";
|
|
50
|
+
String TEMP_FILE_SUFFIX = "temp";
|
|
54
51
|
final File file = File.createTempFile(NAME, TEMP_FILE_SUFFIX, outputDir);
|
|
55
52
|
file.deleteOnExit();
|
|
56
53
|
|
|
@@ -49,7 +49,7 @@ public class ImageReader {
|
|
|
49
49
|
imageReference = dataSource.getResult();
|
|
50
50
|
if (imageReference != null) {
|
|
51
51
|
CloseableImage image = imageReference.get();
|
|
52
|
-
if (image
|
|
52
|
+
if (image instanceof CloseableStaticBitmap) {
|
|
53
53
|
CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
|
|
54
54
|
Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
|
|
55
55
|
if (bitmap != null) {
|
|
@@ -104,11 +104,9 @@ public class ImageReader {
|
|
|
104
104
|
logoHolder.setController(controller);
|
|
105
105
|
} else {
|
|
106
106
|
BitmapDescriptor iconBitmapDescriptor = getBitmapDescriptorByName(uri);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
(uri)));
|
|
111
|
-
}
|
|
107
|
+
imp.setIconBitmapDescriptor(iconBitmapDescriptor);
|
|
108
|
+
imp.setIconBitmap(BitmapFactory.decodeResource(this.resources, getDrawableResourceByName
|
|
109
|
+
(uri)));
|
|
112
110
|
imp.update();
|
|
113
111
|
}
|
|
114
112
|
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
package com.airbnb.android.react.maps;
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
|
-
import android.graphics.Canvas;
|
|
5
4
|
import android.graphics.Rect;
|
|
6
|
-
import android.os.Build;
|
|
7
5
|
|
|
8
|
-
import com.facebook.react.uimanager.ViewProps;
|
|
9
6
|
import com.facebook.react.views.view.ReactViewGroup;
|
|
10
7
|
|
|
11
8
|
public class ViewAttacherGroup extends ReactViewGroup {
|
|
@@ -17,9 +14,7 @@ public class ViewAttacherGroup extends ReactViewGroup {
|
|
|
17
14
|
this.setVisibility(VISIBLE);
|
|
18
15
|
this.setAlpha(0.0f);
|
|
19
16
|
this.setRemoveClippedSubviews(false);
|
|
20
|
-
|
|
21
|
-
this.setClipBounds(new Rect(0, 0, 0, 0));
|
|
22
|
-
}
|
|
17
|
+
this.setClipBounds(new Rect(0, 0, 0, 0));
|
|
23
18
|
this.setOverflow("hidden"); // Change to ViewProps.HIDDEN until RN 0.57 is base
|
|
24
19
|
}
|
|
25
20
|
|
|
@@ -8,10 +8,10 @@ import java.util.LinkedList;
|
|
|
8
8
|
public class ViewChangesTracker {
|
|
9
9
|
|
|
10
10
|
private static ViewChangesTracker instance;
|
|
11
|
-
private Handler handler;
|
|
12
|
-
private LinkedList<AirMapMarker> markers = new LinkedList<>();
|
|
11
|
+
private final Handler handler;
|
|
12
|
+
private final LinkedList<AirMapMarker> markers = new LinkedList<>();
|
|
13
13
|
private boolean hasScheduledFrame = false;
|
|
14
|
-
private Runnable updateRunnable;
|
|
14
|
+
private final Runnable updateRunnable;
|
|
15
15
|
private final long fps = 40;
|
|
16
16
|
|
|
17
17
|
private ViewChangesTracker() {
|
|
@@ -56,7 +56,7 @@ public class ViewChangesTracker {
|
|
|
56
56
|
return markers.contains(marker);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
private LinkedList<AirMapMarker> markersToRemove = new LinkedList<>();
|
|
59
|
+
private final LinkedList<AirMapMarker> markersToRemove = new LinkedList<>();
|
|
60
60
|
|
|
61
61
|
public void update() {
|
|
62
62
|
for (AirMapMarker marker : markers) {
|
package/lib/Geojson.d.ts
CHANGED
|
@@ -130,6 +130,17 @@ export declare type GeojsonProps = {
|
|
|
130
130
|
* @platform — Android: Supported
|
|
131
131
|
*/
|
|
132
132
|
title?: MarkerProps['title'];
|
|
133
|
+
/**
|
|
134
|
+
* Sets whether this marker should track view changes.
|
|
135
|
+
* It's recommended to turn it off whenever it's possible to improve custom marker performance.
|
|
136
|
+
* This is the default value for all point markers in your geojson data. It can be overriden
|
|
137
|
+
* on a per point basis by adding a `trackViewChanges` property to the `properties` object on the point.
|
|
138
|
+
*
|
|
139
|
+
* @default true
|
|
140
|
+
* @platform iOS: Google Maps only
|
|
141
|
+
* @platform Android: Supported
|
|
142
|
+
*/
|
|
143
|
+
tracksViewChanges?: boolean;
|
|
133
144
|
/**
|
|
134
145
|
* The order in which this tile overlay is drawn with respect to other overlays. An overlay
|
|
135
146
|
* with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays
|
package/lib/Geojson.js
CHANGED
|
@@ -31,14 +31,15 @@ const MapMarker_1 = __importDefault(require("./MapMarker"));
|
|
|
31
31
|
const MapPolyline_1 = __importDefault(require("./MapPolyline"));
|
|
32
32
|
const MapPolygon_1 = __importDefault(require("./MapPolygon"));
|
|
33
33
|
const Geojson = (props) => {
|
|
34
|
-
const { geojson, strokeColor, fillColor, strokeWidth, color, title, image, zIndex, onPress, lineCap, lineJoin, tappable, miterLimit, lineDashPhase, lineDashPattern, markerComponent, } = props;
|
|
34
|
+
const { geojson, strokeColor, fillColor, strokeWidth, color, title, image, zIndex, onPress, lineCap, lineJoin, tappable, tracksViewChanges, miterLimit, lineDashPhase, lineDashPattern, markerComponent, } = props;
|
|
35
35
|
const pointOverlays = makePointOverlays(geojson.features);
|
|
36
36
|
const lineOverlays = makeLineOverlays(geojson.features);
|
|
37
37
|
const polygonOverlays = makePolygonOverlays(geojson.features);
|
|
38
38
|
return (<React.Fragment>
|
|
39
39
|
{pointOverlays.map((overlay, index) => {
|
|
40
40
|
const markerColor = getColor(color, overlay, 'marker-color');
|
|
41
|
-
|
|
41
|
+
const pointOverlayTracksViewChanges = overlay.feature.properties?.tracksViewChanges || tracksViewChanges;
|
|
42
|
+
return (<MapMarker_1.default key={index} coordinate={overlay.coordinates} tracksViewChanges={pointOverlayTracksViewChanges} image={image} title={title} pinColor={markerColor} zIndex={zIndex} onPress={() => onPress && onPress(overlay)}>
|
|
42
43
|
{markerComponent}
|
|
43
44
|
</MapMarker_1.default>);
|
|
44
45
|
})}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Leland Richardson <leland.m.richardson@gmail.com>",
|
|
7
7
|
"homepage": "https://github.com/react-native-maps/react-native-maps#readme",
|
|
8
|
-
"version": "1.
|
|
8
|
+
"version": "1.2.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|