diff --git a/index.html b/index.html
index a1f8e7d7..800c0aa8 100644
--- a/index.html
+++ b/index.html
@@ -130,7 +130,7 @@
Source files
-
+
@@ -142,7 +142,7 @@ Source files
-
+
diff --git a/mapshaper-gui.js b/mapshaper-gui.js
index 18e4f285..38236cd9 100644
--- a/mapshaper-gui.js
+++ b/mapshaper-gui.js
@@ -3500,15 +3500,6 @@
}
}
- function deleteFeature(lyr, fid) {
- var records = lyr.data?.getRecords();
- if (records) records.splice(fid, 1);
- lyr.shapes.splice(fid, 1);
- if (isProjectedLayer(lyr) && lyr.shapes != lyr.gui.displayLayer.shapes) {
- lyr.gui.displayLayer.shapes.splice(fid, 1);
- }
- }
-
// p: one point in source data coords
function appendNewPoint(lyr, p) {
lyr.shapes.push([p]);
@@ -3521,15 +3512,20 @@
}
}
- function deletePoint(lyr, fid) {
- deleteFeature(lyr, fid);
+ function deleteFeature(lyr, fid) {
+ var records = lyr.data?.getRecords();
+ if (records) records.splice(fid, 1);
+ lyr.shapes.splice(fid, 1);
+ if (isProjectedLayer(lyr) && lyr.geometry_type == 'point') {
+ lyr.gui.displayLayer.shapes.splice(fid, 1); // point layer
+ }
}
- function insertPoint(lyr, fid, shp, d) {
+ function insertFeature(lyr, fid, shp, d) {
var records = lyr.data?.getRecords();
if (records) records.splice(fid, 0, d);
lyr.shapes.splice(fid, 0, shp);
- if (isProjectedLayer(lyr)) {
+ if (isProjectedLayer(lyr) && lyr.geometry_type == 'point') {
var shp2 = projectPointCoords(shp, lyr.gui.projectPoint);
lyr.gui.displayLayer.shapes.splice(fid, 0, shp2);
}
@@ -4255,6 +4251,10 @@
setDisplayProjection(gui, cmd);
} else {
line.hide(); // hide cursor while command is being run
+ // quit certain edit modes
+ if (!gui.interaction.modeWorksWithConsole(gui.interaction.getMode())) {
+ gui.interaction.turnOff();
+ }
runMapshaperCommands(cmd, function(err, flags) {
if (flags) {
gui.clearMode();
@@ -5606,12 +5606,12 @@
addHistoryState(undo, redo);
});
- gui.on('point_delete', function(e) {
+ gui.on('feature_delete', function(e) {
var redo = function() {
- deletePoint(e.data.target, e.fid);
+ deleteFeature(e.data.target, e.fid);
};
var undo = function() {
- insertPoint(e.data.target, e.fid, e.coords, e.d);
+ insertFeature(e.data.target, e.fid, e.coords, e.d);
};
addHistoryState(undo, redo);
});
@@ -5966,6 +5966,10 @@
setMode('off');
};
+ this.modeWorksWithConsole = function(mode) {
+ return ['off', 'info'];
+ };
+
this.modeUsesHitDetection = function(mode) {
return ['info', 'selection', 'data', 'labels', 'edit_points', 'vertices', 'rectangles', 'edit_lines', 'edit_polygons'].includes(mode);
};
@@ -10243,8 +10247,8 @@
function removePoint(target, id) {
var d = target.data ? target.data.getRecords()[id] : null;
var coords = target.shapes[id];
- deletePoint(target, id);
- gui.dispatchEvent('point_delete', {coords, d, target, fid: id});
+ deleteFeature(target, id);
+ gui.dispatchEvent('feature_delete', {coords, d, target, fid: id});
gui.dispatchEvent('map-needs-refresh');
hit.setHitId(-1);
}
@@ -10492,7 +10496,7 @@
}
gui.keyboard.on('keydown', function(e) {
- if (active() && e.keyName == 'space') {
+ if (pathDrawing() && e.keyName == 'space') {
e.stopPropagation(); // prevent console from opening if shift-panning
}
}, null, 1);
@@ -10506,6 +10510,7 @@
deleteActiveVertex(e, vInfo);
};
}
+
// don't allow copying of open paths as geojson in polygon mode
gui.contextMenu.open(e, target);
});
@@ -10669,7 +10674,7 @@
// esc or enter key finishes a path
gui.keyboard.on('keydown', function(e) {
- if (active() && (e.keyName == 'esc' || e.keyName == 'enter')) {
+ if (pathDrawing() && (e.keyName == 'esc' || e.keyName == 'enter')) {
e.stopPropagation();
finishCurrentPath();
e.originalEvent.preventDefault(); // block console "enter"
@@ -12402,6 +12407,7 @@ GUI and setting the size and crop of SVG output.