react-native-maps 1.21.0-alpha.99 → 1.22.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 (234) hide show
  1. package/README.md +9 -4
  2. package/android/build.gradle +65 -72
  3. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  4. package/android/src/main/RCTAppDependencyProvider.h +25 -0
  5. package/android/src/main/RCTAppDependencyProvider.mm +55 -0
  6. package/android/src/main/RCTModulesConformingToProtocolsProvider.h +18 -0
  7. package/android/src/main/RCTModulesConformingToProtocolsProvider.mm +33 -0
  8. package/android/src/main/RCTThirdPartyComponentsProvider.h +16 -0
  9. package/android/src/main/RCTThirdPartyComponentsProvider.mm +28 -0
  10. package/android/src/main/ReactAppDependencyProvider.podspec +34 -0
  11. package/android/src/main/java/com/facebook/fbreact/specs/NativeAirMapsModuleSpec.java +63 -0
  12. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerDelegate.java +35 -0
  13. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCalloutManagerInterface.java +17 -0
  14. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCircleManagerDelegate.java +49 -0
  15. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsCircleManagerInterface.java +23 -0
  16. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerDelegate.java +49 -0
  17. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsGooglePolygonManagerInterface.java +23 -0
  18. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerDelegate.java +209 -0
  19. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMapViewManagerInterface.java +74 -0
  20. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerDelegate.java +104 -0
  21. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsMarkerManagerInterface.java +39 -0
  22. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerDelegate.java +45 -0
  23. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsOverlayManagerInterface.java +22 -0
  24. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerDelegate.java +58 -0
  25. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsPolylineManagerInterface.java +26 -0
  26. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsUrlTileManagerDelegate.java +62 -0
  27. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsUrlTileManagerInterface.java +27 -0
  28. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsWMSTileManagerDelegate.java +56 -0
  29. package/android/src/main/java/com/facebook/react/viewmanagers/RNMapsWMSTileManagerInterface.java +25 -0
  30. package/android/src/main/java/com/rnmaps/fabric/MapViewManager.java +5 -1
  31. package/android/src/main/java/com/rnmaps/fabric/NativeAirMapsModule.java +1 -1
  32. package/android/src/main/java/com/rnmaps/fabric/OverlayManager.java +9 -3
  33. package/android/src/main/java/com/rnmaps/fabric/UrlTileManager.java +124 -0
  34. package/android/src/main/java/com/rnmaps/fabric/WMSTileManager.java +114 -0
  35. package/android/src/main/java/com/rnmaps/maps/MapAirModulePackage.java +19 -3
  36. package/android/src/main/java/com/rnmaps/maps/MapMarker.java +608 -603
  37. package/android/src/main/java/com/rnmaps/maps/MapMarkerManager.java +3 -3
  38. package/android/src/main/java/com/rnmaps/maps/MapOverlay.java +2 -22
  39. package/android/src/main/java/com/rnmaps/maps/MapOverlayManager.java +23 -1
  40. package/android/src/main/java/com/rnmaps/maps/MapUrlTile.java +18 -18
  41. package/android/src/main/java/com/rnmaps/maps/MapUrlTileManager.java +10 -14
  42. package/android/src/main/java/com/rnmaps/maps/MapView.java +58 -49
  43. package/android/src/main/java/com/rnmaps/maps/MapWMSTile.java +3 -3
  44. package/android/src/main/java/com/rnmaps/maps/MapWMSTileManager.java +10 -10
  45. package/android/src/main/jni/CMakeLists.txt +36 -0
  46. package/android/src/main/jni/RNMapsSpecs-generated.cpp +68 -0
  47. package/android/src/main/jni/RNMapsSpecs.h +31 -0
  48. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.cpp +31 -0
  49. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ComponentDescriptors.h +33 -0
  50. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.cpp +979 -0
  51. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/EventEmitters.h +860 -0
  52. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.cpp +227 -0
  53. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/Props.h +1297 -0
  54. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI-generated.cpp +74 -0
  55. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/RNMapsSpecsJSI.h +268 -0
  56. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.cpp +26 -0
  57. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/ShadowNodes.h +131 -0
  58. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/States.cpp +16 -0
  59. package/android/src/main/jni/react/renderer/components/RNMapsSpecs/States.h +137 -0
  60. package/app.plugin.js +1 -0
  61. package/ios/AirGoogleMaps/AIRGoogleMap.h +13 -13
  62. package/ios/AirGoogleMaps/{AIRGoogleMap.m → AIRGoogleMap.mm} +32 -34
  63. package/ios/AirGoogleMaps/AIRGoogleMapManager.h +1 -0
  64. package/ios/AirGoogleMaps/AIRGoogleMapManager.mm +543 -0
  65. package/ios/AirGoogleMaps/AIRGoogleMapMarker.m +3 -3
  66. package/ios/AirGoogleMaps/AIRGoogleMapMarkerManager.m +1 -1
  67. package/ios/AirGoogleMaps/AIRGoogleMapUrlTile.m +2 -2
  68. package/ios/AirGoogleMaps/AIRGoogleMapWMSTile.m +2 -2
  69. package/ios/AirGoogleMaps/RNMapsGoogleMapView.h +5 -2
  70. package/ios/AirGoogleMaps/RNMapsGoogleMapView.mm +41 -33
  71. package/ios/AirGoogleMaps/RNMapsGoogleMapViewManager.mm +16 -1
  72. package/ios/AirGoogleMaps/RNMapsGooglePolygonView.mm +23 -14
  73. package/ios/AirGoogleMaps/RNMapsGooglePolygonViewManager.mm +1 -0
  74. package/ios/AirMaps/AIRMap.h +8 -9
  75. package/ios/AirMaps/{AIRMap.m → AIRMap.mm} +18 -14
  76. package/ios/AirMaps/AIRMapManager.m +8 -19
  77. package/ios/AirMaps/AIRMapMarker.m +57 -44
  78. package/ios/AirMaps/AIRMapOverlay.m +2 -2
  79. package/ios/AirMaps/AIRMapWMSTile.m +8 -8
  80. package/ios/AirMaps/FabricPlaceholders/PlaceHolderGoogleMapView.h +25 -0
  81. package/ios/AirMaps/FabricPlaceholders/PlaceHolderGoogleMapView.mm +77 -0
  82. package/ios/AirMaps/FabricPlaceholders/PlaceHolderPolygonView.h +25 -0
  83. package/ios/AirMaps/FabricPlaceholders/PlaceHolderPolygonView.mm +51 -0
  84. package/ios/AirMaps/RNMapsAirModule.h +2 -3
  85. package/ios/AirMaps/RNMapsAirModule.mm +14 -0
  86. package/ios/AirMaps/RNMapsDefines.h +1 -0
  87. package/ios/AirMaps/RNMapsMapView.h +5 -2
  88. package/ios/AirMaps/RNMapsMapView.mm +16 -6
  89. package/ios/AirMaps/RNMapsMapViewManager.mm +19 -1
  90. package/ios/AirMaps/RNMapsMarkerView.mm +12 -4
  91. package/ios/AirMaps/RNMapsMarkerViewManager.mm +7 -0
  92. package/ios/AirMaps/module.modulemap +6 -0
  93. package/ios/AirMaps.xcodeproj/project.pbxproj +15 -55
  94. package/ios/generated/RCTAppDependencyProvider.h +25 -0
  95. package/ios/generated/RCTAppDependencyProvider.mm +55 -0
  96. package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  97. package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  98. package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
  99. package/ios/generated/RCTThirdPartyComponentsProvider.mm +26 -0
  100. package/ios/{AirMaps → generated}/RNMapsAirModuleDelegate.h +1 -1
  101. package/ios/generated/RNMapsSpecs/ComponentDescriptors.cpp +29 -0
  102. package/ios/generated/RNMapsSpecs/ComponentDescriptors.h +31 -0
  103. package/ios/generated/RNMapsSpecs/EventEmitters.cpp +977 -0
  104. package/ios/generated/RNMapsSpecs/EventEmitters.h +846 -0
  105. package/ios/generated/RNMapsSpecs/Props.cpp +194 -0
  106. package/ios/generated/RNMapsSpecs/Props.h +1224 -0
  107. package/ios/generated/RNMapsSpecs/RCTComponentViewHelpers.h +591 -0
  108. package/ios/generated/RNMapsSpecs/RNMapsSpecs-generated.mm +92 -0
  109. package/ios/generated/RNMapsSpecs/RNMapsSpecs.h +137 -0
  110. package/ios/generated/RNMapsSpecs/ShadowNodes.cpp +24 -0
  111. package/ios/generated/RNMapsSpecs/ShadowNodes.h +109 -0
  112. package/ios/generated/RNMapsSpecs/States.cpp +16 -0
  113. package/ios/generated/RNMapsSpecs/States.h +113 -0
  114. package/ios/generated/RNMapsSpecsJSI-generated.cpp +74 -0
  115. package/ios/generated/RNMapsSpecsJSI.h +268 -0
  116. package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
  117. package/ios/generated/module.modulemap +15 -0
  118. package/package.json +34 -27
  119. package/plugin/build/android.js +58 -0
  120. package/plugin/build/index.js +10 -0
  121. package/plugin/build/ios.js +172 -0
  122. package/react-native-google-maps.podspec +27 -0
  123. package/react-native-maps-generated.podspec +31 -0
  124. package/react-native-maps.podspec +52 -46
  125. package/react-native.config.js +16 -0
  126. package/src/AnimatedRegion.ts +169 -0
  127. package/src/Geojson.tsx +541 -0
  128. package/src/MapCallout.tsx +77 -0
  129. package/src/MapCalloutSubview.tsx +64 -0
  130. package/src/MapCircle.tsx +162 -0
  131. package/src/MapHeatmap.tsx +125 -0
  132. package/src/MapLocalTile.tsx +60 -0
  133. package/src/MapMarker.tsx +531 -0
  134. package/src/MapMarkerNativeComponent.ts +51 -0
  135. package/src/MapOverlay.tsx +178 -0
  136. package/src/MapPolygon.tsx +188 -0
  137. package/src/MapPolygon.types.ts +25 -0
  138. package/src/MapPolyline.tsx +215 -0
  139. package/src/MapUrlTile.tsx +169 -0
  140. package/src/MapView.tsx +1230 -0
  141. package/src/MapView.types.ts +212 -0
  142. package/src/MapView.web.ts +2 -0
  143. package/src/MapViewNativeComponent.ts +86 -0
  144. package/src/MapWMSTile.tsx +148 -0
  145. package/src/ProviderConstants.ts +2 -0
  146. package/src/createFabricMap.tsx +253 -0
  147. package/src/decorateMapComponent.ts +229 -0
  148. package/src/fixImageProp.ts +17 -0
  149. package/src/index.ts +52 -0
  150. package/src/sharedTypes.ts +101 -0
  151. package/{specs → src/specs}/NativeComponentCircle.ts +3 -4
  152. package/{specs → src/specs}/NativeComponentGoogleMapView.ts +15 -9
  153. package/{specs → src/specs}/NativeComponentMapView.ts +61 -32
  154. package/{specs → src/specs}/NativeComponentOverlay.ts +11 -2
  155. package/{specs → src/specs}/NativeComponentPolyline.ts +1 -1
  156. package/src/specs/NativeComponentUrlTile.ts +128 -0
  157. package/src/specs/NativeComponentWMSTile.ts +107 -0
  158. package/ios/AirGoogleMaps/AIRGoogleMapManager.m +0 -533
  159. package/lib/AnimatedRegion.d.ts +0 -19
  160. package/lib/AnimatedRegion.js +0 -134
  161. package/lib/Geojson.d.ts +0 -204
  162. package/lib/Geojson.js +0 -166
  163. package/lib/MapCallout.d.ts +0 -40
  164. package/lib/MapCallout.js +0 -51
  165. package/lib/MapCalloutSubview.d.ts +0 -34
  166. package/lib/MapCalloutSubview.js +0 -48
  167. package/lib/MapCircle.d.ts +0 -117
  168. package/lib/MapCircle.js +0 -53
  169. package/lib/MapHeatmap.d.ts +0 -78
  170. package/lib/MapHeatmap.js +0 -59
  171. package/lib/MapLocalTile.d.ts +0 -35
  172. package/lib/MapLocalTile.js +0 -44
  173. package/lib/MapMarker.d.ts +0 -322
  174. package/lib/MapMarker.js +0 -158
  175. package/lib/MapMarkerNativeComponent.d.ts +0 -15
  176. package/lib/MapMarkerNativeComponent.js +0 -15
  177. package/lib/MapOverlay.d.ts +0 -88
  178. package/lib/MapOverlay.js +0 -65
  179. package/lib/MapPolygon.d.ts +0 -140
  180. package/lib/MapPolygon.js +0 -53
  181. package/lib/MapPolygon.types.d.ts +0 -18
  182. package/lib/MapPolyline.d.ts +0 -156
  183. package/lib/MapPolyline.js +0 -53
  184. package/lib/MapUrlTile.d.ts +0 -134
  185. package/lib/MapUrlTile.js +0 -44
  186. package/lib/MapView.d.ts +0 -703
  187. package/lib/MapView.js +0 -427
  188. package/lib/MapView.types.d.ts +0 -161
  189. package/lib/MapView.types.js +0 -2
  190. package/lib/MapView.web.d.ts +0 -1
  191. package/lib/MapView.web.js +0 -9
  192. package/lib/MapViewNativeComponent.d.ts +0 -18
  193. package/lib/MapViewNativeComponent.js +0 -19
  194. package/lib/MapWMSTile.d.ts +0 -116
  195. package/lib/MapWMSTile.js +0 -44
  196. package/lib/ProviderConstants.d.ts +0 -2
  197. package/lib/ProviderConstants.js +0 -5
  198. package/lib/createFabricMap.d.ts +0 -24
  199. package/lib/createFabricMap.js +0 -188
  200. package/lib/decorateMapComponent.d.ts +0 -36
  201. package/lib/decorateMapComponent.js +0 -120
  202. package/lib/fixImageProp.d.ts +0 -4
  203. package/lib/fixImageProp.js +0 -16
  204. package/lib/index.d.ts +0 -38
  205. package/lib/index.js +0 -81
  206. package/lib/sharedTypes.d.ts +0 -81
  207. package/lib/sharedTypes.js +0 -2
  208. package/lib/sharedTypesInternal.js +0 -2
  209. package/lib/specs/NativeAirMapsModule.d.ts +0 -31
  210. package/lib/specs/NativeAirMapsModule.js +0 -4
  211. package/lib/specs/NativeComponentCallout.d.ts +0 -46
  212. package/lib/specs/NativeComponentCallout.js +0 -9
  213. package/lib/specs/NativeComponentCircle.d.ts +0 -74
  214. package/lib/specs/NativeComponentCircle.js +0 -7
  215. package/lib/specs/NativeComponentGoogleMapView.d.ts +0 -713
  216. package/lib/specs/NativeComponentGoogleMapView.js +0 -22
  217. package/lib/specs/NativeComponentGooglePolygon.d.ts +0 -75
  218. package/lib/specs/NativeComponentGooglePolygon.js +0 -7
  219. package/lib/specs/NativeComponentMapView.d.ts +0 -847
  220. package/lib/specs/NativeComponentMapView.js +0 -20
  221. package/lib/specs/NativeComponentMarker.d.ts +0 -258
  222. package/lib/specs/NativeComponentMarker.js +0 -19
  223. package/lib/specs/NativeComponentOverlay.d.ts +0 -67
  224. package/lib/specs/NativeComponentOverlay.js +0 -7
  225. package/lib/specs/NativeComponentPolyline.d.ts +0 -101
  226. package/lib/specs/NativeComponentPolyline.js +0 -7
  227. /package/ios/AirMaps/{UIView +AirMap.m → UIView+AirMap.m} +0 -0
  228. /package/ios/{AirMaps → generated}/RNMapsHostVewDelegate.h +0 -0
  229. /package/{lib/MapPolygon.types.js → plugin/build/types.js} +0 -0
  230. /package/{lib/sharedTypesInternal.d.ts → src/sharedTypesInternal.ts} +0 -0
  231. /package/{specs → src/specs}/NativeAirMapsModule.ts +0 -0
  232. /package/{specs → src/specs}/NativeComponentCallout.ts +0 -0
  233. /package/{specs → src/specs}/NativeComponentGooglePolygon.ts +0 -0
  234. /package/{specs → src/specs}/NativeComponentMarker.ts +0 -0
@@ -57,595 +57,599 @@ import java.util.Map;
57
57
 
58
58
  public class MapMarker extends MapFeature {
59
59
 
60
- private MarkerOptions markerOptions;
61
- private Marker marker;
62
- private int width;
63
- private int height;
64
- private String identifier;
65
-
66
- private LatLng position;
67
- private String title;
68
- private String snippet;
69
-
70
- private boolean anchorIsSet;
71
- private float anchorX;
72
- private float anchorY;
73
-
74
- private MapCallout calloutView;
75
- private View wrappedCalloutView;
76
- private final Context context;
77
-
78
- private float markerHue = 0.0f; // should be between 0 and 360
79
- private BitmapDescriptor iconBitmapDescriptor;
80
- private Bitmap iconBitmap;
81
-
82
- private float rotation = 0.0f;
83
- private boolean flat = false;
84
- private boolean draggable = false;
85
- private int zIndex = 0;
86
- private float opacity = 1.0f;
87
-
88
- private float calloutAnchorX;
89
- private float calloutAnchorY;
90
- private boolean calloutAnchorIsSet;
91
-
92
- private boolean tracksViewChanges = true;
93
- private boolean tracksViewChangesActive = false;
94
-
95
- private boolean hasCustomMarkerView = false;
96
- private final MapMarkerManager markerManager;
97
- private String imageUri;
98
- private boolean loadingImage;
99
-
100
- private final DraweeHolder<?> logoHolder;
101
- private ImageManager.OnImageLoadedListener imageLoadedListener;
102
- private DataSource<CloseableReference<CloseableImage>> dataSource;
103
- private final ControllerListener<ImageInfo> mLogoControllerListener =
104
- new BaseControllerListener<ImageInfo>() {
105
- @Override
106
- public void onSubmit(String id, Object callerContext){
107
- loadingImage = true;
108
- }
109
- @Override
110
- public void onFinalImageSet(
111
- String id,
112
- @Nullable final ImageInfo imageInfo,
113
- @Nullable Animatable animatable) {
114
- CloseableReference<CloseableImage> imageReference = null;
115
- try {
116
- imageReference = dataSource.getResult();
117
- if (imageReference != null) {
118
- CloseableImage image = imageReference.get();
119
- if (image instanceof CloseableStaticBitmap) {
120
- CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
121
- Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
122
- if (bitmap != null) {
123
- bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
124
- iconBitmap = bitmap;
125
- iconBitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
60
+ private MarkerOptions markerOptions;
61
+ private Marker marker;
62
+ private int width;
63
+ private int height;
64
+ private String identifier;
65
+
66
+ private LatLng position;
67
+ private String title;
68
+ private String snippet;
69
+
70
+ private boolean anchorIsSet;
71
+ private float anchorX;
72
+ private float anchorY;
73
+
74
+ private MapCallout calloutView;
75
+ private View wrappedCalloutView;
76
+ private final Context context;
77
+
78
+ private float markerHue = 0.0f; // should be between 0 and 360
79
+ private BitmapDescriptor iconBitmapDescriptor;
80
+ private Bitmap iconBitmap;
81
+
82
+ private float rotation = 0.0f;
83
+ private boolean flat = false;
84
+ private boolean draggable = false;
85
+ private int zIndex = 0;
86
+ private float opacity = 1.0f;
87
+
88
+ private float calloutAnchorX;
89
+ private float calloutAnchorY;
90
+ private boolean calloutAnchorIsSet;
91
+
92
+ private boolean tracksViewChanges = true;
93
+ private boolean tracksViewChangesActive = false;
94
+
95
+ private boolean hasCustomMarkerView = false;
96
+ private final MapMarkerManager markerManager;
97
+ private String imageUri;
98
+ private boolean loadingImage;
99
+
100
+ private final DraweeHolder<?> logoHolder;
101
+ private ImageManager.OnImageLoadedListener imageLoadedListener;
102
+ private DataSource<CloseableReference<CloseableImage>> dataSource;
103
+ private final ControllerListener<ImageInfo> mLogoControllerListener =
104
+ new BaseControllerListener<ImageInfo>() {
105
+ @Override
106
+ public void onSubmit(String id, Object callerContext) {
107
+ loadingImage = true;
108
+ }
109
+
110
+ @Override
111
+ public void onFinalImageSet(
112
+ String id,
113
+ @Nullable final ImageInfo imageInfo,
114
+ @Nullable Animatable animatable) {
115
+ CloseableReference<CloseableImage> imageReference = null;
116
+ try {
117
+ imageReference = dataSource.getResult();
118
+ if (imageReference != null) {
119
+ CloseableImage image = imageReference.get();
120
+ if (image instanceof CloseableStaticBitmap) {
121
+ CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
122
+ Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
123
+ if (bitmap != null) {
124
+ bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
125
+ iconBitmap = bitmap;
126
+ iconBitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
127
+ }
128
+ }
129
+ }
130
+ } finally {
131
+ dataSource.close();
132
+ if (imageReference != null) {
133
+ CloseableReference.closeSafely(imageReference);
134
+ }
135
+ }
136
+ if (MapMarker.this.markerManager != null && MapMarker.this.imageUri != null) {
137
+ MapMarker.this.markerManager.getSharedIcon(MapMarker.this.imageUri)
138
+ .updateIcon(iconBitmapDescriptor, iconBitmap);
139
+ }
140
+ update(true);
141
+ loadingImage = false;
142
+ if (imageLoadedListener != null) {
143
+ imageLoadedListener.onImageLoaded(null, null, false);
144
+ // fire and forget
145
+ imageLoadedListener = null;
146
+ }
126
147
  }
127
- }
148
+ };
149
+
150
+ public MapMarker(Context context, MapMarkerManager markerManager) {
151
+ super(context);
152
+ this.context = context;
153
+ this.markerManager = markerManager;
154
+ logoHolder = DraweeHolder.create(createDraweeHierarchy(), context);
155
+ logoHolder.onAttach();
156
+ }
157
+
158
+ public MapMarker(Context context, MarkerOptions options, MapMarkerManager markerManager) {
159
+ super(context);
160
+ this.context = context;
161
+ this.markerManager = markerManager;
162
+ logoHolder = DraweeHolder.create(createDraweeHierarchy(), context);
163
+ logoHolder.onAttach();
164
+
165
+ position = options.getPosition();
166
+ setAnchor(options.getAnchorU(), options.getAnchorV());
167
+ setCalloutAnchor(options.getInfoWindowAnchorU(), options.getInfoWindowAnchorV());
168
+ setTitle(options.getTitle());
169
+ setSnippet(options.getSnippet());
170
+ setRotation(options.getRotation());
171
+ setFlat(options.isFlat());
172
+ setDraggable(options.isDraggable());
173
+ setZIndex(Math.round(options.getZIndex()));
174
+ setOpacity(options.getAlpha());
175
+ iconBitmapDescriptor = options.getIcon();
176
+ }
177
+
178
+ private GenericDraweeHierarchy createDraweeHierarchy() {
179
+ return new GenericDraweeHierarchyBuilder(getResources())
180
+ .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
181
+ .setFadeDuration(0)
182
+ .build();
183
+ }
184
+
185
+ public void setCoordinate(ReadableMap coordinate) {
186
+ setCoordinate(new LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude")));
187
+ }
188
+
189
+ public void setCoordinate(LatLng position) {
190
+ this.position = position;
191
+ if (marker != null) {
192
+ marker.setPosition(position);
193
+ }
194
+ update(false);
195
+ }
196
+
197
+ public void setIdentifier(String identifier) {
198
+ this.identifier = identifier;
199
+ update(false);
200
+ }
201
+
202
+ public String getIdentifier() {
203
+ return this.identifier;
204
+ }
205
+
206
+ public void setTitle(String title) {
207
+ this.title = title;
208
+ if (marker != null) {
209
+ marker.setTitle(title);
210
+ }
211
+ update(false);
212
+ }
213
+
214
+ public void setSnippet(String snippet) {
215
+ this.snippet = snippet;
216
+ if (marker != null) {
217
+ marker.setSnippet(snippet);
218
+ }
219
+ update(false);
220
+ }
221
+
222
+ public void setRotation(float rotation) {
223
+ this.rotation = rotation;
224
+ if (marker != null) {
225
+ marker.setRotation(rotation);
226
+ }
227
+ update(false);
228
+ }
229
+
230
+ public void setFlat(boolean flat) {
231
+ this.flat = flat;
232
+ if (marker != null) {
233
+ marker.setFlat(flat);
234
+ }
235
+ update(false);
236
+ }
237
+
238
+ public void setDraggable(boolean draggable) {
239
+ this.draggable = draggable;
240
+ if (marker != null) {
241
+ marker.setDraggable(draggable);
242
+ }
243
+ update(false);
244
+ }
245
+
246
+ public void setZIndex(int zIndex) {
247
+ this.zIndex = zIndex;
248
+ if (marker != null) {
249
+ marker.setZIndex(zIndex);
250
+ }
251
+ update(false);
252
+ }
253
+
254
+ public void setOpacity(float opacity) {
255
+ this.opacity = opacity;
256
+ if (marker != null) {
257
+ marker.setAlpha(opacity);
258
+ }
259
+ update(false);
260
+ }
261
+
262
+ public void setMarkerHue(float markerHue) {
263
+ this.markerHue = markerHue;
264
+ update(false);
265
+ }
266
+
267
+ public void setAnchor(double x, double y) {
268
+ anchorIsSet = true;
269
+ anchorX = (float) x;
270
+ anchorY = (float) y;
271
+ if (marker != null) {
272
+ marker.setAnchor(anchorX, anchorY);
273
+ }
274
+ update(false);
275
+ }
276
+
277
+ public void setCalloutAnchor(double x, double y) {
278
+ calloutAnchorIsSet = true;
279
+ calloutAnchorX = (float) x;
280
+ calloutAnchorY = (float) y;
281
+ if (marker != null) {
282
+ marker.setInfoWindowAnchor(calloutAnchorX, calloutAnchorY);
283
+ }
284
+ update(false);
285
+ }
286
+
287
+ public void setTracksViewChanges(boolean tracksViewChanges) {
288
+ this.tracksViewChanges = tracksViewChanges;
289
+ updateTracksViewChanges();
290
+ }
291
+
292
+ private void updateTracksViewChanges() {
293
+ boolean shouldTrack = tracksViewChanges && hasCustomMarkerView && marker != null;
294
+ if (shouldTrack == tracksViewChangesActive) return;
295
+ tracksViewChangesActive = shouldTrack;
296
+
297
+ if (shouldTrack) {
298
+ ViewChangesTracker.getInstance().addMarker(this);
299
+ } else {
300
+ ViewChangesTracker.getInstance().removeMarker(this);
301
+
302
+ // Let it render one more time to avoid race conditions.
303
+ // i.e. Image onLoad ->
304
+ // ViewChangesTracker may not get a chance to render ->
305
+ // setState({ tracksViewChanges: false }) ->
306
+ // image loaded but not rendered.
307
+ updateMarkerIcon();
308
+ }
309
+ }
310
+
311
+ public LatLng getPosition() {
312
+ return position;
313
+ }
314
+
315
+ public boolean updateCustomForTracking() {
316
+ if (!tracksViewChangesActive)
317
+ return false;
318
+
319
+ updateMarkerIcon();
320
+
321
+ return true;
322
+ }
323
+
324
+ public void updateMarkerIcon() {
325
+ if (marker == null) return;
326
+
327
+ marker.setIcon(getIcon());
328
+ }
329
+
330
+ public LatLng interpolate(float fraction, LatLng a, LatLng b) {
331
+ double lat = (b.latitude - a.latitude) * fraction + a.latitude;
332
+ double lng = (b.longitude - a.longitude) * fraction + a.longitude;
333
+ return new LatLng(lat, lng);
334
+ }
335
+
336
+ public void animateToCoodinate(LatLng finalPosition, Integer duration) {
337
+ TypeEvaluator<LatLng> typeEvaluator = new TypeEvaluator<LatLng>() {
338
+ @Override
339
+ public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
340
+ return interpolate(fraction, startValue, endValue);
341
+ }
342
+ };
343
+ Property<Marker, LatLng> property = Property.of(Marker.class, LatLng.class, "position");
344
+ ObjectAnimator animator = ObjectAnimator.ofObject(
345
+ marker,
346
+ property,
347
+ typeEvaluator,
348
+ finalPosition);
349
+ animator.setDuration(duration);
350
+ animator.start();
351
+ }
352
+
353
+ public void setImage(String uri) {
354
+
355
+ boolean shouldLoadImage = true;
356
+
357
+ if (this.markerManager != null) {
358
+ // remove marker from previous shared icon if needed, to avoid future updates from it.
359
+ // remove the shared icon completely if no markers on it as well.
360
+ // this is to avoid memory leak due to orphan bitmaps.
361
+ //
362
+ // However in case where client want to update all markers from icon A to icon B
363
+ // and after some time to update back from icon B to icon A
364
+ // it may be better to keep it though. We assume that is rare.
365
+ if (this.imageUri != null) {
366
+ this.markerManager.getSharedIcon(this.imageUri).removeMarker(this);
367
+ this.markerManager.removeSharedIconIfEmpty(this.imageUri);
128
368
  }
129
- } finally {
130
- dataSource.close();
131
- if (imageReference != null) {
132
- CloseableReference.closeSafely(imageReference);
369
+ if (uri != null) {
370
+ // listening for marker bitmap descriptor update, as well as check whether to load the image.
371
+ MapMarkerManager.AirMapMarkerSharedIcon sharedIcon = this.markerManager.getSharedIcon(uri);
372
+ sharedIcon.addMarker(this);
373
+ shouldLoadImage = sharedIcon.shouldLoadImage();
133
374
  }
134
- }
135
- if (MapMarker.this.markerManager != null && MapMarker.this.imageUri != null) {
136
- MapMarker.this.markerManager.getSharedIcon(MapMarker.this.imageUri)
137
- .updateIcon(iconBitmapDescriptor, iconBitmap);
138
- }
139
- update(true);
140
- loadingImage = false;
141
- if (imageLoadedListener != null){
142
- imageLoadedListener.onImageLoaded(null, null, false);
143
- // fire and forget
144
- imageLoadedListener = null;
145
- }
146
375
  }
147
- };
148
-
149
- public MapMarker(Context context, MapMarkerManager markerManager) {
150
- super(context);
151
- this.context = context;
152
- this.markerManager = markerManager;
153
- logoHolder = DraweeHolder.create(createDraweeHierarchy(), context);
154
- logoHolder.onAttach();
155
- }
156
-
157
- public MapMarker(Context context, MarkerOptions options, MapMarkerManager markerManager) {
158
- super(context);
159
- this.context = context;
160
- this.markerManager = markerManager;
161
- logoHolder = DraweeHolder.create(createDraweeHierarchy(), context);
162
- logoHolder.onAttach();
163
-
164
- position = options.getPosition();
165
- setAnchor(options.getAnchorU(), options.getAnchorV());
166
- setCalloutAnchor(options.getInfoWindowAnchorU(), options.getInfoWindowAnchorV());
167
- setTitle(options.getTitle());
168
- setSnippet(options.getSnippet());
169
- setRotation(options.getRotation());
170
- setFlat(options.isFlat());
171
- setDraggable(options.isDraggable());
172
- setZIndex(Math.round(options.getZIndex()));
173
- setOpacity(options.getAlpha());
174
- iconBitmapDescriptor = options.getIcon();
175
- }
176
-
177
- private GenericDraweeHierarchy createDraweeHierarchy() {
178
- return new GenericDraweeHierarchyBuilder(getResources())
179
- .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
180
- .setFadeDuration(0)
181
- .build();
182
- }
183
-
184
- public void setCoordinate(ReadableMap coordinate) {
185
- setCoordinate(new LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude")));
186
- }
187
- public void setCoordinate(LatLng position){
188
- this.position = position;
189
- if (marker != null) {
190
- marker.setPosition(position);
191
- }
192
- update(false);
193
- }
194
-
195
- public void setIdentifier(String identifier) {
196
- this.identifier = identifier;
197
- update(false);
198
- }
199
-
200
- public String getIdentifier() {
201
- return this.identifier;
202
- }
203
-
204
- public void setTitle(String title) {
205
- this.title = title;
206
- if (marker != null) {
207
- marker.setTitle(title);
208
- }
209
- update(false);
210
- }
211
-
212
- public void setSnippet(String snippet) {
213
- this.snippet = snippet;
214
- if (marker != null) {
215
- marker.setSnippet(snippet);
216
- }
217
- update(false);
218
- }
219
-
220
- public void setRotation(float rotation) {
221
- this.rotation = rotation;
222
- if (marker != null) {
223
- marker.setRotation(rotation);
224
- }
225
- update(false);
226
- }
227
-
228
- public void setFlat(boolean flat) {
229
- this.flat = flat;
230
- if (marker != null) {
231
- marker.setFlat(flat);
232
- }
233
- update(false);
234
- }
235
-
236
- public void setDraggable(boolean draggable) {
237
- this.draggable = draggable;
238
- if (marker != null) {
239
- marker.setDraggable(draggable);
240
- }
241
- update(false);
242
- }
243
-
244
- public void setZIndex(int zIndex) {
245
- this.zIndex = zIndex;
246
- if (marker != null) {
247
- marker.setZIndex(zIndex);
248
- }
249
- update(false);
250
- }
251
-
252
- public void setOpacity(float opacity) {
253
- this.opacity = opacity;
254
- if (marker != null) {
255
- marker.setAlpha(opacity);
256
- }
257
- update(false);
258
- }
259
-
260
- public void setMarkerHue(float markerHue) {
261
- this.markerHue = markerHue;
262
- update(false);
263
- }
264
-
265
- public void setAnchor(double x, double y) {
266
- anchorIsSet = true;
267
- anchorX = (float) x;
268
- anchorY = (float) y;
269
- if (marker != null) {
270
- marker.setAnchor(anchorX, anchorY);
271
- }
272
- update(false);
273
- }
274
-
275
- public void setCalloutAnchor(double x, double y) {
276
- calloutAnchorIsSet = true;
277
- calloutAnchorX = (float) x;
278
- calloutAnchorY = (float) y;
279
- if (marker != null) {
280
- marker.setInfoWindowAnchor(calloutAnchorX, calloutAnchorY);
281
- }
282
- update(false);
283
- }
284
-
285
- public void setTracksViewChanges(boolean tracksViewChanges) {
286
- this.tracksViewChanges = tracksViewChanges;
287
- updateTracksViewChanges();
288
- }
289
-
290
- private void updateTracksViewChanges() {
291
- boolean shouldTrack = tracksViewChanges && hasCustomMarkerView && marker != null;
292
- if (shouldTrack == tracksViewChangesActive) return;
293
- tracksViewChangesActive = shouldTrack;
294
-
295
- if (shouldTrack) {
296
- ViewChangesTracker.getInstance().addMarker(this);
297
- } else {
298
- ViewChangesTracker.getInstance().removeMarker(this);
299
-
300
- // Let it render one more time to avoid race conditions.
301
- // i.e. Image onLoad ->
302
- // ViewChangesTracker may not get a chance to render ->
303
- // setState({ tracksViewChanges: false }) ->
304
- // image loaded but not rendered.
305
- updateMarkerIcon();
306
- }
307
- }
308
-
309
- public LatLng getPosition() {
310
- return position;
311
- }
312
-
313
- public boolean updateCustomForTracking() {
314
- if (!tracksViewChangesActive)
315
- return false;
316
-
317
- updateMarkerIcon();
318
-
319
- return true;
320
- }
321
-
322
- public void updateMarkerIcon() {
323
- if (marker == null) return;
324
-
325
- marker.setIcon(getIcon());
326
- }
327
-
328
- public LatLng interpolate(float fraction, LatLng a, LatLng b) {
329
- double lat = (b.latitude - a.latitude) * fraction + a.latitude;
330
- double lng = (b.longitude - a.longitude) * fraction + a.longitude;
331
- return new LatLng(lat, lng);
332
- }
333
-
334
- public void animateToCoodinate(LatLng finalPosition, Integer duration) {
335
- TypeEvaluator<LatLng> typeEvaluator = new TypeEvaluator<LatLng>() {
336
- @Override
337
- public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
338
- return interpolate(fraction, startValue, endValue);
339
- }
340
- };
341
- Property<Marker, LatLng> property = Property.of(Marker.class, LatLng.class, "position");
342
- ObjectAnimator animator = ObjectAnimator.ofObject(
343
- marker,
344
- property,
345
- typeEvaluator,
346
- finalPosition);
347
- animator.setDuration(duration);
348
- animator.start();
349
- }
350
-
351
- public void setImage(String uri) {
352
-
353
- boolean shouldLoadImage = true;
354
-
355
- if (this.markerManager != null) {
356
- // remove marker from previous shared icon if needed, to avoid future updates from it.
357
- // remove the shared icon completely if no markers on it as well.
358
- // this is to avoid memory leak due to orphan bitmaps.
359
- //
360
- // However in case where client want to update all markers from icon A to icon B
361
- // and after some time to update back from icon B to icon A
362
- // it may be better to keep it though. We assume that is rare.
363
- if (this.imageUri != null) {
364
- this.markerManager.getSharedIcon(this.imageUri).removeMarker(this);
365
- this.markerManager.removeSharedIconIfEmpty(this.imageUri);
366
- }
367
- if (uri != null) {
368
- // listening for marker bitmap descriptor update, as well as check whether to load the image.
369
- MapMarkerManager.AirMapMarkerSharedIcon sharedIcon = this.markerManager.getSharedIcon(uri);
370
- sharedIcon.addMarker(this);
371
- shouldLoadImage = sharedIcon.shouldLoadImage();
372
- }
373
- }
374
-
375
- this.imageUri = uri;
376
- if (!shouldLoadImage) {return;}
377
-
378
- if (uri == null) {
379
- iconBitmapDescriptor = null;
380
- update(true);
381
- } else if (uri.startsWith("http://") || uri.startsWith("https://") ||
382
- uri.startsWith("file://") || uri.startsWith("asset://") || uri.startsWith("data:")) {
383
- ImageRequest imageRequest = ImageRequestBuilder
384
- .newBuilderWithSource(Uri.parse(uri))
385
- .build();
386
-
387
- ImagePipeline imagePipeline = Fresco.getImagePipeline();
388
- dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
389
- DraweeController controller = Fresco.newDraweeControllerBuilder()
390
- .setImageRequest(imageRequest)
391
- .setControllerListener(mLogoControllerListener)
392
- .setOldController(logoHolder.getController())
393
- .build();
394
- logoHolder.setController(controller);
395
- } else {
396
- iconBitmapDescriptor = getBitmapDescriptorByName(uri);
397
- int drawableId = getDrawableResourceByName(uri);
398
- iconBitmap = BitmapFactory.decodeResource(getResources(), drawableId);
399
- if (iconBitmap == null) { // VectorDrawable or similar
400
- Drawable drawable = getResources().getDrawable(drawableId);
401
- iconBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
402
- drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
403
- Canvas canvas = new Canvas(iconBitmap);
404
- drawable.draw(canvas);
405
- }
406
- if (this.markerManager != null) {
407
- this.markerManager.getSharedIcon(uri).updateIcon(iconBitmapDescriptor, iconBitmap);
408
- }
409
- update(true);
410
- }
411
- }
412
-
413
- public void setIconBitmapDescriptor(BitmapDescriptor bitmapDescriptor, Bitmap bitmap) {
414
- this.iconBitmapDescriptor = bitmapDescriptor;
415
- this.iconBitmap = bitmap;
416
- this.update(true);
417
- }
418
-
419
- public void setIconBitmap(Bitmap bitmap) {
420
- this.iconBitmap = bitmap;
421
- }
422
-
423
- public MarkerOptions getMarkerOptions() {
424
- if (markerOptions == null) {
425
- markerOptions = new MarkerOptions();
426
- }
427
-
428
- fillMarkerOptions(markerOptions);
429
- return markerOptions;
430
- }
431
-
432
- @Override
433
- public void addView(View child, int index) {
434
- super.addView(child, index);
435
- // if children are added, it means we are rendering a custom marker
436
- if (!(child instanceof MapCallout)) {
437
- hasCustomMarkerView = true;
438
- updateTracksViewChanges();
439
- }
440
- update(true);
441
- }
442
-
443
- @Override
444
- public void requestLayout() {
445
- super.requestLayout();
446
-
447
- if (getChildCount() == 0) {
448
- if (hasCustomMarkerView) {
449
- hasCustomMarkerView = false;
450
- clearDrawableCache();
376
+
377
+ this.imageUri = uri;
378
+ if (!shouldLoadImage) {
379
+ return;
380
+ }
381
+
382
+ if (uri == null) {
383
+ iconBitmapDescriptor = null;
384
+ update(true);
385
+ } else if (uri.startsWith("http://") || uri.startsWith("https://") ||
386
+ uri.startsWith("file://") || uri.startsWith("asset://") || uri.startsWith("data:")) {
387
+ ImageRequest imageRequest = ImageRequestBuilder
388
+ .newBuilderWithSource(Uri.parse(uri))
389
+ .build();
390
+
391
+ ImagePipeline imagePipeline = Fresco.getImagePipeline();
392
+ dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
393
+ DraweeController controller = Fresco.newDraweeControllerBuilder()
394
+ .setImageRequest(imageRequest)
395
+ .setControllerListener(mLogoControllerListener)
396
+ .setOldController(logoHolder.getController())
397
+ .build();
398
+ logoHolder.setController(controller);
399
+ } else {
400
+ iconBitmapDescriptor = getBitmapDescriptorByName(uri);
401
+ int drawableId = getDrawableResourceByName(uri);
402
+ iconBitmap = BitmapFactory.decodeResource(getResources(), drawableId);
403
+ if (iconBitmap == null) { // VectorDrawable or similar
404
+ Drawable drawable = getResources().getDrawable(drawableId);
405
+ iconBitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
406
+ drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
407
+ Canvas canvas = new Canvas(iconBitmap);
408
+ drawable.draw(canvas);
409
+ }
410
+ if (this.markerManager != null) {
411
+ this.markerManager.getSharedIcon(uri).updateIcon(iconBitmapDescriptor, iconBitmap);
412
+ }
413
+ update(true);
414
+ }
415
+ }
416
+
417
+ public void setIconBitmapDescriptor(BitmapDescriptor bitmapDescriptor, Bitmap bitmap) {
418
+ this.iconBitmapDescriptor = bitmapDescriptor;
419
+ this.iconBitmap = bitmap;
420
+ this.update(true);
421
+ }
422
+
423
+ public void setIconBitmap(Bitmap bitmap) {
424
+ this.iconBitmap = bitmap;
425
+ }
426
+
427
+ public MarkerOptions getMarkerOptions() {
428
+ if (markerOptions == null) {
429
+ markerOptions = new MarkerOptions();
430
+ }
431
+
432
+ fillMarkerOptions(markerOptions);
433
+ return markerOptions;
434
+ }
435
+
436
+ @Override
437
+ public void addView(View child, int index) {
438
+ super.addView(child, index);
439
+ // if children are added, it means we are rendering a custom marker
440
+ if (!(child instanceof MapCallout)) {
441
+ hasCustomMarkerView = true;
442
+ updateTracksViewChanges();
443
+ }
444
+ update(true);
445
+ }
446
+
447
+ @Override
448
+ public void requestLayout() {
449
+ super.requestLayout();
450
+
451
+ if (getChildCount() == 0) {
452
+ if (hasCustomMarkerView) {
453
+ hasCustomMarkerView = false;
454
+ clearDrawableCache();
455
+ updateTracksViewChanges();
456
+ update(true);
457
+ }
458
+ }
459
+ }
460
+
461
+ @Override
462
+ public Object getFeature() {
463
+ return marker;
464
+ }
465
+
466
+ @Override
467
+ public void addToMap(Object collection) {
468
+ MarkerManager.Collection markerCollection = (MarkerManager.Collection) collection;
469
+ marker = markerCollection.addMarker(getMarkerOptions());
451
470
  updateTracksViewChanges();
471
+ }
472
+
473
+ @Override
474
+ public void removeFromMap(Object collection) {
475
+ if (marker == null) {
476
+ return;
477
+ }
478
+ MarkerManager.Collection markerCollection = (MarkerManager.Collection) collection;
479
+ markerCollection.remove(marker);
480
+ marker = null;
481
+ updateTracksViewChanges();
482
+ }
483
+
484
+ private BitmapDescriptor getIcon() {
485
+ if (hasCustomMarkerView) {
486
+ // creating a bitmap from an arbitrary view
487
+ if (iconBitmapDescriptor != null) {
488
+ Bitmap viewBitmap = createDrawable();
489
+ int width = Math.max(iconBitmap.getWidth(), viewBitmap.getWidth());
490
+ int height = Math.max(iconBitmap.getHeight(), viewBitmap.getHeight());
491
+ Bitmap combinedBitmap = Bitmap.createBitmap(width, height, iconBitmap.getConfig());
492
+ Canvas canvas = new Canvas(combinedBitmap);
493
+ canvas.drawBitmap(iconBitmap, 0, 0, null);
494
+ canvas.drawBitmap(viewBitmap, 0, 0, null);
495
+ return BitmapDescriptorFactory.fromBitmap(combinedBitmap);
496
+ } else {
497
+ return BitmapDescriptorFactory.fromBitmap(createDrawable());
498
+ }
499
+ } else if (iconBitmapDescriptor != null) {
500
+ // use local image as a marker
501
+ return iconBitmapDescriptor;
502
+ } else {
503
+ // render the default marker pin
504
+ return BitmapDescriptorFactory.defaultMarker(this.markerHue);
505
+ }
506
+ }
507
+
508
+ private MarkerOptions fillMarkerOptions(MarkerOptions options) {
509
+ options.position(position);
510
+ if (anchorIsSet) options.anchor(anchorX, anchorY);
511
+ if (calloutAnchorIsSet) options.infoWindowAnchor(calloutAnchorX, calloutAnchorY);
512
+ options.title(title);
513
+ options.snippet(snippet);
514
+ options.rotation(rotation);
515
+ options.flat(flat);
516
+ options.draggable(draggable);
517
+ options.zIndex(zIndex);
518
+ options.alpha(opacity);
519
+ options.icon(getIcon());
520
+ return options;
521
+ }
522
+
523
+ public void update(boolean updateIcon) {
524
+ if (marker == null) {
525
+ return;
526
+ }
527
+
528
+ if (updateIcon)
529
+ updateMarkerIcon();
530
+
531
+ if (anchorIsSet) {
532
+ marker.setAnchor(anchorX, anchorY);
533
+ } else {
534
+ marker.setAnchor(0.5f, 1.0f);
535
+ }
536
+
537
+ if (calloutAnchorIsSet) {
538
+ marker.setInfoWindowAnchor(calloutAnchorX, calloutAnchorY);
539
+ } else {
540
+ marker.setInfoWindowAnchor(0.5f, 0);
541
+ }
542
+ }
543
+
544
+ public void update(int width, int height) {
545
+ this.width = width;
546
+ this.height = height;
547
+
452
548
  update(true);
453
- }
454
- }
455
- }
456
-
457
- @Override
458
- public Object getFeature() {
459
- return marker;
460
- }
461
-
462
- @Override
463
- public void addToMap(Object collection) {
464
- MarkerManager.Collection markerCollection = (MarkerManager.Collection) collection;
465
- marker = markerCollection.addMarker(getMarkerOptions());
466
- updateTracksViewChanges();
467
- }
468
-
469
- @Override
470
- public void removeFromMap(Object collection) {
471
- if (marker == null) {
472
- return;
473
- }
474
- MarkerManager.Collection markerCollection = (MarkerManager.Collection) collection;
475
- markerCollection.remove(marker);
476
- marker = null;
477
- updateTracksViewChanges();
478
- }
479
-
480
- private BitmapDescriptor getIcon() {
481
- if (hasCustomMarkerView) {
482
- // creating a bitmap from an arbitrary view
483
- if (iconBitmapDescriptor != null) {
484
- Bitmap viewBitmap = createDrawable();
485
- int width = Math.max(iconBitmap.getWidth(), viewBitmap.getWidth());
486
- int height = Math.max(iconBitmap.getHeight(), viewBitmap.getHeight());
487
- Bitmap combinedBitmap = Bitmap.createBitmap(width, height, iconBitmap.getConfig());
488
- Canvas canvas = new Canvas(combinedBitmap);
489
- canvas.drawBitmap(iconBitmap, 0, 0, null);
490
- canvas.drawBitmap(viewBitmap, 0, 0, null);
491
- return BitmapDescriptorFactory.fromBitmap(combinedBitmap);
492
- } else {
493
- return BitmapDescriptorFactory.fromBitmap(createDrawable());
494
- }
495
- } else if (iconBitmapDescriptor != null) {
496
- // use local image as a marker
497
- return iconBitmapDescriptor;
498
- } else {
499
- // render the default marker pin
500
- return BitmapDescriptorFactory.defaultMarker(this.markerHue);
501
- }
502
- }
503
-
504
- private MarkerOptions fillMarkerOptions(MarkerOptions options) {
505
- options.position(position);
506
- if (anchorIsSet) options.anchor(anchorX, anchorY);
507
- if (calloutAnchorIsSet) options.infoWindowAnchor(calloutAnchorX, calloutAnchorY);
508
- options.title(title);
509
- options.snippet(snippet);
510
- options.rotation(rotation);
511
- options.flat(flat);
512
- options.draggable(draggable);
513
- options.zIndex(zIndex);
514
- options.alpha(opacity);
515
- options.icon(getIcon());
516
- return options;
517
- }
518
-
519
- public void update(boolean updateIcon) {
520
- if (marker == null) {
521
- return;
522
- }
523
-
524
- if (updateIcon)
525
- updateMarkerIcon();
526
-
527
- if (anchorIsSet) {
528
- marker.setAnchor(anchorX, anchorY);
529
- } else {
530
- marker.setAnchor(0.5f, 1.0f);
531
- }
532
-
533
- if (calloutAnchorIsSet) {
534
- marker.setInfoWindowAnchor(calloutAnchorX, calloutAnchorY);
535
- } else {
536
- marker.setInfoWindowAnchor(0.5f, 0);
537
- }
538
- }
539
-
540
- public void update(int width, int height) {
541
- this.width = width;
542
- this.height = height;
543
-
544
- update(true);
545
- }
546
-
547
- private Bitmap mLastBitmapCreated = null;
548
-
549
- private void clearDrawableCache() {
550
- mLastBitmapCreated = null;
551
- }
552
-
553
- private Bitmap createDrawable() {
554
- int width = this.width <= 0 ? 100 : this.width;
555
- int height = this.height <= 0 ? 100 : this.height;
556
- this.buildDrawingCache();
557
-
558
- // Do not create the doublebuffer-bitmap each time. reuse it to save memory.
559
- Bitmap bitmap = mLastBitmapCreated;
560
-
561
- if (bitmap == null ||
562
- bitmap.isRecycled() ||
563
- bitmap.getWidth() != width ||
564
- bitmap.getHeight() != height) {
565
- bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
566
- mLastBitmapCreated = bitmap;
567
- } else {
568
- bitmap.eraseColor(Color.TRANSPARENT);
569
- }
570
-
571
- Canvas canvas = new Canvas(bitmap);
572
- this.draw(canvas);
573
-
574
- return bitmap;
575
- }
576
-
577
- public void setCalloutView(MapCallout view) {
578
- this.calloutView = view;
579
- }
580
-
581
- public MapCallout getCalloutView() {
582
- return this.calloutView;
583
- }
584
-
585
- public View getCallout() {
586
- if (this.calloutView == null) return null;
549
+ }
550
+
551
+ private Bitmap mLastBitmapCreated = null;
587
552
 
588
- if (this.wrappedCalloutView == null) {
589
- this.wrapCalloutView();
553
+ private void clearDrawableCache() {
554
+ mLastBitmapCreated = null;
590
555
  }
591
556
 
592
- if (this.calloutView.getTooltip()) {
593
- return this.wrappedCalloutView;
594
- } else {
595
- return null;
557
+ private Bitmap createDrawable() {
558
+ int width = this.width <= 0 ? 100 : this.width;
559
+ int height = this.height <= 0 ? 100 : this.height;
560
+ this.buildDrawingCache();
561
+
562
+ // Do not create the doublebuffer-bitmap each time. reuse it to save memory.
563
+ Bitmap bitmap = mLastBitmapCreated;
564
+
565
+ if (bitmap == null ||
566
+ bitmap.isRecycled() ||
567
+ bitmap.getWidth() != width ||
568
+ bitmap.getHeight() != height) {
569
+ bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
570
+ mLastBitmapCreated = bitmap;
571
+ } else {
572
+ bitmap.eraseColor(Color.TRANSPARENT);
573
+ }
574
+
575
+ Canvas canvas = new Canvas(bitmap);
576
+ this.draw(canvas);
577
+
578
+ return bitmap;
596
579
  }
597
- }
598
580
 
599
- public View getInfoContents() {
600
- if (this.calloutView == null) return null;
581
+ public void setCalloutView(MapCallout view) {
582
+ this.calloutView = view;
583
+ }
601
584
 
602
- if (this.wrappedCalloutView == null) {
603
- this.wrapCalloutView();
585
+ public MapCallout getCalloutView() {
586
+ return this.calloutView;
604
587
  }
605
588
 
606
- if (this.calloutView.getTooltip()) {
607
- return null;
608
- } else {
609
- return this.wrappedCalloutView;
589
+ public View getCallout() {
590
+ if (this.calloutView == null) return null;
591
+
592
+ if (this.wrappedCalloutView == null) {
593
+ this.wrapCalloutView();
594
+ }
595
+
596
+ if (this.calloutView.getTooltip()) {
597
+ return this.wrappedCalloutView;
598
+ } else {
599
+ return null;
600
+ }
610
601
  }
611
- }
612
602
 
613
- private void wrapCalloutView() {
614
- // some hackery is needed to get the arbitrary infowindow view to render centered, and
615
- // with only the width/height that it needs.
616
- if (this.calloutView == null || this.calloutView.getChildCount() == 0) {
617
- return;
603
+ public View getInfoContents() {
604
+ if (this.calloutView == null) return null;
605
+
606
+ if (this.wrappedCalloutView == null) {
607
+ this.wrapCalloutView();
608
+ }
609
+
610
+ if (this.calloutView.getTooltip()) {
611
+ return null;
612
+ } else {
613
+ return this.wrappedCalloutView;
614
+ }
618
615
  }
619
616
 
620
- LinearLayout LL = new LinearLayout(context);
621
- LL.setOrientation(LinearLayout.VERTICAL);
622
- LL.setLayoutParams(new LinearLayout.LayoutParams(
623
- this.calloutView.width,
624
- this.calloutView.height,
625
- 0f
626
- ));
617
+ private void wrapCalloutView() {
618
+ // some hackery is needed to get the arbitrary infowindow view to render centered, and
619
+ // with only the width/height that it needs.
620
+ if (this.calloutView == null || this.calloutView.getChildCount() == 0) {
621
+ return;
622
+ }
627
623
 
624
+ LinearLayout LL = new LinearLayout(context);
625
+ LL.setOrientation(LinearLayout.VERTICAL);
626
+ LL.setLayoutParams(new LinearLayout.LayoutParams(
627
+ this.calloutView.width,
628
+ this.calloutView.height,
629
+ 0f
630
+ ));
628
631
 
629
- LinearLayout LL2 = new LinearLayout(context);
630
- LL2.setOrientation(LinearLayout.HORIZONTAL);
631
- LL2.setLayoutParams(new LinearLayout.LayoutParams(
632
- this.calloutView.width,
633
- this.calloutView.height,
634
- 0f
635
- ));
636
632
 
637
- LL.addView(LL2);
638
- LL2.addView(this.calloutView);
633
+ LinearLayout LL2 = new LinearLayout(context);
634
+ LL2.setOrientation(LinearLayout.HORIZONTAL);
635
+ LL2.setLayoutParams(new LinearLayout.LayoutParams(
636
+ this.calloutView.width,
637
+ this.calloutView.height,
638
+ 0f
639
+ ));
639
640
 
640
- this.wrappedCalloutView = LL;
641
- }
641
+ LL.addView(LL2);
642
+ LL2.addView(this.calloutView);
642
643
 
643
- private int getDrawableResourceByName(String name) {
644
- return getResources().getIdentifier(
645
- name,
646
- "drawable",
647
- getContext().getPackageName());
648
- }
644
+ this.wrappedCalloutView = LL;
645
+ }
646
+
647
+ private int getDrawableResourceByName(String name) {
648
+ return getResources().getIdentifier(
649
+ name,
650
+ "drawable",
651
+ getContext().getPackageName());
652
+ }
649
653
 
650
654
  public boolean isLoadingImage() {
651
655
  return loadingImage;
@@ -660,42 +664,43 @@ public class MapMarker extends MapFeature {
660
664
  }
661
665
 
662
666
  @FunctionalInterface
663
- public interface EventCreator<T extends Event> {
664
- T create(int surfaceId, int viewId, WritableMap payload);
665
- }
666
- public <T extends Event> void dispatchEvent(WritableMap payload, MapView.EventCreator<T> creator) {
667
- // Cast context to ReactContext
668
- ReactContext reactContext = (ReactContext) context;
669
-
670
- // Get the event dispatcher
671
- EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, getId());
672
-
673
- // If there is a dispatcher, create and dispatch the event
674
- if (eventDispatcher != null) {
675
- int surfaceId = UIManagerHelper.getSurfaceId(reactContext);
676
- T event = creator.create(surfaceId, getId(), payload);
677
- eventDispatcher.dispatchEvent(event);
678
- }
679
- }
680
-
681
- private BitmapDescriptor getBitmapDescriptorByName(String name) {
682
- return BitmapDescriptorFactory.fromResource(getDrawableResourceByName(name));
683
- }
684
-
685
- public static Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
686
- MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
687
- builder.put(OnSelectEvent.EVENT_NAME, MapBuilder.of("registrationName", OnSelectEvent.EVENT_NAME));
688
- builder.put(OnDeselectEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDeselectEvent.EVENT_NAME));
689
- builder.put(OnPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPressEvent.EVENT_NAME));
690
- return builder.build();
691
- }
692
-
693
- public static Map<String, Object> getExportedCustomDirectEventTypeConstants() {
694
- return MapBuilder.of(
695
- OnDragEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDragEvent.EVENT_NAME),
696
- OnDragStartEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDragStartEvent.EVENT_NAME),
697
- OnDragEndEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDragEndEvent.EVENT_NAME)
698
- );
699
- }
667
+ public interface EventCreator<T extends Event> {
668
+ T create(int surfaceId, int viewId, WritableMap payload);
669
+ }
670
+
671
+ public <T extends Event> void dispatchEvent(WritableMap payload, MapView.EventCreator<T> creator) {
672
+ // Cast context to ReactContext
673
+ ReactContext reactContext = (ReactContext) context;
674
+
675
+ // Get the event dispatcher
676
+ EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, getId());
677
+
678
+ // If there is a dispatcher, create and dispatch the event
679
+ if (eventDispatcher != null) {
680
+ int surfaceId = UIManagerHelper.getSurfaceId(reactContext);
681
+ T event = creator.create(surfaceId, getId(), payload);
682
+ eventDispatcher.dispatchEvent(event);
683
+ }
684
+ }
685
+
686
+ private BitmapDescriptor getBitmapDescriptorByName(String name) {
687
+ return BitmapDescriptorFactory.fromResource(getDrawableResourceByName(name));
688
+ }
689
+
690
+ public static Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
691
+ MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
692
+ builder.put(OnPressEvent.EVENT_NAME, MapBuilder.of("registrationName", OnPressEvent.EVENT_NAME));
693
+ return builder.build();
694
+ }
695
+
696
+ public static Map<String, Object> getExportedCustomDirectEventTypeConstants() {
697
+ return MapBuilder.of(
698
+ OnSelectEvent.EVENT_NAME, MapBuilder.of("registrationName", OnSelectEvent.EVENT_NAME),
699
+ OnDeselectEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDeselectEvent.EVENT_NAME),
700
+ OnDragEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDragEvent.EVENT_NAME),
701
+ OnDragStartEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDragStartEvent.EVENT_NAME),
702
+ OnDragEndEvent.EVENT_NAME, MapBuilder.of("registrationName", OnDragEndEvent.EVENT_NAME)
703
+ );
704
+ }
700
705
 
701
706
  }