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: 17, // 초기 줌 레벨
});

map.on('load', () => {
  // 원 소스 생성
  map.addSource('circleSource', {
    'type': 'geojson',
    'data': {
      'type': 'Feature',
      'geometry': {
        'type': 'Point',
        'coordinates': [127.0584339, 37.507009]
      }
    }
  });

  // 원 스타일이 정의된 레이어 생성
  map.addLayer({
    'id': 'circleLayer',
    'type': 'circle',
    'source': 'circleSource',
    'layout': {},
    'paint': {
      'circle-radius': 10,
      'circle-color': '#B42222',
      'circle-opacity': 0.6,
      'circle-stroke-color': '#142311',
      'circle-stroke-opacity': 1,
      'circle-stroke-width': 5
    }
  });
});

// 원 삭제
const removeCircle = document.getElementById('removeCircle');
removeCircle.addEventListener('click', () => {
  if (map.getLayer('circleLayer')) map.removeLayer('circleLayer');
  map.removeSource('circleSource');
});