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

Double clicking on map produces "Cannot read property '0' of undefined" error #16

Closed
DanielO opened this issue Jul 30, 2018 · 5 comments

Comments

@DanielO
Copy link

DanielO commented Jul 30, 2018

Hi,
If I double click on the map I get this error in the console..

d3.min.js:2 Uncaught TypeError: Cannot read property '0' of undefined
    at Function.t.rotate (d3.min.js:2)
    at HTMLCanvasElement.<anonymous> (celestial.min.js:6)
    at HTMLCanvasElement.t (d3.min.js:1)
    at o (d3.min.js:3)
    at Object.u (d3.min.js:3)
    at Rn (d3.min.js:1)
    at Tn (d3.min.js:1)

If I look at Function.t.rotate..

                    if (r !== t) {
                        r.each("start.zoom", function() {
                            this.__chart__ && (y = this.__chart__),
                            p.rotate(y.r).scale(y.k),
                            l(e)
                        }).tween("zoom:zoom", function() {

The object 'y' has x, y & k properties but not r so d3.rotate gets fed an undefined and chokes.

Not sure if this is related to issue #10 or something with similar symptoms.

@ofrohn
Copy link
Owner

ofrohn commented Jul 31, 2018

Hint: If you delete the min from d3 and celestial where you include them in the html, as in
d3.min.js -> d3.js and celestial.min.js -> celestial.js
you get the proper function names, not minified single-letter ones!

@ofrohn
Copy link
Owner

ofrohn commented Jul 31, 2018

As for the error, it's possible that it's related to #10, but when I try it, the map keeps working despite the error, and on the next move zooms in a bit.
So I just need to properly handle the double click event and zoom in one step straight way, the thing it wants to do anyway...

@DanielO
Copy link
Author

DanielO commented Jul 31, 2018

Interesting - for me it does not zoom in when I double click. I am using Chrome 67.0.3396.99 on OSX FWIW.

@ofrohn
Copy link
Owner

ofrohn commented Aug 7, 2018

Turns out the double click event was already handled, but differently in d3 and the zoom module I use d3.geo.zoom, that clashed with each other. Simply deactivating one and zooming manually did the trick.

If you pull the latest version, it should work now. I also tweaked the zoom levels for the + / - buttons a bit, I think it's less tedious now.

@DanielO
Copy link
Author

DanielO commented Aug 10, 2018

Looks good, thanks.

@DanielO DanielO closed this as completed Aug 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants