simplegeo / polymaps

Polymaps is a free JavaScript library for making dynamic, interactive maps in modern web browsers.
http://polymaps.org/
Other
1.6k stars 213 forks source link

'show' event is called with bad data the first time #128

Open cespare opened 12 years ago

cespare commented 12 years ago

This one caused me a lot of confusion.

The first time a geoJson tile is needed, before the load callback fires, the show callback fires with a callback parameter e that seems invalid (e.features is an empty array). Immediately after this happens, the load callback fires with the expected feature data in the argument, and when the same tile is shown again subsequently, the show callback is called with the feature data as expected (in my scenario I'm using tile(false)).

This seems like strange and incorrect behavior. I ran into this because I'm using the show event to dynamically style the features, and the styling wasn't working the first time the tile is shown (but did work if I zoomed in/out again to re-show the tile). Furthermore, to fix this behavior I had to attach my styling callback to the load event as well, which doesn't seem like it should be necessary.

IMO the correct behavior would be to fire the show event after the load event, and to pass in the new tile's features to the show callback.