react-native-map4d-map-dtqg 0.1.1 → 0.1.3
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/LICENSE +21 -21
- package/README.md +133 -88
- package/android/build.gradle +60 -60
- package/android/src/main/AndroidManifest.xml +4 -4
- package/android/src/main/java/com/reactnativemap4dmap/ImageUtils.java +87 -87
- package/android/src/main/java/com/reactnativemap4dmap/Map4dMapModule.java +298 -298
- package/android/src/main/java/com/reactnativemap4dmap/Map4dMapPackage.java +35 -35
- package/android/src/main/java/com/reactnativemap4dmap/Map4dMapViewManager.java +31 -31
- package/android/src/main/java/com/reactnativemap4dmap/RMFBuilding.java +167 -167
- package/android/src/main/java/com/reactnativemap4dmap/RMFBuildingManager.java +121 -121
- package/android/src/main/java/com/reactnativemap4dmap/RMFCircle.java +105 -105
- package/android/src/main/java/com/reactnativemap4dmap/RMFCircleManager.java +121 -121
- package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRenderer.java +502 -502
- package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRendererManager.java +143 -143
- package/android/src/main/java/com/reactnativemap4dmap/RMFFeature.java +17 -17
- package/android/src/main/java/com/reactnativemap4dmap/RMFMapView.java +1172 -1172
- package/android/src/main/java/com/reactnativemap4dmap/RMFMapViewManager.java +231 -226
- package/android/src/main/java/com/reactnativemap4dmap/RMFMarker.java +412 -412
- package/android/src/main/java/com/reactnativemap4dmap/RMFMarkerManager.java +211 -211
- package/android/src/main/java/com/reactnativemap4dmap/RMFPOI.java +222 -222
- package/android/src/main/java/com/reactnativemap4dmap/RMFPOIManager.java +119 -119
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolygon.java +172 -172
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolygonManager.java +147 -147
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolyline.java +146 -146
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolylineManager.java +137 -137
- package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlay.java +95 -95
- package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlayManager.java +64 -64
- package/android/src/main/java/com/reactnativemap4dmap/SizeReportingShadowNode.java +31 -31
- package/android/src/main/java/com/reactnativemap4dmap/ViewAttacherGroup.java +31 -31
- package/android/src/main/java/com/reactnativemap4dmap/ViewChangesTracker.java +70 -70
- package/android/src/main/java/vn/map4d/map/annotations/RMFBitmapDescriptor.java +9 -9
- package/ios/Map4dMap.h +7 -7
- package/ios/Map4dMap.m +14 -14
- package/ios/Map4dMap.xcodeproj/project.pbxproj +2 -2
- package/ios/Map4dMapViewManager.m +34 -34
- package/ios/RCTConvert+Map4dMap.h +33 -33
- package/ios/RCTConvert+Map4dMap.m +112 -112
- package/ios/RMFCircle.h +37 -37
- package/ios/RMFCircle.m +100 -100
- package/ios/RMFCircleManager.h +18 -18
- package/ios/RMFCircleManager.m +155 -155
- package/ios/RMFCircleMap4d.h +23 -23
- package/ios/RMFCircleMap4d.m +13 -13
- package/ios/RMFCoordinate.h +22 -22
- package/ios/RMFCoordinate.m +13 -13
- package/ios/RMFDirectionsMarkerOptions.h +24 -24
- package/ios/RMFDirectionsMarkerOptions.m +23 -23
- package/ios/RMFDirectionsRenderer.h +47 -47
- package/ios/RMFDirectionsRenderer.m +182 -182
- package/ios/RMFDirectionsRendererManager.h +17 -17
- package/ios/RMFDirectionsRendererManager.m +84 -84
- package/ios/RMFDirectionsRendererMap4d.h +21 -21
- package/ios/RMFDirectionsRendererMap4d.m +12 -12
- package/ios/RMFDummyView.h +6 -6
- package/ios/RMFDummyView.m +12 -12
- package/ios/RMFEventResponse.h +39 -39
- package/ios/RMFEventResponse.m +98 -98
- package/ios/RMFIcon.h +24 -24
- package/ios/RMFIcon.m +35 -35
- package/ios/RMFMapView.h +84 -84
- package/ios/RMFMapView.m +376 -376
- package/ios/RMFMapViewManager.h +17 -17
- package/ios/RMFMapViewManager.m +509 -493
- package/ios/RMFMarker.h +57 -57
- package/ios/RMFMarker.m +267 -267
- package/ios/RMFMarkerManager.h +17 -17
- package/ios/RMFMarkerManager.m +156 -156
- package/ios/RMFMarkerMap4d.h +19 -19
- package/ios/RMFMarkerMap4d.m +13 -13
- package/ios/RMFPOI.h +38 -38
- package/ios/RMFPOI.m +123 -123
- package/ios/RMFPOIManager.h +18 -18
- package/ios/RMFPOIManager.m +168 -168
- package/ios/RMFPOIMap4d.h +22 -22
- package/ios/RMFPOIMap4d.m +12 -12
- package/ios/RMFPolygon.h +41 -41
- package/ios/RMFPolygon.m +106 -106
- package/ios/RMFPolygonManager.h +18 -18
- package/ios/RMFPolygonManager.m +141 -141
- package/ios/RMFPolygonMap4d.h +23 -23
- package/ios/RMFPolygonMap4d.m +15 -15
- package/ios/RMFPolyline.h +38 -38
- package/ios/RMFPolyline.m +101 -101
- package/ios/RMFPolylineManager.h +18 -18
- package/ios/RMFPolylineManager.m +139 -139
- package/ios/RMFPolylineMap4d.h +22 -22
- package/ios/RMFPolylineMap4d.m +15 -15
- package/ios/building/RMFBuilding.h +41 -41
- package/ios/building/RMFBuilding.m +104 -104
- package/ios/building/RMFBuildingManager.h +19 -19
- package/ios/building/RMFBuildingManager.m +133 -133
- package/ios/building/RMFBuildingMap4d.h +23 -23
- package/ios/building/RMFBuildingMap4d.m +15 -15
- package/ios/overlays/RMFTileOverlay.h +36 -36
- package/ios/overlays/RMFTileOverlay.m +64 -64
- package/ios/overlays/RMFTileOverlayManager.h +17 -17
- package/ios/overlays/RMFTileOverlayManager.m +27 -27
- package/lib/commonjs/components/MFBanDoSo.js +109 -0
- package/lib/commonjs/components/MFBanDoSo.js.map +1 -0
- package/lib/commonjs/components/MFBuilding.js +26 -26
- package/lib/commonjs/components/MFBuilding.js.map +1 -1
- package/lib/commonjs/components/MFCircle.js +20 -20
- package/lib/commonjs/components/MFCircle.js.map +1 -1
- package/lib/commonjs/components/MFDirectionsRenderer.js +32 -32
- package/lib/commonjs/components/MFDirectionsRenderer.js.map +1 -1
- package/lib/commonjs/components/MFMapView.js +89 -70
- package/lib/commonjs/components/MFMapView.js.map +1 -1
- package/lib/commonjs/components/MFMarker.js +35 -35
- package/lib/commonjs/components/MFMarker.js.map +1 -1
- package/lib/commonjs/components/MFPOI.js +20 -20
- package/lib/commonjs/components/MFPOI.js.map +1 -1
- package/lib/commonjs/components/MFPolygon.js +22 -22
- package/lib/commonjs/components/MFPolygon.js.map +1 -1
- package/lib/commonjs/components/MFPolyline.js +18 -18
- package/lib/commonjs/components/MFPolyline.js.map +1 -1
- package/lib/commonjs/components/MFTileOverlay.js +9 -9
- package/lib/commonjs/components/MFTileOverlay.js.map +1 -1
- package/lib/commonjs/components/Map4dMapView.js.map +1 -1
- package/lib/commonjs/components/extends/AreaFocusManager.js +205 -0
- package/lib/commonjs/components/extends/AreaFocusManager.js.map +1 -0
- package/lib/commonjs/components/extends/AreaFocuser.js +21 -259
- package/lib/commonjs/components/extends/AreaFocuser.js.map +1 -1
- package/lib/commonjs/components/extends/BoundHelper.js +36 -0
- package/lib/commonjs/components/extends/BoundHelper.js.map +1 -0
- package/lib/commonjs/components/extends/area/AreaFocusAreas.js +167 -0
- package/lib/commonjs/components/extends/area/AreaFocusAreas.js.map +1 -0
- package/lib/commonjs/components/extends/area/AreaFocusGeometryUtils.js +164 -0
- package/lib/commonjs/components/extends/area/AreaFocusGeometryUtils.js.map +1 -0
- package/lib/commonjs/components/extends/area/AreaFocusSession.js +100 -0
- package/lib/commonjs/components/extends/area/AreaFocusSession.js.map +1 -0
- package/lib/commonjs/components/extends/area/AreaFocusTypes.js +40 -0
- package/lib/commonjs/components/extends/area/AreaFocusTypes.js.map +1 -0
- package/lib/commonjs/components/internal/DefaultRoadmapStyle.js +2288 -0
- package/lib/commonjs/components/internal/DefaultRoadmapStyle.js.map +1 -0
- package/lib/commonjs/components/internal/GeojsonStyleUtils.js +139 -0
- package/lib/commonjs/components/internal/GeojsonStyleUtils.js.map +1 -0
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/MFBanDoSo.js +92 -0
- package/lib/module/components/MFBanDoSo.js.map +1 -0
- package/lib/module/components/MFBuilding.js +26 -26
- package/lib/module/components/MFBuilding.js.map +1 -1
- package/lib/module/components/MFCircle.js +20 -20
- package/lib/module/components/MFCircle.js.map +1 -1
- package/lib/module/components/MFDirectionsRenderer.js +32 -32
- package/lib/module/components/MFDirectionsRenderer.js.map +1 -1
- package/lib/module/components/MFMapView.js +88 -70
- package/lib/module/components/MFMapView.js.map +1 -1
- package/lib/module/components/MFMarker.js +35 -35
- package/lib/module/components/MFMarker.js.map +1 -1
- package/lib/module/components/MFPOI.js +20 -20
- package/lib/module/components/MFPOI.js.map +1 -1
- package/lib/module/components/MFPolygon.js +22 -22
- package/lib/module/components/MFPolygon.js.map +1 -1
- package/lib/module/components/MFPolyline.js +18 -18
- package/lib/module/components/MFPolyline.js.map +1 -1
- package/lib/module/components/MFTileOverlay.js +9 -9
- package/lib/module/components/MFTileOverlay.js.map +1 -1
- package/lib/module/components/Map4dMapView.js.map +1 -1
- package/lib/module/components/extends/AreaFocusManager.js +193 -0
- package/lib/module/components/extends/AreaFocusManager.js.map +1 -0
- package/lib/module/components/extends/AreaFocuser.js +21 -259
- package/lib/module/components/extends/AreaFocuser.js.map +1 -1
- package/lib/module/components/extends/BoundHelper.js +29 -0
- package/lib/module/components/extends/BoundHelper.js.map +1 -0
- package/lib/module/components/extends/area/AreaFocusAreas.js +156 -0
- package/lib/module/components/extends/area/AreaFocusAreas.js.map +1 -0
- package/lib/module/components/extends/area/AreaFocusGeometryUtils.js +153 -0
- package/lib/module/components/extends/area/AreaFocusGeometryUtils.js.map +1 -0
- package/lib/module/components/extends/area/AreaFocusSession.js +93 -0
- package/lib/module/components/extends/area/AreaFocusSession.js.map +1 -0
- package/lib/module/components/extends/area/AreaFocusTypes.js +33 -0
- package/lib/module/components/extends/area/AreaFocusTypes.js.map +1 -0
- package/lib/module/components/internal/DefaultRoadmapStyle.js +2281 -0
- package/lib/module/components/internal/DefaultRoadmapStyle.js.map +1 -0
- package/lib/module/components/internal/GeojsonStyleUtils.js +130 -0
- package/lib/module/components/internal/GeojsonStyleUtils.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/components/Map4dMapView.d.ts +7 -7
- package/package.json +152 -152
- package/react-native-map4d-map.podspec +20 -20
- package/src/components/MFBanDoSo.js +124 -0
- package/src/components/MFBuilding.js +187 -187
- package/src/components/MFCircle.js +173 -173
- package/src/components/MFDirectionsRenderer.js +237 -237
- package/src/components/MFMapView.js +464 -447
- package/src/components/MFMarker.js +246 -246
- package/src/components/MFPOI.js +184 -184
- package/src/components/MFPolygon.js +186 -186
- package/src/components/MFPolyline.js +172 -172
- package/src/components/MFTileOverlay.js +45 -45
- package/src/components/Map4dMapView.tsx +26 -26
- package/src/components/extends/AreaFocusManager.js +196 -0
- package/src/components/extends/AreaFocuser.js +61 -338
- package/src/components/extends/BoundHelper.js +32 -0
- package/src/components/extends/area/AreaFocusAreas.js +164 -0
- package/src/components/extends/area/AreaFocusGeometryUtils.js +164 -0
- package/src/components/extends/area/AreaFocusSession.js +100 -0
- package/src/components/extends/area/AreaFocusTypes.js +36 -0
- package/src/components/internal/DefaultRoadmapStyle.js +3365 -0
- package/src/components/internal/GeojsonStyleUtils.js +143 -0
- package/src/index.js +25 -23
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/9.0-milestone-1/checksums/checksums.lock +0 -0
- package/android/.gradle/9.0-milestone-1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/9.0-milestone-1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/9.0-milestone-1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.0-milestone-1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.0-milestone-1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/config.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -1570
- package/android/.idea/copilot.data.migration.ask2agent.xml +0 -6
- package/android/.idea/gradle.xml +0 -12
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
|
@@ -1,502 +1,502 @@
|
|
|
1
|
-
package com.reactnativemap4dmap;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.graphics.Bitmap;
|
|
5
|
-
import android.graphics.BitmapFactory;
|
|
6
|
-
import android.graphics.Canvas;
|
|
7
|
-
import android.graphics.drawable.Animatable;
|
|
8
|
-
import android.graphics.drawable.Drawable;
|
|
9
|
-
import android.net.Uri;
|
|
10
|
-
|
|
11
|
-
import androidx.annotation.ColorInt;
|
|
12
|
-
import androidx.annotation.NonNull;
|
|
13
|
-
import androidx.annotation.Nullable;
|
|
14
|
-
|
|
15
|
-
import com.facebook.common.references.CloseableReference;
|
|
16
|
-
import com.facebook.datasource.DataSource;
|
|
17
|
-
import com.facebook.drawee.backends.pipeline.Fresco;
|
|
18
|
-
import com.facebook.drawee.controller.BaseControllerListener;
|
|
19
|
-
import com.facebook.drawee.controller.ControllerListener;
|
|
20
|
-
import com.facebook.drawee.drawable.ScalingUtils;
|
|
21
|
-
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
|
22
|
-
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
|
23
|
-
import com.facebook.drawee.interfaces.DraweeController;
|
|
24
|
-
import com.facebook.drawee.view.DraweeHolder;
|
|
25
|
-
import com.facebook.imagepipeline.core.ImagePipeline;
|
|
26
|
-
import com.facebook.imagepipeline.image.CloseableImage;
|
|
27
|
-
import com.facebook.imagepipeline.image.CloseableStaticBitmap;
|
|
28
|
-
import com.facebook.imagepipeline.image.ImageInfo;
|
|
29
|
-
import com.facebook.imagepipeline.request.ImageRequest;
|
|
30
|
-
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|
31
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
32
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
33
|
-
|
|
34
|
-
import java.util.ArrayList;
|
|
35
|
-
import java.util.List;
|
|
36
|
-
|
|
37
|
-
import vn.map4d.map.annotations.MFBitmapDescriptor;
|
|
38
|
-
import vn.map4d.map.annotations.MFBitmapDescriptorFactory;
|
|
39
|
-
import vn.map4d.map.annotations.MFDirectionsRenderer;
|
|
40
|
-
import vn.map4d.map.annotations.MFDirectionsRendererOptions;
|
|
41
|
-
import vn.map4d.map.core.Map4D;
|
|
42
|
-
import vn.map4d.types.MFLocationCoordinate;
|
|
43
|
-
|
|
44
|
-
public class RMFDirectionsRenderer extends RMFFeature {
|
|
45
|
-
|
|
46
|
-
private MFDirectionsRendererOptions options;
|
|
47
|
-
private MFDirectionsRenderer directionsRenderer;
|
|
48
|
-
|
|
49
|
-
private List<List<MFLocationCoordinate>> paths;
|
|
50
|
-
private MFLocationCoordinate startLocation;
|
|
51
|
-
private MFLocationCoordinate endLocation;
|
|
52
|
-
private String jsonData;
|
|
53
|
-
private float width;
|
|
54
|
-
private int activedIndex;
|
|
55
|
-
|
|
56
|
-
@ColorInt
|
|
57
|
-
private int activeStrokeColor;
|
|
58
|
-
|
|
59
|
-
@ColorInt
|
|
60
|
-
private int activeOutlineColor;
|
|
61
|
-
|
|
62
|
-
@ColorInt
|
|
63
|
-
private int inactiveStrokeColor;
|
|
64
|
-
|
|
65
|
-
@ColorInt
|
|
66
|
-
private int inactiveOutlineColor;
|
|
67
|
-
|
|
68
|
-
@ColorInt
|
|
69
|
-
private int titleColor;
|
|
70
|
-
|
|
71
|
-
@Nullable
|
|
72
|
-
private MFBitmapDescriptor startIcon;
|
|
73
|
-
|
|
74
|
-
@Nullable
|
|
75
|
-
private MFBitmapDescriptor endIcon;
|
|
76
|
-
|
|
77
|
-
private String startLabel;
|
|
78
|
-
|
|
79
|
-
private String endLabel;
|
|
80
|
-
|
|
81
|
-
private boolean originPOIVisible;
|
|
82
|
-
|
|
83
|
-
private boolean destinationPOIVisible;
|
|
84
|
-
|
|
85
|
-
private final DraweeHolder<?> startIconHolder;
|
|
86
|
-
private final DraweeHolder<?> endIconHolder;
|
|
87
|
-
private DataSource<CloseableReference<CloseableImage>> startIconDataSource;
|
|
88
|
-
private DataSource<CloseableReference<CloseableImage>> endIconDataSource;
|
|
89
|
-
private final ControllerListener<ImageInfo> mStartIconControllerListener =
|
|
90
|
-
new BaseControllerListener<ImageInfo>() {
|
|
91
|
-
@Override
|
|
92
|
-
public void onFinalImageSet(
|
|
93
|
-
String id,
|
|
94
|
-
@javax.annotation.Nullable final ImageInfo imageInfo,
|
|
95
|
-
@javax.annotation.Nullable Animatable animatable) {
|
|
96
|
-
CloseableReference<CloseableImage> imageReference = null;
|
|
97
|
-
try {
|
|
98
|
-
imageReference = startIconDataSource.getResult();
|
|
99
|
-
if (imageReference != null) {
|
|
100
|
-
CloseableImage image = imageReference.get();
|
|
101
|
-
if (image != null && image instanceof CloseableStaticBitmap) {
|
|
102
|
-
CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
|
|
103
|
-
Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
|
|
104
|
-
if (bitmap != null) {
|
|
105
|
-
bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
|
|
106
|
-
startIcon = MFBitmapDescriptorFactory.fromBitmap(bitmap);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} finally {
|
|
111
|
-
startIconDataSource.close();
|
|
112
|
-
if (imageReference != null) {
|
|
113
|
-
CloseableReference.closeSafely(imageReference);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (RMFDirectionsRenderer.this.directionsRenderer != null) {
|
|
118
|
-
RMFDirectionsRenderer.this.directionsRenderer.setStartIcon(startIcon);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
private final ControllerListener<ImageInfo> mEndIconControllerListener =
|
|
124
|
-
new BaseControllerListener<ImageInfo>() {
|
|
125
|
-
@Override
|
|
126
|
-
public void onFinalImageSet(
|
|
127
|
-
String id,
|
|
128
|
-
@javax.annotation.Nullable final ImageInfo imageInfo,
|
|
129
|
-
@javax.annotation.Nullable Animatable animatable) {
|
|
130
|
-
CloseableReference<CloseableImage> imageReference = null;
|
|
131
|
-
try {
|
|
132
|
-
imageReference = endIconDataSource.getResult();
|
|
133
|
-
if (imageReference != null) {
|
|
134
|
-
CloseableImage image = imageReference.get();
|
|
135
|
-
if (image != null && image instanceof CloseableStaticBitmap) {
|
|
136
|
-
CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
|
|
137
|
-
Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
|
|
138
|
-
if (bitmap != null) {
|
|
139
|
-
bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
|
|
140
|
-
endIcon = MFBitmapDescriptorFactory.fromBitmap(bitmap);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
} finally {
|
|
145
|
-
endIconDataSource.close();
|
|
146
|
-
if (imageReference != null) {
|
|
147
|
-
CloseableReference.closeSafely(imageReference);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (RMFDirectionsRenderer.this.directionsRenderer != null) {
|
|
152
|
-
RMFDirectionsRenderer.this.directionsRenderer.setEndIcon(endIcon);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
public RMFDirectionsRenderer(Context context) {
|
|
158
|
-
super(context);
|
|
159
|
-
paths = new ArrayList<>();
|
|
160
|
-
jsonData = null;
|
|
161
|
-
width = 10.f;
|
|
162
|
-
MFDirectionsRendererOptions optionsDefault = new MFDirectionsRendererOptions();
|
|
163
|
-
startLocation = optionsDefault.getStartLocation();
|
|
164
|
-
endLocation = optionsDefault.getEndLocation();
|
|
165
|
-
activeStrokeColor = optionsDefault.getActiveStrokeColor();
|
|
166
|
-
activeOutlineColor = optionsDefault.getActiveOutlineColor();
|
|
167
|
-
inactiveStrokeColor = optionsDefault.getInactiveStrokeColor();
|
|
168
|
-
inactiveOutlineColor = optionsDefault.getInactiveOutlineColor();
|
|
169
|
-
titleColor = optionsDefault.getTitleColor();
|
|
170
|
-
originPOIVisible = optionsDefault.isOriginPOIVisible();
|
|
171
|
-
destinationPOIVisible = optionsDefault.isDestinationPOIVisible();
|
|
172
|
-
startIcon = null;
|
|
173
|
-
endIcon = null;
|
|
174
|
-
startLabel = "";
|
|
175
|
-
endLabel = "";
|
|
176
|
-
startIconHolder = DraweeHolder.create(createDraweeHierarchy(), context);
|
|
177
|
-
startIconHolder.onAttach();
|
|
178
|
-
endIconHolder = DraweeHolder.create(createDraweeHierarchy(), context);
|
|
179
|
-
endIconHolder.onAttach();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
private GenericDraweeHierarchy createDraweeHierarchy() {
|
|
183
|
-
return new GenericDraweeHierarchyBuilder(getResources())
|
|
184
|
-
.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
|
|
185
|
-
.setFadeDuration(0)
|
|
186
|
-
.build();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
@Override
|
|
190
|
-
public void addToMap(Map4D map) {
|
|
191
|
-
this.directionsRenderer = map.addDirectionsRenderer(getOptions());
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
@Override
|
|
195
|
-
public void removeFromMap(Map4D map) {
|
|
196
|
-
if (directionsRenderer == null) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
directionsRenderer.remove();
|
|
200
|
-
directionsRenderer = null;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
@Override
|
|
204
|
-
public Object getFeature() {
|
|
205
|
-
return directionsRenderer;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
public MFDirectionsRendererOptions getOptions() {
|
|
209
|
-
if (options == null) {
|
|
210
|
-
options = new MFDirectionsRendererOptions();
|
|
211
|
-
}
|
|
212
|
-
fillOptions(options);
|
|
213
|
-
return options;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
private MFDirectionsRendererOptions fillOptions(MFDirectionsRendererOptions options) {
|
|
217
|
-
List<List<MFLocationCoordinate>> paths = new ArrayList<>();
|
|
218
|
-
for (int i = 0; i < this.paths.size(); ++i) {
|
|
219
|
-
List<MFLocationCoordinate> path = this.paths.get(i);
|
|
220
|
-
MFLocationCoordinate[] pathArray = new MFLocationCoordinate[path.size()];
|
|
221
|
-
path.toArray(pathArray);
|
|
222
|
-
paths.add(path);
|
|
223
|
-
}
|
|
224
|
-
options.paths(paths);
|
|
225
|
-
options.startLocation(startLocation);
|
|
226
|
-
options.endLocation(endLocation);
|
|
227
|
-
options.activedIndex(activedIndex);
|
|
228
|
-
options.jsonData(jsonData);
|
|
229
|
-
options.width(width);
|
|
230
|
-
if (!startLabel.isEmpty()) {
|
|
231
|
-
options.startLabel(startLabel);
|
|
232
|
-
}
|
|
233
|
-
if (!endLabel.isEmpty()) {
|
|
234
|
-
options.endLabel(endLabel);
|
|
235
|
-
}
|
|
236
|
-
if (startIcon != null) {
|
|
237
|
-
options.startIcon(startIcon);
|
|
238
|
-
}
|
|
239
|
-
if (endIcon != null) {
|
|
240
|
-
options.endIcon(endIcon);
|
|
241
|
-
}
|
|
242
|
-
options.originPOIVisible(originPOIVisible);
|
|
243
|
-
options.destinationPOIVisible(destinationPOIVisible);
|
|
244
|
-
options.activeStrokeColor(activeStrokeColor);
|
|
245
|
-
options.activeOutlineColor(activeOutlineColor);
|
|
246
|
-
options.inactiveStrokeColor(inactiveStrokeColor);
|
|
247
|
-
options.inactiveOutlineColor(inactiveOutlineColor);
|
|
248
|
-
options.titleColor(titleColor);
|
|
249
|
-
return options;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
public void setPaths(ReadableArray paths) {
|
|
253
|
-
if (paths == null) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
this.paths = new ArrayList<>(paths.size());
|
|
258
|
-
for (int i = 0; i < paths.size(); i++) {
|
|
259
|
-
ReadableArray path = paths.getArray(i);
|
|
260
|
-
List<MFLocationCoordinate> coordinates = new ArrayList<>();
|
|
261
|
-
for (int j = 0; j < path.size(); j++) {
|
|
262
|
-
ReadableMap coordinate = path.getMap(j);
|
|
263
|
-
coordinates.add(new MFLocationCoordinate(
|
|
264
|
-
coordinate.getDouble("latitude"),
|
|
265
|
-
coordinate.getDouble("longitude")));
|
|
266
|
-
}
|
|
267
|
-
this.paths.add(coordinates);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
public void setStartLocation(ReadableMap data) {
|
|
272
|
-
this.startLocation = new MFLocationCoordinate(data.getDouble("latitude"), data.getDouble("longitude"));
|
|
273
|
-
if (directionsRenderer != null) {
|
|
274
|
-
directionsRenderer.setStartLocation(this.startLocation);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
public void setEndLocation(ReadableMap data) {
|
|
279
|
-
this.endLocation = new MFLocationCoordinate(data.getDouble("latitude"), data.getDouble("longitude"));
|
|
280
|
-
if (directionsRenderer != null) {
|
|
281
|
-
directionsRenderer.setEndLocation(this.endLocation);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
public void setJsonData(@NonNull String jsonData) {
|
|
286
|
-
this.jsonData = jsonData;
|
|
287
|
-
if (directionsRenderer != null) {
|
|
288
|
-
directionsRenderer.setJsonData(this.jsonData);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
public void setActivedIndex(int activedIndex) {
|
|
293
|
-
this.activedIndex = activedIndex;
|
|
294
|
-
if (directionsRenderer != null) {
|
|
295
|
-
directionsRenderer.setActivedIndex(this.activedIndex);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
public void setWidth(float width) {
|
|
300
|
-
this.width = width;
|
|
301
|
-
if (directionsRenderer != null) {
|
|
302
|
-
directionsRenderer.setWidth(this.width);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
public void setActiveStrokeColor(@ColorInt int color) {
|
|
307
|
-
this.activeStrokeColor = color;
|
|
308
|
-
if (directionsRenderer != null) {
|
|
309
|
-
directionsRenderer.setActiveStrokeColor(color);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
public void setActiveOutlineColor(@ColorInt int color) {
|
|
314
|
-
this.activeOutlineColor = color;
|
|
315
|
-
if (directionsRenderer != null) {
|
|
316
|
-
directionsRenderer.setActiveOutlineColor(color);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
public void setInactiveStrokeColor(@ColorInt int color) {
|
|
321
|
-
this.inactiveStrokeColor = color;
|
|
322
|
-
if (directionsRenderer != null) {
|
|
323
|
-
directionsRenderer.setInactiveStrokeColor(color);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
public void setInactiveOutlineColor(@ColorInt int color) {
|
|
328
|
-
this.inactiveOutlineColor = color;
|
|
329
|
-
if (directionsRenderer != null) {
|
|
330
|
-
directionsRenderer.setInactiveOutlineColor(color);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
public void setTitleColor(@ColorInt int color) {
|
|
335
|
-
this.titleColor = color;
|
|
336
|
-
if (directionsRenderer != null) {
|
|
337
|
-
directionsRenderer.setTitleColor(color);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
public void setStartLabel(@NonNull String label) {
|
|
342
|
-
startLabel = label;
|
|
343
|
-
if (directionsRenderer != null) {
|
|
344
|
-
directionsRenderer.setStartLabel(startLabel);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
public void setEndLabel(@NonNull String label) {
|
|
349
|
-
endLabel = label;
|
|
350
|
-
if (directionsRenderer != null) {
|
|
351
|
-
directionsRenderer.setEndLabel(endLabel);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
public void setOriginPOIVisible(boolean visible) {
|
|
356
|
-
originPOIVisible = visible;
|
|
357
|
-
if (directionsRenderer != null) {
|
|
358
|
-
directionsRenderer.setOriginPOIVisible(visible);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
public void setDestinationPOIVisible(boolean visible) {
|
|
363
|
-
destinationPOIVisible = visible;
|
|
364
|
-
if (directionsRenderer != null) {
|
|
365
|
-
directionsRenderer.setDestinationPOIVisible(visible);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
public void setStartIcon(String uri) {
|
|
370
|
-
if (uri == null) {
|
|
371
|
-
startIcon = null;
|
|
372
|
-
}
|
|
373
|
-
else if (uri.startsWith("http://") || uri.startsWith("https://") ||
|
|
374
|
-
uri.startsWith("file://") || uri.startsWith("asset://") || uri.startsWith("data:")) {
|
|
375
|
-
ImageRequest imageRequest = ImageRequestBuilder
|
|
376
|
-
.newBuilderWithSource(Uri.parse(uri))
|
|
377
|
-
.build();
|
|
378
|
-
|
|
379
|
-
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
|
380
|
-
startIconDataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
|
|
381
|
-
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
|
382
|
-
.setImageRequest(imageRequest)
|
|
383
|
-
.setControllerListener(mStartIconControllerListener)
|
|
384
|
-
.setOldController(startIconHolder.getController())
|
|
385
|
-
.build();
|
|
386
|
-
startIconHolder.setController(controller);
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
startIcon = ImageUtils.getBitmapDescriptorByName(this, uri);
|
|
390
|
-
if (startIcon != null) {
|
|
391
|
-
int drawableId = ImageUtils.getDrawableResourceByName(this, uri);
|
|
392
|
-
Bitmap iconBitmap = BitmapFactory.decodeResource(getResources(), drawableId);
|
|
393
|
-
if (iconBitmap == null) { // VectorDrawable or similar
|
|
394
|
-
Drawable drawable = getResources().getDrawable(drawableId);
|
|
395
|
-
iconBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
|
396
|
-
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
|
397
|
-
Canvas canvas = new Canvas(iconBitmap);
|
|
398
|
-
drawable.draw(canvas);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
public void setEndIcon(String uri) {
|
|
405
|
-
if (uri == null) {
|
|
406
|
-
endIcon = null;
|
|
407
|
-
}
|
|
408
|
-
else if (uri.startsWith("http://") || uri.startsWith("https://") ||
|
|
409
|
-
uri.startsWith("file://") || uri.startsWith("asset://") || uri.startsWith("data:")) {
|
|
410
|
-
ImageRequest imageRequest = ImageRequestBuilder
|
|
411
|
-
.newBuilderWithSource(Uri.parse(uri))
|
|
412
|
-
.build();
|
|
413
|
-
|
|
414
|
-
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
|
415
|
-
endIconDataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
|
|
416
|
-
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
|
417
|
-
.setImageRequest(imageRequest)
|
|
418
|
-
.setControllerListener(mEndIconControllerListener)
|
|
419
|
-
.setOldController(endIconHolder.getController())
|
|
420
|
-
.build();
|
|
421
|
-
endIconHolder.setController(controller);
|
|
422
|
-
}
|
|
423
|
-
else {
|
|
424
|
-
endIcon = ImageUtils.getBitmapDescriptorByName(this, uri);
|
|
425
|
-
if (endIcon != null) {
|
|
426
|
-
int drawableId = ImageUtils.getDrawableResourceByName(this, uri);
|
|
427
|
-
Bitmap iconBitmap = BitmapFactory.decodeResource(getResources(), drawableId);
|
|
428
|
-
if (iconBitmap == null) { // VectorDrawable or similar
|
|
429
|
-
Drawable drawable = getResources().getDrawable(drawableId);
|
|
430
|
-
iconBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
|
431
|
-
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
|
432
|
-
Canvas canvas = new Canvas(iconBitmap);
|
|
433
|
-
drawable.draw(canvas);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
public void setOriginPOIOptions(ReadableMap map) {
|
|
440
|
-
if (map == null) {
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
if (map.hasKey("coordinate")) {
|
|
445
|
-
ReadableMap coordinate = map.getMap("coordinate");
|
|
446
|
-
this.setStartLocation(coordinate);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
if (map.hasKey("icon")) {
|
|
450
|
-
ReadableMap icon = map.getMap("icon");
|
|
451
|
-
if (icon.hasKey("uri")) {
|
|
452
|
-
String uri = icon.getString("uri");
|
|
453
|
-
this.setStartIcon(uri);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
if (map.hasKey("title")) {
|
|
458
|
-
String title = map.getString("title");
|
|
459
|
-
this.setStartLabel(title);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
if (map.hasKey("titleColor")) {
|
|
463
|
-
this.setTitleColor(map.getInt("titleColor"));
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
if (map.hasKey("visible")) {
|
|
467
|
-
this.setOriginPOIVisible(map.getBoolean("visible"));
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
public void setDestinationPOIOptions(ReadableMap map) {
|
|
472
|
-
if (map == null) {
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
if (map.hasKey("coordinate")) {
|
|
477
|
-
ReadableMap coordinate = map.getMap("coordinate");
|
|
478
|
-
this.setEndLocation(coordinate);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
if (map.hasKey("icon")) {
|
|
482
|
-
ReadableMap icon = map.getMap("icon");
|
|
483
|
-
if (icon.hasKey("uri")) {
|
|
484
|
-
String uri = icon.getString("uri");
|
|
485
|
-
this.setEndIcon(uri);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
if (map.hasKey("title")) {
|
|
490
|
-
String title = map.getString("title");
|
|
491
|
-
this.setEndLabel(title);
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
if (map.hasKey("titleColor")) {
|
|
495
|
-
this.setTitleColor(map.getInt("titleColor"));
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
if (map.hasKey("visible")) {
|
|
499
|
-
this.setDestinationPOIVisible(map.getBoolean("visible"));
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
}
|
|
1
|
+
package com.reactnativemap4dmap;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.graphics.Bitmap;
|
|
5
|
+
import android.graphics.BitmapFactory;
|
|
6
|
+
import android.graphics.Canvas;
|
|
7
|
+
import android.graphics.drawable.Animatable;
|
|
8
|
+
import android.graphics.drawable.Drawable;
|
|
9
|
+
import android.net.Uri;
|
|
10
|
+
|
|
11
|
+
import androidx.annotation.ColorInt;
|
|
12
|
+
import androidx.annotation.NonNull;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
|
|
15
|
+
import com.facebook.common.references.CloseableReference;
|
|
16
|
+
import com.facebook.datasource.DataSource;
|
|
17
|
+
import com.facebook.drawee.backends.pipeline.Fresco;
|
|
18
|
+
import com.facebook.drawee.controller.BaseControllerListener;
|
|
19
|
+
import com.facebook.drawee.controller.ControllerListener;
|
|
20
|
+
import com.facebook.drawee.drawable.ScalingUtils;
|
|
21
|
+
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
|
22
|
+
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
|
23
|
+
import com.facebook.drawee.interfaces.DraweeController;
|
|
24
|
+
import com.facebook.drawee.view.DraweeHolder;
|
|
25
|
+
import com.facebook.imagepipeline.core.ImagePipeline;
|
|
26
|
+
import com.facebook.imagepipeline.image.CloseableImage;
|
|
27
|
+
import com.facebook.imagepipeline.image.CloseableStaticBitmap;
|
|
28
|
+
import com.facebook.imagepipeline.image.ImageInfo;
|
|
29
|
+
import com.facebook.imagepipeline.request.ImageRequest;
|
|
30
|
+
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|
31
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
32
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
33
|
+
|
|
34
|
+
import java.util.ArrayList;
|
|
35
|
+
import java.util.List;
|
|
36
|
+
|
|
37
|
+
import vn.map4d.map.annotations.MFBitmapDescriptor;
|
|
38
|
+
import vn.map4d.map.annotations.MFBitmapDescriptorFactory;
|
|
39
|
+
import vn.map4d.map.annotations.MFDirectionsRenderer;
|
|
40
|
+
import vn.map4d.map.annotations.MFDirectionsRendererOptions;
|
|
41
|
+
import vn.map4d.map.core.Map4D;
|
|
42
|
+
import vn.map4d.types.MFLocationCoordinate;
|
|
43
|
+
|
|
44
|
+
public class RMFDirectionsRenderer extends RMFFeature {
|
|
45
|
+
|
|
46
|
+
private MFDirectionsRendererOptions options;
|
|
47
|
+
private MFDirectionsRenderer directionsRenderer;
|
|
48
|
+
|
|
49
|
+
private List<List<MFLocationCoordinate>> paths;
|
|
50
|
+
private MFLocationCoordinate startLocation;
|
|
51
|
+
private MFLocationCoordinate endLocation;
|
|
52
|
+
private String jsonData;
|
|
53
|
+
private float width;
|
|
54
|
+
private int activedIndex;
|
|
55
|
+
|
|
56
|
+
@ColorInt
|
|
57
|
+
private int activeStrokeColor;
|
|
58
|
+
|
|
59
|
+
@ColorInt
|
|
60
|
+
private int activeOutlineColor;
|
|
61
|
+
|
|
62
|
+
@ColorInt
|
|
63
|
+
private int inactiveStrokeColor;
|
|
64
|
+
|
|
65
|
+
@ColorInt
|
|
66
|
+
private int inactiveOutlineColor;
|
|
67
|
+
|
|
68
|
+
@ColorInt
|
|
69
|
+
private int titleColor;
|
|
70
|
+
|
|
71
|
+
@Nullable
|
|
72
|
+
private MFBitmapDescriptor startIcon;
|
|
73
|
+
|
|
74
|
+
@Nullable
|
|
75
|
+
private MFBitmapDescriptor endIcon;
|
|
76
|
+
|
|
77
|
+
private String startLabel;
|
|
78
|
+
|
|
79
|
+
private String endLabel;
|
|
80
|
+
|
|
81
|
+
private boolean originPOIVisible;
|
|
82
|
+
|
|
83
|
+
private boolean destinationPOIVisible;
|
|
84
|
+
|
|
85
|
+
private final DraweeHolder<?> startIconHolder;
|
|
86
|
+
private final DraweeHolder<?> endIconHolder;
|
|
87
|
+
private DataSource<CloseableReference<CloseableImage>> startIconDataSource;
|
|
88
|
+
private DataSource<CloseableReference<CloseableImage>> endIconDataSource;
|
|
89
|
+
private final ControllerListener<ImageInfo> mStartIconControllerListener =
|
|
90
|
+
new BaseControllerListener<ImageInfo>() {
|
|
91
|
+
@Override
|
|
92
|
+
public void onFinalImageSet(
|
|
93
|
+
String id,
|
|
94
|
+
@javax.annotation.Nullable final ImageInfo imageInfo,
|
|
95
|
+
@javax.annotation.Nullable Animatable animatable) {
|
|
96
|
+
CloseableReference<CloseableImage> imageReference = null;
|
|
97
|
+
try {
|
|
98
|
+
imageReference = startIconDataSource.getResult();
|
|
99
|
+
if (imageReference != null) {
|
|
100
|
+
CloseableImage image = imageReference.get();
|
|
101
|
+
if (image != null && image instanceof CloseableStaticBitmap) {
|
|
102
|
+
CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
|
|
103
|
+
Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
|
|
104
|
+
if (bitmap != null) {
|
|
105
|
+
bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
|
|
106
|
+
startIcon = MFBitmapDescriptorFactory.fromBitmap(bitmap);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} finally {
|
|
111
|
+
startIconDataSource.close();
|
|
112
|
+
if (imageReference != null) {
|
|
113
|
+
CloseableReference.closeSafely(imageReference);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (RMFDirectionsRenderer.this.directionsRenderer != null) {
|
|
118
|
+
RMFDirectionsRenderer.this.directionsRenderer.setStartIcon(startIcon);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
private final ControllerListener<ImageInfo> mEndIconControllerListener =
|
|
124
|
+
new BaseControllerListener<ImageInfo>() {
|
|
125
|
+
@Override
|
|
126
|
+
public void onFinalImageSet(
|
|
127
|
+
String id,
|
|
128
|
+
@javax.annotation.Nullable final ImageInfo imageInfo,
|
|
129
|
+
@javax.annotation.Nullable Animatable animatable) {
|
|
130
|
+
CloseableReference<CloseableImage> imageReference = null;
|
|
131
|
+
try {
|
|
132
|
+
imageReference = endIconDataSource.getResult();
|
|
133
|
+
if (imageReference != null) {
|
|
134
|
+
CloseableImage image = imageReference.get();
|
|
135
|
+
if (image != null && image instanceof CloseableStaticBitmap) {
|
|
136
|
+
CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
|
|
137
|
+
Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
|
|
138
|
+
if (bitmap != null) {
|
|
139
|
+
bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
|
|
140
|
+
endIcon = MFBitmapDescriptorFactory.fromBitmap(bitmap);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
} finally {
|
|
145
|
+
endIconDataSource.close();
|
|
146
|
+
if (imageReference != null) {
|
|
147
|
+
CloseableReference.closeSafely(imageReference);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (RMFDirectionsRenderer.this.directionsRenderer != null) {
|
|
152
|
+
RMFDirectionsRenderer.this.directionsRenderer.setEndIcon(endIcon);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
public RMFDirectionsRenderer(Context context) {
|
|
158
|
+
super(context);
|
|
159
|
+
paths = new ArrayList<>();
|
|
160
|
+
jsonData = null;
|
|
161
|
+
width = 10.f;
|
|
162
|
+
MFDirectionsRendererOptions optionsDefault = new MFDirectionsRendererOptions();
|
|
163
|
+
startLocation = optionsDefault.getStartLocation();
|
|
164
|
+
endLocation = optionsDefault.getEndLocation();
|
|
165
|
+
activeStrokeColor = optionsDefault.getActiveStrokeColor();
|
|
166
|
+
activeOutlineColor = optionsDefault.getActiveOutlineColor();
|
|
167
|
+
inactiveStrokeColor = optionsDefault.getInactiveStrokeColor();
|
|
168
|
+
inactiveOutlineColor = optionsDefault.getInactiveOutlineColor();
|
|
169
|
+
titleColor = optionsDefault.getTitleColor();
|
|
170
|
+
originPOIVisible = optionsDefault.isOriginPOIVisible();
|
|
171
|
+
destinationPOIVisible = optionsDefault.isDestinationPOIVisible();
|
|
172
|
+
startIcon = null;
|
|
173
|
+
endIcon = null;
|
|
174
|
+
startLabel = "";
|
|
175
|
+
endLabel = "";
|
|
176
|
+
startIconHolder = DraweeHolder.create(createDraweeHierarchy(), context);
|
|
177
|
+
startIconHolder.onAttach();
|
|
178
|
+
endIconHolder = DraweeHolder.create(createDraweeHierarchy(), context);
|
|
179
|
+
endIconHolder.onAttach();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private GenericDraweeHierarchy createDraweeHierarchy() {
|
|
183
|
+
return new GenericDraweeHierarchyBuilder(getResources())
|
|
184
|
+
.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
|
|
185
|
+
.setFadeDuration(0)
|
|
186
|
+
.build();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@Override
|
|
190
|
+
public void addToMap(Map4D map) {
|
|
191
|
+
this.directionsRenderer = map.addDirectionsRenderer(getOptions());
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@Override
|
|
195
|
+
public void removeFromMap(Map4D map) {
|
|
196
|
+
if (directionsRenderer == null) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
directionsRenderer.remove();
|
|
200
|
+
directionsRenderer = null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@Override
|
|
204
|
+
public Object getFeature() {
|
|
205
|
+
return directionsRenderer;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public MFDirectionsRendererOptions getOptions() {
|
|
209
|
+
if (options == null) {
|
|
210
|
+
options = new MFDirectionsRendererOptions();
|
|
211
|
+
}
|
|
212
|
+
fillOptions(options);
|
|
213
|
+
return options;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private MFDirectionsRendererOptions fillOptions(MFDirectionsRendererOptions options) {
|
|
217
|
+
List<List<MFLocationCoordinate>> paths = new ArrayList<>();
|
|
218
|
+
for (int i = 0; i < this.paths.size(); ++i) {
|
|
219
|
+
List<MFLocationCoordinate> path = this.paths.get(i);
|
|
220
|
+
MFLocationCoordinate[] pathArray = new MFLocationCoordinate[path.size()];
|
|
221
|
+
path.toArray(pathArray);
|
|
222
|
+
paths.add(path);
|
|
223
|
+
}
|
|
224
|
+
options.paths(paths);
|
|
225
|
+
options.startLocation(startLocation);
|
|
226
|
+
options.endLocation(endLocation);
|
|
227
|
+
options.activedIndex(activedIndex);
|
|
228
|
+
options.jsonData(jsonData);
|
|
229
|
+
options.width(width);
|
|
230
|
+
if (!startLabel.isEmpty()) {
|
|
231
|
+
options.startLabel(startLabel);
|
|
232
|
+
}
|
|
233
|
+
if (!endLabel.isEmpty()) {
|
|
234
|
+
options.endLabel(endLabel);
|
|
235
|
+
}
|
|
236
|
+
if (startIcon != null) {
|
|
237
|
+
options.startIcon(startIcon);
|
|
238
|
+
}
|
|
239
|
+
if (endIcon != null) {
|
|
240
|
+
options.endIcon(endIcon);
|
|
241
|
+
}
|
|
242
|
+
options.originPOIVisible(originPOIVisible);
|
|
243
|
+
options.destinationPOIVisible(destinationPOIVisible);
|
|
244
|
+
options.activeStrokeColor(activeStrokeColor);
|
|
245
|
+
options.activeOutlineColor(activeOutlineColor);
|
|
246
|
+
options.inactiveStrokeColor(inactiveStrokeColor);
|
|
247
|
+
options.inactiveOutlineColor(inactiveOutlineColor);
|
|
248
|
+
options.titleColor(titleColor);
|
|
249
|
+
return options;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
public void setPaths(ReadableArray paths) {
|
|
253
|
+
if (paths == null) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
this.paths = new ArrayList<>(paths.size());
|
|
258
|
+
for (int i = 0; i < paths.size(); i++) {
|
|
259
|
+
ReadableArray path = paths.getArray(i);
|
|
260
|
+
List<MFLocationCoordinate> coordinates = new ArrayList<>();
|
|
261
|
+
for (int j = 0; j < path.size(); j++) {
|
|
262
|
+
ReadableMap coordinate = path.getMap(j);
|
|
263
|
+
coordinates.add(new MFLocationCoordinate(
|
|
264
|
+
coordinate.getDouble("latitude"),
|
|
265
|
+
coordinate.getDouble("longitude")));
|
|
266
|
+
}
|
|
267
|
+
this.paths.add(coordinates);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
public void setStartLocation(ReadableMap data) {
|
|
272
|
+
this.startLocation = new MFLocationCoordinate(data.getDouble("latitude"), data.getDouble("longitude"));
|
|
273
|
+
if (directionsRenderer != null) {
|
|
274
|
+
directionsRenderer.setStartLocation(this.startLocation);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
public void setEndLocation(ReadableMap data) {
|
|
279
|
+
this.endLocation = new MFLocationCoordinate(data.getDouble("latitude"), data.getDouble("longitude"));
|
|
280
|
+
if (directionsRenderer != null) {
|
|
281
|
+
directionsRenderer.setEndLocation(this.endLocation);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
public void setJsonData(@NonNull String jsonData) {
|
|
286
|
+
this.jsonData = jsonData;
|
|
287
|
+
if (directionsRenderer != null) {
|
|
288
|
+
directionsRenderer.setJsonData(this.jsonData);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
public void setActivedIndex(int activedIndex) {
|
|
293
|
+
this.activedIndex = activedIndex;
|
|
294
|
+
if (directionsRenderer != null) {
|
|
295
|
+
directionsRenderer.setActivedIndex(this.activedIndex);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
public void setWidth(float width) {
|
|
300
|
+
this.width = width;
|
|
301
|
+
if (directionsRenderer != null) {
|
|
302
|
+
directionsRenderer.setWidth(this.width);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
public void setActiveStrokeColor(@ColorInt int color) {
|
|
307
|
+
this.activeStrokeColor = color;
|
|
308
|
+
if (directionsRenderer != null) {
|
|
309
|
+
directionsRenderer.setActiveStrokeColor(color);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
public void setActiveOutlineColor(@ColorInt int color) {
|
|
314
|
+
this.activeOutlineColor = color;
|
|
315
|
+
if (directionsRenderer != null) {
|
|
316
|
+
directionsRenderer.setActiveOutlineColor(color);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
public void setInactiveStrokeColor(@ColorInt int color) {
|
|
321
|
+
this.inactiveStrokeColor = color;
|
|
322
|
+
if (directionsRenderer != null) {
|
|
323
|
+
directionsRenderer.setInactiveStrokeColor(color);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
public void setInactiveOutlineColor(@ColorInt int color) {
|
|
328
|
+
this.inactiveOutlineColor = color;
|
|
329
|
+
if (directionsRenderer != null) {
|
|
330
|
+
directionsRenderer.setInactiveOutlineColor(color);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
public void setTitleColor(@ColorInt int color) {
|
|
335
|
+
this.titleColor = color;
|
|
336
|
+
if (directionsRenderer != null) {
|
|
337
|
+
directionsRenderer.setTitleColor(color);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
public void setStartLabel(@NonNull String label) {
|
|
342
|
+
startLabel = label;
|
|
343
|
+
if (directionsRenderer != null) {
|
|
344
|
+
directionsRenderer.setStartLabel(startLabel);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
public void setEndLabel(@NonNull String label) {
|
|
349
|
+
endLabel = label;
|
|
350
|
+
if (directionsRenderer != null) {
|
|
351
|
+
directionsRenderer.setEndLabel(endLabel);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
public void setOriginPOIVisible(boolean visible) {
|
|
356
|
+
originPOIVisible = visible;
|
|
357
|
+
if (directionsRenderer != null) {
|
|
358
|
+
directionsRenderer.setOriginPOIVisible(visible);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
public void setDestinationPOIVisible(boolean visible) {
|
|
363
|
+
destinationPOIVisible = visible;
|
|
364
|
+
if (directionsRenderer != null) {
|
|
365
|
+
directionsRenderer.setDestinationPOIVisible(visible);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
public void setStartIcon(String uri) {
|
|
370
|
+
if (uri == null) {
|
|
371
|
+
startIcon = null;
|
|
372
|
+
}
|
|
373
|
+
else if (uri.startsWith("http://") || uri.startsWith("https://") ||
|
|
374
|
+
uri.startsWith("file://") || uri.startsWith("asset://") || uri.startsWith("data:")) {
|
|
375
|
+
ImageRequest imageRequest = ImageRequestBuilder
|
|
376
|
+
.newBuilderWithSource(Uri.parse(uri))
|
|
377
|
+
.build();
|
|
378
|
+
|
|
379
|
+
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
|
380
|
+
startIconDataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
|
|
381
|
+
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
|
382
|
+
.setImageRequest(imageRequest)
|
|
383
|
+
.setControllerListener(mStartIconControllerListener)
|
|
384
|
+
.setOldController(startIconHolder.getController())
|
|
385
|
+
.build();
|
|
386
|
+
startIconHolder.setController(controller);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
startIcon = ImageUtils.getBitmapDescriptorByName(this, uri);
|
|
390
|
+
if (startIcon != null) {
|
|
391
|
+
int drawableId = ImageUtils.getDrawableResourceByName(this, uri);
|
|
392
|
+
Bitmap iconBitmap = BitmapFactory.decodeResource(getResources(), drawableId);
|
|
393
|
+
if (iconBitmap == null) { // VectorDrawable or similar
|
|
394
|
+
Drawable drawable = getResources().getDrawable(drawableId);
|
|
395
|
+
iconBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
|
396
|
+
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
|
397
|
+
Canvas canvas = new Canvas(iconBitmap);
|
|
398
|
+
drawable.draw(canvas);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
public void setEndIcon(String uri) {
|
|
405
|
+
if (uri == null) {
|
|
406
|
+
endIcon = null;
|
|
407
|
+
}
|
|
408
|
+
else if (uri.startsWith("http://") || uri.startsWith("https://") ||
|
|
409
|
+
uri.startsWith("file://") || uri.startsWith("asset://") || uri.startsWith("data:")) {
|
|
410
|
+
ImageRequest imageRequest = ImageRequestBuilder
|
|
411
|
+
.newBuilderWithSource(Uri.parse(uri))
|
|
412
|
+
.build();
|
|
413
|
+
|
|
414
|
+
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
|
415
|
+
endIconDataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
|
|
416
|
+
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
|
417
|
+
.setImageRequest(imageRequest)
|
|
418
|
+
.setControllerListener(mEndIconControllerListener)
|
|
419
|
+
.setOldController(endIconHolder.getController())
|
|
420
|
+
.build();
|
|
421
|
+
endIconHolder.setController(controller);
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
endIcon = ImageUtils.getBitmapDescriptorByName(this, uri);
|
|
425
|
+
if (endIcon != null) {
|
|
426
|
+
int drawableId = ImageUtils.getDrawableResourceByName(this, uri);
|
|
427
|
+
Bitmap iconBitmap = BitmapFactory.decodeResource(getResources(), drawableId);
|
|
428
|
+
if (iconBitmap == null) { // VectorDrawable or similar
|
|
429
|
+
Drawable drawable = getResources().getDrawable(drawableId);
|
|
430
|
+
iconBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
|
|
431
|
+
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
|
432
|
+
Canvas canvas = new Canvas(iconBitmap);
|
|
433
|
+
drawable.draw(canvas);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
public void setOriginPOIOptions(ReadableMap map) {
|
|
440
|
+
if (map == null) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (map.hasKey("coordinate")) {
|
|
445
|
+
ReadableMap coordinate = map.getMap("coordinate");
|
|
446
|
+
this.setStartLocation(coordinate);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if (map.hasKey("icon")) {
|
|
450
|
+
ReadableMap icon = map.getMap("icon");
|
|
451
|
+
if (icon.hasKey("uri")) {
|
|
452
|
+
String uri = icon.getString("uri");
|
|
453
|
+
this.setStartIcon(uri);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
if (map.hasKey("title")) {
|
|
458
|
+
String title = map.getString("title");
|
|
459
|
+
this.setStartLabel(title);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (map.hasKey("titleColor")) {
|
|
463
|
+
this.setTitleColor(map.getInt("titleColor"));
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (map.hasKey("visible")) {
|
|
467
|
+
this.setOriginPOIVisible(map.getBoolean("visible"));
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
public void setDestinationPOIOptions(ReadableMap map) {
|
|
472
|
+
if (map == null) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (map.hasKey("coordinate")) {
|
|
477
|
+
ReadableMap coordinate = map.getMap("coordinate");
|
|
478
|
+
this.setEndLocation(coordinate);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (map.hasKey("icon")) {
|
|
482
|
+
ReadableMap icon = map.getMap("icon");
|
|
483
|
+
if (icon.hasKey("uri")) {
|
|
484
|
+
String uri = icon.getString("uri");
|
|
485
|
+
this.setEndIcon(uri);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
if (map.hasKey("title")) {
|
|
490
|
+
String title = map.getString("title");
|
|
491
|
+
this.setEndLabel(title);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (map.hasKey("titleColor")) {
|
|
495
|
+
this.setTitleColor(map.getInt("titleColor"));
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if (map.hasKey("visible")) {
|
|
499
|
+
this.setDestinationPOIVisible(map.getBoolean("visible"));
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|