Skip to content

Commit 2051b60

Browse files
authored
UPDATE react-native-hms-map 5.2.0-302 (#99)
* UPDATE react-native-hms-map 5.2.0-302
1 parent 6d3aee8 commit 2051b60

23 files changed

Lines changed: 868 additions & 501 deletions

react-native-hms-map/README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<p align="center">
77
<a href="https://www.npmjs.com/package/@hmscore/react-native-hms-map"><img src="https://img.shields.io/npm/dm/@hmscore/react-native-hms-map?color=%23007EC6&style=for-the-badge" alt="downloads"></a>
88
<a href="https://www.npmjs.com/package/@hmscore/react-native-hms-map"><img src="https://img.shields.io/npm/v/@hmscore/react-native-hms-map?color=%23ed2a1c&style=for-the-badge" alt="NPM version"></a>
9-
<a href="/LICENCE"><img src="https://img.shields.io/npm/l/@hmscore/react-native-hms-map.svg?color=%3bcc62&style=for-the-badge" alt="License"></a>
9+
<a href="./LICENCE"><img src="https://img.shields.io/npm/l/@hmscore/react-native-hms-map.svg?color=%3bcc62&style=for-the-badge" alt="License"></a>
1010
</p>
1111

1212
----
@@ -15,7 +15,7 @@ Map Kit is an SDK for map development. It covers map data of more than 200 count
1515

1616
This module enables communication between Huawei Map SDK and React Native platform. It exposes all functionality provided by Huawei Map SDK.
1717

18-
[> Learn More](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/introduction-0000001050143001)
18+
[> Learn More](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/introduction-0000001050143001?ha_source=hms1)
1919

2020
## Installation
2121

@@ -25,20 +25,22 @@ $ npm i @hmscore/react-native-hms-map
2525

2626
## Documentation
2727

28-
- [Quick Start](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/preparedevenv-0000001050032222)
29-
- [Reference](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-References/overview-0000001062710399)
28+
- [Quick Start](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/preparedevenv-0000001050032222?ha_source=hms1)
29+
- [Reference](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-References/overview-0000001062710399?ha_source=hms1)
30+
31+
## Additional Topics
32+
- [Interacting with a Map](https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides/interactmap-0000001050032236?ha_source=hms1)
3033

3134
## Questions or Issues
3235

3336
If you have questions about how to use HMS samples, try the following options:
34-
- [Stack Overflow](https://stackoverflow.com/questions/tagged/huawei-mobile-services) is the best place for any programming questions. Be sure to tag your question with
35-
**huawei-mobile-services**.
37+
- [Stack Overflow](https://stackoverflow.com/questions/tagged/huawei-mobile-services) is the best place for any programming questions. Be sure to tag your question with **huawei-mobile-services**.
3638
- [Github](https://github.com/HMS-Core/hms-react-native-plugin) is the official repository for these plugins, You can open an issue or submit your ideas.
37-
- [Huawei Developer Forum](https://forums.developer.huawei.com/forumPortal/en/home?fid=0101187876626530001) HMS Core Module is great for general questions, or seeking recommendations and opinions.
38-
- [Huawei Developer Docs](https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin) is place to official documentation for all HMS Core Kits, you can find detailed documentations in there.
39+
- [Huawei Developer Forum](https://forums.developer.huawei.com/forumPortal/en/home?fid=0101187876626530001&ha_source=hms1) HMS Core Module is great for general questions, or seeking recommendations and opinions.
40+
- [Huawei Developer Docs](https://developer.huawei.com/consumer/en/doc/overview/HMS-Core-Plugin?ha_source=hms1) is place to official documentation for all HMS Core Kits, you can find detailed documentations in there.
3941

4042
If you run into a bug in our samples, please submit an issue to the [GitHub repository](https://github.com/HMS-Core/hms-react-native-plugin).
4143

4244
## License
4345

44-
Huawei React-Native Plugin is licensed under [Apache 2.0 license](LICENCE)
46+
Huawei React-Native Plugin is licensed under [Apache 2.0 license](LICENCE)

react-native-hms-map/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ repositories {
4949
dependencies {
5050
//noinspection GradleDynamicVersion
5151
implementation 'com.facebook.react:react-native:+' // From node_modules
52-
implementation 'com.huawei.hms:maps:5.1.0.300' // Add your sdk
52+
implementation 'com.huawei.hms:maps:5.2.0.302' // Add your sdk
5353
}

react-native-hms-map/android/src/main/java/com/huawei/hms/rn/map/HMSGroundOverlayView.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,35 @@
3535
import com.huawei.hms.maps.model.LatLngBounds;
3636
import com.huawei.hms.rn.map.logger.HMSLogger;
3737
import com.huawei.hms.rn.map.utils.ReactUtils;
38+
import com.huawei.hms.rn.map.utils.UriIconController;
39+
import com.huawei.hms.rn.map.utils.UriIconView;
3840

3941
import static com.huawei.hms.rn.map.HMSMapView.MapLayerView;
4042
import static com.huawei.hms.rn.map.HMSMapView.MapLayerViewManager;
4143

42-
public class HMSGroundOverlayView extends MapLayerView {
44+
public class HMSGroundOverlayView extends MapLayerView implements UriIconView {
4345
private static final String TAG = HMSGroundOverlayView.class.getSimpleName();
4446
private static final String REACT_CLASS = HMSGroundOverlayView.class.getSimpleName();
4547
private GroundOverlayOptions mGroundOverlayOptions = new GroundOverlayOptions();
4648
private GroundOverlay mGroundOverlay;
4749
private boolean mOptionPositionSet = false;
50+
private final UriIconController uriIconController;
4851

4952
public HMSGroundOverlayView(Context context) {
5053
super(context);
54+
uriIconController = new UriIconController(context, this);
55+
}
56+
57+
@Override
58+
public void setUriIcon(BitmapDescriptor bitmapDescriptor, ReadableMap options) {
59+
mGroundOverlayOptions.image(bitmapDescriptor);
60+
if (mGroundOverlay != null) {
61+
mGroundOverlay.setImage(bitmapDescriptor);
62+
}
5163
}
5264

5365
public static class Manager extends MapLayerViewManager<HMSGroundOverlayView> {
54-
private HMSLogger logger;
66+
private final HMSLogger logger;
5567

5668
public Manager(Context context) {
5769
super();
@@ -141,9 +153,9 @@ public void setClickable(boolean clickable) {
141153

142154
private void setImage(ReadableMap image) {
143155
BitmapDescriptor bitmapDescriptor = ReactUtils.getBitmapDescriptorFromReadableMap(image);
144-
mGroundOverlayOptions.image(bitmapDescriptor);
145-
if (mGroundOverlay != null) {
146-
mGroundOverlay.setImage(bitmapDescriptor);
156+
setUriIcon(bitmapDescriptor, null);
157+
if(image.hasKey("uri")){
158+
uriIconController.setUriIcon(image);
147159
}
148160
}
149161

react-native-hms-map/android/src/main/java/com/huawei/hms/rn/map/HMSMapView.java

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import android.util.Log;
3333
import android.view.View;
3434

35+
import com.facebook.react.bridge.Dynamic;
3536
import com.facebook.react.bridge.LifecycleEventListener;
3637
import com.facebook.react.bridge.Promise;
3738
import com.facebook.react.bridge.ReactApplicationContext;
@@ -57,6 +58,7 @@
5758
import com.huawei.hms.maps.OnMapReadyCallback;
5859
import com.huawei.hms.maps.UiSettings;
5960
import com.huawei.hms.maps.common.util.DistanceCalculator;
61+
import com.huawei.hms.maps.model.BitmapDescriptor;
6062
import com.huawei.hms.maps.model.CameraPosition;
6163
import com.huawei.hms.maps.model.Circle;
6264
import com.huawei.hms.maps.model.GroundOverlay;
@@ -70,14 +72,16 @@
7072
import com.huawei.hms.maps.model.TileOverlay;
7173
import com.huawei.hms.rn.map.logger.HMSLogger;
7274
import com.huawei.hms.rn.map.utils.ReactUtils;
75+
import com.huawei.hms.rn.map.utils.UriIconController;
76+
import com.huawei.hms.rn.map.utils.UriIconView;
7377

7478
import java.io.ByteArrayOutputStream;
7579
import java.util.ArrayList;
7680
import java.util.HashMap;
7781
import java.util.List;
7882
import java.util.Map;
7983

80-
public class HMSMapView extends MapView implements OnMapReadyCallback, LifecycleEventListener,
84+
public class HMSMapView extends MapView implements UriIconView, OnMapReadyCallback, LifecycleEventListener,
8185
HuaweiMap.CancelableCallback, HuaweiMap.OnMapLoadedCallback, HuaweiMap.SnapshotReadyCallback,
8286
HuaweiMap.InfoWindowAdapter, HuaweiMap.OnCameraIdleListener,
8387
HuaweiMap.OnCameraMoveCanceledListener, HuaweiMap.OnCameraMoveListener, HuaweiMap.OnCameraMoveStartedListener,
@@ -125,12 +129,14 @@ public class HMSMapView extends MapView implements OnMapReadyCallback, Lifecycle
125129
private boolean initialCompassEnabled;
126130
private boolean initialZoomControlsEnabled;
127131
private Point centerCoordinates = new Point();
132+
private UriIconController uriIconController;
128133

129134
private final HMSLogger logger;
130135

131136
public HMSMapView(final Context context, HuaweiMapOptions huaweiMapOptions) {
132137
super(context, huaweiMapOptions);
133138
logger = HMSLogger.getInstance(context);
139+
uriIconController = new UriIconController(context, this);
134140
if (context instanceof ReactContext) {
135141
mReactContext = (ReactContext) context;
136142
}
@@ -780,6 +786,34 @@ private void setTrafficEnabled(boolean trafficEnabled) {
780786
}
781787
}
782788

789+
private void setMarkerClusterColor(int color){
790+
if(mUiSettings != null){
791+
mUiSettings.setMarkerClusterColor(color);
792+
}
793+
}
794+
795+
private void setMarkerClusterTextColor(int color){
796+
if(mUiSettings != null){
797+
mUiSettings.setMarkerClusterTextColor(color);
798+
}
799+
}
800+
801+
private void setMarkerClusterIcon(ReadableMap icon){
802+
if(icon.hasKey("uri")){
803+
uriIconController.setUriIcon(icon);
804+
return;
805+
}
806+
if(mUiSettings != null){
807+
BitmapDescriptor bitmapDescriptor = ReactUtils.getBitmapDescriptorFromReadableMap(icon);
808+
setUriIcon(bitmapDescriptor, null);
809+
}
810+
}
811+
812+
@Override
813+
public void setUriIcon(BitmapDescriptor bitmapDescriptor, ReadableMap options) {
814+
mUiSettings.setMarkerClusterIcon(bitmapDescriptor);
815+
}
816+
783817
public interface MapLayer {
784818
/**
785819
* Adds a layer on the map
@@ -1029,6 +1063,30 @@ public void receiveCommand(@NonNull HMSMapView root, int commandId, @Nullable Re
10291063
}
10301064
}
10311065

1066+
@ReactProp(name="markerClusterColor")
1067+
public void setMarkerClusterColor(HMSMapView view, Dynamic color){
1068+
if (color.getType() == ReadableType.Array) {
1069+
view.setMarkerClusterColor(ReactUtils.getColorFromRgbaArray(color.asArray()));
1070+
} else if (color.getType() == ReadableType.Number) {
1071+
view.setMarkerClusterColor(color.asInt());
1072+
}
1073+
}
1074+
1075+
@ReactProp(name="markerClusterTextColor")
1076+
public void setMarkerClusterTextColor(HMSMapView view, Dynamic color){
1077+
if (color.getType() == ReadableType.Array) {
1078+
view.setMarkerClusterTextColor(ReactUtils.getColorFromRgbaArray(color.asArray()));
1079+
} else if (color.getType() == ReadableType.Number) {
1080+
view.setMarkerClusterTextColor(color.asInt());
1081+
}
1082+
}
1083+
1084+
@ReactProp(name="markerClusterIcon")
1085+
public void setMarkerClusterIcon(HMSMapView view, ReadableMap icon){
1086+
view.setMarkerClusterIcon(icon);
1087+
}
1088+
1089+
10321090
@ReactProp(name = "pointToCenter")
10331091
public void setPointToCenter(HMSMapView view, ReadableMap pointToCenter) {
10341092
logger.startMethodExecutionTimer("HMSMap.pointToCenter");

0 commit comments

Comments
 (0)