Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b222b96
🔧 chore(build.gradle): Gradle, SDK 버전 업데이트
chlee1001 Jan 25, 2024
7368958
✨ 피트(index.tsx): PropsWithChildren 타입을 NaverMapView 컴포넌트에 적용
chlee1001 Jan 25, 2024
75129f2
🔀 refactor(reactNativeNMap): NMapsMap에서 NMapsGeometry로 NMGLatLng 임포트 …
chlee1001 Jan 25, 2024
188adf0
🔧 refactor(reactNativeNMap): 이벤트 핸들러 이름 변경
chlee1001 Jan 25, 2024
d19816d
🔧 refactor(RNNaverMapView.java, RNNaverMapViewContainer.java, RNNaver…
chlee1001 Jan 25, 2024
534cd93
🔥 refactor(RNNaverMapView.java, RNNaverMapViewContainer.java, RNNaver…
chlee1001 Jan 25, 2024
2be9dea
🐛 fix(RNNaverMapCircleOverlay.h): onCircleClick 속성 선언에 세미콜론 추가
chlee1001 Jan 26, 2024
684d21a
🔖 버전(package.json): 패키지 버전을 0.0.66에서 0.0.67로 업데이트
chlee1001 Jan 26, 2024
941468c
🔥 remove(RNNaverMapViewManager.java): FusedLocationSource 인스턴스 생성 제거
chlee1001 Jan 30, 2024
7668656
🐛 fix(README.md, index.tsx): 'contentsRegion'을 'contentRegion'으로 수정
chlee1001 Jan 30, 2024
8211e73
🐛 fix(RNNaverMapView.java): IndexOutOfBoundsException 방어 코드 추가
chlee1001 Jan 30, 2024
11e4535
🔀 refactor(react-native-nmap.podspec): 저자 및 홈페이지 정보 업데이트
chlee1001 Jan 30, 2024
47dd654
🔧 chore(package.json): 패키지 버전 업데이트 및 종속성 업데이트 패키지 버전을 0.0.67에서 0.0.68…
chlee1001 Jan 31, 2024
0ca6bc0
🔧 refactor(RNNaverMapView.java): setCenter 메소드에 zoom 파라미터 추가
chlee1001 Feb 1, 2024
7a82db8
:memo: docs(README.md): 업데이트 된 animateToCoordinate 메서드의 파라미터를 반영했습니다.
chlee1001 Feb 1, 2024
1672ac4
🐛 fix(RNNaverMapViewManager.java): 누락된 닫는 중괄호 추가
chlee1001 Feb 1, 2024
aeed6e2
🔧 refactor(RNNaverMapCircleOverlay.java): onClick 메소드 오버라이드 추가
chlee1001 Feb 2, 2024
f21d5eb
:wrench: chore: package-lock.json 파일 업데이트
chlee1001 May 5, 2024
61b6083
📝 (README.md): 네이버 지도 저장소 URL 업데이트
chlee1001 Sep 19, 2024
3e6614f
⬆️ (package.json): 버전 0.0.69에서 0.0.70으로 업그레이드
chlee1001 Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ $ cd ios/ && pod install

`/android/build.gradle` 파일에 아래와 같이 레포지터리를 추가합니다

> ⚠️ Bintray 지원 중단에 의해 jfrog로 수정되었습니다
> ~~⚠️ Bintray 지원 중단에 의해 jfrog로 수정되었습니다~~
>
> jgrog에서 repository로 변경되었습니다. [공식문서](https://navermaps.github.io/android-map-sdk/guide-ko/1.html)

```
allprojects {
Expand All @@ -43,7 +45,7 @@ allprojects {
jcenter()
// 네이버 지도 저장소
maven {
url 'https://naver.jfrog.io/artifactory/maven/'
url 'https://repository.map.naver.com/archive/maven'
}
}
}
Expand Down Expand Up @@ -152,7 +154,7 @@ interface NaverMapViewProps {
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()
contentRegion: [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: {
Expand All @@ -179,7 +181,7 @@ interface NaverMapViewProps {
useTextureView?: boolean; // android only
}
/// component method
animateToCoordinate: (coord: Coord) => void;
animateToCoordinate: (coord: Coord, zoom?: number) => void;
animateToTwoCoordinates: (c1: Coord, c2: Coord) => void;
animateToCoordinates: (coords: Coord[], bounds?: {
top: number;
Expand Down
12 changes: 6 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.4.3'
}
}

android {
compileSdkVersion rootProject.ext.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 28
buildToolsVersion rootProject.ext.hasProperty('buildToolsVersion') ? rootProject.ext.buildToolsVersion : "28.0.3"
compileSdkVersion rootProject.ext.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
buildToolsVersion rootProject.ext.hasProperty('buildToolsVersion') ? rootProject.ext.buildToolsVersion : "33.0.0"

defaultConfig {
minSdkVersion rootProject.ext.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 16
targetSdkVersion rootProject.ext.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 28
targetSdkVersion rootProject.ext.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33

versionCode 1
versionName "1.0"
Expand Down Expand Up @@ -48,12 +48,12 @@ repositories {
jcenter()
mavenCentral()
maven {
url 'https://naver.jfrog.io/artifactory/maven/'
url 'https://repository.map.naver.com/archive/maven'
}
}

dependencies {
implementation 'com.facebook.react:react-native:+'
implementation "com.naver.maps:map-sdk:${rootProject.ext.hasProperty('mapSdkVersion') ? rootProject.ext.mapSdkVersion : '3.12.0'}"
implementation "com.naver.maps:map-sdk:${rootProject.ext.hasProperty('mapSdkVersion') ? rootProject.ext.mapSdkVersion : '3.19.1'}"
implementation "com.google.android.gms:play-services-location:16.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import android.content.Context;

import androidx.annotation.NonNull;
import com.naver.maps.geometry.LatLng;
import com.naver.maps.map.overlay.CircleOverlay;
import com.naver.maps.map.overlay.Overlay;

public class RNNaverMapCircleOverlay extends ClickableRNNaverMapFeature<CircleOverlay> {
public RNNaverMapCircleOverlay(EventEmittable emitter, Context context) {
Expand Down Expand Up @@ -34,4 +36,10 @@ public void setOutlineColor(int color) {
public void setZIndex(int zIndex) {
feature.setZIndex(zIndex);
}
}

@Override
public boolean onClick(@NonNull Overlay overlay) {
super.onClick(overlay);
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

import android.graphics.PointF;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.airbnb.android.react.maps.ViewAttacherGroup;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.naver.maps.geometry.LatLng;
Expand All @@ -26,18 +23,21 @@
import java.util.List;

public class RNNaverMapView extends MapView implements OnMapReadyCallback, NaverMap.OnCameraIdleListener, NaverMap.OnMapClickListener, RNNaverMapViewProps {
private static final int LOCATION_PERMISSION_REQUEST_CODE = 100;
private ThemedReactContext themedReactContext;
private FusedLocationSource locationSource;
private NaverMap naverMap;
private NaverMapSdk naverMapSdk;
private ViewAttacherGroup attacherGroup;
private long lastTouch = 0;
private final List<RNNaverMapFeature<?>> features = new ArrayList<>();

public RNNaverMapView(@NonNull ThemedReactContext themedReactContext, ReactApplicationContext appContext, FusedLocationSource locationSource, NaverMapOptions naverMapOptions, Bundle instanceStateBundle) {
public RNNaverMapView(@NonNull ThemedReactContext themedReactContext, ReactApplicationContext appContext, NaverMapOptions naverMapOptions, Bundle instanceStateBundle) {
super(ReactUtil.getNonBuggyContext(themedReactContext, appContext), naverMapOptions);
this.themedReactContext = themedReactContext;
this.locationSource = locationSource;
this.locationSource = new FusedLocationSource(appContext.getCurrentActivity(), LOCATION_PERMISSION_REQUEST_CODE);
super.onCreate(instanceStateBundle);
naverMapSdk = NaverMapSdk.getInstance(appContext);
// super.onStart();
getMapAsync(this);

Expand Down Expand Up @@ -68,15 +68,24 @@ public void onMapReady(@NonNull NaverMap naverMap) {
lastTouch = System.currentTimeMillis();
}
});
naverMapSdk.flushCache(() -> Log.i("NaverMap", "Map Cache Clean"));
onInitialized();
}

@Override
public void setCenter(LatLng latLng) {
getMapAsync(e -> {
CameraUpdate cameraUpdate = CameraUpdate.scrollTo(latLng).animate(CameraAnimation.Easing);
naverMap.moveCamera(cameraUpdate);
});
public void setCenter(LatLng latLng, Double zoom) {
if(zoom >= 0) {
getMapAsync(e -> {
CameraUpdate cameraUpdate = CameraUpdate.scrollAndZoomTo(latLng, zoom)
.animate(CameraAnimation.Easing);
naverMap.moveCamera(cameraUpdate);
});
} else {
getMapAsync(e -> {
CameraUpdate cameraUpdate = CameraUpdate.scrollTo(latLng).animate(CameraAnimation.Easing);
naverMap.moveCamera(cameraUpdate);
});
}
}

@Override
Expand All @@ -88,15 +97,15 @@ public void setCenter(LatLng latLng, Double zoom, Double tilt, Double bearing) {
double bearingValue = bearing == null ? cam.bearing : bearing;

naverMap.moveCamera(CameraUpdate.toCameraPosition(new CameraPosition(latLng, zoomValue, tiltValue, bearingValue))
.animate(CameraAnimation.Easing));
.animate(CameraAnimation.Easing));
});
}

@Override
public void zoomTo(LatLngBounds latLngBounds, int paddingInPx) {
getMapAsync(e -> {
CameraUpdate cameraUpdate = CameraUpdate.fitBounds(latLngBounds, paddingInPx)
.animate(CameraAnimation.Easing);
.animate(CameraAnimation.Easing);
naverMap.moveCamera(cameraUpdate);
});
}
Expand All @@ -106,7 +115,7 @@ public void setTilt(int tilt) {
getMapAsync(e -> {
final CameraPosition cameraPosition = naverMap.getCameraPosition();
naverMap.moveCamera(CameraUpdate.toCameraPosition(
new CameraPosition(cameraPosition.target, cameraPosition.zoom, tilt, cameraPosition.bearing)));
new CameraPosition(cameraPosition.target, cameraPosition.zoom, tilt, cameraPosition.bearing)));
});
}

Expand All @@ -115,7 +124,7 @@ public void setBearing(int bearing) {
getMapAsync(e -> {
final CameraPosition cameraPosition = naverMap.getCameraPosition();
naverMap.moveCamera(CameraUpdate.toCameraPosition(
new CameraPosition(cameraPosition.target, cameraPosition.zoom, cameraPosition.tilt, bearing)));
new CameraPosition(cameraPosition.target, cameraPosition.zoom, cameraPosition.tilt, bearing)));
});
}

Expand Down Expand Up @@ -271,6 +280,10 @@ public int getFeatureCount() {

@Override
public View getFeatureAt(int index) {
// java.lang.IndexOutOfBoundsException 예외가 발생해서 방어함.
if (index < 0 || index >= features.size()) {
return null;
}
return features.get(index);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@

import androidx.annotation.NonNull;

import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ThemedReactContext;
import com.naver.maps.geometry.LatLng;
import com.naver.maps.geometry.LatLngBounds;
import com.naver.maps.map.NaverMap;
import com.naver.maps.map.NaverMapOptions;
import com.naver.maps.map.util.FusedLocationSource;

public class RNNaverMapViewContainer extends FrameLayout implements RNNaverMapViewProps {
private RNNaverMapView mapView;
private Bundle instanceStateBundle = new Bundle();
private boolean isAttachedToWindow = false;

public RNNaverMapViewContainer(@NonNull ThemedReactContext themedReactContext, ReactApplicationContext appContext, FusedLocationSource locationSource, NaverMapOptions naverMapOptions) {
public RNNaverMapViewContainer(@NonNull ThemedReactContext themedReactContext, ReactApplicationContext appContext, NaverMapOptions naverMapOptions) {
super(ReactUtil.getNonBuggyContext(themedReactContext, appContext));
this.mapView = new RNNaverMapView(themedReactContext, appContext, locationSource, naverMapOptions, instanceStateBundle);
this.mapView = new RNNaverMapView(themedReactContext, appContext, naverMapOptions, instanceStateBundle);
addView(mapView);
}

Expand Down Expand Up @@ -97,9 +95,10 @@ public void onStop() {
}

@Override
public void setCenter(LatLng latLng) {
if (mapView != null)
mapView.setCenter(latLng);
public void setCenter(LatLng latLng, Double zoom) {
if (mapView != null) {
mapView.setCenter(latLng, zoom);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,26 @@

public class RNNaverMapViewManager extends ViewGroupManager<RNNaverMapViewContainer> {
private final ReactApplicationContext appContext;
private final FusedLocationSource locationSource;

private static final int ANIMATE_TO_REGION = 1;
private static final int ANIMATE_TO_COORDINATE = 2;
private static final int ANIMATE_TO_TWO_COORDINATES = 3;
private static final int SET_LOCATION_TRACKING_MODE = 4;
private static final int ANIMATE_TO_COORDINATES = 6;
private static final int SET_LAYER_GROUP_ENABLED = 7;
private static final int LOCATION_PERMISSION_REQUEST_CODE = 100;
private static final List<String> LAYER_GROUPS = Collections.unmodifiableList(Arrays.asList(
NaverMap.LAYER_GROUP_BUILDING,
NaverMap.LAYER_GROUP_TRANSIT,
NaverMap.LAYER_GROUP_BICYCLE,
NaverMap.LAYER_GROUP_TRAFFIC,
NaverMap.LAYER_GROUP_CADASTRAL,
NaverMap.LAYER_GROUP_MOUNTAIN
NaverMap.LAYER_GROUP_BUILDING,
NaverMap.LAYER_GROUP_TRANSIT,
NaverMap.LAYER_GROUP_BICYCLE,
NaverMap.LAYER_GROUP_TRAFFIC,
NaverMap.LAYER_GROUP_CADASTRAL,
NaverMap.LAYER_GROUP_MOUNTAIN
));

public RNNaverMapViewManager(ReactApplicationContext context) {
super();
this.appContext = context;
locationSource = new FusedLocationSource(context.getCurrentActivity(), 0x1000);
}

@NonNull
Expand All @@ -63,7 +62,7 @@ public String getName() {
@NonNull
@Override
protected RNNaverMapViewContainer createViewInstance(@NonNull ThemedReactContext reactContext) {
return new RNNaverMapViewContainer(reactContext, appContext, locationSource, getNaverMapViewOptions());
return new RNNaverMapViewContainer(reactContext, appContext, getNaverMapViewOptions());
}

@Override
Expand All @@ -80,10 +79,10 @@ protected NaverMapOptions getNaverMapViewOptions() {
public void setCenter(RNNaverMapViewContainer mapView, @Nullable ReadableMap option) {
if (option != null) {
mapView.setCenter(
toNaverLatLng(option),
getDoubleOrNull(option, "zoom"),
getDoubleOrNull(option, "tilt"),
getDoubleOrNull(option, "bearing"));
toNaverLatLng(option),
getDoubleOrNull(option, "zoom"),
getDoubleOrNull(option, "tilt"),
getDoubleOrNull(option, "bearing"));
}
}

Expand Down Expand Up @@ -245,8 +244,8 @@ public void receiveCommand(@NonNull RNNaverMapViewContainer mapView, int command
final double lngDelta = region.getDouble("longitudeDelta");

LatLngBounds bounds = new LatLngBounds(
new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
);
mapView.moveCameraFitBound(bounds, 0, 0, 0, 0);

Expand All @@ -265,9 +264,9 @@ public void receiveCommand(@NonNull RNNaverMapViewContainer mapView, int command
final double lng2 = region2.getDouble("longitude");

mapView.zoomTo(new LatLngBounds(
new LatLng(Math.max(lat1, lat2), Math.min(lng1, lng2)),
new LatLng(Math.min(lat1, lat2), Math.max(lng1, lng2))),
Math.round(padding * density));
new LatLng(Math.max(lat1, lat2), Math.min(lng1, lng2)),
new LatLng(Math.min(lat1, lat2), Math.max(lng1, lng2))),
Math.round(padding * density));

break;
}
Expand All @@ -289,7 +288,7 @@ public void receiveCommand(@NonNull RNNaverMapViewContainer mapView, int command

break;
case ANIMATE_TO_COORDINATE:
mapView.setCenter(toNaverLatLng(args.getMap(0)));
mapView.setCenter(toNaverLatLng(args.getMap(0)), args.getDouble(1));
break;

case SET_LOCATION_TRACKING_MODE:
Expand Down Expand Up @@ -327,13 +326,13 @@ public void receiveCommand(@NonNull RNNaverMapViewContainer mapView, int command
@Override
public java.util.Map<String, Integer> getCommandsMap() {
return MapBuilder.<String, Integer>builder()
.put("animateToRegion", ANIMATE_TO_REGION)
.put("animateToCoordinate", ANIMATE_TO_COORDINATE)
.put("animateToTwoCoordinates", ANIMATE_TO_TWO_COORDINATES)
.put("setLocationTrackingMode", SET_LOCATION_TRACKING_MODE)
.put("animateToCoordinates", ANIMATE_TO_COORDINATES)
.put("setLayerGroupEnabled", SET_LAYER_GROUP_ENABLED)
.build();
.put("animateToRegion", ANIMATE_TO_REGION)
.put("animateToCoordinate", ANIMATE_TO_COORDINATE)
.put("animateToTwoCoordinates", ANIMATE_TO_TWO_COORDINATES)
.put("setLocationTrackingMode", SET_LOCATION_TRACKING_MODE)
.put("animateToCoordinates", ANIMATE_TO_COORDINATES)
.put("setLayerGroupEnabled", SET_LAYER_GROUP_ENABLED)
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface RNNaverMapViewProps {

void onStop();

void setCenter(LatLng latLng);
void setCenter(LatLng latLng, Double zoom);

void setCenter(LatLng latLng, Double zoom, Double tilt, Double bearing);

Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allprojects {

// 네이버 지도 저장소
maven {
url 'https://naver.jfrog.io/artifactory/maven/'
url 'https://repository.map.naver.com/archive/maven'
}

maven { url 'https://jitpack.io' }
Expand Down
Loading