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.
Files changed (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +41 -0
  3. package/android/build.gradle +60 -0
  4. package/android/src/main/AndroidManifest.xml +4 -0
  5. package/android/src/main/java/com/reactnativemap4dmap/ImageUtils.java +87 -0
  6. package/android/src/main/java/com/reactnativemap4dmap/Map4dMapModule.java +298 -0
  7. package/android/src/main/java/com/reactnativemap4dmap/Map4dMapPackage.java +35 -0
  8. package/android/src/main/java/com/reactnativemap4dmap/Map4dMapViewManager.java +31 -0
  9. package/android/src/main/java/com/reactnativemap4dmap/RMFBuilding.java +167 -0
  10. package/android/src/main/java/com/reactnativemap4dmap/RMFBuildingManager.java +121 -0
  11. package/android/src/main/java/com/reactnativemap4dmap/RMFCircle.java +105 -0
  12. package/android/src/main/java/com/reactnativemap4dmap/RMFCircleManager.java +122 -0
  13. package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRenderer.java +502 -0
  14. package/android/src/main/java/com/reactnativemap4dmap/RMFDirectionsRendererManager.java +143 -0
  15. package/android/src/main/java/com/reactnativemap4dmap/RMFFeature.java +18 -0
  16. package/android/src/main/java/com/reactnativemap4dmap/RMFMapView.java +1172 -0
  17. package/android/src/main/java/com/reactnativemap4dmap/RMFMapViewManager.java +226 -0
  18. package/android/src/main/java/com/reactnativemap4dmap/RMFMarker.java +412 -0
  19. package/android/src/main/java/com/reactnativemap4dmap/RMFMarkerManager.java +212 -0
  20. package/android/src/main/java/com/reactnativemap4dmap/RMFPOI.java +222 -0
  21. package/android/src/main/java/com/reactnativemap4dmap/RMFPOIManager.java +119 -0
  22. package/android/src/main/java/com/reactnativemap4dmap/RMFPolygon.java +173 -0
  23. package/android/src/main/java/com/reactnativemap4dmap/RMFPolygonManager.java +148 -0
  24. package/android/src/main/java/com/reactnativemap4dmap/RMFPolyline.java +146 -0
  25. package/android/src/main/java/com/reactnativemap4dmap/RMFPolylineManager.java +138 -0
  26. package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlay.java +95 -0
  27. package/android/src/main/java/com/reactnativemap4dmap/RMFTileOverlayManager.java +65 -0
  28. package/android/src/main/java/com/reactnativemap4dmap/SizeReportingShadowNode.java +31 -0
  29. package/android/src/main/java/com/reactnativemap4dmap/ViewAttacherGroup.java +31 -0
  30. package/android/src/main/java/com/reactnativemap4dmap/ViewChangesTracker.java +70 -0
  31. package/android/src/main/java/vn/map4d/map/annotations/RMFBitmapDescriptor.java +9 -0
  32. package/ios/Map4dMap.h +7 -0
  33. package/ios/Map4dMap.m +14 -0
  34. package/ios/Map4dMap.xcodeproj/project.pbxproj +282 -0
  35. package/ios/Map4dMapViewManager.m +34 -0
  36. package/ios/RCTConvert+Map4dMap.h +33 -0
  37. package/ios/RCTConvert+Map4dMap.m +112 -0
  38. package/ios/RMFCircle.h +37 -0
  39. package/ios/RMFCircle.m +100 -0
  40. package/ios/RMFCircleManager.h +18 -0
  41. package/ios/RMFCircleManager.m +155 -0
  42. package/ios/RMFCircleMap4d.h +23 -0
  43. package/ios/RMFCircleMap4d.m +13 -0
  44. package/ios/RMFCoordinate.h +22 -0
  45. package/ios/RMFCoordinate.m +13 -0
  46. package/ios/RMFDirectionsMarkerOptions.h +24 -0
  47. package/ios/RMFDirectionsMarkerOptions.m +23 -0
  48. package/ios/RMFDirectionsRenderer.h +47 -0
  49. package/ios/RMFDirectionsRenderer.m +182 -0
  50. package/ios/RMFDirectionsRendererManager.h +17 -0
  51. package/ios/RMFDirectionsRendererManager.m +84 -0
  52. package/ios/RMFDirectionsRendererMap4d.h +21 -0
  53. package/ios/RMFDirectionsRendererMap4d.m +12 -0
  54. package/ios/RMFDummyView.h +7 -0
  55. package/ios/RMFDummyView.m +13 -0
  56. package/ios/RMFEventResponse.h +39 -0
  57. package/ios/RMFEventResponse.m +98 -0
  58. package/ios/RMFIcon.h +24 -0
  59. package/ios/RMFIcon.m +35 -0
  60. package/ios/RMFMapView.h +84 -0
  61. package/ios/RMFMapView.m +376 -0
  62. package/ios/RMFMapViewManager.h +17 -0
  63. package/ios/RMFMapViewManager.m +493 -0
  64. package/ios/RMFMarker.h +57 -0
  65. package/ios/RMFMarker.m +267 -0
  66. package/ios/RMFMarkerManager.h +17 -0
  67. package/ios/RMFMarkerManager.m +156 -0
  68. package/ios/RMFMarkerMap4d.h +19 -0
  69. package/ios/RMFMarkerMap4d.m +13 -0
  70. package/ios/RMFPOI.h +38 -0
  71. package/ios/RMFPOI.m +123 -0
  72. package/ios/RMFPOIManager.h +18 -0
  73. package/ios/RMFPOIManager.m +168 -0
  74. package/ios/RMFPOIMap4d.h +22 -0
  75. package/ios/RMFPOIMap4d.m +12 -0
  76. package/ios/RMFPolygon.h +41 -0
  77. package/ios/RMFPolygon.m +106 -0
  78. package/ios/RMFPolygonManager.h +18 -0
  79. package/ios/RMFPolygonManager.m +141 -0
  80. package/ios/RMFPolygonMap4d.h +23 -0
  81. package/ios/RMFPolygonMap4d.m +15 -0
  82. package/ios/RMFPolyline.h +38 -0
  83. package/ios/RMFPolyline.m +101 -0
  84. package/ios/RMFPolylineManager.h +18 -0
  85. package/ios/RMFPolylineManager.m +139 -0
  86. package/ios/RMFPolylineMap4d.h +22 -0
  87. package/ios/RMFPolylineMap4d.m +15 -0
  88. package/ios/building/RMFBuilding.h +41 -0
  89. package/ios/building/RMFBuilding.m +104 -0
  90. package/ios/building/RMFBuildingManager.h +19 -0
  91. package/ios/building/RMFBuildingManager.m +133 -0
  92. package/ios/building/RMFBuildingMap4d.h +23 -0
  93. package/ios/building/RMFBuildingMap4d.m +15 -0
  94. package/ios/overlays/RMFTileOverlay.h +36 -0
  95. package/ios/overlays/RMFTileOverlay.m +64 -0
  96. package/ios/overlays/RMFTileOverlayManager.h +17 -0
  97. package/ios/overlays/RMFTileOverlayManager.m +27 -0
  98. package/lib/commonjs/components/MFBuilding.js +192 -0
  99. package/lib/commonjs/components/MFBuilding.js.map +1 -0
  100. package/lib/commonjs/components/MFCircle.js +181 -0
  101. package/lib/commonjs/components/MFCircle.js.map +1 -0
  102. package/lib/commonjs/components/MFDirectionsRenderer.js +240 -0
  103. package/lib/commonjs/components/MFDirectionsRenderer.js.map +1 -0
  104. package/lib/commonjs/components/MFMapView.js +375 -0
  105. package/lib/commonjs/components/MFMapView.js.map +1 -0
  106. package/lib/commonjs/components/MFMarker.js +255 -0
  107. package/lib/commonjs/components/MFMarker.js.map +1 -0
  108. package/lib/commonjs/components/MFPOI.js +204 -0
  109. package/lib/commonjs/components/MFPOI.js.map +1 -0
  110. package/lib/commonjs/components/MFPolygon.js +183 -0
  111. package/lib/commonjs/components/MFPolygon.js.map +1 -0
  112. package/lib/commonjs/components/MFPolyline.js +173 -0
  113. package/lib/commonjs/components/MFPolyline.js.map +1 -0
  114. package/lib/commonjs/components/MFTileOverlay.js +51 -0
  115. package/lib/commonjs/components/MFTileOverlay.js.map +1 -0
  116. package/lib/commonjs/components/Map4dMapView.js +19 -0
  117. package/lib/commonjs/components/Map4dMapView.js.map +1 -0
  118. package/lib/commonjs/index.js +78 -0
  119. package/lib/commonjs/index.js.map +1 -0
  120. package/lib/module/components/MFBuilding.js +178 -0
  121. package/lib/module/components/MFBuilding.js.map +1 -0
  122. package/lib/module/components/MFCircle.js +167 -0
  123. package/lib/module/components/MFCircle.js.map +1 -0
  124. package/lib/module/components/MFDirectionsRenderer.js +226 -0
  125. package/lib/module/components/MFDirectionsRenderer.js.map +1 -0
  126. package/lib/module/components/MFMapView.js +361 -0
  127. package/lib/module/components/MFMapView.js.map +1 -0
  128. package/lib/module/components/MFMarker.js +240 -0
  129. package/lib/module/components/MFMarker.js.map +1 -0
  130. package/lib/module/components/MFPOI.js +190 -0
  131. package/lib/module/components/MFPOI.js.map +1 -0
  132. package/lib/module/components/MFPolygon.js +169 -0
  133. package/lib/module/components/MFPolygon.js.map +1 -0
  134. package/lib/module/components/MFPolyline.js +159 -0
  135. package/lib/module/components/MFPolyline.js.map +1 -0
  136. package/lib/module/components/MFTileOverlay.js +38 -0
  137. package/lib/module/components/MFTileOverlay.js.map +1 -0
  138. package/lib/module/components/Map4dMapView.js +10 -0
  139. package/lib/module/components/Map4dMapView.js.map +1 -0
  140. package/lib/module/index.js +11 -0
  141. package/lib/module/index.js.map +1 -0
  142. package/lib/typescript/components/Map4dMapView.d.ts +7 -0
  143. package/package.json +152 -0
  144. package/react-native-map4d-map.podspec +20 -0
  145. package/src/components/MFBuilding.js +188 -0
  146. package/src/components/MFCircle.js +173 -0
  147. package/src/components/MFDirectionsRenderer.js +237 -0
  148. package/src/components/MFMapView.js +374 -0
  149. package/src/components/MFMarker.js +246 -0
  150. package/src/components/MFPOI.js +184 -0
  151. package/src/components/MFPolygon.js +186 -0
  152. package/src/components/MFPolyline.js +172 -0
  153. package/src/components/MFTileOverlay.js +45 -0
  154. package/src/components/Map4dMapView.tsx +27 -0
  155. package/src/index.js +21 -0
@@ -0,0 +1,267 @@
1
+ //
2
+ // RMFMarker.m
3
+ // Map4dMap
4
+ //
5
+ // Created by Huy Dang on 4/28/20.
6
+ // Copyright © 2020 IOTLink. All rights reserved.
7
+ //
8
+
9
+ #import "RMFMarker.h"
10
+ #import <Foundation/Foundation.h>
11
+ #import <React/RCTLog.h>
12
+ #import <React/RCTImageView.h>
13
+ #import <Map4dMap/Map4dMap.h>
14
+ #import "RMFEventResponse.h"
15
+ #import "RMFDummyView.h"
16
+
17
+ @implementation RMFMarker {
18
+ // RCTImageLoaderCancellationBlock _reloadImageCancellationBlock;
19
+ UIView *_iconView;
20
+ NSMutableArray* observables;
21
+ }
22
+
23
+ - (instancetype)init {
24
+ if ((self = [super init])) {
25
+ _map4dMarker = [[RMFMarkerMap4d alloc] init];
26
+ _map4dMarker.reactMarker = self;
27
+
28
+ _coordinate = _map4dMarker.position;
29
+ _anchor = _map4dMarker.groundAnchor;
30
+ _elevation = _map4dMarker.elevation;
31
+ _rotation = _map4dMarker.rotation;
32
+ _draggable = _map4dMarker.draggable;
33
+ _infoWindowAnchor = _map4dMarker.infoWindowAnchor;
34
+ _title = nil;//_map4dMarker.title;
35
+ _snippet = nil;//_map4dMarker.snippet;
36
+ _icon = nil;
37
+ _zIndex = _map4dMarker.zIndex;
38
+ _visible = true;//!_map4dMarker.isHidden;
39
+ _userData = nil;
40
+ _iconView = nil;
41
+ observables = [[NSMutableArray alloc] init];
42
+ }
43
+ return self;
44
+ }
45
+
46
+ - (void)setMapView:(RMFMapView *)mapView {
47
+ if (mapView != nil) {
48
+ if (self.icon == nil) {
49
+ _map4dMarker.icon = nil;
50
+ } else {
51
+ _map4dMarker.icon = [UIImage imageWithCGImage:self.icon.image.CGImage scale:[UIScreen mainScreen].scale orientation:self.icon.image.imageOrientation];
52
+ }
53
+ }
54
+ _map4dMarker.map = mapView;
55
+ }
56
+
57
+ /** Property */
58
+
59
+ - (void)setCoordinate:(CLLocationCoordinate2D)coordinate {
60
+ _coordinate = coordinate;
61
+ _map4dMarker.position = coordinate;
62
+ }
63
+
64
+ - (void)setAnchor:(CGPoint)anchor {
65
+ _anchor = anchor;
66
+ _map4dMarker.groundAnchor = anchor;
67
+ }
68
+
69
+ - (void)setElevation:(double)elevation {
70
+ _elevation = elevation;
71
+ _map4dMarker.elevation = elevation;
72
+ }
73
+
74
+ - (void)setRotation:(double)rotation {
75
+ _rotation = rotation;
76
+ _map4dMarker.rotation = rotation;
77
+ }
78
+
79
+ - (void)setDraggable:(BOOL)draggable {
80
+ _draggable = draggable;
81
+ _map4dMarker.draggable = draggable;
82
+ }
83
+
84
+ - (void) setInfoWindowAnchor:(CGPoint)infoWindowAnchor {
85
+ _infoWindowAnchor = infoWindowAnchor;
86
+ _map4dMarker.infoWindowAnchor = infoWindowAnchor;
87
+ }
88
+
89
+ - (void)setTitle:(NSString *)title {
90
+ _title = title;
91
+ _map4dMarker.title = title;
92
+ }
93
+
94
+ - (void)setSnippet:(NSString *)snippet {
95
+ _snippet = snippet;
96
+ _map4dMarker.snippet = snippet;
97
+ }
98
+
99
+ - (void)setIcon:(RMFIcon *)icon {
100
+ _icon = icon;
101
+ if (icon == nil) {
102
+ _map4dMarker.icon = nil;
103
+ return;
104
+ }
105
+ dispatch_async(dispatch_get_global_queue(0,0), ^{
106
+ NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: icon.uri]];
107
+ if (imageData != nil) {
108
+ dispatch_async(dispatch_get_main_queue(), ^{
109
+ self->_icon.image = [UIImage imageWithData:imageData];
110
+ if (self->_map4dMarker.map != nil) {
111
+ CGFloat scale = [UIScreen mainScreen].scale;
112
+ self->_map4dMarker.icon = [UIImage imageWithCGImage:[self->_icon.image CGImage] scale:scale orientation:self->_icon.image.imageOrientation];
113
+ }
114
+ });
115
+ }
116
+ });
117
+ }
118
+
119
+ - (void)setZIndex:(float)zIndex {
120
+ _zIndex = zIndex;
121
+ _map4dMarker.zIndex = zIndex;
122
+ }
123
+
124
+ - (void)setVisible:(BOOL)visible {
125
+ _visible = visible;
126
+ _map4dMarker.isHidden = !visible;
127
+ }
128
+
129
+ - (void)setUserInteractionEnabled:(BOOL)enabled {
130
+ [super setUserInteractionEnabled:enabled];
131
+ _map4dMarker.userInteractionEnabled = enabled;
132
+ }
133
+
134
+ - (void)setUserData:(NSDictionary *)userData {
135
+ _userData = userData;
136
+ }
137
+
138
+ - (NSDictionary*)responseWithAction:(NSString*)action pixel:(CGPoint)pixel {
139
+ CLLocationCoordinate2D tapLocation = [_map4dMarker.map.projection coordinateForPoint:pixel];
140
+ NSMutableDictionary* response = [NSMutableDictionary dictionaryWithDictionary:[RMFEventResponse fromCoordinate:tapLocation
141
+ pixel:pixel]];
142
+ response[@"marker"] = @{
143
+ kRMFLatLngCoordinateResponseKey: [RMFEventResponse fromCoordinate:_map4dMarker.position],
144
+ @"userData": _userData != nil ? _userData : @{}
145
+ };
146
+ response[@"action"] = action;
147
+ return response;
148
+ }
149
+
150
+ /** Event */
151
+ - (void)didBeginDraggingMarkerAtPixel:(CGPoint)pixel {
152
+ if (self.onDragStart) {
153
+ self.onDragStart([self responseWithAction:@"marker-drag-start" pixel:pixel]);
154
+ }
155
+ }
156
+
157
+ - (void)didEndDraggingMarkerAtPixel:(CGPoint)pixel {
158
+ if (self.onDragEnd) {
159
+ self.onDragEnd([self responseWithAction:@"marker-drag-end" pixel:pixel]);
160
+ }
161
+ }
162
+
163
+ - (void)didDragMarkerAtPixel:(CGPoint)pixel {
164
+ if (self.onDrag) {
165
+ self.onDrag([self responseWithAction:@"marker-drag" pixel:pixel]);
166
+ }
167
+ }
168
+
169
+ - (void)didTapInfoWindowAtPixel:(CGPoint)pixel {
170
+ if (self.onPressInfoWindow) {
171
+ self.onPressInfoWindow([self responseWithAction:@"marker-info-window-press" pixel:pixel]);
172
+ }
173
+ }
174
+
175
+ - (void)didTapAtPixel:(CGPoint)pixel {
176
+ if (self.onPress) {
177
+ self.onPress([self responseWithAction:@"marker-press" pixel:pixel]);
178
+ };
179
+ }
180
+
181
+ - (void)layoutSubviews {
182
+ [super layoutSubviews];
183
+ float width = 0;
184
+ float height = 0;
185
+
186
+ for (UIView *v in [_iconView subviews]) {
187
+ float fw = v.frame.origin.x + v.frame.size.width;
188
+ float fh = v.frame.origin.y + v.frame.size.height;
189
+
190
+ width = MAX(fw, width);
191
+ height = MAX(fh, height);
192
+ }
193
+ [_iconView setFrame:CGRectMake(0, 0, width, height)];
194
+ [self->_map4dMarker setIconView:_iconView];
195
+ }
196
+
197
+ - (void)iconViewInsertSubview:(UIView*)subview atIndex:(NSInteger)atIndex {
198
+ if (!_map4dMarker.iconView) {
199
+ _iconView = [[UIView alloc] init];
200
+ _map4dMarker.iconView = _iconView;
201
+ }
202
+ [_iconView insertSubview:subview atIndex:atIndex];
203
+ }
204
+
205
+ - (void) removeAllObserver {
206
+ for (UIView* v in observables) {
207
+ [v removeObserver:self forKeyPath:@"image"];
208
+ [v removeObserver:self forKeyPath:@"bounds"];
209
+ }
210
+ [observables removeAllObjects];
211
+ }
212
+
213
+ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
214
+ {
215
+ UIApplicationState appState = [[UIApplication sharedApplication] applicationState];
216
+ if (context == (__bridge void * _Nullable)(_iconView)) {
217
+ if (_map4dMarker != NULL) {
218
+ //TODO: remove me
219
+ //RCTImageView will clear image when window == nil or app go to background mode --> causes a bug, marker is updated without image.
220
+ //TODO: how to fix if we stop cheating?
221
+ if (context == (__bridge void * _Nullable) self.map4dMarker.iconView
222
+ && (!self.window || appState == UIApplicationStateBackground)
223
+ ) {
224
+ return;
225
+ }
226
+ [self.map4dMarker setIconView:_iconView];
227
+ }
228
+ } else {
229
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
230
+ }
231
+ }
232
+
233
+ - (void)addObserver:(UIView*)view {
234
+ if ([view isKindOfClass:[RCTImageView class]]) {
235
+ [view addObserver:self forKeyPath:@"image" options:NSKeyValueObservingOptionNew context:(__bridge void * _Nullable)(_iconView)];
236
+ [view addObserver:self forKeyPath:@"bounds" options:NSKeyValueObservingOptionNew context:(__bridge void * _Nullable)(_iconView)];
237
+ [observables addObject:view];
238
+ }
239
+
240
+ NSArray<UIView *> *reactSubviews = [view reactSubviews];
241
+ for (int i = 0; i < reactSubviews.count; i++) {
242
+ UIView* view = [reactSubviews objectAtIndex:i];
243
+ [self addObserver:view];
244
+ }
245
+ }
246
+
247
+
248
+ - (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex {
249
+ [self iconViewInsertSubview:(UIView*)subview atIndex:atIndex+1];
250
+ [self removeAllObserver];
251
+ [self addObserver:(UIView *) subview];
252
+ RMFDummyView *dummySubview = [[RMFDummyView alloc] initWithView:(UIView *)subview];
253
+ [super insertReactSubview:(UIView*)dummySubview atIndex:atIndex];
254
+ }
255
+
256
+ - (void)removeReactSubview:(id<RCTComponent>)dummySubview {
257
+ [self removeAllObserver];
258
+ UIView* subview = ((RMFDummyView*)dummySubview).view;
259
+ [(UIView*)subview removeFromSuperview];
260
+ [super removeReactSubview:(UIView*)dummySubview];
261
+ }
262
+
263
+ - (void)dealloc {
264
+ [self removeAllObserver];
265
+ }
266
+
267
+ @end
@@ -0,0 +1,17 @@
1
+ //
2
+ // RMFMarkerManager.h
3
+ // Map4dMap
4
+ //
5
+ // Created by Huy Dang on 4/24/20.
6
+ // Copyright © 2020 IOTLink. All rights reserved.
7
+ //
8
+
9
+ #ifndef RMFMarkerManager_h
10
+ #define RMFMarkerManager_h
11
+
12
+ #import <React/RCTViewManager.h>
13
+
14
+ @interface RMFMarkerManager : RCTViewManager
15
+ @end
16
+
17
+ #endif /* RMFMarkerManager_h */
@@ -0,0 +1,156 @@
1
+ //
2
+ // RMFMarkerManager.m
3
+ // Map4dMap
4
+ //
5
+ // Created by Huy Dang on 4/28/20.
6
+ // Copyright © 2020 IOTLink. All rights reserved.
7
+ //
8
+
9
+ #import "RMFMarkerManager.h"
10
+ #import "RMFMarker.h"
11
+ #import <React/RCTConvert+CoreLocation.h>
12
+ #import <React/RCTBridge.h>
13
+ #import <React/RCTUIManager.h>
14
+
15
+ @implementation RMFMarkerManager
16
+
17
+ RCT_EXPORT_MODULE(RMFMarker)
18
+
19
+ - (UIView *)view {
20
+ RMFMarker * marker = [[RMFMarker alloc] init];
21
+ return marker;
22
+ }
23
+
24
+ RCT_EXPORT_VIEW_PROPERTY(coordinate, CLLocationCoordinate2D)
25
+ RCT_EXPORT_VIEW_PROPERTY(anchor, CGPoint)
26
+ RCT_EXPORT_VIEW_PROPERTY(elevation, double)
27
+ RCT_EXPORT_VIEW_PROPERTY(rotation, double)
28
+ RCT_EXPORT_VIEW_PROPERTY(draggable, BOOL)
29
+ RCT_EXPORT_VIEW_PROPERTY(infoWindowAnchor, CGPoint)
30
+ RCT_EXPORT_VIEW_PROPERTY(title, NSString)
31
+ RCT_EXPORT_VIEW_PROPERTY(snippet, NSString)
32
+ RCT_EXPORT_VIEW_PROPERTY(userInteractionEnabled, BOOL)
33
+ RCT_EXPORT_VIEW_PROPERTY(icon, RMFIcon)
34
+ RCT_EXPORT_VIEW_PROPERTY(zIndex, float)
35
+ RCT_EXPORT_VIEW_PROPERTY(visible, BOOL)
36
+ RCT_EXPORT_VIEW_PROPERTY(userData, NSDictionary)
37
+
38
+ RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
39
+ RCT_EXPORT_VIEW_PROPERTY(onPressInfoWindow, RCTDirectEventBlock)
40
+ RCT_EXPORT_VIEW_PROPERTY(onDragStart, RCTDirectEventBlock)
41
+ RCT_EXPORT_VIEW_PROPERTY(onDrag, RCTDirectEventBlock)
42
+ RCT_EXPORT_VIEW_PROPERTY(onDragEnd, RCTDirectEventBlock)
43
+
44
+ RCT_EXPORT_METHOD(setCoordinate:(nonnull NSNumber *)reactTag
45
+ withCoordinate:(id)coordinate)
46
+ {
47
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
48
+ id view = viewRegistry[reactTag];
49
+ if (![view isKindOfClass:[RMFMarker class]]) {
50
+ RCTLogError(@"Invalid view returned from registry, expecting RMFMarker, got: %@", view);
51
+ } else {
52
+ RMFMarker *marker = (RMFMarker *)view;
53
+ [marker setCoordinate:[RCTConvert CLLocationCoordinate2D:coordinate]];
54
+ }
55
+ }];
56
+ }
57
+
58
+ RCT_EXPORT_METHOD(setRotation:(nonnull NSNumber *)reactTag
59
+ rotation:(double)rotation)
60
+ {
61
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
62
+ id view = viewRegistry[reactTag];
63
+ if (![view isKindOfClass:[RMFMarker class]]) {
64
+ RCTLogError(@"Invalid view returned from registry, expecting RMFMarker, got: %@", view);
65
+ } else {
66
+ RMFMarker *marker = (RMFMarker *)view;
67
+ [marker setRotation:rotation];
68
+ }
69
+ }];
70
+ }
71
+
72
+ RCT_EXPORT_METHOD(setTitle:(nonnull NSNumber *)reactTag
73
+ title:(NSString*)title)
74
+ {
75
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
76
+ id view = viewRegistry[reactTag];
77
+ if (![view isKindOfClass:[RMFMarker class]]) {
78
+ RCTLogError(@"Invalid view returned from registry, expecting RMFMarker, got: %@", view);
79
+ } else {
80
+ RMFMarker *marker = (RMFMarker *)view;
81
+ [marker setTitle:title];
82
+ }
83
+ }];
84
+ }
85
+
86
+ RCT_EXPORT_METHOD(setSnippet:(nonnull NSNumber *)reactTag
87
+ snippet:(NSString*)snippet)
88
+ {
89
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
90
+ id view = viewRegistry[reactTag];
91
+ if (![view isKindOfClass:[RMFMarker class]]) {
92
+ RCTLogError(@"Invalid view returned from registry, expecting RMFMarker, got: %@", view);
93
+ } else {
94
+ RMFMarker *marker = (RMFMarker *)view;
95
+ [marker setSnippet:snippet];
96
+ }
97
+ }];
98
+ }
99
+
100
+ RCT_EXPORT_METHOD(setDraggable:(nonnull NSNumber *)reactTag
101
+ draggable:(BOOL)draggable)
102
+ {
103
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
104
+ id view = viewRegistry[reactTag];
105
+ if (![view isKindOfClass:[RMFMarker class]]) {
106
+ RCTLogError(@"Invalid view returned from registry, expecting RMFMarker, got: %@", view);
107
+ } else {
108
+ RMFMarker *marker = (RMFMarker *)view;
109
+ [marker setDraggable:draggable];
110
+ }
111
+ }];
112
+ }
113
+
114
+ RCT_EXPORT_METHOD(setZIndex:(nonnull NSNumber *)reactTag
115
+ zIndex:(float)zIndex)
116
+ {
117
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
118
+ id view = viewRegistry[reactTag];
119
+ if (![view isKindOfClass:[RMFMarker class]]) {
120
+ RCTLogError(@"Invalid view returned from registry, expecting RMFMarker, got: %@", view);
121
+ } else {
122
+ RMFMarker *marker = (RMFMarker *)view;
123
+ [marker setZIndex:zIndex];
124
+ }
125
+ }];
126
+ }
127
+
128
+ RCT_EXPORT_METHOD(setVisible:(nonnull NSNumber *)reactTag
129
+ visible:(BOOL)visible)
130
+ {
131
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
132
+ id view = viewRegistry[reactTag];
133
+ if (![view isKindOfClass:[RMFMarker class]]) {
134
+ RCTLogError(@"Invalid view returned from registry, expecting RMFMarker, got: %@", view);
135
+ } else {
136
+ RMFMarker *marker = (RMFMarker *)view;
137
+ [marker setVisible:visible];
138
+ }
139
+ }];
140
+ }
141
+
142
+ RCT_EXPORT_METHOD(setUserData:(nonnull NSNumber *)reactTag
143
+ userData:(id)json)
144
+ {
145
+ [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
146
+ id view = viewRegistry[reactTag];
147
+ if (![view isKindOfClass:[RMFMarker class]]) {
148
+ RCTLogError(@"Invalid view returned from registry, expecting RMFMarker, got: %@", view);
149
+ } else {
150
+ RMFMarker *marker = (RMFMarker *)view;
151
+ [marker setUserData:[RCTConvert NSDictionary:json]];
152
+ }
153
+ }];
154
+ }
155
+
156
+ @end
@@ -0,0 +1,19 @@
1
+ //
2
+ // RMFMarkerMap4d.h
3
+ // Map4dMap
4
+ //
5
+ // Created by Huy Dang on 5/4/20.
6
+ // Copyright © 2020 IOTLink. All rights reserved.
7
+ //
8
+
9
+ #ifndef RMFMarkerMap4d_h
10
+ #define RMFMarkerMap4d_h
11
+
12
+ #import <Map4dMap/Map4dMap.h>
13
+
14
+ @class RMFMarker;
15
+ @interface RMFMarkerMap4d : MFMarker
16
+ @property (nonatomic, weak) RMFMarker *reactMarker;
17
+ @end
18
+
19
+ #endif /* RMFMarkerMap4d_h */
@@ -0,0 +1,13 @@
1
+ //
2
+ // RMFMarkerMap4d.m
3
+ // Map4dMap
4
+ //
5
+ // Created by Huy Dang on 5/4/20.
6
+ // Copyright © 2020 IOTLink. All rights reserved.
7
+ //
8
+
9
+ #import "RMFMarkerMap4d.h"
10
+ #import <Foundation/Foundation.h>
11
+
12
+ @implementation RMFMarkerMap4d
13
+ @end
package/ios/RMFPOI.h ADDED
@@ -0,0 +1,38 @@
1
+ //
2
+ // RMFPOI.h
3
+ // Map4dMap
4
+ //
5
+ // Created by Huy Dang on 7/5/20.
6
+ // Copyright © 2020 IOTLink. All rights reserved.
7
+ //
8
+
9
+ #ifndef RMFPOI_h
10
+ #define RMFPOI_h
11
+
12
+ #import <React/UIView+React.h>
13
+ #import "RMFPOIMap4d.h"
14
+ #import "RMFMapView.h"
15
+ #import "RMFIcon.h"
16
+
17
+ @interface RMFPOI : UIView
18
+
19
+ @property (nonatomic, strong, nonnull) RMFPOIMap4d * map4dPOI;
20
+
21
+ @property (nonatomic, copy) RCTBubblingEventBlock _Nullable onPress;
22
+
23
+ @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
24
+ @property (nonatomic, strong, nullable) NSString *title;
25
+ @property (nonatomic, strong, nullable) UIColor* titleColor;
26
+ @property (nonatomic, strong, nullable) NSString* subtitle;
27
+ @property (nonatomic, strong, nullable) NSString* poiType;
28
+ @property (nonatomic, copy, nullable) RMFIcon *icon;
29
+ @property (nonatomic, assign) float zIndex;
30
+ @property (nonatomic, assign) BOOL visible;
31
+ @property (nonatomic, copy, nullable) NSDictionary * userData;
32
+
33
+ - (void)didTapAtPixel:(CGPoint)pixel;
34
+ - (void)setMapView:(RMFMapView* _Nullable)mapView;
35
+
36
+ @end
37
+
38
+ #endif /* RMFPOI_h */
package/ios/RMFPOI.m ADDED
@@ -0,0 +1,123 @@
1
+ //
2
+ // RMFPOI.m
3
+ // Map4dMap
4
+ //
5
+ // Created by Huy Dang on 7/5/20.
6
+ // Copyright © 2020 IOTLink. All rights reserved.
7
+ //
8
+
9
+ #import "RMFPOI.h"
10
+ #import <Foundation/Foundation.h>
11
+ #import "RMFEventResponse.h"
12
+
13
+ @implementation RMFPOI
14
+
15
+ - (instancetype)init {
16
+ if ((self = [super init])) {
17
+ _map4dPOI = [[RMFPOIMap4d alloc] init];
18
+ _map4dPOI.reactPOI = self;
19
+
20
+ _coordinate = _map4dPOI.position;
21
+ _title = nil;//_map4dPOI.title;
22
+ _titleColor = _map4dPOI.color;
23
+ _subtitle = nil;//_map4dPOI.subtitle;
24
+ _poiType = nil;//_map4dPOI.type;
25
+ _icon = nil;
26
+ _zIndex = _map4dPOI.zIndex;
27
+ _visible = true;//!_map4dPOI.isHidden;
28
+ _userData = nil;
29
+ }
30
+ return self;
31
+ }
32
+
33
+ - (void)setMapView:(RMFMapView *)mapView {
34
+ _map4dPOI.map = mapView;
35
+ }
36
+
37
+ /** Properties */
38
+
39
+ - (void)setCoordinate:(CLLocationCoordinate2D)coordinate {
40
+ _coordinate = coordinate;
41
+ _map4dPOI.position = coordinate;
42
+ }
43
+
44
+ - (void)setTitle:(NSString *)title {
45
+ _title = title;
46
+ _map4dPOI.title = title;
47
+ }
48
+
49
+ - (void)setTitleColor:(UIColor *)titleColor {
50
+ _titleColor = titleColor;
51
+ _map4dPOI.color = titleColor;
52
+ }
53
+
54
+ - (void)setSubtitle:(NSString *)subtitle {
55
+ _subtitle = subtitle;
56
+ _map4dPOI.subtitle = subtitle;
57
+ }
58
+
59
+ - (void)setPoiType:(NSString *)poiType {
60
+ _poiType = poiType;
61
+ _map4dPOI.type = poiType;
62
+ }
63
+ - (void)setIcon:(RMFIcon *)icon {
64
+ _icon = icon;
65
+ if (icon == nil || icon.uri == nil) {
66
+ _map4dPOI.icon = nil;
67
+ return;
68
+ }
69
+
70
+ dispatch_async(dispatch_get_global_queue(0,0), ^{
71
+ NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: icon.uri]];
72
+ if (imageData != nil) {
73
+ dispatch_async(dispatch_get_main_queue(), ^{
74
+ UIImage* icon = [UIImage imageWithData:imageData];
75
+ self->_map4dPOI.icon = [UIImage imageWithCGImage:[icon CGImage]
76
+ scale:[UIScreen mainScreen].scale
77
+ orientation:icon.imageOrientation];
78
+ });
79
+ }
80
+ });
81
+ }
82
+
83
+ - (void)setZIndex:(float)zIndex {
84
+ _zIndex = zIndex;
85
+ _map4dPOI.zIndex = zIndex;
86
+ }
87
+
88
+ - (void)setVisible:(BOOL)visible {
89
+ _visible = visible;
90
+ _map4dPOI.isHidden = !visible;
91
+ }
92
+
93
+ - (void)setUserInteractionEnabled:(BOOL)enabled {
94
+ [super setUserInteractionEnabled:enabled];
95
+ _map4dPOI.userInteractionEnabled = enabled;
96
+ }
97
+
98
+ - (void)setUserData:(NSDictionary *)userData {
99
+ _userData = userData;
100
+ // _map4dPOI.userData = userData;
101
+ }
102
+
103
+ /** Event */
104
+
105
+ - (void)didTapAtPixel:(CGPoint)pixel {
106
+ if (!self.onPress) {
107
+ return;
108
+ }
109
+
110
+ CLLocationCoordinate2D tapLocation = [_map4dPOI.map.projection coordinateForPoint:pixel];
111
+ NSMutableDictionary* response = [NSMutableDictionary dictionaryWithDictionary:[RMFEventResponse fromCoordinate:tapLocation
112
+ pixel:pixel]];
113
+ response[@"poi"] = @{
114
+ kRMFLatLngCoordinateResponseKey: [RMFEventResponse fromCoordinate:_coordinate],
115
+ @"title": _title,
116
+ @"userData": _userData != nil ? _userData : @{}
117
+ };
118
+ response[@"action"] = @"poi-press";
119
+
120
+ self.onPress(response);
121
+ }
122
+
123
+ @end
@@ -0,0 +1,18 @@
1
+ //
2
+ // RMFPOIManager.h
3
+ // Map4dMap
4
+ //
5
+ // Created by Huy Dang on 7/5/20.
6
+ // Copyright © 2020 IOTLink. All rights reserved.
7
+ //
8
+
9
+ #ifndef RMFPOIManager_h
10
+ #define RMFPOIManager_h
11
+
12
+ #import <React/RCTViewManager.h>
13
+
14
+ @interface RMFPOIManager : RCTViewManager
15
+
16
+ @end
17
+
18
+ #endif /* RMFPOIManager_h */