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

Event object types required by new Evented#fire are not exported #6522

Closed
bfrengley opened this issue Apr 16, 2018 · 9 comments
Closed

Event object types required by new Evented#fire are not exported #6522

bfrengley opened this issue Apr 16, 2018 · 9 comments

Comments

@bfrengley
Copy link
Contributor

mapbox-gl-js version: master (to be release 0.45.0)

With the changes in 87c6332 made as a part of #6218, Evented#fire (and by extension Map#fire) expects an Event object rather than a string, as previously. However, the Event and ErrorEvent types are not exposed to mapbox-gl-js consumers, while the Evented class is documented as part of the public API.

Calls to Map#fire can be made by creating an object in the shape of an Event object (e.g., map.fire({ type: 'move', originalEvent: e })), but with the lack of documentation of Event and ErrorEvent, this isn't obvious.

Is there intention to export and/or document these types?

@jfirebaugh
Copy link
Contributor

No, the intention is that Evented#fire is private as of the next release; see 2b64571.

If you can tell us more about your use of map.fire, we may be able to suggest an alternative.

@bfrengley
Copy link
Contributor Author

Ah, I missed that--my bad.

Currently we have custom implementations of ScrollZoomHandler and DragPanHandler which better suit our requirements, and we are using map.fire to manually fire move/zoom/scroll and their complementary start/end events.

@jfirebaugh
Copy link
Contributor

Related: mapbox/mapbox-gl-draw#766

@jfirebaugh
Copy link
Contributor

Thanks for reporting this. We elected to roll back that change until we have a suitable replacement for your use case; Map#fire will continue to support the existing usage in the meantime.

@bfrengley
Copy link
Contributor Author

Thanks! 🙂

@schorsch
Copy link

schorsch commented May 4, 2018

Sorry to ask, as i could not find a discussion about that in other tickets, but what are the reasons to privatice Evented?
Some kind of event handling is needed anyway for the default events, map.on('xy) , so where are the problems to expose such to custom events?

@foundryspatial-duncan
Copy link

foundryspatial-duncan commented Jun 6, 2018

If you can tell us more about your use of map.fire, we may be able to suggest an alternative.

Can you please advise on how to simulate a map click at given coordinates? It used to be something like map.fire('click', <something>); - I can't think of how I'd do this with an external event emitting library.

edit: nevermind, I was hung up on problems explained in this issue.

The project I'm working on is still using 0.44.2 anyway, but the docs for that version are gone from the website (?)

@korywka
Copy link
Contributor

korywka commented Oct 30, 2018

@jfirebaugh fire is good for custom plugins:

https://www.mapbox.com/mapbox-gl-js/api/#icontrol

Other way we need to pass callbacks to constructor 😞

@allthesignals
Copy link
Contributor

allthesignals commented Jan 24, 2020

@jfirebaugh Is there a main thread for discussion about the future of Map#fire? I am running across a few relevant threads, both issues and PRs:

mapbox/mapbox-gl-draw#766
#6605
#6607
#6604

I ask because I would like to build out some functionality on the mapbox-gl-accessibility plugin, but it would depend on Map#fire. I'd like to see if there's a plan for this method before going forward.

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

No branches or pull requests

6 participants