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

[Map] Modify rotate button to allow switching between North and orientation defined by user #169

Open
3 of 5 tasks
rudokemper opened this issue Nov 5, 2018 · 10 comments
Open
3 of 5 tasks
Assignees
Labels
beginner friendly Good for newcomers Hacktoberfest Hacktoberfest 2023 mapbox / maplibre

Comments

@rudokemper
Copy link
Member

rudokemper commented Nov 5, 2018

Currently, clicking the standard map rotate button brings the user to North exclusively. We should make this button more useful for local communities by using it to switch back and forth between a user-defined orientation and north.

  • Create custom compass icon
  • Change onClick behavior to switch between user-defined orientation and north
  • Add rotation behavior to custom compass icon
  • Add "click and hold" behavior to custom compass icon (@newguyen)
  • Add CMS integration (@rudokemper)
@rudokemper rudokemper added beginner friendly Good for newcomers map labels Nov 5, 2018
@rudokemper rudokemper added this to the Terrastories as a Service milestone Nov 5, 2018
@rudokemper rudokemper changed the title Modify map rotate button to allow switching between North and orientation defined by user [Map] Modify rotate button to allow switching between North and orientation defined by user Apr 10, 2019
@tomekr
Copy link

tomekr commented Jan 20, 2020

Hello! Is the idea here that any registered user will have an extra button of some kind here:

Screen Shot 2020-01-20 at 1 31 25 PM

Where they can set a default orientation and then this setting is saved to their profile?

@tomekr
Copy link

tomekr commented Jan 20, 2020

Here's a little spike I came up with showing my interpretation of it:

user-orient

Unfortunately, the NavigationControl API is pretty limited and there doesn't appear to be much in the way of customization options (but today is the first time I've used the Mapbox API so maybe there is another way outside of just the API).

As a result, I added a separate button that at the moment keeps you where you're looking but just switches to the default bearing and pitch parameters.

@rudokemper
Copy link
Member Author

Hi @tomekr! Thanks for looking into this issue! Sorry if the explanation wasn't clear.

The idea was that that the fourth button (image) could toggle between two different settings: a user-defined orientation, and North. Currently it only switches back to North.

Let's assume you've moved around on the map and adjusted the orientation. Upon the first click of the button, the orientation should switch to the user-defined orientation. Upon the second click, it should switch to North. Third click, back to user-defined, and so on.

If there is no user-defined orientation, then it can be set to North as default. So clicking the button will only bring the user to North.

@tomekr
Copy link

tomekr commented Jan 22, 2020

@rudokemper got it, yea that component on the map is defined by the NavigationControl API (used here in the code. Unfortunately, the API doesn't expose custom behavior for the alternate click.

Could copy it and create a custom component? https://github.com/mapbox/mapbox-gl-js/blob/dd317abdb5c4238fd4149d59431fcf545edfd60d/src/ui/control/navigation_control.js#L35-L145

@rudokemper
Copy link
Member Author

That makes sense to me. @kalimar, any insight?

@kalimar
Copy link
Contributor

kalimar commented Feb 8, 2020

@tomekr that's correct the NavigationControl API is very limited. I think we will need a custom button to control the camera for custom orientations. The easiest thing would be too hide the default NavigationControl and replace it with the custom one.

@rudokemper Where would you like the user to select this? Should it be an option every user has or an admin? Once we decide that, the button is pretty easy to implement.

@tomekr pretty much has it done with the custom button. Happy to clarify what I'm saying if necessary (sorry a little rushed here today).

@rudokemper
Copy link
Member Author

rudokemper commented Feb 10, 2020

@kalimar @tomekr I think that we can have the custom button replacing the default NavigationControl, and having it reset to North only as a standard. Then, somewhere in the code**, there can be a parameter where the administrator can insert a custom orientation. This value is set to blank on a default Terrastories build and therefore ignored by the custom button. Once the administrator defines an orientation using that parameter, the custom button will then use that orientation along with North. I hope that makes sense.

** eventually we will want to build the ability to set the orientation into a UI field in the Terrastories back-end, but this will do for now.

@rudokemper
Copy link
Member Author

Hi @tomekr! Were you still interested in working on this, or maybe sharing a WIP of what you did so somebody else could finish it (and also give you credit as co-author)?

@rudokemper
Copy link
Member Author

@tomekr just following up on the awesome work you did already :)

@rudokemper rudokemper assigned rudokemper and unassigned rudokemper Aug 8, 2022
@newguyen
Copy link

newguyen commented Aug 8, 2022

Hello! I started to look into incorporating Kalimar's suggestion to address this issue and create the functionality. With some of the refactoring going on, would it be possible for me to work on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginner friendly Good for newcomers Hacktoberfest Hacktoberfest 2023 mapbox / maplibre
Projects
None yet
Development

No branches or pull requests

5 participants