Skip to content

Commit

Permalink
init of srbu changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaGeo committed Sep 12, 2023
1 parent 8c4b6d3 commit 77849f7
Show file tree
Hide file tree
Showing 7 changed files with 513 additions and 561 deletions.
89 changes: 89 additions & 0 deletions app/static/css/map.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
@charset "UTF-8";

/*ags-map.css*/
#agsMap{
display:block;
margin:10px auto;
padding:0px;
width:90%;
height:600px;
}

#agsLeafletMap{
display:block;
margin:0px;
padding:0px;
width:100%;
height:600px;
}

.leaflet-popup-content table{
margin:4px;
}

.leaflet-popup-content table>tbody>tr>*{
padding:2px 4px;
}

.leaflet-popup-content table>tbody>tr>th{
background-color:#CCC;
}

#agsMapLookups{
padding:0px;
text-align:center;
}

#agsMapLookups>article{
display:inline-block;
width:45%;
height:120px;
overflow:hidden;
}

#agsMapLookups input{
padding:4px 8px;
}

#agsMapLookups input.lookupBtn{
padding:6px 12px;
background-color:#246;
color:#FFFFFF;
border-radius:5px;
border:none;
box-shadow: 2px 2px 4px #444;
opacity:0.8;
cursor:pointer;
}

#agsMapLookups input.lookupBtn:hover{
box-shadow: 1px 1px 2px #222;
opacity:1;
}

#agsMapLookups input.lookupBtn:disabled{
background-color:#CCC;
color:#444;
opacity:0.5;
box-shadow: 2px 2px 4px #FFF;
}

#extentStatusMsg{
display:inline-block;
border:1px solid #CCC;
padding:4px 8px;
}

#drawIcon{
display:inline-block;
border:1px solid #CCC;
padding:0px;
margin:0px;
background-image: url("../js/Leaflet/draw/images/spritesheet.svg");
background-image: linear-gradient(transparent, transparent), url('../js/Leaflet/draw/images/spritesheet.svg');
background-repeat: no-repeat;
background-size:200px 20px;
background-position: -40px 0px;
width:20px;
height:20px;
}
30 changes: 30 additions & 0 deletions app/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,33 @@
width: 5px;
height: 10px;
}

#extentModal{
background-color:rgba(0,0,0,0.7);
position:absolute;
width:100%;
top:0px;
left:0px;
height:600px;
border:1px solid #000000;
z-index:9999;
margin:0px;
text-align:center;
padding:20px;
}

#extentModal>*{
margin:0px 20px;
padding:10px 20px;
color:#FFFFFF;
background-color:rgba(0,0,0,0.7);
}

#extentValid>a{
color:#FFFFFF;
}

#closeModalBtn{
padding:3px 5px;
float:right;
}
145 changes: 73 additions & 72 deletions app/static/js/L.TileLayer.BetterWMS.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,74 @@
L.TileLayer.BetterWMS = L.TileLayer.WMS.extend({

onAdd: function (map) {
// Triggered when the layer is added to a map.
// Register a click listener, then do all the upstream WMS things
L.TileLayer.WMS.prototype.onAdd.call(this, map);
map.on('click', this.getFeatureInfo, this);
},

onRemove: function (map) {
// Triggered when the layer is removed from a map.
// Unregister a click listener, then do all the upstream WMS things
L.TileLayer.WMS.prototype.onRemove.call(this, map);
map.off('click', this.getFeatureInfo, this);
},

getFeatureInfo: function (evt) {
// Make an AJAX request to the server and hope for the best
var url = this.getFeatureInfoUrl(evt.latlng),
showResults = L.Util.bind(this.showGetFeatureInfo, this);
$.ajax({
url: url,
success: function (data, status, xhr) {
var err = typeof data === 'string' ? null : data;
showResults(err, evt.latlng, data);
},
error: function (xhr, status, error) {
showResults(error);
}
});
},

getFeatureInfoUrl: function (latlng) {
// Construct a GetFeatureInfo request URL given a point
var point = this._map.latLngToContainerPoint(latlng, this._map.getZoom()),
size = this._map.getSize(),

params = {
request: 'GetFeatureInfo',
service: 'WMS',
srs: 'EPSG:4326',
styles: this.wmsParams.styles,
transparent: this.wmsParams.transparent,
version: this.wmsParams.version,
format: this.wmsParams.format,
bbox: this._map.getBounds().toBBoxString(),
height: size.y,
width: size.x,
layers: this.wmsParams.layers,
query_layers: this.wmsParams.layers,
info_format: 'text/html'
};

params[params.version === '1.3.0' ? 'i' : 'x'] = point.x;
params[params.version === '1.3.0' ? 'j' : 'y'] = point.y;

return this._url + L.Util.getParamString(params, this._url, true);
},

showGetFeatureInfo: function (err, latlng, content) {
if (err) { console.log(err); return; } // do nothing if there's an error

// Otherwise show the content in a popup, or something.
L.popup({ maxWidth: 500})
.setLatLng(latlng)
.setContent(content)
.openOn(this._map);
}
});

L.tileLayer.betterWms = function (url, options) {
return new L.TileLayer.BetterWMS(url, options);
};

onAdd: function (map) {
// Triggered when the layer is added to a map.
// Register a click listener, then do all the upstream WMS things
L.TileLayer.WMS.prototype.onAdd.call(this, map);
map.on('click', this.getFeatureInfo, this);
},

onRemove: function (map) {
// Triggered when the layer is removed from a map.
// Unregister a click listener, then do all the upstream WMS things
L.TileLayer.WMS.prototype.onRemove.call(this, map);
map.off('click', this.getFeatureInfo, this);
},

getFeatureInfo: function (evt) {
// Make an AJAX request to the server and hope for the best
var url = this.getFeatureInfoUrl(evt.latlng),
showResults = L.Util.bind(this.showGetFeatureInfo, this);
$.ajax({
url: url,
success: function (data, status, xhr) {
var err = typeof data === 'string' ? null : data;
showResults(err, evt.latlng, data);
},
error: function (xhr, status, error) {
showResults(error);
}
});
},

getFeatureInfoUrl: function (latlng) {
// Construct a GetFeatureInfo request URL given a point
var point = this._map.latLngToContainerPoint(latlng, this._map.getZoom()),
size = this._map.getSize(),

params = {
request: 'GetFeatureInfo',
service: 'WMS',
srs: 'EPSG:4326',
styles: this.wmsParams.styles,
transparent: this.wmsParams.transparent,
version: this.wmsParams.version,
format: this.wmsParams.format,
bbox: this._map.getBounds().toBBoxString(),
height: size.y,
width: size.x,
layers: this.wmsParams.layers,
query_layers: this.wmsParams.layers,
info_format: 'text/html'
};

params[params.version === '1.3.0' ? 'i' : 'x'] = point.x;
params[params.version === '1.3.0' ? 'j' : 'y'] = point.y;

return this._url + L.Util.getParamString(params, this._url, true);
},

showGetFeatureInfo: function (err, latlng, content) {
// do nothing if there's an error
if(err){console.log(err);return;}
// do nothing if can't find "Lithostratigraphy" in content (~empty content)
if(content.indexOf("Lithostratigraphy") === -1){return;};
// do nothing if WMS popup disabled
if(!agsMap.drawing.showWMSpopup){return;};
// otherwise show the content in a popup
L.popup({"maxWidth":500}).setLatLng(latlng).setContent(content).openOn(this._map);
}
});

L.tileLayer.betterWms = function (url, options) {
return new L.TileLayer.BetterWMS(url, options);
};
Loading

0 comments on commit 77849f7

Please sign in to comment.