Skip to content

Commit 7fc5d1b

Browse files
authored
feat:geojson中polygon属性补充,用户位置按钮配置 (#20)
1 parent 571d5a3 commit 7fc5d1b

File tree

7 files changed

+17
-23
lines changed

7 files changed

+17
-23
lines changed

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ export struct AIRMap {
108108
LWLog('AIRMap.aboutToAppear----->权限申请通过')
109109
// 启用我的位置图层
110110
this.mapController?.setMyLocationEnabled(true);
111-
// 启用我的位置按钮
112-
this.mapController?.setMyLocationControlsEnabled(true);
113-
//首次设置我的位置
111+
// 我的位置按钮
112+
this.mapController?.setMyLocationControlsEnabled(this.descriptor.rawProps.showsMyLocationButton);
113+
// 首次设置我的位置
114114
geoLocationManager.getCurrentLocation().then((result) => {
115115
console.log('current location: ' + JSON.stringify(result));
116116
// 设置用户的位置
@@ -223,6 +223,7 @@ export struct AIRMap {
223223
minZoom: this.descriptor.rawProps.minZoomLevel,
224224
rotateGesturesEnabled: this.descriptor.rawProps.rotateEnabled,
225225
scaleControlsEnabled: this.descriptor.rawProps.showsScale,
226+
alwaysShowScaleEnabled: this.descriptor.rawProps.showsScale,
226227
scrollGesturesEnabled: this.descriptor.rawProps.scrollEnabled,
227228
tiltGesturesEnabled: true,
228229
zoomGesturesEnabled: this.descriptor.rawProps.zoomEnabled,

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

+4-13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export struct AIRMapMarker {
3535
@BuilderParam buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
3636
@State descriptor: AIRMapMarkerDescriptor = {} as AIRMapMarkerDescriptor
3737
protected cleanUpCallbacks: (() => void)[] = []
38+
private marker?: map.Marker;
3839

3940
aboutToAppear() {
4041
LWLog('AIRMapMarker.aboutToAppear 初始化 AIRMapMarker...')
@@ -46,7 +47,7 @@ export struct AIRMapMarker {
4647
this.marker?.setPosition({latitude: this.descriptor.rawProps.coordinate.latitude, longitude: this.descriptor.rawProps.coordinate.longitude})
4748
this.marker?.setRotation(this.descriptor.rawProps.rotation);
4849
this.marker?.setZIndex(this.descriptor.rawProps.zIndex);
49-
this.marker?.setAlpha(this.descriptor.rawProps.opacity?this.descriptor.rawProps.opacity:1.0);
50+
this.marker?.setAlpha(this.descriptor.rawProps.opacity ?? 1.0);
5051
this.marker?.setMarkerAnchor(MapsManager.getInstance().getPointX(this.descriptor.rawProps.anchor, 0.5), MapsManager.getInstance().getPointX(this.descriptor.rawProps.anchor, 1));
5152
this.marker?.setClickable(this.descriptor.rawProps.tappable===undefined?true:this.descriptor.rawProps.tappable);
5253
this.marker?.setDraggable(this.descriptor.rawProps.draggable===undefined?true:this.descriptor.rawProps.draggable);
@@ -62,13 +63,9 @@ export struct AIRMapMarker {
6263
(command, args: [ESObject, ESObject, ESObject]) => {
6364
LWLog('AIRMapMarker.aboutToAppear----------command=' + command, JSON.stringify(args))
6465
if (command === 'showCallout') {
65-
if (this.marker) {
66-
this.marker.setInfoWindowVisible(true);
67-
}
66+
this.marker?.setInfoWindowVisible(true);
6867
} else if (command === 'hideCallout') {
69-
if (this.marker) {
70-
this.marker.setInfoWindowVisible(false);
71-
}
68+
this.marker?.setInfoWindowVisible(false);
7269
} else if (command === 'redrawCallout') {
7370
//todo 华为地图不支持 当infoWindow为自定义view的时候,调用此方法更新infoWindow里的内容
7471
} else if (command === 'animateMarkerToCoordinate') {
@@ -99,12 +96,6 @@ export struct AIRMapMarker {
9996
});
10097
}
10198

102-
private marker?: map.Marker;
103-
104-
public setMarker(marker: map.Marker){
105-
this.marker = marker;
106-
}
107-
10899
aboutToDisappear() {
109100
this.cleanUpCallbacks.forEach(cb => cb());
110101
this.marker?.remove();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export struct Geojson {
4646

4747
if (MapsManager.getInstance().isInitMapController()) {
4848
MapsManager.getInstance().addGeojson(this.descriptor);
49-
}else {
49+
} else {
5050
setTimeout(()=>{
5151
MapsManager.getInstance().addGeojson(this.descriptor);
5252
}, 500)

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

-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ export class MapsManager{
113113
};
114114
return this.mapController.addMarker(markerOptions).then(marker => {
115115
LWLog('MapsManager.addMarker----------marker=' + marker.getId())
116-
_this.setMarker(marker);
117116

118117
this.mapController?.on("markerClick", (marker)=>{
119118
_this.ctx.rnInstance.emitComponentEvent(_this.descriptor.tag, AIR_MAP_MARKER_TYPE, { type: "onPress" });

harmony/maps/src/main/ets/MapsPackage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MapsTurboModulesFactory extends TurboModulesFactory {
3434
console.log(TAG, '初始化 MapsTurboModulesFactory.createTurboModule=' + name)
3535
if (name === REACT_CLASS_AIRMAP_MANAGER) {
3636
return new AIRMapManager(this.ctx);
37-
}else if(name === REACT_CLASS_AIRMAP_MARKER_MANAGER){
37+
} else if (name === REACT_CLASS_AIRMAP_MARKER_MANAGER){
3838
return new AIRMapMarkerManager(this.ctx);
3939
}
4040
return null;

harmony/maps/src/main/ets/MapsTurboManager.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,8 @@ export class MapsTurboManager{
215215
return new Promise((resolve, reject) => {
216216
let params: site.ReverseGeocodeParams = {
217217
location: {
218-
longitude: 10.252502,
219-
latitude: 43.8739168
220-
// longitude: coordinate.longitude,
221-
// latitude: coordinate.latitude
218+
longitude: coordinate.longitude,
219+
latitude: coordinate.latitude
222220
},
223221
language: "zh",
224222
radius: 10

src/Geojson.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ const Geojson = (props: GeojsonProps) => {
261261
strokeColor={lineStrokeColor}
262262
fillColor={polygonFillColor}
263263
strokeWidth={lineStrokeWidth}
264+
lineCap={lineCap}
265+
lineJoin={lineJoin}
266+
lineDashPhase={lineDashPhase}
267+
lineDashPattern={lineDashPattern}
268+
miterLimit={miterLimit}
264269
tappable={tappable}
265270
onPress={() => onPress && onPress(overlay)}
266271
zIndex={zIndex}

0 commit comments

Comments
 (0)