Skip to content

Commit

Permalink
made tracking options configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
hwbllmnn committed Mar 20, 2018
1 parent a68b998 commit 1ea4e81
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/Button/GeoLocationButton/GeoLocationButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import OlGeolocation from 'ol/geolocation';
import OlGeomLineString from 'ol/geom/linestring';
import OlOverlay from 'ol/overlay';

import ToggleButton from '../ToggleButton/ToggleButton.jsx';
import { MathUtil } from '../../index';
import {
MathUtil,
ToggleButton
} from '../../index';

import './GeoLocationButton.less';
import mapMarker from '../../../assets/geolocation-marker.png';
Expand Down Expand Up @@ -75,7 +77,13 @@ class GeoLocationButton extends React.Component {
*
* @type {Boolean}
*/
follow: PropTypes.bool
follow: PropTypes.bool,

/**
* The openlayers tracking options.
* @type {Object}
*/
trackingOptions: PropTypes.object
};

/**
Expand All @@ -86,7 +94,12 @@ class GeoLocationButton extends React.Component {
onGeolocationChange: () => undefined,
onError: () => undefined,
showMarker: true,
follow: true
follow: true,
trackingOptions: {
maximumAge: 10000,
enableHighAccuracy: true,
timeout: 600000
}
}

/**
Expand Down Expand Up @@ -175,11 +188,7 @@ class GeoLocationButton extends React.Component {
// Geolocation Control
this.geolocationInteraction = new OlGeolocation({
projection: view.getProjection(),
trackingOptions: {
maximumAge: 10000,
enableHighAccuracy: true,
timeout: 600000
}
trackingOptions: this.props.trackingOptions
});
this.geolocationInteraction.setTracking(true);
if (this.props.showMarker) {
Expand Down

0 comments on commit 1ea4e81

Please sign in to comment.