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

ENH: provide mapbox viewport coordinates in relayout data #4399

Closed
jonmmease opened this issue Dec 2, 2019 · 6 comments · Fixed by #4413
Closed

ENH: provide mapbox viewport coordinates in relayout data #4399

jonmmease opened this issue Dec 2, 2019 · 6 comments · Fixed by #4413
Labels
feature something new

Comments

@jonmmease
Copy link
Contributor

I would like the mapbox subplot relayout data to include the lon/lat of the viewport corners. This would make it possible to use a mapbox subplot to display an image layer that is dynamically generated for the current viewport.

The relayout data currently includes mapbox.center, mapbox.zoom, mapbox.bearing, and mapbox.pitch. I would like to propose that we include a mapbox.coordinates property that contains an array of the lon/lat coordinates of the four corners of the viewport.

This would match the coordinates property that is expected in image layers. See https://docs.mapbox.com/mapbox-gl-js/example/image-on-a-map/.

These points can be generated from the mapbox API by following the example in
mapbox/mapbox-gl-js#2375 (comment).

Question:
Could coordinates be something that is added only to relayout data, or would it need to be a new figure property as well? The reason it's not clear to me that it should be a property is that it would be read-only. I don't think we could really support setting coordinates as a way to set where to place the viewport (at least in the case of non-zero bearing and pitch).

@etpinard
Copy link
Contributor

etpinard commented Dec 2, 2019

Could coordinates be something that is added only to relayout data, or would it need to be a new figure property as well?

It could, but it would be a first. At the moment, we only include key-values of the attributes that changed during an interaction.

I think I would prefer emitting coordinates in a different plotly_ event.

@nicolaskruchten
Copy link
Contributor

coordinates is derivable from center/zoom/bearing/pitch but it's much, much easier for that derivation to happen in plotly.js via the mapbox code itself. It makes sense to me to add this in the same event, as a favour to non-JS users of this data :)

@alexcjohnson
Copy link
Collaborator

For now though plotly_relayout event data maps exactly to Plotly.relayout arguments, so in principle folks may be using this to accumulate changes that get fed back to the same or another plot later. If we add in other things that look like attributes, this would lead to invalid figures - mostly silently so, but confusing and potentially painful in case there's any chance we'd add attributes with these names later.

But perhaps we could add something that is clearly NOT an attribute? Like:
_derived: {coordinates: ...}

@nicolaskruchten
Copy link
Contributor

But perhaps we could add something that is clearly NOT an attribute? Like:
_derived: {coordinates: ...}

Yes, this is the kind of thing I was thinking

@etpinard
Copy link
Contributor

etpinard commented Dec 3, 2019

I'd be ok with adding something like _derived: {coordinates: ...}

@etpinard etpinard added the feature something new label Dec 3, 2019
@jonmmease
Copy link
Contributor Author

Works for me! I'll open a PR shortly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants