Skip to content

Commit

Permalink
Merge pull request #89 from mym0404/additional-cluster-properties
Browse files Browse the repository at this point in the history
Additional cluster properties including width, height
  • Loading branch information
mym0404 authored Jul 13, 2024
2 parents 7df3a33 + a619b1b commit c2953a3
Show file tree
Hide file tree
Showing 32 changed files with 933 additions and 1,621 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
}
],
"react-native/no-inline-styles": "off",
"@typescript-eslint/no-unused-vars": "off"
"@typescript-eslint/no-unused-vars": "off",
"react/react-in-jsx-scope": "off"
}
}
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

15 changes: 9 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ jobs:
- name: Setup
uses: ./.github/actions/setup




- name: Cache turborepo for Android
uses: actions/cache@v4
with:
Expand All @@ -93,16 +96,16 @@ jobs:
fi
- name: Install JDK
if: env.turbo_cache_hit != 1
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'

- name: Finalize Android SDK
if: env.turbo_cache_hit != 1
run: |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Display ANDROID_HOME
run: echo $ANDROID_HOME

- name: Cache Gradle
if: env.turbo_cache_hit != 1
Expand Down Expand Up @@ -160,7 +163,7 @@ jobs:
${{ runner.os }}-cocoapods-
- name: Install pod for codegen stuffs
run: yarn pod
run: yarn pod:update
- name: Build example for iOS
run: yarn turbo:ios

67 changes: 37 additions & 30 deletions .husky/_/check
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,50 @@ fi

call_lefthook()
{
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/')

if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook -h >/dev/null 2>&1
then
lefthook "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook"
then
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
fi
}

Expand Down
67 changes: 37 additions & 30 deletions .husky/_/format
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,50 @@ fi

call_lefthook()
{
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/')

if test -n "$LEFTHOOK_BIN"
then
"$LEFTHOOK_BIN" "$@"
elif lefthook -h >/dev/null 2>&1
then
lefthook "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
dir="$(git rev-parse --show-toplevel)"
osArch=$(uname | tr '[:upper:]' '[:lower:]')
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook"
then
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook"
then
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
"$dir/node_modules/lefthook/bin/index.js" "$@"

elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook "$@"
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook "$@"
elif pnpm lefthook -h >/dev/null 2>&1
then
pnpm lefthook "$@"
elif swift package plugin lefthook >/dev/null 2>&1
then
swift package --disable-sandbox plugin lefthook "$@"
elif command -v mint >/dev/null 2>&1
then
mint run csjones/lefthook-plugin "$@"
elif command -v npx >/dev/null 2>&1
then
npx lefthook "$@"
else
echo "Can't find lefthook in PATH"
fi
fi
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import com.mjstudio.reactnativenavermap.event.NaverMapInitializeEvent
import com.mjstudio.reactnativenavermap.event.NaverMapOptionChangeEvent
import com.mjstudio.reactnativenavermap.event.NaverMapScreenToCoordinateEvent
import com.mjstudio.reactnativenavermap.event.NaverMapTapEvent
import com.mjstudio.reactnativenavermap.overlay.marker.cluster.RNCNaverMapClusterDataHolder
import com.mjstudio.reactnativenavermap.overlay.marker.cluster.RNCNaverMapClusterKey
import com.mjstudio.reactnativenavermap.overlay.marker.cluster.RNCNaverMapClustererHolder
import com.mjstudio.reactnativenavermap.overlay.marker.cluster.RNCNaverMapClusterMarkerUpdater
import com.mjstudio.reactnativenavermap.overlay.marker.cluster.RNCNaverMapLeafDataHolder
import com.mjstudio.reactnativenavermap.overlay.marker.cluster.RNCNaverMapLeafMarkerHolder
import com.mjstudio.reactnativenavermap.overlay.marker.cluster.RNCNaverMapLeafMarkerUpdater
import com.mjstudio.reactnativenavermap.util.CameraAnimationUtil
Expand Down Expand Up @@ -69,7 +71,7 @@ class RNCNaverMapViewManager : RNCNaverMapViewManagerSpec<RNCNaverMapViewWrapper
private var isFirstCameraMoving = true
private var lastClustersPropKey = "NOT_SET"

private val clustererHolders = mutableMapOf<String, RNCNaverMapClustererHolder>()
private val clustererHolders = mutableMapOf<String, RNCNaverMapLeafDataHolder>()

private lateinit var reactAppContext: ReactApplicationContext

Expand Down Expand Up @@ -552,6 +554,8 @@ class RNCNaverMapViewManager : RNCNaverMapViewManagerSpec<RNCNaverMapViewWrapper

value.getArray("clusters")?.toArrayList()?.filterIsInstance<Map<String, Any?>>()?.forEach {
val clustererKey = it["key"] as? String
val clusterWidth = it["width"] as? Double
val clusterHeight = it["height"] as? Double
val screenDistance = it["screenDistance"] as? Double
val minZoom = it["minZoom"] as? Double
val maxZoom = it["maxZoom"] as? Double
Expand All @@ -561,6 +565,8 @@ class RNCNaverMapViewManager : RNCNaverMapViewManagerSpec<RNCNaverMapViewWrapper
val clusterer =
Clusterer
.Builder<RNCNaverMapClusterKey>()
.clusterMarkerUpdater(RNCNaverMapClusterMarkerUpdater(RNCNaverMapClusterDataHolder(clusterWidth, clusterHeight)))
.leafMarkerUpdater(RNCNaverMapLeafMarkerUpdater())
.also { cluster ->
if (screenDistance != null) {
cluster.screenDistance(screenDistance)
Expand All @@ -574,8 +580,7 @@ class RNCNaverMapViewManager : RNCNaverMapViewManagerSpec<RNCNaverMapViewWrapper
if (animate != null) {
cluster.animate(animate)
}
}.leafMarkerUpdater(RNCNaverMapLeafMarkerUpdater())
.build()
}.build()

val keyPairs =
markers.associate { marker ->
Expand All @@ -587,14 +592,13 @@ class RNCNaverMapViewManager : RNCNaverMapViewManagerSpec<RNCNaverMapViewWrapper
val height = marker["height"] as? Double

RNCNaverMapClusterKey(
identifier,
LatLng(latitude, longitude),
image,
width,
height,
RNCNaverMapLeafMarkerHolder(
identifier,
reactAppContext,
latlng = LatLng(latitude, longitude),
context = reactAppContext,
image,
width,
height,
onTapLeaf =
if (isLeafTapCallbackExist) {
{
Expand All @@ -618,7 +622,7 @@ class RNCNaverMapViewManager : RNCNaverMapViewManagerSpec<RNCNaverMapViewWrapper
clusterer.addAll(keyPairs)
clusterer.map = map
clustererHolders[clustererKey!!] =
RNCNaverMapClustererHolder(
RNCNaverMapLeafDataHolder(
clustererKey,
clusterer,
reactAppContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.mjstudio.reactnativenavermap.overlay.marker.cluster

internal data class RNCNaverMapClusterDataHolder internal constructor(
val width: Double? = null,
val height: Double? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import com.naver.maps.geometry.LatLng
import com.naver.maps.map.clustering.ClusteringKey

internal data class RNCNaverMapClusterKey(
val identifier: String,
val latlng: LatLng,
val image: Map<*, *>? = null,
val width: Double?,
val height: Double?,
val holder: RNCNaverMapLeafMarkerHolder,
) : ClusteringKey {
override fun getPosition(): LatLng = latlng
override fun getPosition(): LatLng = holder.latlng
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.mjstudio.reactnativenavermap.overlay.marker.cluster

import com.mjstudio.reactnativenavermap.util.px
import com.naver.maps.map.clustering.ClusterMarkerInfo
import com.naver.maps.map.clustering.DefaultClusterMarkerUpdater
import com.naver.maps.map.overlay.Marker
import com.naver.maps.map.overlay.Marker.SIZE_AUTO

internal class RNCNaverMapClusterMarkerUpdater(
private val holder: RNCNaverMapClusterDataHolder,
) : DefaultClusterMarkerUpdater() {
override fun updateClusterMarker(
info: ClusterMarkerInfo,
marker: Marker,
) {
super.updateClusterMarker(info, marker)
val (width, height) = holder
marker.width = width?.px ?: SIZE_AUTO
marker.height = height?.px ?: SIZE_AUTO
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.facebook.react.bridge.ReactApplicationContext
import com.mjstudio.reactnativenavermap.util.image.createDraweeHierarchy
import com.naver.maps.map.clustering.Clusterer

internal data class RNCNaverMapClustererHolder internal constructor(
internal data class RNCNaverMapLeafDataHolder internal constructor(
val identifier: String,
val clusterer: Clusterer<RNCNaverMapClusterKey>,
val context: ReactApplicationContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import com.facebook.drawee.generic.GenericDraweeHierarchy
import com.facebook.drawee.view.DraweeHolder
import com.facebook.react.bridge.ReactApplicationContext
import com.mjstudio.reactnativenavermap.util.image.createDraweeHierarchy
import com.naver.maps.geometry.LatLng

internal data class RNCNaverMapLeafMarkerHolder(
val identifier: String,
val latlng: LatLng,
val context: ReactApplicationContext,
val image: Map<*, *>? = null,
val width: Double?,
val height: Double?,
val onTapLeaf: (() -> Unit)?,
) {
val imageHolder: DraweeHolder<GenericDraweeHierarchy> by lazy {
Expand Down
Loading

0 comments on commit c2953a3

Please sign in to comment.