33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
import React, { useContext, useState } from 'react';
|
|
import { Button } from "@common/components";
|
|
import { GisContext } from './Gis';
|
|
import GisApp from './lib/gis.core';
|
|
|
|
export default React.memo(function MapToggleBtn() {
|
|
const { gisCore } = useContext(GisContext);
|
|
const [activeMap, setActiveMap] = useState({ label: '일반', type: 'base' }); // 기본 선택값
|
|
|
|
const handleSelect = mapObj => {
|
|
setActiveMap(mapObj);
|
|
gisCore.changeBaseLayer(mapObj.type);
|
|
};
|
|
|
|
return (
|
|
<div className="mapbtn">
|
|
<button className="sprite_gis viewer" title="지도선택">지도 선택</button>
|
|
<ul className="choice_map">
|
|
<li className={activeMap.type === 'base' ? 'on' : ''}>
|
|
<button className="map1" id="base" title="일반지도" onClick={() => handleSelect({ label: '일반', type: 'base' })}>
|
|
<div>일반지도</div>
|
|
</button>
|
|
</li>
|
|
<li className={activeMap.type === 'satellite' ? 'on' : ''}>
|
|
<button className="map2" id="satelite" title="위성지도" onClick={() => handleSelect({ label: '위성', type: 'satellite' })}>
|
|
<div>위성지도</div>
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
);
|
|
});
|