-
카테고리
-
세부 분야
모바일 앱 개발
-
해결 여부
미해결
Marker 클릭시 해당 Marker size나 또는 색상을 변경할 수 있나요?
23.04.08 18:33 작성 23.04.08 19:04 수정 조회수 252
0
안녕하세요. 문의사항이 있습니다.
네이버 지도에 Marker가 많을 때 임의로 한 마커를 클릭하면
임의로 클릭한 Marker의 사이즈나 색상등을 변경할 수 있는지 문의드립니다.
소스는 아래와 같고,
mapRef.current[index].width = 40
mapRef.current[index].height = 40
이런식으로 변경을 해도 변경이 되지 않아 문의 드립니다.
const mapRef = useRef([]);
<Marker
ref={el => mapRef.current[idx] = el}
key={item.code}
coordinate={location}
image={require("../../assets/images/pin_primary.png")}
width={35}
height={35}
useTextureView={true}
onClick={() => mapClickHanlder(idx)}
//caption={{text:item.title_text}}
/>
const mapClickHanlder = useCallback((index) => {
console.log("map click: ", mapRef.current[index]);
const selectedMarker = mapRef.current[index];
selectMarker.width = 40;
selectMarker.height = 40;
console.log(selectedMarker);
}, []);
답변을 작성해보세요.
0
조현영
지식공유자2023.04.08
ref로 하는 게 아니라 마커를 별도의 컴포넌트로 만들고 image width height를 state로 만들어서 set으로 변경하면 됩니다.
답변 1