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

Width and height of jQuery Vector map not getting set #109

Closed
ghost opened this issue Feb 19, 2014 · 3 comments
Closed

Width and height of jQuery Vector map not getting set #109

ghost opened this issue Feb 19, 2014 · 3 comments

Comments

@ghost
Copy link

ghost commented Feb 19, 2014

I'm running Rails 4,
I have the following .js:
jQuery('#vmap').vectorMap({ map: 'usa_en'})

And in my view I have:

Both jquery.vmap.usa.js/jquery.vmap.js and jqvmap.css files are being included (in my assets folder), however, I get the following error when I run:

Error: Invalid value for attribute width="null" jquery.vmap.js?body=1:126
VectorCanvas.setSize jquery.vmap.js?body=1:126
VectorCanvas jquery.vmap.js?body=1:114
WorldMap jquery.vmap.js?body=1:392
$.fn.vectorMap jquery.vmap.js?body=1:70
(anonymous function) vmap.js?body=1:1
Error: Invalid value for attribute height="null" jquery.vmap.js?body=1:127
VectorCanvas.setSize jquery.vmap.js?body=1:127
VectorCanvas jquery.vmap.js?body=1:114
WorldMap jquery.vmap.js?body=1:392
$.fn.vectorMap jquery.vmap.js?body=1:70
(anonymous function) vmap.js?body=1:1

@raisen
Copy link

raisen commented Jun 30, 2014

I am getting the same error, did you figure out how to fix it?

@ghost
Copy link
Author

ghost commented Aug 13, 2014

I guess, you should correct your initial code like this:
$(document).ready(function(){
jQuery('#vmap').vectorMap({ map: 'usa_en'})
})

@manifestinteractive
Copy link
Contributor

@ghost has it correct, you cannot get the width and height of an element during page load, which your code was likely running during. You can either put your script in your body tag, or use an onload event handler.

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

2 participants