question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENH: provide mapbox viewport coordinates in relayout data

See original GitHub issue

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 https://github.com/mapbox/mapbox-gl-js/issues/2375#issuecomment-204297638.

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).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
alexcjohnsoncommented, Dec 3, 2019

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: ...}

0reactions
jonmmeasecommented, Dec 3, 2019

Works for me! I’ll open a PR shortly…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Center the map on a clicked feature | Mapbox GL JS
Create a free account to start building with Mapbox. Use events and flyTo to center the map on a feature in a circle...
Read more >
Examples | Mapbox GL JS
Accept coordinates as input to a geocoder. Use the mapbox-gl-geocoder control to search for places using Mapbox Geocoding API. Add 3D terrain to...
Read more >
Properties and options | Mapbox GL JS
Mapbox GL JS's global properties and options that you can access while initializing your map or accessing information about its status.
Read more >
Fit a map to a bounding box | Mapbox GL JS
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"> ... #map { position: absolute; top: 0; bottom: 0; width: 100%; }. </style>.
Read more >
Geography and geometry | Mapbox GL JS
LngLat and LngLatBounds represent points and rectangles in geographic coordinates. Point represents points in screen coordinates.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found