Move of Parkings

This commit is contained in:
portree_kid 2020-02-09 22:22:09 +01:00
parent d727ea19e4
commit d186361627
2 changed files with 32 additions and 5 deletions

View File

@ -289,6 +289,18 @@
if (distance > 0 && distance < snap) { if (distance > 0 && distance < snap) {
layers.push({d: distance, l: layer, latlng: layer._latlng, glueindex: layer.glueindex}) layers.push({d: distance, l: layer, latlng: layer._latlng, glueindex: layer.glueindex})
} }
} else if (layer instanceof L.ParkingSpot) {
let distance = layer._latlng.distanceTo(eventLatlng)
if (distance > 0 && distance < snap) {
layers.push({d: distance, l: layer, latlng: layer._latlng, glueindex: layer.glueindex})
}
} else if (layer instanceof L.HoldNode) {
let distance = layer._latlng.distanceTo(eventLatlng)
if (distance > 0 && distance < snap) {
layers.push({d: distance, l: layer, latlng: layer._latlng, glueindex: layer.glueindex})
}
} else {
console.log(layer)
} }
}) })
layers.sort((l1, l2) => l1.d - l2.d) layers.sort((l1, l2) => l1.d - l2.d)

View File

@ -92,16 +92,16 @@ L.ParkingSpot = L.Circle.extend({
addListeners: function () { addListeners: function () {
this.on('editable:drawing:move', function (event) { this.on('editable:drawing:move', function (event) {
console.log("Move : ", event); console.log("Move : ", event);
console.log("Move : ", event.latlng);
// Is it the edit vertex (Middle) moving? // Is it the edit vertex (Middle) moving?
if(event.target.editor._resizeLatLng.__vertex._icon !== event.sourceTarget._element){ if(event.target.editor._resizeLatLng.__vertex._icon !== event.sourceTarget._element){
this.follow(event.target.id, event); event.target.setLatLng(event.latlng);
event.target.updateVertexFromDirection(); event.target.updateVertexFromDirection();
this.follow(event.target.id, event);
} }
else if(event.target.editor._resizeLatLng.__vertex._icon === event.sourceTarget._element) { else if(event.target.editor._resizeLatLng.__vertex._icon === event.sourceTarget._element) {
event.target.updateDirectionFromVertex(); event.target.updateDirectionFromVertex();
event.target.updateVertexFromDirection(); event.target.updateVertexFromDirection();
console.log(event);
} }
}); });
/* /*
@ -134,7 +134,10 @@ L.ParkingSpot = L.Circle.extend({
follow (dragIndex, event) { follow (dragIndex, event) {
this.featureLookup[dragIndex].forEach(element => { this.featureLookup[dragIndex].forEach(element => {
if(element !== event.target){ if(element !== event.target){
if (element instanceof L.HoldNode) { if (element instanceof L.RunwayNode) {
element.setLatLng(event.latlng);
}
else if (element instanceof L.HoldNode) {
element.setLatLng(event.latlng); element.setLatLng(event.latlng);
} }
else if (element instanceof L.ParkingSpot) { else if (element instanceof L.ParkingSpot) {
@ -158,6 +161,17 @@ L.ParkingSpot = L.Circle.extend({
element.updateEndVertex(event.latlng); element.updateEndVertex(event.latlng);
element.updateMiddle(); element.updateMiddle();
} }
} else if (element instanceof L.Editable.VertexMarker) {
console.log(element);
element.setLatLng(event.latlng);
element.latlngs.forEach((latlng, index) => {
console.log(latlng);
if (latlng.__vertex === element) {
latlng.update(event.latlng);
}
});
element.editor.feature.setLatLngs(element.latlngs);
element.editor.feature.updateMiddle();
} }
} }
}) })
@ -183,6 +197,7 @@ var parkingSpot = function (n, layerGroup) {
// event.target.createDirection(); // event.target.createDirection();
}); });
circle.id = n.attr('index'); circle.id = n.attr('index');
circle.glueindex = n.attr('index');
/* /*
<Parking index="2" <Parking index="2"
type="gate" type="gate"