Skip to content

Commit 3fe40ed

Browse files
author
Dino
committed
android > marker caption > offset 파라미터 누락, px to dp 변환 추가
1 parent 39b6481 commit 3fe40ed

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

android/src/main/java/com/github/quadflask/react/navermap/RNNaverMapMarker.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,12 @@ public void setHeight(int height) {
148148
feature.setHeight(height);
149149
}
150150

151-
public void setCaption(String text, int textSize, int color, int haloColor, Align... aligns) {
151+
public void setCaption(String text, int textSize, int color, int haloColor, int offset, Align... aligns) {
152152
feature.setCaptionText(text);
153153
feature.setCaptionTextSize(textSize);
154154
feature.setCaptionColor(color);
155155
feature.setCaptionHaloColor(haloColor);
156+
feature.setCaptionOffset(offset);
156157
feature.setCaptionAligns(aligns);
157158
}
158159

android/src/main/java/com/github/quadflask/react/navermap/RNNaverMapMarkerManager.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.github.quadflask.react.navermap.ReactUtil.parseAlign;
2020
import static com.github.quadflask.react.navermap.ReactUtil.parseColorString;
2121
import static com.github.quadflask.react.navermap.ReactUtil.toNaverLatLng;
22+
import static com.github.quadflask.react.navermap.ReactUtil.px2dp;
2223

2324
public class RNNaverMapMarkerManager extends EventEmittableViewGroupManager<RNNaverMapMarker> {
2425
private static final Align DEFAULT_CAPTION_ALIGN = Align.Bottom;
@@ -136,9 +137,10 @@ public void setCaption(RNNaverMapMarker view, ReadableMap map) {
136137
int textSize = map.hasKey("textSize") ? map.getInt("textSize") : 16;
137138
int color = map.hasKey("color") ? parseColorString(map.getString("color")) : Color.BLACK;
138139
int haloColor = map.hasKey("haloColor") ? parseColorString(map.getString("haloColor")) : Color.WHITE;
140+
int offset = map.hasKey("offset") ? px2dp(map.getInt("offset"), metrics) : 0;
139141
Align align = map.hasKey("align") ? parseAlign(map.getInt("align")) : DEFAULT_CAPTION_ALIGN;
140142

141-
view.setCaption(text, textSize, color, haloColor, align);
143+
view.setCaption(text, textSize, color, haloColor, offset, align);
142144
}
143145

144146
@Override

android/src/main/java/com/github/quadflask/react/navermap/ReactUtil.java

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.quadflask.react.navermap;
22

33
import android.content.Context;
4+
import android.util.DisplayMetrics;
45
import android.graphics.Color;
56
import android.graphics.PointF;
67

@@ -163,4 +164,10 @@ public static Context getNonBuggyContext(ThemedReactContext reactContext, ReactA
163164
}
164165
return superContext;
165166
}
167+
168+
public static int px2dp(int px, DisplayMetrics metrics){
169+
float dp = px * ((float) metrics.density);
170+
171+
return (int) dp;
172+
}
166173
}

0 commit comments

Comments
 (0)