-
Notifications
You must be signed in to change notification settings - Fork 28
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
79 center zoom hash #187
79 center zoom hash #187
Conversation
The © info and map scale are hidden behind the content on ≥ large screens |
Seems like the map pan/zooms on route change on very large screens but not on smaller screens. |
This needs to account for the $breakpoints: (
small: 0,
medium: 640px,
large: 1024px,
xlarge: 1200px,
xxlarge: 1440px,
); |
To keep the media queries in sync with the JS consider using this method to have the CSS tell the JavaScript which media query is being used: http://zerosixthree.se/detecting-media-queries-with-javascript/ |
Will tackle tomorrow, not ready to merge yet |
# Conflicts: # app/styles/layouts/_l-default.scss
app/components/main-map.js
Outdated
@@ -43,8 +43,16 @@ export default Ember.Component.extend({ | |||
const height = el.height(); | |||
const width = el.width(); | |||
|
|||
const fullWidth = $('.navigation-area').width(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chriswhong is this the only div where we can get correct information about the width of the screen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's just the closest one. Just need something full width so we can calculate the percentage that the details pane will take up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it - so I think window width will do.
app/components/main-map.js
Outdated
return { | ||
padding: selected && (type !== 'zoning-district') ? padding : 0, | ||
offset: [offset, 0], | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chriswhong what should this computed be doing in terms of the view? Having trouble figuring out how to test / verify. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^^ I have some ideas on how to approach this differently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This offsets the fitbounds, I am not sure how you would test the output, you would need to be able to read the centerpoint of the map vs the center of the highlighted polygon somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I just mean manual testing. Why does zoning-district get padding but not others? Thanks!
app/components/main-map.js
Outdated
@computed('mainMap.shouldFitBounds') | ||
shouldFitBounds(shouldFitBounds) { | ||
return shouldFitBounds; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll refactor this to a computed alias (shrink 4 lines of code into 1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, shouldFitBounds: alias('mainMap.shouldFitBounds')
app/routes/index.js
Outdated
didTransition() { | ||
this.get('mainMap').set('selected', null); | ||
this.get('mainMap').set('shouldFitBounds', false); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take care of this but if you're setting on a property you don't need to get it, you can just write:
this.set('mainMap.selected',null);
Alternatively, if there are multiple properties, you can just say:
this.get('mainMap')
.setProperties({
selected: null,
shouldFitBounds: false,
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to know!
app/routes/lot.js
Outdated
@@ -14,5 +14,6 @@ export default Ember.Route.extend({ | |||
afterModel(model) { | |||
const mainMap = this.get('mainMap'); | |||
mainMap.set('selected', model); | |||
mainMap.set('shouldFitBounds', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, I'll take care of it tonight:
this.get('mainMap')
.setProperties({
selected: null,
shouldFitBounds: false,
});
app/routes/zma.js
Outdated
const application = this.controllerFor('application'); | ||
application.resetQueryParams(); | ||
didTransition() { | ||
this.get('mainMap').set('shouldFitBounds', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.set('mainMap.shouldFitBounds', true);
app/routes/zoning-district.js
Outdated
|
||
actions: { | ||
didTransition() { | ||
this.get('mainMap').set('shouldFitBounds', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
I pulled down the latest on this and got a weird merge conflict. I fixed the |
…a into 79-center-zoom-hash
Resize was being called before a route transition finished (and actually affected the DOM) and after a fitBounds animation finished, meaning it never had the correct DOM context to resize properly. Two things had to happen: - ember-mapbox-gl’s call needed to be wrapped in an afterRender callback in the Run cycle so that things were synchronous - resize() must be called before fitBounds, but after a render has completed Fix is now in place globally, but resize is commented out for now pending some other decision.
Also don’t use private variables
In favor of 2 commits ago
…a into 79-center-zoom-hash
@chriswhong @andycochran There is a long discussion thread on this related issue here: mapbox/mapbox-gl-js#1740. Basically, MapboxGL does not yet provide a way to globally offset the map's internal concept of a "center", although it does provide an "around" option (https://www.mapbox.com/mapbox-gl-js/api/#cameraoptions) for a select few panning/zoom methods. I think this will have to be the working solution for now but we'll need to find a more organized way to deal with the layout widths to calculate offsets since that will cause issues for mobile and other views. |
This PR adds the mapboxGL map hash, allowing us to persist map views on page reload.
It also changes the fitbounds behavior
TODO: Add logic to
fitBoundsOptions
to make sure it works on mobile