Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1에 onCameraIdle 이벤트 추가 #114

Open
wants to merge 3 commits into
base: v1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.mjstudio.reactnativenavermap.event

import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event

class NaverMapCameraIdleEvent(
surfaceId: Int,
viewId: Int,
private val latitude: Double,
private val longitude: Double,
private val zoom: Double,
private val tilt: Double,
private val bearing: Double,
) : Event<NaverMapCameraIdleEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

override fun canCoalesce(): Boolean = false

override fun getCoalescingKey(): Short = 0

override fun getEventData(): WritableMap =
Arguments.createMap().apply {
putDouble("latitude", latitude)
putDouble("longitude", longitude)
putDouble("zoom", zoom)
putDouble("tilt", tilt)
putDouble("bearing", bearing)
}

companion object {
const val EVENT_NAME = "topCameraIdle"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.ViewGroup
import com.airbnb.android.react.maps.ViewAttacherGroup
import com.facebook.react.uimanager.ThemedReactContext
import com.mjstudio.reactnativenavermap.event.NaverMapCameraChangeEvent
import com.mjstudio.reactnativenavermap.event.NaverMapCameraIdleEvent
import com.mjstudio.reactnativenavermap.event.NaverMapInitializeEvent
import com.mjstudio.reactnativenavermap.event.NaverMapOptionChangeEvent
import com.mjstudio.reactnativenavermap.event.NaverMapTapEvent
Expand Down Expand Up @@ -69,6 +70,21 @@ class RNCNaverMapView(
}
}

it.addOnCameraIdleListener {
reactContext.emitEvent(reactTag) { surfaceId, reactTag ->
NaverMapCameraIdleEvent(
surfaceId,
reactTag,
it.cameraPosition.target.latitude,
it.cameraPosition.target.longitude,
it.cameraPosition.zoom,
it.cameraPosition.tilt,
it.cameraPosition.bearing,
)
}
}


it.setOnMapClickListener { pointF, latLng ->
reactContext.emitEvent(reactTag) { surfaceId, reactTag ->
NaverMapTapEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.annotations.ReactProp
import com.mjstudio.reactnativenavermap.RNCNaverMapViewManagerSpec
import com.mjstudio.reactnativenavermap.event.NaverMapCameraChangeEvent
import com.mjstudio.reactnativenavermap.event.NaverMapCameraIdleEvent
import com.mjstudio.reactnativenavermap.event.NaverMapCoordinateToScreenEvent
import com.mjstudio.reactnativenavermap.event.NaverMapInitializeEvent
import com.mjstudio.reactnativenavermap.event.NaverMapOptionChangeEvent
Expand Down Expand Up @@ -114,6 +115,7 @@ class RNCNaverMapViewManager : RNCNaverMapViewManagerSpec<RNCNaverMapViewWrapper
registerDirectEvent(this, NaverMapInitializeEvent.EVENT_NAME)
registerDirectEvent(this, NaverMapOptionChangeEvent.EVENT_NAME)
registerDirectEvent(this, NaverMapCameraChangeEvent.EVENT_NAME)
registerDirectEvent(this, NaverMapCameraIdleEvent.EVENT_NAME)
registerDirectEvent(this, NaverMapTapEvent.EVENT_NAME)
registerDirectEvent(this, NaverMapScreenToCoordinateEvent.EVENT_NAME)
registerDirectEvent(this, NaverMapCoordinateToScreenEvent.EVENT_NAME)
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=true
newArchEnabled=false
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true
Loading