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