div id 称为缓冲区。当用户点击缓冲区时,事件点被缓冲 1 英里
<div id="map2" class="col-md-4 well">
<p>GeoDjango is da bomb</p>
<button id="Highlands" class="form-control btn-primary">Highlands</button>
<button id="buffer" class="form-control btn-warning">Buffer</button>
</div>
javascript
var incidences = new L.GeoJSON.AJAX("http://127.0.0.1:8000/incidence_data/", {
onEachFeature: function (feature, layer) {
//console.log(feature.properties);
layer.bindPopup(feature.properties.name.toString())
}
});
incidences.addTo(map);
var incidences2 = incidences.toGeoJSON();
$("#buffer").click(function () {
if ($("#buffer").html() == 'Buffer') {
var buff = turf.buffer(incidences2, 1, {'units': 'miles'});
bufferLayer = L.geoJSON(buff).addTo(map);
$("#buffer").html("Remove Buffer");
} else {
map.removeLayer(bufferLayer);
$("#buffer").html("Buffer");
}
});
我不确定缓冲区是否正在执行,因为控制台中绝对没有任何内容。
我发现这个问题与我的非常相似。https://gis.stackexchange.com/questions/285077/does-turf-js-work-with-geodjango