Determine allowed zone from admin boundaries (#359)

This commit is contained in:
Norbert Renner 2021-01-15 22:29:20 +01:00 committed by GitHub
parent 5df0765d51
commit a5f04dd9cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 1925 additions and 1171 deletions

View file

@ -35,6 +35,10 @@ BR.NogoAreas = L.Control.extend({
fillOpacity: 0.1,
},
polylineOptions: {
smoothFactor: 0.5,
},
initialize: function () {
this._wasRouteDrawing = false;
},
@ -233,6 +237,9 @@ BR.NogoAreas = L.Control.extend({
var geoJSON = L.geoJson(turf.featureCollection(cleanedGeoJSONFeatures), {
onEachFeature: function (feature, layer) {
layer.options.nogoWeight = feature.properties.nogoWeight || nogoWeight;
if (feature.geometry.type === 'LineString') {
L.setOptions(layer, self.polylineOptions);
}
},
});
var nogosPoints = geoJSON.getLayers().filter(function (e) {
@ -308,6 +315,15 @@ BR.NogoAreas = L.Control.extend({
var polylines = options.polylines;
var polygons = options.polygons;
this._clear();
this._addNogos(nogos, polylines, polygons);
},
addNogos: function (nogos, polylines, polygons) {
this._addNogos(nogos, polylines, polygons);
this._fireUpdate();
},
_addNogos: function (nogos, polylines, polygons) {
if (nogos) {
for (var i = 0; i < nogos.length; i++) {
nogos[i].setStyle(this.style);
@ -328,6 +344,26 @@ BR.NogoAreas = L.Control.extend({
}
},
removeNogos: function (nogos, polylines, polygons) {
if (nogos) {
for (var i = 0; i < nogos.length; i++) {
this.drawnItems.removeLayer(nogos[i]);
}
}
if (polylines) {
for (var i = 0; i < polylines.length; i++) {
this.drawnItems.removeLayer(polylines[i]);
}
}
if (polygons) {
for (var i = 0; i < polygons.length; i++) {
this.drawnItems.removeLayer(polygons[i]);
}
}
this._fireUpdate();
},
_clear: function () {
this.drawnItems.clearLayers();
},