Class: Geolocation

cercaliagl.Geolocation


Javascript ES5

const geolocation = new cercaliagl.Geolocation();

Utility the get current geolocation. User browser must be allow to get GPS position. It is possible to handle an event when position is changed.

Example usage.

const map = new Map({
  target: 'map',
  controls: [],
});

map.whenReady(() => {
  const geolocation = new cercaliagl.Geolocation();
  geolocation.setTracking(true);
  geolocation.on('change', () => {
    const marker = new cercaliagl.Marker({
      position: geolocation.getPosition(),
      icon: new cercaliagl.Icon({ src: 'resources/img/geolocation.png' }),
    });
    const geometry = geolocation.getAccuracyGeometry();
    const feature = new cercaliagl.Feature({ geometry: geometry });
    map.addMarker(marker);
    map.addFeature(feature);
    map.centerToFeatures([feature]);
  });
});

new Geolocation()

Methods

getAccuracy(){number}

Returns:
geometry

getAltitudeAccuracy(){number}

getHeading(){number}

getSpeed(){number}

getTracking(){boolean}

Returns:
Tracking

setTracking(tracking)

Name Type Description
tracking boolean

Tracking