GeolocateControl : 위치 컨트롤
지도 위에 올릴 수 있는 위치 컨트롤입니다. 생성되는 기본 위치는 top-right입니다.
해당 버튼을 사용해 브라우저의 Geolocation API로 사용자의 위치를 맵에 표시할 수 있습니다.
Chrome을 포함한 최신 브라우저에 대한 위치정보 지원을 위해서는 사이트가 HTTPS를 통해 제공되어야 합니다.

GeolocateControl로 사용할 수 있는 기본 옵션은 GeolocateOptions를 확인해주세요.


[GeolocateControl 생성 방법]
GeolocateControl은 Map 생성 후 addControl로 생성할 수 있습니다.
Map 생성 시 MapOptions으로도 GeolocateControl을 설정할 수 있으며, 더 자세한 설명은 MapMapOptions을 통해 확인할 수 있습니다.

Example

map.addControl(new ktGms.control.GeolocateControl({}));
map.addControl(new ktGms.control.GeolocateControl({
positionOptions: {enableHighAccuracy: false, timeout: 6000},
fitBoundsOptions: {maxZoom:15},
trackUserLocation: false,
showUserLocation: true,
showAccuracyCircle: true,
}), 'top-left');

See

GeolocateControl 위치 컨트롤 생성 예제

Hierarchy

  • GeolocateControl

Implements

  • IControl

Constructors

Methods

Constructors

Methods

  • Parameters

    • type: string

      수신할 이벤트 유형입니다.

      • trackuserlocationend : GeolocateControl이 백그라운드 상태로 변경될 때 - trackUserLocation을 true로 설정해 지도에 표출되는 dot은 이동하고, camera는 이동하지 않는 상태에서 사용자가 camera를 움직였을 때
      • trackuserlocationstart : GeolocateControl이 활성 잠금 상태로 변경될 때 - 처음 Geolocation API가 success로 반환되었을 때(이후 geolocate event 호출됨), 마지막으로 알려진 위치를 사용하여 위치 업데이트가 발생했을 때(geolocate event는 호출되지 않음)
      • geolocate : Geolocation API가 success로 반환되고, 위치 업데이트가 일어날 때
      • error : Geolocation API가 error로 반환되고, 위치 업데이트가 일어날 때
      • outofmaxbounds : Geolocation API가 success로 반환되었지만, map maxBounds를 벗어난 위치 업데이트가 일어날 때
    • listener: Listener

      이벤트가 발생했을 때 호출되는 콜백함수입니다.

    Returns GeolocateControl

    this

  • on에서 추가했던 이벤트에 대한 콜백 리스너를 제거합니다.

    Parameters

    • type: string

      추가했던 이벤트 유형입니다.

    • listener: Listener

      제거할 이벤트 리스너(콜백함수)입니다.

    Returns GeolocateControl

    this

  • 이벤트가 발생할 때 한 번만 호출되는 콜백 리스너를 추가합니다. 이벤트가 처음 발생했을 때에만 콜백 리스너가 호출됩니다.

    Parameters

    • type: string

      수신할 이벤트 유형입니다. 이벤트 유형은 on와 동일합니다.

    • Optional listener: Listener

      이벤트가 발생했을 때 한 번만 호출되는 콜백함수입니다.

    Returns Promise<any> | GeolocateControl

    this

  • 사용자 위치 정보 요청을 보내고 map을 사용자 위치로 이동합니다.

    Returns boolean

    control이 지도에 추가되기 전에 호출되면 false, 아니라면 true를 반환합니다.

    Example

    let geolocate = new ktGms.control.GeolocateControl({});
    map.addControl(geolocate);
    map.on('load', function(){
    geolocate.trigger();
    })

Generated using TypeDoc