Skip to content

Loading…

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

Closed
amirtcheva opened this Issue · 3 comments

3 participants

@amirtcheva

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

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

@ghost

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

@manifestinteractive

@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
Something went wrong with that request. Please try again.