Telerik-Verified-Plugins / Mapbox

Native OpenGL maps for your Cordova app
112 stars 52 forks source link

Button for centering the map to our own geolocation #79

Open cusspvz opened 7 years ago

cusspvz commented 7 years ago

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

cusspvz commented 7 years ago

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

Nauzer commented 7 years ago

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 commented 7 years ago

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

dagatsoin commented 7 years ago

Right. I see those steps:

cusspvz commented 7 years ago

@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:

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

dagatsoin commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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?