到目前为止,我已经创建了一个标记,将其传输到 geoJSON,并使用 Turf.buffer 在它周围创建了一个缓冲区。当我在地图上拖动它时,如何让这个缓冲区“粘”到标记上?
<script>
L.mapbox.accessToken = 'fg.eyJ1IjoisdflksdaklsjZWwiLCJhIjoiRHNwX0ZWNCJ9.Ov2O5sslkdqV93_R0lq3Q';
var map = L.mapbox.map('map', 'example.kf6j9ec4')
.setView([38.633, -90.319],12);
var marker = L.marker(new L.LatLng(38.633, -90.319), {
icon: L.mapbox.marker.icon({
'marker-color': '1B05E3',
"marker-symbol": "pitch"
}),
draggable: true
});
marker.bindPopup('This marker is draggable! Move it around to see what locales are in your "area of walkability".');
//Make the marker a feature
var pointMarker = marker.toGeoJSON();
//buffer the marker geoJSON feature
var buffered = turf.buffer(pointMarker, 2, 'miles');
var resultFeatures = buffered.features.concat(pointMarker);
var result = {
"type": "FeatureCollection",
"features": resultFeatures
};
L.mapbox.featureLayer().setGeoJSON(buffered).addTo(map);
marker.addTo(map);
</script>