WEB JS

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

    공간객체 불러오기


    지도에 GeoJSON 형태의 문자열을 불러와서 공간객체를 생성하는 예제입니다. GeoJSON 은 공간 객체의 목록을 표시하기 위한 JSON 형태의 문자열입니다.

    {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[127.0586339,37.507009000000025]},"properties":null},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[127.03863390000001,37.505009000000015],[127.03863390000001,37.487008999999986],[127.0486339,37.487008999999986],[127.0486339,37.507009000000025]]},"properties":null},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[127.0586339,37.507009000000025],[127.0586339,37.487008999999986],[127.0886339,37.487008999999986],[127.0886339,37.507009000000025],[127.0586339,37.507009000000025]],[[127.06863389999998,37.49700899999999],[127.06863389999998,37.49200899999998],[127.07863390000001,37.49200899999998],[127.07863390000001,37.49700899999999],[127.06863389999998,37.49700899999999]]]},"properties":null}]}
    // 지도를 생성합니다.
    var map = new routo.maps.Map("map");
    
    // GeoJSON 을 요청합니다.
    fetch('./routo-data.json').then(function (response) {
          return response.json();
    }).then(function (geojson) {
          // 불러온 GeoJSON에서 공간 객체 목록을 지도에 추가합니다.
          map.data.addGeoJson(geojson);
    }).catch(function (error) {
    
    });