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

Button for centering the map to our own geolocation #79

Open
cusspvz opened this issue Jun 5, 2017 · 8 comments
Open

Button for centering the map to our own geolocation #79

cusspvz opened this issue Jun 5, 2017 · 8 comments

Comments

@cusspvz
Copy link
Contributor

cusspvz commented Jun 5, 2017

This issue is a proposal for introducing a button that handles the map centering to the user's geolocation.

@cusspvz
Copy link
Contributor Author

cusspvz commented Jun 5, 2017

@dagatsoin @EddyVerbruggen @Anothar what's the difficulty we would have to implement this?

@Nauzer
Copy link

Nauzer commented Jun 6, 2017

Hi @cusspvz.

Why not use your own button that you position on top of the map and use:

Mapbox.setCenter(
  {
    lat: 52.3602160, // mandatory
    lng: 4.8891680,  // mandatory
    animated: false  // default true
  }
);

@cusspvz
Copy link
Contributor Author

cusspvz commented Jun 6, 2017

Hey @Nauzer, thanks for your reply. Because we cannot place elements over the mapview yet.

@dagatsoin
Copy link

Right.
I see those steps:

  • create a custom View/Button
  • add a click listener to it
  • write a method to retrieve position
  • add a RegisterUserPositionCallback to register a callback to send back the position to the JS part.
  • optional: add an option to pass down a custom image for the button (inspired by Feature image marker #42)

@cusspvz
Copy link
Contributor Author

cusspvz commented Jun 7, 2017

@dagatsoin nice! Seems we got a path.

Although the button placement and position should be optional, don't you agree?

If I had to design an API I would do it like:

  • having a boolean option on map creation that sets if the button will be actually visible/placed or not - geolocationButton
  • having a callback, in case we want to pass to the JS side whenever that button was clicked - onGeolocationButtonClickCallback
  • having an option to determine the button's position over the map - ENUM( 'top-left', 'top-right', 'bottom-left', 'bottom-right', 'middle-left', 'middle-right' ), as it should have a default I would choose 'top-left'.

Note: Doesn't the mapbox gl native provides some sort of controls mechanisms already?

@dagatsoin
Copy link

That seems good, but I would prefer the option to specify the layout params for the button instead of restrictive ENUM values so: (int width, int height, int left, int top, int right, int bottom)

@cusspvz
Copy link
Contributor Author

cusspvz commented Jun 8, 2017

Nice come up @dagatsoin ! I prefer it as well, but how would you handle the non-specified ones? Should they be int or either null, being null the default?

@dagatsoin
Copy link

dagatsoin commented Jun 10, 2017

What about passing an object {width, height, left, top, right, bottom}?

The native method should also have a default place/dimension. So the passing value will just override the default position.

About the implementation of the default position in the native method, I used to use LayoutParams object to set size and margin.
I don't know a lot about android layout. Maybe @Anothar could help us find a better way?

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

3 participants