0

I am new to leaflet.js and CartoDB.js. What I am trying to do is create a editable webmap, sourcing (and writing) data to my CartoDB SQL tables. I can render the map from CartoDB, but when I add the links to leaflet.js my map layers disappear. This JS Fiddle shows this. If you comment out lines 5 and 6, it works:

<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />

4

1 回答 1

1

使用 CartoDB 时不需要添加 Leaflet 库的 javascript 和样式表,只需包含 Leaflet Draw 的资产,启用drawControl选项中的选项L.Map就可以了:

资产:

<link type="text/css" rel="stylesheet" href="http://leaflet.github.io/Leaflet.draw/leaflet.draw.css" />
<script type="text/javascript" src="http://leaflet.github.io/Leaflet.draw/leaflet.draw.js"></script>

地图:

new L.Map('cartodb-map', { 
    center: [40,-98],
    zoom: 4,
    drawControl: true
});

这是你的 Fiddle 的一个分支:http: //jsfiddle.net/qnzqtgy7/

于 2015-03-16T20:43:29.877 回答