有没有人使用过图书馆 kartograph.js 和“kartograph.py”?你知道我是否需要'kartograph.py'才能运行吗?如何在不安装python的情况下使用库'kartograph.py'?因为当我在“kartograph.js”中构建“BBOX”时,“kartograph.js”有问题
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');
}
....
感谢您的帮助
HTML 页面。当我构建 $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>