Skip to content

Commit 578b5ce

Browse files
authored
feat: flatten onOptionChanged prop type (#154)
1 parent a162e93 commit 578b5ce

File tree

8 files changed

+83
-78
lines changed

8 files changed

+83
-78
lines changed

README-en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ const jejuRegion: Region = {
275275
logoAlign={'TopRight'}
276276
locale={'ja'}
277277
onInitialized={() => console.log('initialized!')}
278-
onOptionChanged={({ nativeEvent: { locationTrackingMode } }) =>
278+
onOptionChanged={({ locationTrackingMode }) =>
279279
console.log('Option Changed!', locationTrackingMode)
280280
}
281281
onCameraChanged={(args) => console.log(`Camera Changed: ${formatJson(args)}`)}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ const jejuRegion: Region = {
271271
logoAlign={'TopRight'}
272272
locale={'ja'}
273273
onInitialized={() => console.log('initialized!')}
274-
onOptionChanged={({ nativeEvent: { locationTrackingMode } }) =>
274+
onOptionChanged={({ locationTrackingMode }) =>
275275
console.log('Option Changed!', locationTrackingMode)
276276
}
277277
onCameraChanged={(args) => console.log(`Camera Changed: ${formatJson(args)}`)}

android/src/main/java/com/mjstudio/reactnativenavermap/overlay/multipath/RNCNaverMapMultiPathManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ class RNCNaverMapMultiPathManager : RNCNaverMapMultiPathManagerSpec<RNCNaverMapM
9696
value: ReadableArray?,
9797
) {
9898
val coordParts =
99-
value?.toArrayList()?.map { coordPart ->
100-
(coordPart as? ArrayList<*>)?.map { coord ->
99+
(value?.toArrayList() ?: arrayListOf()).map { coordPart ->
100+
(coordPart as? ArrayList<*>)?.mapNotNull { coord ->
101101
(coord as Map<String, *>).getLatLng()
102102
} ?: listOf()
103-
} ?: listOf()
103+
}
104104
view?.setCoordParts(coordParts)
105105
}
106106

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ SPEC CHECKSUMS:
25622562
ReactCommon: 658874decaf8c4fd76cfa3a878b94a869db85b1c
25632563
RNPermissions: 30bf2aa7b7ce0d5e9e2996cd19596757e75cc508
25642564
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
2565-
Yoga: 395b5d614cd7cbbfd76b05d01bd67230a6ad004e
2565+
Yoga: 0c4b7d2aacc910a1f702694fa86be830386f4ceb
25662566

25672567
PODFILE CHECKSUM: 39c77b7a027f87ce1a1f1b74b57ccb9b2ef57a42
25682568

example/src/App.tsx

Lines changed: 54 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
NaverMapCircleOverlay,
88
NaverMapGroundOverlay,
99
NaverMapMarkerOverlay,
10-
NaverMapMultiPathOverlay,
1110
NaverMapPathOverlay,
1211
NaverMapPolygonOverlay,
1312
NaverMapPolylineOverlay,
@@ -27,6 +26,7 @@ import {
2726
PERMISSIONS,
2827
request,
2928
requestLocationAccuracy,
29+
requestMultiple,
3030
} from 'react-native-permissions';
3131
import { Btn, Range, Toggle } from './component/components';
3232
import { type City, getCitiesByRegion } from './db/CityDatabase';
@@ -123,16 +123,16 @@ export default function App() {
123123
});
124124
}
125125
if (Platform.OS === 'android') {
126-
// requestMultiple([
127-
// PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
128-
// PERMISSIONS.ANDROID.ACCESS_BACKGROUND_LOCATION,
129-
// ])
130-
// .then((status) => {
131-
// console.log(`Location request status: ${status}`)
132-
// })
133-
// .catch((e) => {
134-
// console.error(`Location request has been failed: ${e}`)
135-
// })
126+
requestMultiple([
127+
PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
128+
PERMISSIONS.ANDROID.ACCESS_BACKGROUND_LOCATION,
129+
])
130+
.then((status) => {
131+
console.log(`Location request status: ${status}`);
132+
})
133+
.catch((e) => {
134+
console.error(`Location request has been failed: ${e}`);
135+
});
136136
}
137137
}, []);
138138

@@ -238,7 +238,6 @@ export default function App() {
238238
height={100}
239239
image={{ httpUri: 'https://picsum.photos/1000/1201' }}
240240
/>
241-
242241
<NaverMapArrowheadPathOverlay
243242
coords={[
244243
{ longitude: 126.93240597362552, latitude: 32.433509943138404 },
@@ -264,7 +263,6 @@ export default function App() {
264263
globalZIndex={-1}
265264
onTap={() => console.log('hi')}
266265
/>
267-
268266
<NaverMapGroundOverlay
269267
image={{ assetName: 'thumbnail' }}
270268
region={Regions.Jeju}
@@ -284,48 +282,48 @@ export default function App() {
284282
passedColor={'black'}
285283
outlineWidth={1}
286284
/>
287-
<NaverMapMultiPathOverlay
288-
coordParts={[
289-
[
290-
{ latitude: 33.5744287, longitude: 126.982625 },
291-
{ latitude: 33.57152, longitude: 126.97714 },
292-
{ latitude: 33.56607, longitude: 126.98268 },
293-
],
294-
[
295-
{ latitude: 33.56607, longitude: 126.98268 },
296-
{ latitude: 33.56445, longitude: 126.97707 },
297-
{ latitude: 33.55855, longitude: 126.97822 },
298-
],
299-
[
300-
{ latitude: 33.55855, longitude: 126.97822 },
301-
{ latitude: 33.55234, longitude: 126.98456 },
302-
{ latitude: 33.54789, longitude: 126.97333 },
303-
],
304-
]}
305-
colorParts={[
306-
{
307-
color: 'red',
308-
passedColor: 'darkred',
309-
outlineColor: 'white',
310-
passedOutlineColor: 'gray',
311-
},
312-
{
313-
color: 'green',
314-
passedColor: 'darkgreen',
315-
outlineColor: 'white',
316-
passedOutlineColor: 'gray',
317-
},
318-
{
319-
color: 'blue',
320-
passedColor: 'darkblue',
321-
outlineColor: 'white',
322-
passedOutlineColor: 'gray',
323-
},
324-
]}
325-
width={6}
326-
outlineWidth={2}
327-
onTap={() => console.log('MultiPath tapped!')}
328-
/>
285+
{/*<NaverMapMultiPathOverlay*/}
286+
{/* coordParts={[*/}
287+
{/* [*/}
288+
{/* { latitude: 33.5744287, longitude: 126.982625 },*/}
289+
{/* { latitude: 33.57152, longitude: 126.97714 },*/}
290+
{/* { latitude: 33.56607, longitude: 126.98268 },*/}
291+
{/* ],*/}
292+
{/* [*/}
293+
{/* { latitude: 33.56607, longitude: 126.98268 },*/}
294+
{/* { latitude: 33.56445, longitude: 126.97707 },*/}
295+
{/* { latitude: 33.55855, longitude: 126.97822 },*/}
296+
{/* ],*/}
297+
{/* [*/}
298+
{/* { latitude: 33.55855, longitude: 126.97822 },*/}
299+
{/* { latitude: 33.55234, longitude: 126.98456 },*/}
300+
{/* { latitude: 33.54789, longitude: 126.97333 },*/}
301+
{/* ],*/}
302+
{/* ]}*/}
303+
{/* colorParts={[*/}
304+
{/* {*/}
305+
{/* color: 'red',*/}
306+
{/* passedColor: 'darkred',*/}
307+
{/* outlineColor: 'white',*/}
308+
{/* passedOutlineColor: 'gray',*/}
309+
{/* },*/}
310+
{/* {*/}
311+
{/* color: 'green',*/}
312+
{/* passedColor: 'darkgreen',*/}
313+
{/* outlineColor: 'white',*/}
314+
{/* passedOutlineColor: 'gray',*/}
315+
{/* },*/}
316+
{/* {*/}
317+
{/* color: 'blue',*/}
318+
{/* passedColor: 'darkblue',*/}
319+
{/* outlineColor: 'white',*/}
320+
{/* passedOutlineColor: 'gray',*/}
321+
{/* },*/}
322+
{/* ]}*/}
323+
{/* width={6}*/}
324+
{/* outlineWidth={2}*/}
325+
{/* onTap={() => console.log('MultiPath tapped!')}*/}
326+
{/*/>*/}
329327
<NaverMapPolygonOverlay
330328
outlineWidth={5}
331329
outlineColor={'#f2f2'}
@@ -385,7 +383,7 @@ export default function App() {
385383
isShowLocationButton={myLocation}
386384
// isExtentBoundedInKorea
387385
onInitialized={() => console.log('initialized!')}
388-
onOptionChanged={({ nativeEvent: { locationTrackingMode } }) =>
386+
onOptionChanged={({ locationTrackingMode }) =>
389387
console.log('Option Changed!', locationTrackingMode)
390388
}
391389
onCameraChanged={({ region }) => {

ios/RNCNaverMapViewImpl.mm

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,27 +229,26 @@ - (void)mapViewOptionChanged:(NMFMapView*)mapView {
229229
if (!_rncParent.emitter)
230230
return;
231231

232-
NSString* modeString;
232+
std::string modeString;
233233
switch (self.mapView.positionMode) {
234234
case NMFMyPositionDisabled:
235-
modeString = @"None";
235+
modeString = "None";
236236
break;
237237
case NMFMyPositionNormal:
238-
modeString = @"NoFollow";
238+
modeString = "NoFollow";
239239
break;
240240
case NMFMyPositionDirection:
241-
modeString = @"Follow";
241+
modeString = "Follow";
242242
break;
243243
case NMFMyPositionCompass:
244-
modeString = @"Face";
244+
modeString = "Face";
245245
break;
246246
default:
247-
modeString = @"None";
247+
modeString = "None";
248248
break;
249249
}
250250

251-
_rncParent.emitter->onOptionChanged(
252-
{.locationTrackingMode = std::string([modeString UTF8String])});
251+
_rncParent.emitter->onOptionChanged({.locationTrackingMode = modeString});
253252
}
254253

255254
- (void)mapView:(NMFMapView*)mapView cameraIsChangingByReason:(NSInteger)reason {

src/component/NaverMapView.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ export interface NaverMapViewProps extends ViewProps {
432432
*
433433
* @event
434434
*/
435-
onOptionChanged?: (event: {
436-
nativeEvent: { locationTrackingMode: LocationTrackingMode | string };
435+
onOptionChanged?: (params: {
436+
locationTrackingMode: LocationTrackingMode;
437437
}) => void;
438438
/**
439439
* 어떤 이유에 의해서건 카메라가 움직이면 카메라 변경 이벤트가 발생합니다.
@@ -632,7 +632,7 @@ export const NaverMapView = forwardRef(
632632
onCameraIdle: onCameraIdleProp,
633633
onTapMap: onTapMapProp,
634634
onInitialized,
635-
onOptionChanged,
635+
onOptionChanged: onOptionChangedProp,
636636
isScrollGesturesEnabled = true,
637637
isZoomGesturesEnabled = true,
638638
isTiltGesturesEnabled = true,
@@ -1064,7 +1064,15 @@ export const NaverMapView = forwardRef(
10641064
onCameraChanged={onCameraChangedProp ? onCameraChanged : undefined}
10651065
onCameraIdle={onCameraIdleProp ? onCameraIdle : undefined}
10661066
onTapMap={onTapMapProp ? onTapMap : undefined}
1067-
onOptionChanged={onOptionChanged}
1067+
onOptionChanged={
1068+
onOptionChangedProp
1069+
? ({ nativeEvent: { locationTrackingMode } }) =>
1070+
onOptionChangedProp({
1071+
locationTrackingMode:
1072+
locationTrackingMode as LocationTrackingMode,
1073+
})
1074+
: undefined
1075+
}
10681076
mapPadding={mapPadding}
10691077
isShowCompass={isShowCompass}
10701078
isShowIndoorLevelPicker={isShowIndoorLevelPicker}

src/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export {
1818
type NaverMapMarkerOverlayProps,
1919
type SubCaptionType,
2020
} from './component/NaverMapMarkerOverlay';
21-
export {
22-
NaverMapMultiPathOverlay,
23-
type NaverMapMultiPathOverlayProps,
24-
} from './component/NaverMapMultiPathOverlay';
21+
// export {
22+
// NaverMapMultiPathOverlay,
23+
// type NaverMapMultiPathOverlayProps,
24+
// } from './component/NaverMapMultiPathOverlay';
2525
export {
2626
NaverMapPathOverlay,
2727
type NaverMapPathOverlayProps,

0 commit comments

Comments
 (0)