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

Added zoom to location fields #1835

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

iainbeeston
Copy link
Contributor

Description

I've added an extra attribute to the location field so you can override the zoom level in the resource. I've also made mapkick show the map controls so users can zoom in and out if they want to.

Fixes # (issue)

Right now location fields always load at the default zoom level of 15 and there's no way to customize it.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Manual review steps

  1. Find a resource with a location field in the code
  2. View a model that uses that resource and see the zoom level of the location (should be very zoomed-in)
  3. Edit the code so that the field has zoom: 1 on the location field
  4. Reload the page
  5. Check that the location field is now zoomed out really far

Manual reviewer: please leave a comment with output from the test if that's the case.

Right now location fields always load at the default zoom level of 15 and there's no way to customize it.

I've added an extra attribute to the location field so you can override the zoom level in the resource. I've also made mapkick show the map controls so users can zoom in and out if they want to.
@codeclimate
Copy link

codeclimate bot commented Jul 7, 2023

Code Climate has analyzed commit 9943d61 and detected 0 issues on this pull request.

View more on Code Climate.

@adrianthedev adrianthedev added the Enhancement New feature or request label Jul 7, 2023
iainbeeston added a commit to iainbeeston/vitepress-docs that referenced this pull request Jul 7, 2023
@iainbeeston
Copy link
Contributor Author

I've added documentation for this in avo-hq/docs.avohq.io#66


def initialize(id, **args, &block)
hide_on :index
super(id, **args, &block)

@stored_as = args[:stored_as].present? ? args[:stored_as] : nil # You can pass it an array of db columns [:latitude, :longitude]
@zoom = args[:zoom].present? ? args[:zoom].to_i : 15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just saw on the docs that @zoom accept values between [0, 22] I think that would be interesting to raise an informative error about the accepted range if for some reason the value goes out of this range. @iainbeeston and @adrianthedev what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's a good idea... but what is the best way to do that? Should it raise an error if that happens?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first thought was "let's just take the argument from the user and if it's greater than 22, then we force it as 22, but that would generate some technical support as "why isn't Avo working and not letting me add a number greater than 22".
The second thought I had was, to raise an error when that number is greater than 22. But what if the API changes at some point? We'd have to maintain that parity between our validation and the external API.
Now, I'm thinking of just leaving it without validation and directing the user towards the original library (mapkick) because of those two reasons.

So my vote goes to leaving it like that and instructing the user that we only forward the options to the original library.

@Paul-Bob
Copy link
Contributor

Paul-Bob commented Jul 7, 2023

Thank you for the amazing work @iainbeeston!

@adrianthedev
Copy link
Collaborator

Climbing the ladder @iainbeeston
https://avo-hq.github.io/contributors/

@adrianthedev adrianthedev reopened this Jul 7, 2023
@adrianthedev adrianthedev merged commit 35597f5 into avo-hq:main Jul 7, 2023
19 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants