Skip to content

Commit

Permalink
Fix problem where when clickForPlot was used.
Browse files Browse the repository at this point in the history
Clicking on an area of the map where the spatial reference system is invalid, it would cause an error rather than automatically switching to a valid spatial reference system.
  • Loading branch information
Andrew van Breda committed Dec 4, 2023
1 parent 66c604f commit 0809a40
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/jquery.indiciaMapPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,7 @@ var destroyAllFeatures;
var point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
var polygon;
var plotShape;
var system;
if (div.settings.clickForPlot) {
// Get plot shape using jQuery or fall back on form structure option
if ($('#' + div.settings.plotShapeId).val()) {
Expand Down Expand Up @@ -2198,14 +2199,16 @@ var destroyAllFeatures;
plot.wkt = feature.geometry.transform(div.map.projection, div.indiciaProjection).toString();
}
var precision = div.settings.plotPrecision;
system = chooseBestSystem(div, point, _getSystem());
$('select#' + opts.srefSystemId).val(system);
// Request sref of point that was clicked
pointToSref(div, point, _getSystem(), function (data) {
pointToSref(div, point, system, function (data) {
plot.sref = data.sref;
handleSelectedPositionOnMap(lonlat, div, plot);
}, undefined, precision);
} else {
// Clicking to locate an sref (eg an OSGB grid square)
var system = chooseBestSystem(div, point, _getSystem());
system = chooseBestSystem(div, point, _getSystem());
$('select#' + opts.srefSystemId).val(system);
pointToSref(div, point, system, function(data) {
handleSelectedPositionOnMap(lonlat, div, data);
Expand Down

0 comments on commit 0809a40

Please sign in to comment.