{"action":"opened","issue":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/6789","repository_url":"https://api.github.com/repos/mapbox/mapbox-gl-js","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/6789/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/6789/comments","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-js/issues/6789/events","html_url":"https://github.com/mapbox/mapbox-gl-js/issues/6789","id":330639174,"node_id":"MDU6SXNzdWUzMzA2MzkxNzQ=","number":6789,"title":"Allow GeolocateControl to be cancellable","user":{"login":"aendrew","id":185041,"node_id":"MDQ6VXNlcjE4NTA0MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/185041?v=4","gravatar_id":"","url":"https://api.github.com/users/aendrew","html_url":"https://github.com/aendrew","followers_url":"https://api.github.com/users/aendrew/followers","following_url":"https://api.github.com/users/aendrew/following{/other_user}","gists_url":"https://api.github.com/users/aendrew/gists{/gist_id}","starred_url":"https://api.github.com/users/aendrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aendrew/subscriptions","organizations_url":"https://api.github.com/users/aendrew/orgs","repos_url":"https://api.github.com/users/aendrew/repos","events_url":"https://api.github.com/users/aendrew/events{/privacy}","received_events_url":"https://api.github.com/users/aendrew/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-08T12:29:48Z","updated_at":"2018-06-08T12:29:48Z","closed_at":null,"author_association":"NONE","body":"## Motivation\r\n\r\nMy particular use case involves geolocating UK users and firing the normal GeolocateControl behaviour if they're within the UK, displaying error messaging if they're outside it. Currently the `geolocate` event isn't cancellable because it merely contains the `Position` data and not any methods governing how the rest of the interaction works. \r\n\r\nI've added a Stack Overflow question [here](https://stackoverflow.com/questions/50759799/canceling-geolocation-behaviour-in-mapboxgl) in case there's a workaround I'm missing but having looked through the source of [geolocate_control.js](https://github.com/mapbox/mapbox-gl-js/blob/master/src/ui/control/geolocate_control.js) it really doesn't seem possible at present.\r\n\r\n<!--\r\nWhat problem are we trying to solve?  Please link any relevant issues.\r\nWhat use cases are we trying to accommodate?\r\n\r\nFocus on the problem and save design ideas for the next section.\r\n-->\r\n\r\n## Design Alternatives\r\n\r\nMove the firing of the `geolocate` event from [here](https://github.com/mapbox/mapbox-gl-js/blob/master/src/ui/control/geolocate_control.js#L183) to the `_onSuccess` callback; make `geolocate` event cancelable. \r\n\r\n<!--\r\nHow could we accommodate the use cases above?\r\nIs \"do nothing\" an option?\r\n-->\r\n\r\n## Design\r\n\r\n`geolocate` should be a cancelable event; calling `event.preventDefault` causes the behaviour of zooming/panning to the user position and placing the relevant marker to be cancelled\r\n"}}
{"actor":{"display_login":"aendrew"}}