Skip to content
Snippets Groups Projects
Commit 5b85d41e authored by Glenn Vorhes's avatar Glenn Vorhes
Browse files

add caching url generator

parent c25cf398
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ exports.makeServiceUrl = makeServiceUrl;
function localCacheUrl(folder, service) {
var loc = window.location.href;
var url = "/mapserver/" + folder + "/" + service;
if (loc.indexOf('http://transportal.cee.wisc.edu') > -1) {
if (loc.indexOf('transportal.cee.wisc.edu') > -1) {
if (loc.toLowerCase().indexOf('webmapsstage') > -1) {
url = 'https://transportal.cee.wisc.edu/gis/webmapsstage' + url;
}
......
{"version":3,"file":"LayerEsriMapServer.js","sourceRoot":"","sources":["../../src/layers/LayerEsriMapServer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;GAEG;AACH,yCAAwD;AACxD,qDAAuD;AACvD,kDAA6C;AAC7C,2CAAsC;AACtC,8BAAiC;AACjC,0BAA6B;AAE7B,IAAM,EAAE,GAAG,iBAAO,CAAC,QAAQ,CAAC,CAAC;AAI7B;;;;;GAKG;AACH,wBAA+B,MAAc,EAAE,OAAe;IAC1D,MAAM,CAAC,yEAAuE,MAAM,SAAI,OAAO,eAAY,CAAA;AAC/G,CAAC;AAFD,wCAEC;AAED,uBAA8B,MAAc,EAAE,OAAe;IACzD,IAAI,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAE/B,IAAI,GAAG,GAAG,gBAAc,MAAM,SAAI,OAAS,CAAC;IAE5C,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,iCAAiC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA,CAAC;QACrD,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA,CAAC;YAChD,GAAG,GAAG,mDAAmD,GAAG,GAAG,CAAC;QACpE,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,GAAG,GAAG,8CAA8C,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C,aAAa,CAAC,MAAM,CAAC;YACtB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC;QAChC,CAAC,CAAC,CAAC;IAEP,CAAC;IAMD,sBAAI,sCAAM;QAJV;;;WAGG;aACH;YACI,MAAM,CAAC,iBAAM,SAAS,WAA8B,CAAC;QACzD,CAAC;;;OAAA;IAMD,sBAAI,uCAAO;QAJX;;;WAGG;aACH;YACI,MAAM,CAAC,iBAAM,UAAU,WAAmB,CAAC;QAC/C,CAAC;;;OAAA;IACL,yBAAC;AAAD,CAAC,AAnJD,CAAwC,qBAAS,GAmJhD;AAnJY,gDAAkB;AAoJ/B,EAAE,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAC3C,kBAAe,kBAAkB,CAAC","sourcesContent":["/**\r\n * Created by gavorhes on 12/7/2015.\r\n */\r\nimport {LayerBase, LayerBaseOptions} from './LayerBase';\r\nimport * as esriToOl from '../olHelpers/esriToOlStyle';\r\nimport mapPopup from '../olHelpers/mapPopup';\r\nimport provide from '../util/provide';\r\nimport ol = require('custom-ol');\r\nimport $ = require('jquery');\r\n\r\nconst nm = provide('layers');\r\n\r\n\r\n\r\n/**\r\n * Helper to return the url to the service on the production server\r\n * @param {string} folder\r\n * @param {string} service\r\n * @returns {string}\r\n */\r\nexport function makeServiceUrl(folder: string, service: string): string{\r\n return `https://transportal.cee.wisc.edu/applications/arcgis2/rest/services/${folder}/${service}/MapServer`\r\n}\r\n\r\nexport function localCacheUrl(folder: string, service: string): string{\r\n let loc = window.location.href;\r\n\r\n let url = `/mapserver/${folder}/${service}`;\r\n\r\n if (loc.indexOf('http://transportal.cee.wisc.edu') > -1){\r\n if (loc.toLowerCase().indexOf('webmapsstage') > -1){\r\n url = 'https://transportal.cee.wisc.edu/gis/webmapsstage' + url;\r\n } else {\r\n url = 'https://transportal.cee.wisc.edu/gis/webmaps' + url\r\n }\r\n }\r\n\r\n\r\n return url;\r\n}\r\n\r\n\r\n\r\n\r\nexport interface LayerEsriMapServerOptions extends LayerBaseOptions {\r\n addPopup?: boolean;\r\n showLayers?: Array<number>;\r\n}\r\n\r\n/**\r\n * esri mapserver layer\r\n * @augments LayerBase\r\n */\r\nexport class LayerEsriMapServer extends LayerBase {\r\n _esriFormat: ol.format.EsriJSON;\r\n _popupRequest: JQueryXHR;\r\n _showLayers: number[];\r\n\r\n /**\r\n * The base layer for all others\r\n * @param {string} url - resource url\r\n * @param {object} [options] - config\r\n * @param {string} [options.id] - layer id\r\n * @param {string} [options.name=Unnamed Layer] - layer name\r\n * @param {number} [options.opacity=1] - opacity\r\n * @param {boolean} [options.visible=true] - default visible\r\n * @param {number} [options.minZoom=undefined] - min zoom level, 0 - 28\r\n * @param {number} [options.maxZoom=undefined] - max zoom level, 0 - 28\r\n * @param {object} [options.params={}] the get parameters to include to retrieve the layer\r\n * @param {number} [options.zIndex=0] the z index for the layer\r\n * @param {function} [options.loadCallback] function to call on load, context this is the layer object\r\n * @param {boolean} [options.legendCollapse=false] if the legend item should be initially collapsed\r\n * @param {boolean} [options.legendCheckbox=true] if the legend item should have a checkbox for visibility\r\n * @param {boolean} [options.legendContent] additional content to add to the legend\r\n * @param {boolean} [options.addPopup=false] if a popup should be added\r\n * @param {undefined|Array<number>} [options.showLayers=undefined] if a popup should be added\r\n */\r\n constructor(url: string, options: LayerEsriMapServerOptions = {}) {\r\n\r\n super(url, options);\r\n this._source = new ol.source.TileArcGISRest(\r\n {\r\n url: this.url == '' ? undefined : this.url,\r\n params: typeof options.showLayers == 'undefined' ? undefined : {layers: 'show:' + options.showLayers.join(',')}\r\n }\r\n );\r\n\r\n this._showLayers = options.showLayers || [];\r\n\r\n this._olLayer = new ol.layer.Tile({\r\n source: this._source as ol.source.Tile,\r\n visible: this.visible,\r\n opacity: this.opacity,\r\n minResolution: this._minResolution,\r\n maxResolution: this._maxResolution\r\n });\r\n\r\n this._olLayer.setZIndex(this._zIndex);\r\n\r\n options.addPopup = typeof options.addPopup == 'boolean' ? options.addPopup : false;\r\n\r\n this._esriFormat = new ol.format.EsriJSON();\r\n this._popupRequest = null;\r\n\r\n this.addLegendContent();\r\n\r\n if (options.addPopup) {\r\n mapPopup.addMapServicePopup(this);\r\n }\r\n }\r\n\r\n /**\r\n * add additional content to the legend\r\n * @param {string} [additionalContent=''] additional content for legend\r\n */\r\n addLegendContent(additionalContent?: string) {\r\n let urlCopy = this.url;\r\n\r\n if (urlCopy[urlCopy.length - 1] !== '/') {\r\n urlCopy += '/';\r\n }\r\n\r\n urlCopy += 'legend?f=pjson&callback=?';\r\n\r\n $.get(urlCopy, {}, (d) => {\r\n let newHtml = esriToOl.makeMapServiceLegend(d, this._showLayers);\r\n super.addLegendContent(newHtml);\r\n }, 'json');\r\n }\r\n\r\n\r\n getPopupInfo(queryParams: {[s: string]: any}) {\r\n if (!this.visible) {\r\n return;\r\n }\r\n\r\n let urlCopy = this.url;\r\n\r\n if (urlCopy[urlCopy.length - 1] != '/') {\r\n urlCopy += '/';\r\n }\r\n\r\n urlCopy += 'identify?callback=?';\r\n\r\n let __this = this;\r\n\r\n if (this._popupRequest != null) {\r\n this._popupRequest.abort();\r\n }\r\n\r\n\r\n this._popupRequest = $.get(urlCopy, queryParams, function (d) {\r\n for (let r of d['results']) {\r\n\r\n let popupHtml = '<table class=\"esri-popup-table\">';\r\n\r\n for (let a in r['attributes']) {\r\n if (r['attributes'].hasOwnProperty(a)) {\r\n let attrVal = r['attributes'][a];\r\n\r\n if (attrVal == null || attrVal.toString().toLowerCase() == 'null') {\r\n continue;\r\n }\r\n\r\n let attr = a;\r\n if (attr.length > 14) {\r\n attr = attr.slice(0, 11) + '...';\r\n }\r\n\r\n popupHtml += `<tr><td>${attr}</td><td>${attrVal}</td></tr>`;\r\n }\r\n }\r\n\r\n popupHtml += '</table>';\r\n\r\n mapPopup.addMapServicePopupContent(__this._esriFormat.readFeature(r), __this, popupHtml, r['layerName']);\r\n }\r\n }, 'json');\r\n\r\n this._popupRequest.always(function () {\r\n __this._popupRequest = null;\r\n });\r\n\r\n }\r\n\r\n /**\r\n *\r\n * @returns {ol.source.TileArcGISRest} the vector source\r\n */\r\n get source(): ol.source.TileArcGISRest {\r\n return super.getSource() as ol.source.TileArcGISRest;\r\n }\r\n\r\n /**\r\n *\r\n * @returns the ol layer\r\n */\r\n get olLayer(): ol.layer.Tile {\r\n return super.getOlLayer() as ol.layer.Tile;\r\n }\r\n}\r\nnm.LayerEsriMapServer = LayerEsriMapServer;\r\nexport default LayerEsriMapServer;\r\n"]}
\ No newline at end of file
{"version":3,"file":"LayerEsriMapServer.js","sourceRoot":"","sources":["../../src/layers/LayerEsriMapServer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;GAEG;AACH,yCAAwD;AACxD,qDAAuD;AACvD,kDAA6C;AAC7C,2CAAsC;AACtC,8BAAiC;AACjC,0BAA6B;AAE7B,IAAM,EAAE,GAAG,iBAAO,CAAC,QAAQ,CAAC,CAAC;AAI7B;;;;;GAKG;AACH,wBAA+B,MAAc,EAAE,OAAe;IAC1D,MAAM,CAAC,yEAAuE,MAAM,SAAI,OAAO,eAAY,CAAA;AAC/G,CAAC;AAFD,wCAEC;AAED,uBAA8B,MAAc,EAAE,OAAe;IACzD,IAAI,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAE/B,IAAI,GAAG,GAAG,gBAAc,MAAM,SAAI,OAAS,CAAC;IAE5C,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA,CAAC;QAC9C,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA,CAAC;YAChD,GAAG,GAAG,mDAAmD,GAAG,GAAG,CAAC;QACpE,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,GAAG,GAAG,8CAA8C,GAAG,GAAG,CAAA;QAC9D,CAAC;IACL,CAAC;IAGD,MAAM,CAAC,GAAG,CAA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AChC,CAAC,CAAC,CAAC;IAEP,CAAC;IAMD,sBAAI,sCAAM;QAJV;;;WAGG;aACH;YACI,MAAM,CAAC,iBAAM,SAAS,WAA8B,CAAC;QACzD,CAAC;;;OAAA;IAMD,sBAAI,uCAAO;QAJX;;;WAGG;aACH;YACI,MAAM,CAAC,iBAAM,UAAU,WAAmB,CAAC;QAC/C,CAAC;;;OAAA;IACL,yBAAC;AAAD,CAAC,AAnJD,CAAwC,qBAAS,GAmJhD;AAnJY,gDAAkB;AAoJ/B,EAAE,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;AAC3C,kBAAe,kBAAkB,CAAC","sourcesContent":["/**\r\n * Created by gavorhes on 12/7/2015.\r\n */\r\nimport {LayerBase, LayerBaseOptions} from './LayerBase';\r\nimport * as esriToOl from '../olHelpers/esriToOlStyle';\r\nimport mapPopup from '../olHelpers/mapPopup';\r\nimport provide from '../util/provide';\r\nimport ol = require('custom-ol');\r\nimport $ = require('jquery');\r\n\r\nconst nm = provide('layers');\r\n\r\n\r\n\r\n/**\r\n * Helper to return the url to the service on the production server\r\n * @param {string} folder\r\n * @param {string} service\r\n * @returns {string}\r\n */\r\nexport function makeServiceUrl(folder: string, service: string): string{\r\n return `https://transportal.cee.wisc.edu/applications/arcgis2/rest/services/${folder}/${service}/MapServer`\r\n}\r\n\r\nexport function localCacheUrl(folder: string, service: string): string{\r\n let loc = window.location.href;\r\n\r\n let url = `/mapserver/${folder}/${service}`;\r\n\r\n if (loc.indexOf('transportal.cee.wisc.edu') > -1){\r\n if (loc.toLowerCase().indexOf('webmapsstage') > -1){\r\n url = 'https://transportal.cee.wisc.edu/gis/webmapsstage' + url;\r\n } else {\r\n url = 'https://transportal.cee.wisc.edu/gis/webmaps' + url\r\n }\r\n }\r\n\r\n\r\n return url;\r\n}\r\n\r\n\r\n\r\n\r\nexport interface LayerEsriMapServerOptions extends LayerBaseOptions {\r\n addPopup?: boolean;\r\n showLayers?: Array<number>;\r\n}\r\n\r\n/**\r\n * esri mapserver layer\r\n * @augments LayerBase\r\n */\r\nexport class LayerEsriMapServer extends LayerBase {\r\n _esriFormat: ol.format.EsriJSON;\r\n _popupRequest: JQueryXHR;\r\n _showLayers: number[];\r\n\r\n /**\r\n * The base layer for all others\r\n * @param {string} url - resource url\r\n * @param {object} [options] - config\r\n * @param {string} [options.id] - layer id\r\n * @param {string} [options.name=Unnamed Layer] - layer name\r\n * @param {number} [options.opacity=1] - opacity\r\n * @param {boolean} [options.visible=true] - default visible\r\n * @param {number} [options.minZoom=undefined] - min zoom level, 0 - 28\r\n * @param {number} [options.maxZoom=undefined] - max zoom level, 0 - 28\r\n * @param {object} [options.params={}] the get parameters to include to retrieve the layer\r\n * @param {number} [options.zIndex=0] the z index for the layer\r\n * @param {function} [options.loadCallback] function to call on load, context this is the layer object\r\n * @param {boolean} [options.legendCollapse=false] if the legend item should be initially collapsed\r\n * @param {boolean} [options.legendCheckbox=true] if the legend item should have a checkbox for visibility\r\n * @param {boolean} [options.legendContent] additional content to add to the legend\r\n * @param {boolean} [options.addPopup=false] if a popup should be added\r\n * @param {undefined|Array<number>} [options.showLayers=undefined] if a popup should be added\r\n */\r\n constructor(url: string, options: LayerEsriMapServerOptions = {}) {\r\n\r\n super(url, options);\r\n this._source = new ol.source.TileArcGISRest(\r\n {\r\n url: this.url == '' ? undefined : this.url,\r\n params: typeof options.showLayers == 'undefined' ? undefined : {layers: 'show:' + options.showLayers.join(',')}\r\n }\r\n );\r\n\r\n this._showLayers = options.showLayers || [];\r\n\r\n this._olLayer = new ol.layer.Tile({\r\n source: this._source as ol.source.Tile,\r\n visible: this.visible,\r\n opacity: this.opacity,\r\n minResolution: this._minResolution,\r\n maxResolution: this._maxResolution\r\n });\r\n\r\n this._olLayer.setZIndex(this._zIndex);\r\n\r\n options.addPopup = typeof options.addPopup == 'boolean' ? options.addPopup : false;\r\n\r\n this._esriFormat = new ol.format.EsriJSON();\r\n this._popupRequest = null;\r\n\r\n this.addLegendContent();\r\n\r\n if (options.addPopup) {\r\n mapPopup.addMapServicePopup(this);\r\n }\r\n }\r\n\r\n /**\r\n * add additional content to the legend\r\n * @param {string} [additionalContent=''] additional content for legend\r\n */\r\n addLegendContent(additionalContent?: string) {\r\n let urlCopy = this.url;\r\n\r\n if (urlCopy[urlCopy.length - 1] !== '/') {\r\n urlCopy += '/';\r\n }\r\n\r\n urlCopy += 'legend?f=pjson&callback=?';\r\n\r\n $.get(urlCopy, {}, (d) => {\r\n let newHtml = esriToOl.makeMapServiceLegend(d, this._showLayers);\r\n super.addLegendContent(newHtml);\r\n }, 'json');\r\n }\r\n\r\n\r\n getPopupInfo(queryParams: {[s: string]: any}) {\r\n if (!this.visible) {\r\n return;\r\n }\r\n\r\n let urlCopy = this.url;\r\n\r\n if (urlCopy[urlCopy.length - 1] != '/') {\r\n urlCopy += '/';\r\n }\r\n\r\n urlCopy += 'identify?callback=?';\r\n\r\n let __this = this;\r\n\r\n if (this._popupRequest != null) {\r\n this._popupRequest.abort();\r\n }\r\n\r\n\r\n this._popupRequest = $.get(urlCopy, queryParams, function (d) {\r\n for (let r of d['results']) {\r\n\r\n let popupHtml = '<table class=\"esri-popup-table\">';\r\n\r\n for (let a in r['attributes']) {\r\n if (r['attributes'].hasOwnProperty(a)) {\r\n let attrVal = r['attributes'][a];\r\n\r\n if (attrVal == null || attrVal.toString().toLowerCase() == 'null') {\r\n continue;\r\n }\r\n\r\n let attr = a;\r\n if (attr.length > 14) {\r\n attr = attr.slice(0, 11) + '...';\r\n }\r\n\r\n popupHtml += `<tr><td>${attr}</td><td>${attrVal}</td></tr>`;\r\n }\r\n }\r\n\r\n popupHtml += '</table>';\r\n\r\n mapPopup.addMapServicePopupContent(__this._esriFormat.readFeature(r), __this, popupHtml, r['layerName']);\r\n }\r\n }, 'json');\r\n\r\n this._popupRequest.always(function () {\r\n __this._popupRequest = null;\r\n });\r\n\r\n }\r\n\r\n /**\r\n *\r\n * @returns {ol.source.TileArcGISRest} the vector source\r\n */\r\n get source(): ol.source.TileArcGISRest {\r\n return super.getSource() as ol.source.TileArcGISRest;\r\n }\r\n\r\n /**\r\n *\r\n * @returns the ol layer\r\n */\r\n get olLayer(): ol.layer.Tile {\r\n return super.getOlLayer() as ol.layer.Tile;\r\n }\r\n}\r\nnm.LayerEsriMapServer = LayerEsriMapServer;\r\nexport default LayerEsriMapServer;\r\n"]}
\ No newline at end of file
......@@ -27,7 +27,7 @@ export function localCacheUrl(folder: string, service: string): string{
let url = `/mapserver/${folder}/${service}`;
if (loc.indexOf('http://transportal.cee.wisc.edu') > -1){
if (loc.indexOf('transportal.cee.wisc.edu') > -1){
if (loc.toLowerCase().indexOf('webmapsstage') > -1){
url = 'https://transportal.cee.wisc.edu/gis/webmapsstage' + url;
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment