Skip to content

Commit e7c1617

Browse files
authored
feat: MapView的mapType属性,Polygon和Marker添加zIndex属性, (#28)
1 parent 1eeb021 commit e7c1617

File tree

8 files changed

+30
-67
lines changed

8 files changed

+30
-67
lines changed

harmony/maps/src/main/cpp/MapsJSIBinder.h

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace rnoh {
8686
object.setProperty(rt, "image", "string");
8787
object.setProperty(rt, "calloutAnchor", "Point");
8888
object.setProperty(rt, "anchor", "Point");
89+
object.setProperty(rt, "zIndex", "int");
8990
object.setProperty(rt, "tappable", "bool");
9091
object.setProperty(rt, "opacity", "float");
9192
return object;
@@ -110,6 +111,7 @@ namespace rnoh {
110111
object.setProperty(rt, "strokeWidth", "int");
111112
object.setProperty(rt, "lineDashPattern", "array");
112113
object.setProperty(rt, "geodesic", "bool");
114+
object.setProperty(rt, "zIndex", "int");
113115
object.setProperty(rt, "tappable", "bool");
114116
object.setProperty(rt, "lineJoin", "string");
115117
object.setProperty(rt, "lineCap", "string");

harmony/maps/src/main/cpp/MapsNapiBinder.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ return ArkJS(env)
8383
.addProperty("image", props->image)
8484
.addProperty("calloutAnchor", props->calloutAnchor)
8585
.addProperty("anchor", props->anchor)
86+
.addProperty("zIndex", props->zIndex)
8687
.addProperty("tappable", props->tappable)
8788
.addProperty("opacity", props->opacity)
8889
.build();
@@ -105,6 +106,7 @@ return ArkJS(env)
105106
.addProperty("strokeWidth", props->strokeWidth)
106107
.addProperty("lineDashPattern", props->lineDashPattern)
107108
.addProperty("geodesic", props->geodesic)
109+
.addProperty("zIndex", props->zIndex)
108110
.addProperty("tappable", props->tappable)
109111
.addProperty("lineJoin", props->lineJoin)
110112
.addProperty("lineCap", props->lineCap)
@@ -128,7 +130,7 @@ return ArkJS(env)
128130
.addProperty("geodesic", props->geodesic)
129131
.addProperty("lineDashPattern", props->lineDashPattern)
130132
.addProperty("holes", props->holes)
131-
.addProperty("zIndex", props->zIndexa)
133+
.addProperty("zIndex", props->zIndex)
132134
.addProperty("tappable", props->tappable)
133135
.addProperty("lineJoin", props->lineJoin)
134136
.addProperty("lineCap", props->lineCap)
@@ -149,7 +151,7 @@ return ArkJS(env)
149151
.addProperty("radius", props->radius)
150152
.addProperty("fillColor", props->fillColor)
151153
.addProperty("strokeColor", props->strokeColor)
152-
.addProperty("zIndex", props->zIndexa)
154+
.addProperty("zIndex", props->zIndex)
153155
.addProperty("strokeWidth", props->strokeWidth)
154156
.addProperty("lineDashPattern", props->lineDashPattern)
155157
.build();
@@ -203,7 +205,7 @@ return ArkJS(env)
203205
.addProperty("lineCap", props->lineCap)
204206
.addProperty("lineJoin", props->lineJoin)
205207
.addProperty("miterLimit", props->miterLimit)
206-
.addProperty("zIndex", props->zIndexa)
208+
.addProperty("zIndex", props->zIndex)
207209
.addProperty("markerComponent", props->markerComponent)
208210
.addProperty("title", props->title)
209211
.addProperty("tracksViewChanges", props->tracksViewChanges)
@@ -224,7 +226,7 @@ return ArkJS(env)
224226
.addProperty("minimumZ", props->minimumZ)
225227
.addProperty("maximumZ", props->maximumZ)
226228
.addProperty("maximumNativeZ", props->maximumNativeZ)
227-
.addProperty("zIndex", props->zIndexa)
229+
.addProperty("zIndex", props->zIndex)
228230
.addProperty("tileSize", props->tileSize)
229231
.addProperty("doubleTileSize", props->doubleTileSize)
230232
.addProperty("shouldReplaceMapContent", props->shouldReplaceMapContent)
@@ -250,7 +252,7 @@ return ArkJS(env)
250252
.addProperty("minimumZ", props->minimumZ)
251253
.addProperty("maximumZ", props->maximumZ)
252254
.addProperty("maximumNativeZ", props->maximumNativeZ)
253-
.addProperty("zIndex", props->zIndexa)
255+
.addProperty("zIndex", props->zIndex)
254256
.addProperty("tileSize", props->tileSize)
255257
.addProperty("doubleTileSize", props->doubleTileSize)
256258
.addProperty("shouldReplaceMapContent", props->shouldReplaceMapContent)

harmony/maps/src/main/cpp/Props.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ namespace react {
8282
calloutAnchor(convertRawProp(context, rawProps, "calloutAnchor", sourceProps.calloutAnchor, {})),
8383
anchor(convertRawProp(context, rawProps, "anchor", sourceProps.anchor, {})),
8484
tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {true})),
85+
zIndex(convertRawProp(context, rawProps, "zIndex", sourceProps.zIndex, {0})),
8586
opacity(convertRawProp(context, rawProps, "opacity", sourceProps.opacity, {})) {}
8687

8788
AIRMapPolylineProps::AIRMapPolylineProps(const PropsParserContext &context, const AIRMapPolylineProps &sourceProps,
@@ -93,6 +94,7 @@ namespace react {
9394
strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {1})),
9495
lineDashPattern(convertRawProp(context, rawProps, "lineDashPattern", sourceProps.lineDashPattern, {})),
9596
geodesic(convertRawProp(context, rawProps, "geodesic", sourceProps.geodesic, {})),
97+
zIndex(convertRawProp(context, rawProps, "zIndex", sourceProps.zIndex, {0})),
9698
tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false})),
9799
lineJoin(convertRawProp(context, rawProps, "lineJoin", sourceProps.lineJoin, {"round"})),
98100
lineCap(convertRawProp(context, rawProps, "lineCap", sourceProps.lineCap, {"round"})) {}
@@ -107,7 +109,7 @@ namespace react {
107109
geodesic(convertRawProp(context, rawProps, "geodesic", sourceProps.geodesic, {})),
108110
lineDashPattern(convertRawProp(context, rawProps, "lineDashPattern", sourceProps.lineDashPattern, {})),
109111
holes(convertRawProp(context, rawProps, "holes", sourceProps.holes, {})),
110-
zIndexa(convertRawProp(context, rawProps, "zIndexa", sourceProps.zIndexa, {0})),
112+
zIndex(convertRawProp(context, rawProps, "zIndex", sourceProps.zIndex, {0})),
111113
tappable(convertRawProp(context, rawProps, "tappable", sourceProps.tappable, {false})),
112114
lineJoin(convertRawProp(context, rawProps, "lineJoin", sourceProps.lineJoin, {"round"})),
113115
lineCap(convertRawProp(context, rawProps, "lineCap", sourceProps.lineCap, {"round"})) {}
@@ -119,7 +121,7 @@ namespace react {
119121
radius(convertRawProp(context, rawProps, "radius", sourceProps.radius, {})),
120122
fillColor(convertRawProp(context, rawProps, "fillColor", sourceProps.fillColor, {SharedColor(0xFF000000)})),
121123
strokeColor(convertRawProp(context, rawProps, "strokeColor", sourceProps.strokeColor, {SharedColor(0xFF000000)})),
122-
zIndexa(convertRawProp(context, rawProps, "zIndexa", sourceProps.zIndexa, {})),
124+
zIndex(convertRawProp(context, rawProps, "zIndex", sourceProps.zIndex, {})),
123125
strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {1})),
124126
lineDashPattern(convertRawProp(context, rawProps, "lineDashPattern", sourceProps.lineDashPattern, {})) {}
125127

@@ -146,7 +148,7 @@ namespace react {
146148
lineCap(convertRawProp(context, rawProps, "lineCap", sourceProps.lineCap, {})),
147149
lineJoin(convertRawProp(context, rawProps, "lineJoin", sourceProps.lineJoin, {})),
148150
miterLimit(convertRawProp(context, rawProps, "miterLimit", sourceProps.miterLimit, {})),
149-
zIndexa(convertRawProp(context, rawProps, "zIndexa", sourceProps.zIndexa, {})),
151+
zIndex(convertRawProp(context, rawProps, "zIndex", sourceProps.zIndex, {})),
150152
markerComponent(convertRawProp(context, rawProps, "markerComponent", sourceProps.markerComponent, {})),
151153
title(convertRawProp(context, rawProps, "title", sourceProps.title, {})),
152154
tracksViewChanges(convertRawProp(context, rawProps, "tracksViewChanges", sourceProps.tracksViewChanges, {false})) {}
@@ -158,7 +160,7 @@ namespace react {
158160
minimumZ(convertRawProp(context, rawProps, "minimumZ", sourceProps.minimumZ, {})),
159161
maximumZ(convertRawProp(context, rawProps, "maximumZ", sourceProps.maximumZ, {})),
160162
maximumNativeZ(convertRawProp(context, rawProps, "maximumNativeZ", sourceProps.maximumNativeZ, {})),
161-
zIndexa(convertRawProp(context, rawProps, "zIndexa", sourceProps.zIndexa, {})),
163+
zIndex(convertRawProp(context, rawProps, "zIndex", sourceProps.zIndex, {})),
162164
tileSize(convertRawProp(context, rawProps, "tileSize", sourceProps.tileSize, {})),
163165
doubleTileSize(convertRawProp(context, rawProps, "doubleTileSize", sourceProps.doubleTileSize, {})),
164166
shouldReplaceMapContent(
@@ -176,7 +178,7 @@ namespace react {
176178
minimumZ(convertRawProp(context, rawProps, "minimumZ", sourceProps.minimumZ, {})),
177179
maximumZ(convertRawProp(context, rawProps, "maximumZ", sourceProps.maximumZ, {})),
178180
maximumNativeZ(convertRawProp(context, rawProps, "maximumNativeZ", sourceProps.maximumNativeZ, {})),
179-
zIndexa(convertRawProp(context, rawProps, "zIndexa", sourceProps.zIndexa, {})),
181+
zIndex(convertRawProp(context, rawProps, "zIndex", sourceProps.zIndex, {})),
180182
tileSize(convertRawProp(context, rawProps, "tileSize", sourceProps.tileSize, {})),
181183
doubleTileSize(convertRawProp(context, rawProps, "doubleTileSize", sourceProps.doubleTileSize, {})),
182184
shouldReplaceMapContent(

harmony/maps/src/main/cpp/Props.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ namespace react {
9797
std::string image{};
9898
folly::dynamic calloutAnchor{};
9999
folly::dynamic anchor{};
100+
int zIndex{};
100101
bool tappable{};
101102
float opacity{};
102103
};
@@ -113,6 +114,7 @@ namespace react {
113114
folly::dynamic strokeColors{};
114115
int strokeWidth{};
115116
folly::dynamic lineDashPattern{};
117+
int zIndex{};
116118
bool geodesic{};
117119
bool tappable{};
118120
std::string lineJoin{};
@@ -133,7 +135,7 @@ namespace react {
133135
bool geodesic{};
134136
folly::dynamic lineDashPattern{};
135137
folly::dynamic holes{};
136-
int zIndexa{};
138+
int zIndex{};
137139
bool tappable{};
138140
std::string lineJoin{};
139141
std::string lineCap{};
@@ -150,7 +152,7 @@ namespace react {
150152
int radius{};
151153
std::string fillColor{};
152154
std::string strokeColor{};
153-
int zIndexa{};
155+
int zIndex{};
154156
int strokeWidth{};
155157
folly::dynamic lineDashPattern{};
156158
};
@@ -191,7 +193,7 @@ namespace react {
191193
std::string lineCap{};
192194
std::string lineJoin{};
193195
int miterLimit{};
194-
int zIndexa{};
196+
int zIndex{};
195197
folly::dynamic markerComponent{};
196198
std::string title{};
197199
bool tracksViewChanges{};
@@ -208,7 +210,7 @@ namespace react {
208210
int minimumZ{};
209211
int maximumZ{};
210212
int maximumNativeZ{};
211-
int zIndexa{};
213+
int zIndex{};
212214
int tileSize{};
213215
bool doubleTileSize{};
214216
bool shouldReplaceMapContent{};
@@ -230,7 +232,7 @@ namespace react {
230232
int minimumZ{};
231233
int maximumZ{};
232234
int maximumNativeZ{};
233-
int zIndexa{};
235+
int zIndex{};
234236
int tileSize{};
235237
bool doubleTileSize{};
236238
bool shouldReplaceMapContent{};

harmony/maps/src/main/ets/AIRGoogleMaps/AIRGoogleMap.ets

-44
This file was deleted.

harmony/maps/src/main/ets/AIRMaps/AIRMapMarker.ets

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
* SOFTWARE.
2121
*/
2222

23+
import { map } from '@kit.MapKit';
2324
import { RNViewBase, ComponentBuilderContext, Tag, RNComponentContext } from '@rnoh/react-native-openharmony';
2425
import { MapsManager } from '../MapsManager';
25-
import { mapCommon, map } from '@kit.MapKit';
2626
import { AIRMapMarkerDescriptor } from './AIRMapDescriptorTypes';
2727
import { LWLog } from '../LWLog';
2828

29-
export const AIR_MAP_MARKER_TYPE: string = "AIRMapMarker"
29+
export const AIR_MAP_MARKER_TYPE: string = 'AIRMapMarker';
3030

3131
@Component
3232
export struct AIRMapMarker {
@@ -46,16 +46,16 @@ export struct AIRMapMarker {
4646
LWLog('AIRMapMarker.subscribeToDescriptorChanges=' + JSON.stringify(newDescriptor));
4747
this.marker?.setPosition({latitude: this.descriptor.rawProps.coordinate.latitude, longitude: this.descriptor.rawProps.coordinate.longitude})
4848
this.marker?.setRotation(this.descriptor.rawProps.rotation);
49-
this.marker?.setZIndex(this.descriptor.rawProps.zIndex);
5049
this.marker?.setAlpha(this.descriptor.rawProps.opacity ?? 1.0);
51-
this.marker?.setMarkerAnchor(MapsManager.getInstance().getPointX(this.descriptor.rawProps.anchor, 0.5), MapsManager.getInstance().getPointX(this.descriptor.rawProps.anchor, 1));
50+
this.marker?.setMarkerAnchor(MapsManager.getInstance().getPointX(this.descriptor.rawProps.anchor, 0.5), MapsManager.getInstance().getPointY(this.descriptor.rawProps.anchor, 1));
5251
this.marker?.setClickable(this.descriptor.rawProps.tappable===undefined?true:this.descriptor.rawProps.tappable);
5352
this.marker?.setDraggable(this.descriptor.rawProps.draggable===undefined?true:this.descriptor.rawProps.draggable);
5453
this.marker?.setIcon(MapsManager.getInstance().imageSourceConvert(this.descriptor.rawProps.image));
5554
this.marker?.setTitle(this.descriptor.rawProps.title);
5655
this.marker?.setSnippet(this.descriptor.rawProps.description);
5756
this.marker?.setFlat(this.descriptor.rawProps.flat);
58-
this.marker?.setInfoWindowAnchor(MapsManager.getInstance().getPointX(this.descriptor.rawProps.calloutAnchor, 0.5), MapsManager.getInstance().getPointX(this.descriptor.rawProps.calloutAnchor, 0));
57+
this.marker?.setInfoWindowAnchor(MapsManager.getInstance().getPointX(this.descriptor.rawProps.calloutAnchor, 0.5), MapsManager.getInstance().getPointY(this.descriptor.rawProps.calloutAnchor, 0));
58+
this.marker?.setZIndex(this.descriptor.rawProps.zIndex);
5959
}
6060
));
6161
this.cleanUpCallbacks.push(this.ctx.componentCommandReceiver.registerCommandCallback(

harmony/maps/src/main/ets/MapsManager.ets

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export class MapsManager {
159159
width: desc.rawProps.strokeWidth,
160160
gradient: false,
161161
visible: true,
162-
zIndex: 0,
162+
zIndex: desc.rawProps.zIndex,
163163
}
164164
// 创建polyline
165165
return this.mapController.addPolyline(polylineOption).then(mapPolyline => {

src/MapView.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,7 @@ class MapView extends React.Component<MapViewProps, State> {
11651165
...this.props,
11661166
};
11671167
if (
1168-
// @ts-ignore
1169-
Platform.OS === 'ios' || Platform.OS === 'harmony' &&
1168+
Platform.OS === 'ios' &&
11701169
props.provider === ProviderConstants.PROVIDER_DEFAULT &&
11711170
props.mapType &&
11721171
GOOGLE_MAPS_ONLY_TYPES.includes(props.mapType)

0 commit comments

Comments
 (0)