kartograph / kartograph.js

UNMAINTAINED Open source JavaScript renderer for Kartograph SVG maps
http://kartograph.org
GNU Lesser General Public License v3.0
1.51k stars 227 forks source link

SVG created by Inkscape won't work #32

Closed muuki88 closed 11 years ago

muuki88 commented 12 years ago

I wasn't able to create a svg graphic with Inkscape version 0.48.3.1 r9886. The xml seems not be parsed correctly, but I have no clue.

I'm using

Here is the file which produced the error (like any other Inkscape svg).

The error occurs in this method

View.fromXML = function(xml) {
    /*
        constructs a view from XML
    */

    var bbox, bbox_xml, h, pad, w;
    w = Number(xml.getAttribute('w')); // Uncaught TypeError: Cannot call method 'getAttribute' of undefined

    h = Number(xml.getAttribute('h'));
    pad = Number(xml.getAttribute('padding'));
    bbox_xml = xml.getElementsByTagName('bbox')[0];
    bbox = BBox.fromXML(bbox_xml);
    return new kartograph.View(bbox, w, h, pad);
  };
muuki88 commented 11 years ago

This applies to simple svg created with Illustrator, too.

gka commented 11 years ago

Kartograph expects a certain structure in SVG documents, see https://gist.github.com/3434004#file-usa-svg, for example.

muuki88 commented 11 years ago

Okay. I figured out that only absolute coordinates are allowed. Why is that?

CatarinaPBressan commented 10 years ago

@gka ,

What software should I use to generate svg files that are compatible with Kartograph?

EDIT: By the way, the example you linked didn't work.

desmarais commented 10 years ago

@gka, I try to use Kartograph extensively. Is there a concise description of the required structure of SVG documents ? As you outline, https://gist.github.com/3434004#file-usa-svg works fine. But, e.g. the map referenced in http://commons.wikimedia.org/wiki/File:Blank_map_of_Europe.svg does not show up.

pawelpotoniec commented 8 years ago

@gka Please provide some details how to export maps from Illustrator/Inkscape to work well with Kartograph.js? All files are exported using W3C SVG 1.1 version, but does not contain any metadata required by your lib.