import {useState} from 'react' import {__} from '@wordpress/i18n' // Ours import InfoPanel from './info-panel/InfoPanel.tsx' import NaverMap from './map/NaverMap.tsx' import Marker from './map/Marker.tsx' import {getCenter, getIconSize} from '../libs/helper.ts' // Types. import {GroupedLocationMapObjectValue, MapLocationProps} from '../types' // Styles. import '../styles/grouped-locations-map.css' type Props = GroupedLocationMapObjectValue const { size, scaledSize, origin, anchor, } = getIconSize() export default function GroupedLocationMap(props: Props) { const { atts: { height, post_id, width, zoom, }, data, mapIcons: { normal: normalMarker, selected: selectedMarker, }, } = props const [map, setMap] = useState(null), [selected, setSelected] = useState(-1) if (0 === data.length) { return (
{__('[네이버 지도 에러] 지도에 위치가 설정되지 않았습니다.', 'naver_maps')}
) } return ( <> loc.coord)), disableKineticPan: false, zoom: zoom, }} ref={(_map: naver.maps.Map | null) => setMap(() => _map)} style={{ height, width, }} > {map && data.map((location: MapLocationProps, index: number) => { return ( 0 ? location.alt_title : location.title, }} onClick={() => { if (index === selected) { setSelected(-1) } else { setSelected(index) } }} /> ) })} -1 ? data[selected] : undefined} onClose={() => setSelected(-1)} /> ) }