Skip to content

Commit

Permalink
Ensure the bbox input is in the correct form
Browse files Browse the repository at this point in the history
  • Loading branch information
markstuart committed Nov 13, 2023
1 parent 9383084 commit bbc0806
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions ckanext/spatial/public/js/spatial_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ this.ckan.module('spatial-query', function ($, _) {
map.removeLayer(module.extentLayer);
}
module.extentLayer = extentLayer = e.layer;
$('#ext_bbox').val(extentLayer.getBounds().toBBoxString());
module.ext_bbox_input.val(extentLayer.getBounds().toBBoxString());
map.addLayer(extentLayer);
element.find('.btn-primary').removeClass('disabled').addClass('btn-primary');
});
Expand Down Expand Up @@ -199,7 +199,7 @@ this.ckan.module('spatial-query', function ($, _) {
_setPreviousBBBox: function(map, zoom=true) {
previous_bbox = this._getParameterByName('ext_bbox');
if (previous_bbox) {
$('#ext_bbox').val(previous_bbox);
module.ext_bbox_input.val(previous_bbox);
this.extentLayer = this._drawExtentFromCoords(previous_bbox.split(','))
map.addLayer(this.extentLayer);
if (zoom) {
Expand All @@ -214,16 +214,14 @@ this.ckan.module('spatial-query', function ($, _) {
_onReady: function() {
let module = this;
let map;
let form = $(".search-form");
let form = $('#dataset-search-form');
let bbox_input_id = 'ext_bbox';

var buttons;

// Add necessary fields to the search form if not already created
$(['ext_bbox']).each(function(index, item){
if ($("#" + item).length === 0) {
$('<input type="hidden" />').attr({'id': item, 'name': item}).appendTo(form);
}
});
// Add necessary field to the search form if not already created
if ($("#" + bbox_input_id).length === 0) {
$('<input type="hidden" />').attr({'id': bbox_input_id, 'name': bbox_input_id}).appendTo(form);
}
module.ext_bbox_input = $('#dataset-search-form #ext_bbox');

// OK map time
this.mainMap = map = this._createMap('dataset-map-container');
Expand Down

0 comments on commit bbc0806

Please sign in to comment.