WEB GL JS

웹 개발, 어플리케이션에서 활용될 수 있도록 Javascript로 제공되는 지도 플랫폼 입니다.

마커 이벤트 활용


routogl 지도에 표시된 마커에 이벤트를 적용하는 예제입니다.
마커를 클릭하면 이벤트가 실행됩니다.

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // 초기 위치 [lng, lat]
  zoom: 19, // 초기 줌 레벨
});

// 이미지 마커 생성
const root = document.createElement('div');

const el = document.createElement('div');
const width = 50;
const height = 50;
el.className = 'marker';
el.style.backgroundImage = `url(https://tile.routo.com/webgis_tile01/Static/images/icon/Marker_Type_A.png)`;
el.style.width = `${width}px`;
el.style.height = `${height}px`;
el.style.backgroundSize = '100%';
el.style.zIndex = 5000; // zIndex 설정

// 이미지 마커에 클릭 이벤트 설정
el.addEventListener('click', () => {
  alert('이미지 마커를 선택했습니다.');
});

root.appendChild(el);

const marker = new routogl.Marker({
  anchor: 'bottom',
  element: root
})
  .setLngLat([127.0586339, 37.507009])
  .addTo(map);