Error: Invalid value for <g> attribute transform="scale(NaN) translate(NaN, NaN)"
Asked Answered
T

1

6

I am trying to use jVectorMap in an application and I'm receiving this error.

The example shown on their website says that all you have to do is put, $('#map').vectorMap({map: 'world_mill_en'}); on your page.

Well, I have both a div with an id of map as well as this script loaded, and I am getting this error. What is ? I'm guessing it has something to do with SVG or some setting that isn't being set (like height or width?)

Here's my use of the script:

<script>
  $('#map').vectorMap({map: 'world_mill_en'});
</script>

And my div:

<div id="map"></div>

How do I set the height/width of the div? Or do I set this value in vectormap, or is it something else entirely?

Here is how my header scripts are organized:

<script src="js/jquery-1.11.2/jquery-1.11.2.min.js"></script>
<script src="js/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.js"></script> 
<script src="jvectormap/jquery-jvectormap-2.0.2.min.js"></script>
<link rel="stylesheet" href="jvectormap/jquery-jvectormap-2.0.2.css" />
<script src="jvectormap/jquery-jvectormap-world-mill-en.js"></script>
Toothache answered 19/4, 2015 at 21:15 Comment(4)
the width and height you can set either using CSS #map {width:100px;height:100px;} or style attribute style="width:100px;height:100px;"Urana
Possible duplicate of jQuery offset returns invalid value for <span> or inline <div>Circumscribe
did you find an asnwer?Lumumba
In my case, it turned out to be a combination of typo from my side, and weird behaviour of jvectormap. It turns out that when I specified invalid id within ` $('#id-which-doesnt-exist').vectorMap({map: 'world_mill'});` instead of giving a clear error message that that this id doesn't exist. jvectormap simply picked first child of the <body>. (And that child was a regular <h1> element which had no width/height explicitly set. Later jvectormap tries to scale this element and as it doesn't have explicit size set, it fails with sizes of 0,0Lumumba
H
0

use [{x: 0, y: 1}] instead of [[0,1]]

usually this ends up being the cause of this error

Hoosegow answered 21/1, 2019 at 14:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.