Skip to content

Commit

Permalink
Merge pull request #6947 from HistoricEngland/6930_NEW_CS_crosshairs_…
Browse files Browse the repository at this point in the history
…when_editing

6930 Crosshairs code added
  • Loading branch information
chiatt committed Jan 6, 2021
2 parents b2e8aae + 589420d commit 5612c34
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
10 changes: 8 additions & 2 deletions arches/app/media/js/viewmodels/map-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ define([
if (showSelectLayers) {
self.draw.changeMode('simple_select');
self.selectedFeatureIds([]);
} else if (tool) self.draw.changeMode(tool);
} else {
if (tool) {
self.draw.changeMode(tool);
self.map().draw_mode = tool;
}
}
};

self.geojsonWidgets.forEach(function(widget) {
Expand Down Expand Up @@ -385,9 +390,10 @@ define([
});
map.on('draw.update', self.updateTiles);
map.on('draw.delete', self.updateTiles);
map.on('draw.modechange', function() {
map.on('draw.modechange', function(e) {
self.updateTiles();
self.setSelectLayersVisibility(false);
map.draw_mode = e.mode;
});
map.on('draw.selectionchange', function(e) {
self.selectedFeatureIds(e.features.map(function(feature) {
Expand Down
13 changes: 12 additions & 1 deletion arches/app/media/js/viewmodels/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define([
}
};
};

var x = ko.unwrap(params.x) ? params.x : arches.mapDefaultX;
var y = ko.unwrap(params.y) ? params.y : arches.mapDefaultY;
var bounds = ko.unwrap(params.bounds) ? params.bounds : arches.hexBinBounds;
Expand Down Expand Up @@ -278,9 +278,20 @@ define([
self.isFeatureClickable
);
if (hoverFeature && hoverFeature.id && style) map.setFeatureState(hoverFeature, { hover: true });

map.getCanvas().style.cursor = hoverFeature ? 'pointer' : '';
if (self.map().draw_mode) {
var crosshairModes = [
"draw_point",
"draw_line_string",
"draw_polygon",
];
map.getCanvas().style.cursor = crosshairModes.includes(self.map().draw_mode) ? "crosshair" : "";
}
});

map.draw_mode = null;

map.on('click', function(e) {
if (hoverFeature) {
self.onFeatureClick(hoverFeature, e.lngLat);
Expand Down
4 changes: 4 additions & 0 deletions arches/app/media/js/views/components/search/map-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ define([
this.searchByExtent();
} else {
this.draw.changeMode(selectedDrawTool);
self.map().draw_mode = selectedDrawTool;
}
}
}, this);
Expand Down Expand Up @@ -374,6 +375,9 @@ define([
self.searchGeometries(e.features);
self.updateFilter();
});
this.map().on("draw.modechange", function (e) {
self.map().draw_mode = e.mode;
});
},

searchByExtent: function() {
Expand Down

0 comments on commit 5612c34

Please sign in to comment.