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

Don't specify fixed zoom, bearing and pitch for geolocateControl #3936

Closed
carrickpaul opened this issue Jan 10, 2017 · 2 comments
Closed

Don't specify fixed zoom, bearing and pitch for geolocateControl #3936

carrickpaul opened this issue Jan 10, 2017 · 2 comments

Comments

@carrickpaul
Copy link

Motivation

The geolocateControl currently sets the zoom, bearing and pitch to default fixed values on success.
This works for a limited use cases (imagine a map of the world and you want to see what country you're in and it zooms to street level).

You can set the zoom level on the geolocate event, but I'd argue that should be the exception not the norm.

Currently retaining the same zoom after a geolocate is difficult (impossible?) as you have to get the zoom level before the geolocate event is fired, and since it uses a normal zoom function there is no way to differentiate it from other zoom events.

Design Alternatives

  1. Remove the default settings from the success function so the map retains zoom, bearing and pitch by default.
    The user get the same functionality as the current hard coded values using
geoLocate.on('geolocate', function(e) {
  map.setZoom(17)
  map.setBearing(0)
  map.setPitch(0)
})
  1. Pass in options to set these properties on the control (messy?)

Implementation

for

class GeolocateControl extends Evented {

change this

_onSuccess(position) {
  this._map.jumpTo({
    center: [position.coords.longitude, position.coords.latitude],
    zoom: 17,
    bearing: 0,
    pitch: 0
   })
}

to this

_onSuccess(position) {
  this._map.jumpTo({
    center: [position.coords.longitude, position.coords.latitude]
   })
}

mapbox-gl-js version:
v0.30.0

@andrewharvey
Copy link
Collaborator

andrewharvey commented Jan 12, 2017

I think this is fixed by #3737 #3781, although to be honest I haven't checked that fitBounds respects the bearing and pitch.

UPDATE: I've tested this, fitBounds will respect the pitch but resets bearing to 0, so when #3737 #3781 lands it will respect pitch but not bearing. It won't respect zoom but it will respect the maxZoom option.

I couldn't find an existing issue for fitBounds respecting bearing. That said, the geolocation control shouldn't use fitBounds rather it should fit to the center + radius so that at 45deg bearings the map fits the real accuracy circle.

@andrewharvey
Copy link
Collaborator

I couldn't find an existing issue for fitBounds respecting bearing. That said, the geolocation control shouldn't use fitBounds rather it should fit to the center + radius so that at 45deg bearings the map fits the real accuracy circle.

This will ultimately be fixed by #2112

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

No branches or pull requests

2 participants