Question

Is there anyone who has used the library kartograph.js and 'kartograph.py'? Do you know if I need 'kartograph.py' to be able to run?How can I use the library 'kartograph.py' without installing python? Because I have a problem with 'kartograph.js' when I build the 'BBOX' in the 'kartograph.js'

The error in the kartograph.js :

.... 
if (height === 0) height = width * .5;
        alert(width);
        me.viewport = new kartograph.BBox(0, 0, width, height);
**Uncaught TypeError: undefined is not a function**
        me.paper = me.createSVGLayer();
        me.markers = [];
        me.pathById = {};
        me.container.addClass('kartograph');
    }
....

Thank you for your help

The HTML page. The error come when I build $K.map

<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>GEOFRANCE</title>
    <link href="/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/script/js/script.min.js"></script>

  $script(['/script/js/jquery.min.js','/script/js/raphael.min.js', '/script/js/kartograph.js', '/script/js/chroma.min.js'], 'kartograph');

  $script(['/script/js/jquery.qtip.min.js'], 'qtip');

</head>
<body>
<div id="main">

<link rel="stylesheet" type="text/css" href="/Styles/jquery.qtip.css">    
<script type="text/javascript">

$script.ready(['kartograph', 'qtip'], function () {

    $(function () {
        var map,
            colorscale,
            dep_data = {},
            w = $('#map').parent().width();
        $.fn.qtip.defaults.style.classes = 'ui-tooltip-bootstrap';
        $.fn.qtip.defaults.style.def = false;

        $.ajax({
            url: 'departments.json',
            dataType: 'json',
            success: function (data) {
                alert("test : " + w);

                $.each(data, function (i, r) {
                    dep_data[r.id] = r;

                })


                map = $K.map('#map', w, w);

                alert("test2 : " +w);
                map.loadMap('france-departments.svg', function () {
                    map.addLayer('departments', {
                        titles: function (d) { return d.id },
                        styles: {
                            stroke: '0.5px'
                        },
                        tooltips: function (d) {
                            return [d.name, dep_data[d.id].density + '/km<sup>2</sup>'];
                        }
                    });
                    updateMap();
                });
            }
        });

        /*
        * update map colors
        */
        function updateMap() {
            var prop = 'density', // $('.measure.btn-custom').data('value'),
                scale = 'quantiles', // $('.scale.btn-custom').data('value'),
                colors = $('#colors').get(0).value;

            colorscale = new chroma.ColorScale({
                colors: chroma.brewer[colors],
                limits: chroma.limits(dep_data, scale, 7, prop)
            });
            map.getLayer('departments').style({
                fill: function (d) {
                    return colorscale.getColor(dep_data[d.id][prop]);
                }
            });

        }

        // init user interface
        $('.btn').click(function (event) {
            var tgt = $(event.target), par = tgt.parent();
            $('.btn', par).removeClass('btn-custom');
            tgt.addClass('btn-custom');
            updateMap();
        });

        $('#colors').change(updateMap);
        $('#colors').keyup(updateMap);

    });

});
</script>

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

</div>
  </body>
 </html>
Was it helpful?

Solution

You need to generate the map you're going to use with kartograph.py, so this directly answers your next question, yes, you need to install Python to use it. You can't run something written in Python without the Python interpreter.

I'm not really sure where did you read about that BBox method, but the docs say something way different: http://kartograph.org/docs/kartograph.js/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top