Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/quadflask/react-native-naver-map

๐Ÿ—บ๏ธnaver map for react-native
https://github.com/quadflask/react-native-naver-map

naver-map react-native

Last synced: about 3 hours ago
JSON representation

๐Ÿ—บ๏ธnaver map for react-native

Awesome Lists containing this project

README

        

react-native-naver-map [![npm version](https://badge.fury.io/js/react-native-nmap.svg)](https://badge.fury.io/js/react-native-nmap)
-----

๋„ค์ด๋ฒ„๋งต์˜ ๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ ๋ธŒ๋ฆฟ์ง€์ž…๋‹ˆ๋‹ค.

![](https://raw.githubusercontent.com/QuadFlask/react-native-naver-map/master/example/screenshot/screenshot.png)

## ์„ค์น˜

```
npm install react-native-nmap --save;
```

- **React Native 0.60+**

```bash
$ cd ios/ && pod install
```

- **React Native <= 0.59**

```bash
$ react-native link react-native-nmap
$ cd ios/ && pod install
```

> ios์˜ ๊ฒฝ์šฐ `git-lfs` ์„ค์น˜๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. [์ฐธ๊ณ ](https://github.com/navermaps/ios-map-sdk#%EB%8C%80%EC%9A%A9%EB%9F%89-%ED%8C%8C%EC%9D%BC%EC%9D%84-%EB%B0%9B%EA%B8%B0-%EC%9C%84%ED%95%B4-git-lfs-%EC%84%A4%EC%B9%98%EA%B0%80-%ED%95%84%EC%9A%94%ED%95%A9%EB%8B%88%EB%8B%A4)

### ์•ˆ๋“œ๋กœ์ด๋“œ ์ถ”๊ฐ€ ์„ค์ •

[๋„ค์ด๋ฒ„ ๋งต ์•ˆ๋“œ๋กœ์ด๋“œ SDK ๋ฌธ์„œ](https://navermaps.github.io/android-map-sdk/guide-ko/1.html)๋ฅผ ๋”ฐ๋ผ APIํ‚ค์™€ ๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ ๊ฒฝ๋กœ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค

`/android/build.gradle` ํŒŒ์ผ์— ์•„๋ž˜์™€ ๊ฐ™์ด ๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค

> โš ๏ธ Bintray ์ง€์› ์ค‘๋‹จ์— ์˜ํ•ด jfrog๋กœ ์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค

```
allprojects {
repositories {
google()
jcenter()
// ๋„ค์ด๋ฒ„ ์ง€๋„ ์ €์žฅ์†Œ
maven {
url 'https://naver.jfrog.io/artifactory/maven/'
}
}
}
```

`/android/app/src/AndroidManifest.xml`์— ์•„๋ž˜์™€ ๊ฐ™์ด ์ถ”๊ฐ€ํ•˜๊ณ  ๋ฐœ๊ธ‰๋ฐ›์€ ํด๋ผ์ด์–ธํŠธ ์•„์ด๋””๋กœ ๋ฐ”๊ฟ”์ค๋‹ˆ๋‹ค.
```xml



```

### IOS ์ถ”๊ฐ€ ์„ค์ •

[๋„ค์ด๋ฒ„ ๋งต IOS SDK ๋ฌธ์„œ](https://navermaps.github.io/ios-map-sdk/guide-ko/1.html)๋ฅผ ๋”ฐ๋ผ APIํ‚ค์™€ ๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ ๊ฒฝ๋กœ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

`info.plist`์— ์•„๋ž˜์™€ ๊ฐ™์ด ๋ฐœ๊ธ‰๋ฐ›์€ ํด๋ผ์ด์–ธํŠธ ์•„์ด๋””๋ฅผ ์ถ”๊ฐ€ํ•ด์ค๋‹ˆ๋‹ค.

![image](https://user-images.githubusercontent.com/49827449/66392740-b2fd5f00-ea0b-11e9-8c38-23e604b1009d.png)

```xml

...
NMFClientId
YOUR_CLIENT_ID_HERE
...

```

## ์˜ˆ์ œ

> [example/App.js](https://github.com/QuadFlask/react-native-naver-map/blob/master/example/App.js)

```tsx
import NaverMapView, {Circle, Marker, Path, Polyline, Polygon} from "react-native-nmap";

function MyMap() {
const P0 = {latitude: 37.564362, longitude: 126.977011};
const P1 = {latitude: 37.565051, longitude: 126.978567};
const P2 = {latitude: 37.565383, longitude: 126.976292};

return console.warn('onTouch', JSON.stringify(e.nativeEvent))}
onCameraChange={e => console.warn('onCameraChange', JSON.stringify(e))}
onMapClick={e => console.warn('onMapClick', JSON.stringify(e))}>
console.warn('onClick! p0')}/>
console.warn('onClick! p1')}/>
console.warn('onClick! p2')}/>
console.warn('onClick! path')} width={10}/>
console.warn('onClick! polyline')}/>
console.warn('onClick! circle')}/>
console.warn('onClick! polygon')}/>

}
```

## ์ปดํฌ๋„ŒํŠธ

ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ํƒ€์ž… ์ •์˜๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์–ด ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ์‚ฌ์šฉ์„ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.

### ๊ธฐ๋ณธ ํƒ€์ž…

```ts
export interface Coord {
latitude: number;
longitude: number;
}
export interface Region extends Coord {
latitudeDelta: number;
longitudeDelta: number;
}
export interface Rect {
left?: number;
top?: number;
right?: number;
bottom?: number;
}
```

### `NaverMapView`
```ts
interface NaverMapViewProps {
center?: Coord & {
zoom?: number;
tilt?: number;
bearing?: number;
};
tilt?: number;
bearing?: number;
mapPadding?: Rect;
logoMargin?: Rect;
logoGravity?: Gravity;
onInitialized?: Function;
onCameraChange?: (event: {
latitude: number;
longitude: number;
zoom: number;
contentsRegion: [Coord, Coord, Coord, Coord, Coord]; // https://navermaps.github.io/android-map-sdk/reference/com/naver/maps/map/NaverMap.html#getContentRegion()
coveringRegion: [Coord, Coord, Coord, Coord, Coord];
}) => void;
onMapClick?: (event: {
x: number;
y: number;
latitude: number;
longitude: number;
}) => void;
onTouch?: () => void;
showsMyLocationButton?: boolean;
compass?: boolean;
scaleBar?: boolean;
zoomControl?: boolean;
mapType?: MapType;
minZoomLevel?: number;
maxZoomLevel?: number;
buildingHeight?: number;
nightMode?: boolean;
scrollGesturesEnabled?: boolean;
zoomGesturesEnabled?: boolean;
tiltGesturesEnabled?: boolean;
rotateGesturesEnabled?: boolean;
stopGesturesEnabled?: boolean;
useTextureView?: boolean; // android only
}
/// component method
animateToCoordinate: (coord: Coord) => void;
animateToTwoCoordinates: (c1: Coord, c2: Coord) => void;
animateToCoordinates: (coords: Coord[], bounds?: {
top: number;
bottom: number;
left: number;
right: number;
}) => void;
animateToRegion: (region: Region) => void;
setLocationTrackingMode: (mode: number) => void;
setLayerGroupEnabled: (group: LayerGroup, enabled: boolean) => void;
showsMyLocationButton: (show: boolean) => void;
handleOnCameraChange: (event: React.SyntheticEvent<{}, {
latitude: number;
longitude: number;
zoom: number;
}>) => void;
handleOnMapClick: (event: React.SyntheticEvent<{}, {
x: number;
y: number;
latitude: number;
longitude: number;
}>) => void;
```

### `Marker`
```ts
interface MarkerProps {
coordinate: Coord
anchor?: { x: number, y: number }
pinColor?: string
alpha?: number
rotation?: number
flat?: boolean
image?: ImageSourcePropType
onClick?: () => void
width?: number
height?: number
angle?: number
hidden?: boolean
zIndex?: number
iconPerspectiveEnabled?: boolean
isHideCollidedSymbols?: boolean
isHideCollidedMarkers?: boolean
isHideCollidedCaptions?: boolean;
isForceShowIcon?: boolean;
caption?: {
text?: string;
align?: Align;
textSize?: number;
color?: string;
haloColor?: string;
offset?: number;
requestedWidth?: number;
minZoom?: number;
maxZoom?: number;
};
subCaption?: {
text?: string;
textSize?: number;
color?: number;
haloColor?: number;
requestedWidth?: number;
minZoom?: number;
maxZoom?: number;
};
}
```
> ์•ˆ๋“œ๋กœ์ด๋“œ ํ”Œ๋žซํผ์—์„œ ๋งˆ์ปค๋‚ด ์ปค์Šคํ…€ ๋ทฐ๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. `0.0.57`
> ```js
>
>
>
> width: 32, height: 32,
> backgroundColor: 'rgba(0,0,0,0.2)', resizeMode: 'stretch',
> borderWidth: 2, borderColor: 'black'}} fadeDuration={0}/>
> Image
>
>
> image background
>
>
>
> ```

### `Polyline`
```ts
interface PolylineProps {
coordinates: Coord[]
strokeWidth?: number
strokeColor?: string
onClick?: () => void
}
```

### `Path`
```ts
interface PathProps {
coordinates: Coord[]
width?: number
color?: string
outlineWidth?: number
passedColor?: string
outlineColor?: string
passedOutlineColor?: string
pattern?: ImageSourcePropType
patternInterval?: number
onClick?: () => void
}
```

### `Circle`
```ts
export interface CircleProps {
coordinate: Coord[]
radius?: number;
color?: string;
outlineWidth?: number;
outlineColor?: string;
zIndex?: number;
onClick?: () => void
}
```

### `Polygon`
```ts
export interface PolygonProps {
coordinate: Coord[]
outlineWidth?: number;
outlineColor?: string
color?: string;
holes?: Coord[][];
onClick?: () => void
}
```

### `LayerGroup`
```ts
export declare enum LayerGroup {
LAYER_GROUP_BUILDING = "building",
LAYER_GROUP_TRANSIT = "transit",
LAYER_GROUP_BICYCLE = "bike",
LAYER_GROUP_TRAFFIC = "ctt",
LAYER_GROUP_CADASTRAL = "landparcel",
LAYER_GROUP_MOUNTAIN = "mountain"
}
```

## ์ฐธ๊ณ 

- *react-navigation*์˜ ์Šคํƒ ์Šคํฌ๋ฆฐ ์‚ฌ์šฉ์‹œ ์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ ๋งต๋ทฐ๊ฐ€ ๊ฒน์ณ ๋ณด์ด๋Š” ํ˜„์ƒ์ด ์žˆ์„ ๊ฒฝ์šฐ `useTextureView` ์˜ต์…˜์„ ์ถ”๊ฐ€ํ•ด ์ฃผ์„ธ์š”. [#27](https://github.com/QuadFlask/react-native-naver-map/issues/27)

- ์•ˆ๋“œ๋กœ์ด๋“œ์—์„œ `ScrollView` ๋‚ด๋ถ€์— ์ถ”๊ฐ€ํ•  ๊ฒฝ์šฐ `scrollGesturesEnabled`๋ฅผ ์ด์šฉํ•ด ๋งต ์Šคํฌ๋กค์„ ์ œ์–ดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. [#62](https://github.com/QuadFlask/react-native-naver-map/issues/62)

- ๋งˆ์ปค ํด๋Ÿฌ์Šคํ„ฐ๋ง์— ํ•„์š”ํ•œ ์ง€๋„ ์ปจํ…์ธ  ์˜์—ญ์€ `onCameraChange` ์ด๋ฒคํŠธ๋ฅผ ํ†ตํ•ด ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. [#64](https://github.com/QuadFlask/react-native-naver-map/issues/64)