2

I can't get Kartograph.js to display my .svg map. Here's what I've done:

  1. I've successfully made a .svg map from a .shp using the most basic json file I could with kartograph.py, according to Kartograph's docs, doing the basic world.json -o world.svg. Here's the json:

    {
        "layers": [{
            "src": "ne_50m_admin_0_countries.shp",
            "simplify": 3
        }]
    }
    
  2. I've set up a simple http host with python and directed chrome to the host, since I understand you can't do this locally.

  3. I've written the code below. I don't get any errors, so I don't what I've done wrong. Could it be that I haven't put in any layers? I wanted to make as simple an example as possible for my first try.

    <div id="map"></div>
    
    <script>
        function loadMap() {
            var map = kartograph.map('#map');
            map.loadMap('world.svg', function() {
    
            });
        };
    </script>
    <script src="jquery-1.11.0.min.js"></script>
    <script src="kartograph.js-master/dist/kartograph.js"></script>
    <script src="raphael-master/raphael-min.js"></script>`
    

Thanks guys.

blake
  • 21
  • 1

1 Answers1

4

You must add the layer of the svg file.

In this case: map.addLayer('layer_0');

All the code:

$(function() {      
    var map = kartograph.map('#map',800,600)        
    map.loadMap('world.svg', function() {       
        map.addLayer('layer_0');
    });     
});

To see the name of the layer i open the svg file with Inkspace, and then press Shift+Control+X.

JC_2013
  • 83
  • 7