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.

onViewportChange not triggered using NavigationControl

See original GitHub issue

Describe the bug Using default map zoom controls not triggering viewport change event in parent <MapGL>

To Reproduce Steps to reproduce the behavior:

  1. Go to docs example https://urbica.github.io/react-map-gl/#/Controls/NavigationControl
  2. Edit code block adding onViewportChange={viewport=>console.log(JSON.stringify(viewport))} to <MapGL> component
  3. Open console, drag map center…see new viewport config in console
  4. Change zoom using +/- in NavControl … no output

Expected behavior Would expect event to be triggered using NavigationControl but instead it only seems to affect the map-gl instance

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Chrome

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
stepankuzmincommented, Aug 26, 2019

Thanks for the research, @jperals!

Unfortunately we can’t remove check for originalEvent because it is the only way to detect user-initiated events. The most concise way to fix this issue, IMO, is to add originalEvent to events initiated using NavigationControl.

I’ve created PR for this in mapbox-gl-js repo https://github.com/mapbox/mapbox-gl-js/pull/8693

1reaction
stepankuzmincommented, Aug 26, 2019

Hey @jperals! It would be really great! PRs are welcome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rotation control in NavigationControl doesn't work in react ...
I am having an issue with the rotation control not working for react-map-gl. The map renders without and issue and the zoom in/out...
Read more >
react-map-gl | Upgrade Guide
Upgrading to v4. onChangeViewport is removed, use onViewportChange instead; Immutable.js is no longer a dependency; Export experimental.
Read more >
PLAY WITH MAPS IN REACT USING MAPBOX
ADDING A MAP COMPONENT. To include a simple map, first import the MapGL and NavigationControl to show the map and the controls on...
Read more >
react-map-gl - You.com | The Search Engine You Control
react-map-gl makes using Mapbox GL JS in React applications easy. ... by onViewportChanged will now contain additional state fields (tracking not only pitch ......
Read more >
Fit viewport to markers using react-map-gl - DEV Community ‍ ‍
In this post I'm gonna show you how to fit the map viewport to the markers we have ... { Marker, NavigationControl }...
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