Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTML5 navigator.geolocation options as input to the Geolocate control #3473

Closed
andreipopovici opened this issue Oct 27, 2016 · 4 comments

Comments

@andreipopovici
Copy link

Motivation

For mobile uses of Mapbox GL, developers would appreciate the enableHighAccuracy option to enable the device's GPS.

Design Alternatives

In https://github.com/mapbox/mapbox-gl-js/blob/master/js/ui/control/geolocate_control.js#L8, the options to be passed to navigator.geolocation.getCurrentPosition() are hard-coded.

This object could be made a property of the options object passed to the Geolocate control before adding it to the map UI.

Design

Advantage: finer-grained control for advanced use, with sensible (i.e. current) defaults.

Implementation

class GeolocateControl extends Control {

    constructor(options) {
        super();
        this._geoOptions = options && options.geoOptions || { enableHighAccuracy: false, timeout: 6000 /* 6sec */ }
        this._position = options && options.position || 'top-right';
    }

[...]

window.navigator.geolocation.getCurrentPosition(this._success.bind(this), this._error.bind(this), this._geoOptions);
@mollymerp
Copy link
Contributor

@andreipopovici thank you for submitting your issue! we would happily consider a pull request implementing this feature.

@andrewharvey
Copy link
Collaborator

hey @andreipopovici I like this idea, are you planning on implementing this as a pull request? If you are great, but if not I'll give this a go. I just don't want to step on your toes if you're working on it.

@andreipopovici
Copy link
Author

andreipopovici commented Dec 3, 2016 via email

andrewharvey added a commit to andrewharvey/mapbox-gl-js that referenced this issue Dec 5, 2016
lucaswoj pushed a commit that referenced this issue Dec 6, 2016
* add Geolocation PositionOptions as option to Geolocate Control (#3473)

* add option to watchPosition to Geolocate Control
@andrewharvey
Copy link
Collaborator

This issue should be closed by #3739

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants