react-native-map4d-map-dtqg 0.1.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/LICENSE +21 -0
- package/README.md +41 -0
- package/android/build.gradle +60 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactnativemap4dmap/ImageUtils.java +87 -0
- package/android/src/main/java/com/reactnativemap4dmap/Map4dMapModule.java +298 -0
- package/android/src/main/java/com/reactnativemap4dmap/Map4dMapPackage.java +35 -0
- package/android/src/main/java/com/reactnativemap4dmap/Map4dMapViewManager.java +31 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFBuilding.java +167 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFBuildingManager.java +121 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFCircle.java +105 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFCircleManager.java +122 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRenderer.java +502 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRendererManager.java +143 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFFeature.java +18 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFMapView.java +1172 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFMapViewManager.java +226 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFMarker.java +412 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFMarkerManager.java +212 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFPOI.java +222 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFPOIManager.java +119 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolygon.java +173 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolygonManager.java +148 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolyline.java +146 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFPolylineManager.java +138 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlay.java +95 -0
- package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlayManager.java +65 -0
- package/android/src/main/java/com/reactnativemap4dmap/SizeReportingShadowNode.java +31 -0
- package/android/src/main/java/com/reactnativemap4dmap/ViewAttacherGroup.java +31 -0
- package/android/src/main/java/com/reactnativemap4dmap/ViewChangesTracker.java +70 -0
- package/android/src/main/java/vn/map4d/map/annotations/RMFBitmapDescriptor.java +9 -0
- package/ios/Map4dMap.h +7 -0
- package/ios/Map4dMap.m +14 -0
- package/ios/Map4dMap.xcodeproj/project.pbxproj +282 -0
- package/ios/Map4dMapViewManager.m +34 -0
- package/ios/RCTConvert+Map4dMap.h +33 -0
- package/ios/RCTConvert+Map4dMap.m +112 -0
- package/ios/RMFCircle.h +37 -0
- package/ios/RMFCircle.m +100 -0
- package/ios/RMFCircleManager.h +18 -0
- package/ios/RMFCircleManager.m +155 -0
- package/ios/RMFCircleMap4d.h +23 -0
- package/ios/RMFCircleMap4d.m +13 -0
- package/ios/RMFCoordinate.h +22 -0
- package/ios/RMFCoordinate.m +13 -0
- package/ios/RMFDirectionsMarkerOptions.h +24 -0
- package/ios/RMFDirectionsMarkerOptions.m +23 -0
- package/ios/RMFDirectionsRenderer.h +47 -0
- package/ios/RMFDirectionsRenderer.m +182 -0
- package/ios/RMFDirectionsRendererManager.h +17 -0
- package/ios/RMFDirectionsRendererManager.m +84 -0
- package/ios/RMFDirectionsRendererMap4d.h +21 -0
- package/ios/RMFDirectionsRendererMap4d.m +12 -0
- package/ios/RMFDummyView.h +7 -0
- package/ios/RMFDummyView.m +13 -0
- package/ios/RMFEventResponse.h +39 -0
- package/ios/RMFEventResponse.m +98 -0
- package/ios/RMFIcon.h +24 -0
- package/ios/RMFIcon.m +35 -0
- package/ios/RMFMapView.h +84 -0
- package/ios/RMFMapView.m +376 -0
- package/ios/RMFMapViewManager.h +17 -0
- package/ios/RMFMapViewManager.m +493 -0
- package/ios/RMFMarker.h +57 -0
- package/ios/RMFMarker.m +267 -0
- package/ios/RMFMarkerManager.h +17 -0
- package/ios/RMFMarkerManager.m +156 -0
- package/ios/RMFMarkerMap4d.h +19 -0
- package/ios/RMFMarkerMap4d.m +13 -0
- package/ios/RMFPOI.h +38 -0
- package/ios/RMFPOI.m +123 -0
- package/ios/RMFPOIManager.h +18 -0
- package/ios/RMFPOIManager.m +168 -0
- package/ios/RMFPOIMap4d.h +22 -0
- package/ios/RMFPOIMap4d.m +12 -0
- package/ios/RMFPolygon.h +41 -0
- package/ios/RMFPolygon.m +106 -0
- package/ios/RMFPolygonManager.h +18 -0
- package/ios/RMFPolygonManager.m +141 -0
- package/ios/RMFPolygonMap4d.h +23 -0
- package/ios/RMFPolygonMap4d.m +15 -0
- package/ios/RMFPolyline.h +38 -0
- package/ios/RMFPolyline.m +101 -0
- package/ios/RMFPolylineManager.h +18 -0
- package/ios/RMFPolylineManager.m +139 -0
- package/ios/RMFPolylineMap4d.h +22 -0
- package/ios/RMFPolylineMap4d.m +15 -0
- package/ios/building/RMFBuilding.h +41 -0
- package/ios/building/RMFBuilding.m +104 -0
- package/ios/building/RMFBuildingManager.h +19 -0
- package/ios/building/RMFBuildingManager.m +133 -0
- package/ios/building/RMFBuildingMap4d.h +23 -0
- package/ios/building/RMFBuildingMap4d.m +15 -0
- package/ios/overlays/RMFTileOverlay.h +36 -0
- package/ios/overlays/RMFTileOverlay.m +64 -0
- package/ios/overlays/RMFTileOverlayManager.h +17 -0
- package/ios/overlays/RMFTileOverlayManager.m +27 -0
- package/lib/commonjs/components/MFBuilding.js +192 -0
- package/lib/commonjs/components/MFBuilding.js.map +1 -0
- package/lib/commonjs/components/MFCircle.js +181 -0
- package/lib/commonjs/components/MFCircle.js.map +1 -0
- package/lib/commonjs/components/MFDirectionsRenderer.js +240 -0
- package/lib/commonjs/components/MFDirectionsRenderer.js.map +1 -0
- package/lib/commonjs/components/MFMapView.js +375 -0
- package/lib/commonjs/components/MFMapView.js.map +1 -0
- package/lib/commonjs/components/MFMarker.js +255 -0
- package/lib/commonjs/components/MFMarker.js.map +1 -0
- package/lib/commonjs/components/MFPOI.js +204 -0
- package/lib/commonjs/components/MFPOI.js.map +1 -0
- package/lib/commonjs/components/MFPolygon.js +183 -0
- package/lib/commonjs/components/MFPolygon.js.map +1 -0
- package/lib/commonjs/components/MFPolyline.js +173 -0
- package/lib/commonjs/components/MFPolyline.js.map +1 -0
- package/lib/commonjs/components/MFTileOverlay.js +51 -0
- package/lib/commonjs/components/MFTileOverlay.js.map +1 -0
- package/lib/commonjs/components/Map4dMapView.js +19 -0
- package/lib/commonjs/components/Map4dMapView.js.map +1 -0
- package/lib/commonjs/index.js +78 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/components/MFBuilding.js +178 -0
- package/lib/module/components/MFBuilding.js.map +1 -0
- package/lib/module/components/MFCircle.js +167 -0
- package/lib/module/components/MFCircle.js.map +1 -0
- package/lib/module/components/MFDirectionsRenderer.js +226 -0
- package/lib/module/components/MFDirectionsRenderer.js.map +1 -0
- package/lib/module/components/MFMapView.js +361 -0
- package/lib/module/components/MFMapView.js.map +1 -0
- package/lib/module/components/MFMarker.js +240 -0
- package/lib/module/components/MFMarker.js.map +1 -0
- package/lib/module/components/MFPOI.js +190 -0
- package/lib/module/components/MFPOI.js.map +1 -0
- package/lib/module/components/MFPolygon.js +169 -0
- package/lib/module/components/MFPolygon.js.map +1 -0
- package/lib/module/components/MFPolyline.js +159 -0
- package/lib/module/components/MFPolyline.js.map +1 -0
- package/lib/module/components/MFTileOverlay.js +38 -0
- package/lib/module/components/MFTileOverlay.js.map +1 -0
- package/lib/module/components/Map4dMapView.js +10 -0
- package/lib/module/components/Map4dMapView.js.map +1 -0
- package/lib/module/index.js +11 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/components/Map4dMapView.d.ts +7 -0
- package/package.json +152 -0
- package/react-native-map4d-map.podspec +20 -0
- package/src/components/MFBuilding.js +188 -0
- package/src/components/MFCircle.js +173 -0
- package/src/components/MFDirectionsRenderer.js +237 -0
- package/src/components/MFMapView.js +374 -0
- package/src/components/MFMarker.js +246 -0
- package/src/components/MFPOI.js +184 -0
- package/src/components/MFPolygon.js +186 -0
- package/src/components/MFPolyline.js +172 -0
- package/src/components/MFTileOverlay.js +45 -0
- package/src/components/Map4dMapView.tsx +27 -0
- package/src/index.js +21 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
package com.reactnativemap4dmap;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.graphics.Color;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
7
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
8
|
+
|
|
9
|
+
import vn.map4d.map.core.*;
|
|
10
|
+
import vn.map4d.map.annotations.*;
|
|
11
|
+
|
|
12
|
+
import androidx.annotation.ColorInt;
|
|
13
|
+
|
|
14
|
+
import vn.map4d.types.MFLocationCoordinate;
|
|
15
|
+
|
|
16
|
+
import java.util.ArrayList;
|
|
17
|
+
import java.util.List;
|
|
18
|
+
|
|
19
|
+
public class RMFPolygon extends RMFFeature {
|
|
20
|
+
private MFPolygonOptions options;
|
|
21
|
+
private MFPolygon polygon;
|
|
22
|
+
|
|
23
|
+
private List<MFLocationCoordinate> points;
|
|
24
|
+
private List<List<MFLocationCoordinate>> holes;
|
|
25
|
+
private @ColorInt int fillColor;
|
|
26
|
+
private @ColorInt int strokeColor;
|
|
27
|
+
private float strokeWidth;
|
|
28
|
+
private boolean visible;
|
|
29
|
+
private boolean touchable;
|
|
30
|
+
private float zIndex;
|
|
31
|
+
private String userData;
|
|
32
|
+
|
|
33
|
+
public RMFPolygon(Context context) {
|
|
34
|
+
super(context);
|
|
35
|
+
points = new ArrayList<>();
|
|
36
|
+
holes = new ArrayList<>();
|
|
37
|
+
fillColor = Color.RED;
|
|
38
|
+
strokeColor = Color.BLUE;
|
|
39
|
+
strokeWidth = 1.f;
|
|
40
|
+
visible = true;
|
|
41
|
+
touchable = true;
|
|
42
|
+
zIndex = 0.0f;
|
|
43
|
+
userData = null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public void addToMap(Map4D map) {
|
|
47
|
+
this.polygon = map.addPolygon(getOptions());
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public void removeFromMap(Map4D map) {
|
|
51
|
+
if (polygon == null) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
polygon.remove();
|
|
55
|
+
polygon = null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public void setCoordinates(ReadableArray coordinates) {
|
|
59
|
+
this.points = new ArrayList<>(coordinates.size());
|
|
60
|
+
for (int i = 0; i < coordinates.size(); i++) {
|
|
61
|
+
ReadableMap coordinate = coordinates.getMap(i);
|
|
62
|
+
this.points.add(i,
|
|
63
|
+
new MFLocationCoordinate(coordinate.getDouble("latitude"), coordinate.getDouble("longitude")));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public void setHoles(ReadableArray holes) {
|
|
68
|
+
if (holes == null) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.holes = new ArrayList<>(holes.size());
|
|
73
|
+
for (int i = 0; i < holes.size(); i++) {
|
|
74
|
+
ReadableArray hole = holes.getArray(i);
|
|
75
|
+
if (hole.size() < 3) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
List<MFLocationCoordinate> coordinates = new ArrayList<>();
|
|
79
|
+
for (int j = 0; j < hole.size(); j++) {
|
|
80
|
+
ReadableMap coordinate = hole.getMap(j);
|
|
81
|
+
coordinates.add(new MFLocationCoordinate(
|
|
82
|
+
coordinate.getDouble("latitude"),
|
|
83
|
+
coordinate.getDouble("longitude")));
|
|
84
|
+
}
|
|
85
|
+
// If hole is triangle
|
|
86
|
+
if (coordinates.size() == 3) {
|
|
87
|
+
coordinates.add(coordinates.get(0));
|
|
88
|
+
}
|
|
89
|
+
this.holes.add(coordinates);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public void setStrokeWidth(float strokeWidth) {
|
|
94
|
+
this.strokeWidth = strokeWidth;
|
|
95
|
+
if (polygon != null) {
|
|
96
|
+
polygon.setStrokeWidth(strokeWidth);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public void setStrokeColor(@ColorInt int color) {
|
|
101
|
+
this.strokeColor = color;
|
|
102
|
+
if (polygon != null) {
|
|
103
|
+
polygon.setStrokeColor(color);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public void setFillColor(@ColorInt int color) {
|
|
108
|
+
this.fillColor = color;
|
|
109
|
+
if (polygon != null) {
|
|
110
|
+
polygon.setFillColor(color);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public void setVisible(boolean visible) {
|
|
115
|
+
this.visible = visible;
|
|
116
|
+
if (polygon != null) {
|
|
117
|
+
polygon.setVisible(this.visible);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public void setTouchable(boolean touchable) {
|
|
122
|
+
this.touchable = touchable;
|
|
123
|
+
if (polygon != null) {
|
|
124
|
+
polygon.setTouchable(this.touchable);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public void setZIndex(float zIndex) {
|
|
129
|
+
this.zIndex = zIndex;
|
|
130
|
+
if (polygon != null) {
|
|
131
|
+
polygon.setZIndex(this.zIndex);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public void setUserData(ReadableMap userData) {
|
|
136
|
+
this.userData = userData.toString();
|
|
137
|
+
if (polygon != null) {
|
|
138
|
+
polygon.setUserData(this.userData);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public MFPolygonOptions getOptions() {
|
|
143
|
+
if (options == null) {
|
|
144
|
+
options = new MFPolygonOptions();
|
|
145
|
+
}
|
|
146
|
+
fillOptions(options);
|
|
147
|
+
return options;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private MFPolygonOptions fillOptions(MFPolygonOptions options) {
|
|
151
|
+
for (MFLocationCoordinate point : points) {
|
|
152
|
+
options.add(point);
|
|
153
|
+
}
|
|
154
|
+
for (int i = 0; i < holes.size(); ++i) {
|
|
155
|
+
List<MFLocationCoordinate> hole = holes.get(i);
|
|
156
|
+
MFLocationCoordinate[] holeArray = new MFLocationCoordinate[hole.size()];
|
|
157
|
+
hole.toArray(holeArray);
|
|
158
|
+
options.addHole(holeArray);
|
|
159
|
+
}
|
|
160
|
+
options.zIndex(zIndex);
|
|
161
|
+
options.fillColor(fillColor);
|
|
162
|
+
options.strokeColor(strokeColor);
|
|
163
|
+
options.strokeWidth(strokeWidth);
|
|
164
|
+
options.visible(visible);
|
|
165
|
+
options.touchable(touchable);
|
|
166
|
+
options.userData(userData);
|
|
167
|
+
return options;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public Object getFeature() {
|
|
171
|
+
return polygon;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
package com.reactnativemap4dmap;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.os.Build;
|
|
5
|
+
import android.util.DisplayMetrics;
|
|
6
|
+
import android.view.WindowManager;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
9
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
10
|
+
import com.facebook.react.bridge.*;
|
|
11
|
+
import com.facebook.react.uimanager.annotations.*;
|
|
12
|
+
import com.facebook.react.common.MapBuilder;
|
|
13
|
+
|
|
14
|
+
import androidx.annotation.Nullable;
|
|
15
|
+
import androidx.annotation.ColorInt;
|
|
16
|
+
|
|
17
|
+
import java.util.Map;
|
|
18
|
+
import java.util.HashMap;
|
|
19
|
+
|
|
20
|
+
public class RMFPolygonManager extends ViewGroupManager<RMFPolygon> {
|
|
21
|
+
private final DisplayMetrics metrics;
|
|
22
|
+
|
|
23
|
+
private static final int k_setStrokeWidth = 1;
|
|
24
|
+
private static final int k_setStrokeColor = k_setStrokeWidth + 1;
|
|
25
|
+
private static final int k_setFillColor = k_setStrokeColor + 1;
|
|
26
|
+
private static final int k_setVisible = k_setFillColor + 1;
|
|
27
|
+
private static final int k_setTouchable = k_setVisible + 1;
|
|
28
|
+
private static final int k_setZIndex = k_setTouchable + 1;
|
|
29
|
+
private static final int k_setUserData = k_setZIndex + 1;
|
|
30
|
+
|
|
31
|
+
public RMFPolygonManager(final ReactApplicationContext reactContext) {
|
|
32
|
+
super();
|
|
33
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
34
|
+
metrics = new DisplayMetrics();
|
|
35
|
+
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
|
|
36
|
+
.getRealMetrics(metrics);
|
|
37
|
+
} else {
|
|
38
|
+
metrics = reactContext.getResources().getDisplayMetrics();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Override
|
|
43
|
+
public String getName() {
|
|
44
|
+
return "RMFPolygon";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Override
|
|
48
|
+
protected RMFPolygon createViewInstance(final ThemedReactContext reactContext) {
|
|
49
|
+
return new RMFPolygon(reactContext);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Override
|
|
53
|
+
public void receiveCommand(final RMFPolygon view, final int commandId, @Nullable final ReadableArray args) {
|
|
54
|
+
ReadableMap data;
|
|
55
|
+
switch (commandId) {
|
|
56
|
+
case k_setStrokeWidth:
|
|
57
|
+
final float width = (float) args.getDouble(0) * metrics.density;
|
|
58
|
+
view.setStrokeWidth(width);
|
|
59
|
+
break;
|
|
60
|
+
case k_setStrokeColor:
|
|
61
|
+
view.setStrokeColor(args.getInt(0));
|
|
62
|
+
break;
|
|
63
|
+
case k_setFillColor:
|
|
64
|
+
view.setFillColor(args.getInt(0));
|
|
65
|
+
break;
|
|
66
|
+
case k_setVisible:
|
|
67
|
+
view.setVisible(args.getBoolean(0));
|
|
68
|
+
break;
|
|
69
|
+
case k_setTouchable:
|
|
70
|
+
view.setTouchable(args.getBoolean(0));
|
|
71
|
+
break;
|
|
72
|
+
case k_setZIndex:
|
|
73
|
+
view.setZIndex((float) args.getDouble(0));
|
|
74
|
+
break;
|
|
75
|
+
case k_setUserData:
|
|
76
|
+
data = args.getMap(0);
|
|
77
|
+
view.setUserData(data);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Override
|
|
83
|
+
public Map getExportedCustomDirectEventTypeConstants() {
|
|
84
|
+
final Map<String, Map<String, String>> map = MapBuilder.of("onPress", MapBuilder.of("registrationName", "onPress"));
|
|
85
|
+
return map;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Nullable
|
|
89
|
+
@Override
|
|
90
|
+
public Map<String, Integer> getCommandsMap() {
|
|
91
|
+
final HashMap<String, Integer> map = new HashMap();
|
|
92
|
+
map.put("setStrokeWidth", k_setStrokeWidth);
|
|
93
|
+
map.put("setStrokeColor", k_setStrokeColor);
|
|
94
|
+
map.put("setFillColor", k_setFillColor);
|
|
95
|
+
map.put("setVisible", k_setVisible);
|
|
96
|
+
map.put("setTouchable", k_setTouchable);
|
|
97
|
+
map.put("setZIndex", k_setZIndex);
|
|
98
|
+
map.put("setUserData", k_setUserData);
|
|
99
|
+
return map;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@ReactProp(name = "coordinates")
|
|
103
|
+
public void setCoordinates(final RMFPolygon view, final ReadableArray coordinates) {
|
|
104
|
+
view.setCoordinates(coordinates);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@ReactProp(name = "holes")
|
|
108
|
+
public void setHoles(final RMFPolygon view, final ReadableArray holes) {
|
|
109
|
+
view.setHoles(holes);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@ReactProp(name = "strokeWidth")
|
|
113
|
+
public void setStrokeWidth(final RMFPolygon view, final float widthInPoints) {
|
|
114
|
+
final float widthInScreenPx = metrics.density * widthInPoints;
|
|
115
|
+
view.setStrokeWidth(widthInScreenPx);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@ReactProp(name = "strokeColor", customType = "Color")
|
|
119
|
+
public void setStrokeColor(final RMFPolygon view, @ColorInt final int color) {
|
|
120
|
+
view.setStrokeColor(color);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@ReactProp(name = "fillColor", customType = "Color")
|
|
124
|
+
public void setFillColor(final RMFPolygon view, @ColorInt final int color) {
|
|
125
|
+
view.setFillColor(color);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@ReactProp(name = "visible")
|
|
129
|
+
public void setVisible(final RMFPolygon view, final boolean visible) {
|
|
130
|
+
view.setVisible(visible);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@ReactProp(name = "touchable")
|
|
134
|
+
public void setTouchable(final RMFPolygon view, final boolean touchable) {
|
|
135
|
+
view.setTouchable(touchable);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@ReactProp(name = "zIndex")
|
|
139
|
+
public void setZIndex(final RMFPolygon view, final float zIndex) {
|
|
140
|
+
view.setZIndex(zIndex);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@ReactProp(name = "userData")
|
|
144
|
+
public void setUserData(final RMFPolygon view, final ReadableMap userData) {
|
|
145
|
+
view.setUserData(userData);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
package com.reactnativemap4dmap;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.graphics.Color;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
7
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
8
|
+
|
|
9
|
+
import vn.map4d.map.core.*;
|
|
10
|
+
import vn.map4d.map.annotations.*;
|
|
11
|
+
|
|
12
|
+
import androidx.annotation.ColorInt;
|
|
13
|
+
|
|
14
|
+
import vn.map4d.map.camera.*;
|
|
15
|
+
import vn.map4d.types.MFLocationCoordinate;
|
|
16
|
+
|
|
17
|
+
import java.util.ArrayList;
|
|
18
|
+
import java.util.List;
|
|
19
|
+
|
|
20
|
+
public class RMFPolyline extends RMFFeature {
|
|
21
|
+
private MFPolylineOptions options;
|
|
22
|
+
private MFPolyline polyline;
|
|
23
|
+
|
|
24
|
+
private List<MFLocationCoordinate> coordinates;
|
|
25
|
+
private float width;
|
|
26
|
+
private @ColorInt int color;
|
|
27
|
+
private boolean visible;
|
|
28
|
+
private boolean touchable;
|
|
29
|
+
private float zIndex;
|
|
30
|
+
private String userData;
|
|
31
|
+
private MFPatternItem pattern;
|
|
32
|
+
|
|
33
|
+
public RMFPolyline(Context context) {
|
|
34
|
+
super(context);
|
|
35
|
+
this.coordinates = new ArrayList<>();
|
|
36
|
+
width = 2.0f;
|
|
37
|
+
color = Color.BLACK;
|
|
38
|
+
visible = true;
|
|
39
|
+
touchable = true;
|
|
40
|
+
zIndex = 0.0f;
|
|
41
|
+
userData = null;
|
|
42
|
+
pattern = new MFSolidPattern();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public void addToMap(Map4D map) {
|
|
46
|
+
this.polyline = map.addPolyline(getOptions());
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public void removeFromMap(Map4D map) {
|
|
50
|
+
if (polyline == null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
polyline.remove();
|
|
54
|
+
polyline = null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public void setCoordinates(ReadableArray coordinates) {
|
|
58
|
+
this.coordinates = new ArrayList<>(coordinates.size());
|
|
59
|
+
for (int i = 0; i < coordinates.size(); i++) {
|
|
60
|
+
ReadableMap coordinate = coordinates.getMap(i);
|
|
61
|
+
this.coordinates.add(i,
|
|
62
|
+
new MFLocationCoordinate(coordinate.getDouble("latitude"), coordinate.getDouble("longitude")));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public void setWidth(float width) {
|
|
67
|
+
this.width = width;
|
|
68
|
+
if (polyline != null) {
|
|
69
|
+
polyline.setWidth(width);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public void setColor(@ColorInt int color) {
|
|
74
|
+
this.color = color;
|
|
75
|
+
if (polyline != null) {
|
|
76
|
+
polyline.setColor(this.color);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public void setLineStyle(String lineStyle) {
|
|
81
|
+
if (lineStyle.equals("solid")) {
|
|
82
|
+
this.pattern = new MFSolidPattern();
|
|
83
|
+
}
|
|
84
|
+
else if (lineStyle.equals("dotted")) {
|
|
85
|
+
this.pattern = new MFDashPattern((int) this.width, (int) this.width);
|
|
86
|
+
}
|
|
87
|
+
if (polyline != null) {
|
|
88
|
+
polyline.setPattern(this.pattern);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public void setVisible(boolean visible) {
|
|
93
|
+
this.visible = visible;
|
|
94
|
+
if (polyline != null) {
|
|
95
|
+
polyline.setVisible(this.visible);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public void setTouchable(boolean touchable) {
|
|
100
|
+
this.touchable = touchable;
|
|
101
|
+
if (polyline != null) {
|
|
102
|
+
polyline.setTouchable(this.touchable);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public void setZIndex(float zIndex) {
|
|
107
|
+
this.zIndex = zIndex;
|
|
108
|
+
if (polyline != null) {
|
|
109
|
+
polyline.setZIndex(this.zIndex);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public void setUserData(ReadableMap userData) {
|
|
114
|
+
this.userData = userData.toString();
|
|
115
|
+
if (polyline != null) {
|
|
116
|
+
polyline.setUserData(this.userData);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public MFPolylineOptions getOptions() {
|
|
121
|
+
if (options == null) {
|
|
122
|
+
options = new MFPolylineOptions();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
fillOptions(options);
|
|
126
|
+
return options;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private MFPolylineOptions fillOptions(MFPolylineOptions options) {
|
|
130
|
+
for (MFLocationCoordinate coord : coordinates) {
|
|
131
|
+
options.add(coord);
|
|
132
|
+
}
|
|
133
|
+
options.zIndex(zIndex);
|
|
134
|
+
options.width(width);
|
|
135
|
+
options.color(color);
|
|
136
|
+
options.visible(visible);
|
|
137
|
+
options.touchable(touchable);
|
|
138
|
+
options.pattern(pattern);
|
|
139
|
+
options.userData(userData);
|
|
140
|
+
return options;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public Object getFeature() {
|
|
144
|
+
return polyline;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
package com.reactnativemap4dmap;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.os.Build;
|
|
5
|
+
import android.util.DisplayMetrics;
|
|
6
|
+
import android.view.WindowManager;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.uimanager.ViewGroupManager;
|
|
9
|
+
import com.facebook.react.uimanager.ThemedReactContext;
|
|
10
|
+
import com.facebook.react.bridge.*;
|
|
11
|
+
import com.facebook.react.uimanager.annotations.*;
|
|
12
|
+
import com.facebook.react.common.MapBuilder;
|
|
13
|
+
|
|
14
|
+
import androidx.annotation.Nullable;
|
|
15
|
+
import androidx.annotation.ColorInt;
|
|
16
|
+
|
|
17
|
+
import java.util.Map;
|
|
18
|
+
import java.util.HashMap;
|
|
19
|
+
|
|
20
|
+
public class RMFPolylineManager extends ViewGroupManager<RMFPolyline> {
|
|
21
|
+
private final DisplayMetrics metrics;
|
|
22
|
+
|
|
23
|
+
private static final int k_setWidth = 1;
|
|
24
|
+
private static final int k_setColor = k_setWidth + 1;
|
|
25
|
+
private static final int k_setVisible = k_setColor + 1;
|
|
26
|
+
private static final int k_setTouchable = k_setVisible + 1;
|
|
27
|
+
private static final int k_setZIndex = k_setTouchable + 1;
|
|
28
|
+
private static final int k_setUserData = k_setZIndex + 1;
|
|
29
|
+
|
|
30
|
+
public RMFPolylineManager(final ReactApplicationContext reactContext) {
|
|
31
|
+
super();
|
|
32
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
|
33
|
+
metrics = new DisplayMetrics();
|
|
34
|
+
((WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
|
|
35
|
+
.getRealMetrics(metrics);
|
|
36
|
+
} else {
|
|
37
|
+
metrics = reactContext.getResources().getDisplayMetrics();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Override
|
|
42
|
+
public String getName() {
|
|
43
|
+
return "RMFPolyline";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Override
|
|
47
|
+
protected RMFPolyline createViewInstance(final ThemedReactContext reactContext) {
|
|
48
|
+
return new RMFPolyline(reactContext);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
public void receiveCommand(final RMFPolyline view, final int commandId, @Nullable final ReadableArray args) {
|
|
53
|
+
ReadableMap data;
|
|
54
|
+
switch (commandId) {
|
|
55
|
+
case k_setWidth:
|
|
56
|
+
final float width = (float) args.getDouble(0) * metrics.density;
|
|
57
|
+
view.setWidth(width);
|
|
58
|
+
break;
|
|
59
|
+
case k_setColor:
|
|
60
|
+
view.setColor(args.getInt(0));
|
|
61
|
+
break;
|
|
62
|
+
case k_setVisible:
|
|
63
|
+
view.setVisible(args.getBoolean(0));
|
|
64
|
+
break;
|
|
65
|
+
case k_setTouchable:
|
|
66
|
+
view.setTouchable(args.getBoolean(0));
|
|
67
|
+
break;
|
|
68
|
+
case k_setZIndex:
|
|
69
|
+
view.setZIndex((float) args.getDouble(0));
|
|
70
|
+
break;
|
|
71
|
+
case k_setUserData:
|
|
72
|
+
data = args.getMap(0);
|
|
73
|
+
view.setUserData(data);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Override
|
|
79
|
+
public Map getExportedCustomDirectEventTypeConstants() {
|
|
80
|
+
final Map<String, Map<String, String>> map = MapBuilder.of("onPress", MapBuilder.of("registrationName", "onPress"));
|
|
81
|
+
return map;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Nullable
|
|
85
|
+
@Override
|
|
86
|
+
public Map<String, Integer> getCommandsMap() {
|
|
87
|
+
final HashMap<String, Integer> map = new HashMap();
|
|
88
|
+
map.put("setWidth", k_setWidth);
|
|
89
|
+
map.put("setColor", k_setColor);
|
|
90
|
+
map.put("setVisible", k_setVisible);
|
|
91
|
+
map.put("setTouchable", k_setTouchable);
|
|
92
|
+
map.put("setZIndex", k_setZIndex);
|
|
93
|
+
map.put("setUserData", k_setUserData);
|
|
94
|
+
return map;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@ReactProp(name = "coordinates")
|
|
98
|
+
public void setCoordinates(final RMFPolyline view, final ReadableArray coordinates) {
|
|
99
|
+
view.setCoordinates(coordinates);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@ReactProp(name = "width")
|
|
103
|
+
public void setWidth(final RMFPolyline view, final float widthInPoints) {
|
|
104
|
+
final float widthInScreenPx = metrics.density * widthInPoints;
|
|
105
|
+
view.setWidth(widthInScreenPx);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@ReactProp(name = "color", customType = "Color")
|
|
109
|
+
public void setColor(final RMFPolyline view, @ColorInt final int color) {
|
|
110
|
+
view.setColor(color);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@ReactProp(name = "lineStyle")
|
|
114
|
+
public void setLineStyle(final RMFPolyline view, final String lineStyle) {
|
|
115
|
+
view.setLineStyle(lineStyle);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@ReactProp(name = "visible")
|
|
119
|
+
public void setVisible(final RMFPolyline view, final boolean visible) {
|
|
120
|
+
view.setVisible(visible);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@ReactProp(name = "touchable")
|
|
124
|
+
public void setTouchable(final RMFPolyline view, final boolean touchable) {
|
|
125
|
+
view.setTouchable(touchable);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@ReactProp(name = "zIndex")
|
|
129
|
+
public void setZIndex(final RMFPolyline view, final float zIndex) {
|
|
130
|
+
view.setZIndex(zIndex);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@ReactProp(name = "userData")
|
|
134
|
+
public void setUserData(final RMFPolyline view, final ReadableMap userData) {
|
|
135
|
+
view.setUserData(userData);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
package com.reactnativemap4dmap;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import vn.map4d.map.core.*;
|
|
6
|
+
|
|
7
|
+
import vn.map4d.map.overlays.MFTileOverlay;
|
|
8
|
+
import vn.map4d.map.overlays.MFTileOverlayOptions;
|
|
9
|
+
import vn.map4d.map.overlays.MFTileProvider;
|
|
10
|
+
import vn.map4d.map.overlays.MFUrlTileProvider;
|
|
11
|
+
|
|
12
|
+
public class RMFTileOverlay extends RMFFeature {
|
|
13
|
+
|
|
14
|
+
private MFTileOverlayOptions options;
|
|
15
|
+
private MFTileOverlay tileOverlay;
|
|
16
|
+
|
|
17
|
+
private String templateUrl;
|
|
18
|
+
private boolean visible;
|
|
19
|
+
private double zIndex;
|
|
20
|
+
|
|
21
|
+
public RMFTileOverlay(Context context) {
|
|
22
|
+
super(context);
|
|
23
|
+
visible = true;
|
|
24
|
+
zIndex = 0.0f;
|
|
25
|
+
templateUrl = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public void addToMap(Map4D map) {
|
|
29
|
+
this.tileOverlay = map.addTileOverlay(getOptions());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public void removeFromMap(Map4D map) {
|
|
33
|
+
if (tileOverlay == null) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
tileOverlay.remove();
|
|
37
|
+
tileOverlay = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public void setTemplateUrl(String url) {
|
|
41
|
+
this.templateUrl = url;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public void setVisible(boolean visible) {
|
|
45
|
+
this.visible = visible;
|
|
46
|
+
if (tileOverlay != null) {
|
|
47
|
+
tileOverlay.setVisible(this.visible);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void setZIndex(double zIndex) {
|
|
52
|
+
this.zIndex = zIndex;
|
|
53
|
+
if (tileOverlay != null) {
|
|
54
|
+
tileOverlay.setZIndex(this.zIndex);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public MFTileOverlayOptions getOptions() {
|
|
59
|
+
if (options == null) {
|
|
60
|
+
options = new MFTileOverlayOptions();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fillOptions(options);
|
|
64
|
+
return options;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private MFTileOverlayOptions fillOptions(MFTileOverlayOptions options) {
|
|
68
|
+
MFTileProvider tileProvider = new MFUrlTileProvider() {
|
|
69
|
+
@Override
|
|
70
|
+
public String getTileUrl(int x, int y, int zoom) {
|
|
71
|
+
if (templateUrl == null) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
String url;
|
|
75
|
+
if (templateUrl.contains("{z}")) {
|
|
76
|
+
url = templateUrl.replace("{z}", String.valueOf(zoom));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
url = templateUrl.replace("{zoom}", String.valueOf(zoom));
|
|
80
|
+
}
|
|
81
|
+
url = url.replace("{x}", String.valueOf(x));
|
|
82
|
+
url = url.replace("{y}", String.valueOf(y));
|
|
83
|
+
return url;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
options.tileProvider(tileProvider);
|
|
87
|
+
options.zIndex(zIndex);
|
|
88
|
+
options.visible(visible);
|
|
89
|
+
return options;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public Object getFeature() {
|
|
93
|
+
return tileOverlay;
|
|
94
|
+
}
|
|
95
|
+
}
|