From a1a402106c6b55d01d7d0ce744633a4bd64ce761 Mon Sep 17 00:00:00 2001 From: Michael Nelson Date: Thu, 7 Dec 2023 15:34:06 -0800 Subject: [PATCH] Update Geocoder URL Replace the deprecated Geocoder endpoint (apps.gov.bc.ca/pub/geocoder) with the new endpoint (geocoder.api.gov.bc.ca). --- lib/smk.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/smk.js b/lib/smk.js index 9e256eb..bc9b17f 100644 --- a/lib/smk.js +++ b/lib/smk.js @@ -153,7 +153,7 @@ this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.pow(Math.sin { loader: "group", tags: [ { loader: "script", url: "smk/query/query-esri-dynamic.js", load: function () { console.debug( "[smk/query/query-esri-dynamic.js]" ); include.module("query.query-esri-dynamic-js",["query.query-js"],function(){"use strict";function e(){SMK.TYPE.Query.prototype.constructor.apply(this,arguments)}function s(e,r){if(!(e.operator in n))throw new Error("unknown operator: "+JSON.stringify(e));return n[e.operator](e.arguments,r)}$.extend(e.prototype,SMK.TYPE.Query.prototype),(SMK.TYPE.Query["esri-dynamic"]=e).prototype.fetchUniqueValues=function(e,r){var i=this,n=r.layerId[this.layerId].config,o=JSON.parse(n.dynamicLayers[0]),a=n.serviceUrl+"/dynamicLayer/query";return delete o.drawingInfo,SMK.UTIL.asyncReduce(function(n,t){return function(e,n,r,i){var t=e.filter(function(e){return null!=e}),o="(1=1)";e.length!=t.length&&(o="( "+i+" IS NOT NULL )");0=i.maxUniqueValues&&t(),r})},[])},e.prototype.queryLayer=function(e,r,n){var t=n.layerId[this.layerId].config;if(1!=t.dynamicLayers.length)throw new Error("more than one dynamic layer def");var i=t.serviceUrl+"/dynamicLayer/query",o=JSON.parse(t.dynamicLayers[0]);delete o.drawingInfo;var a=s(this.predicate,e);if(!a)throw new Error("filter is empty");var u={f:"geojson",layer:JSON.stringify(o).replace(/^"|"$/g,""),where:a,outFields:"*",inSR:4326,outSR:4326,returnGeometry:!0,returnZ:!1,returnM:!1,returnIdsOnly:!1,returnCountOnly:!1,returnDistinctValues:!1};return r.within&&(u.geometry=n.getView().extent.join(","),u.geometryType="esriGeometryEnvelope",u.spatialRel="esriSpatialRelIntersects"),SMK.UTIL.makePromise(function(e,r){$.ajax({url:i,method:"POST",data:u,dataType:"json"}).then(e,r)}).then(function(e){if(console.log(e),!e)throw new Error("no features");if(!e.features||0==e.features.length)throw new Error("no features");return e.features.map(function(e,r){return t.titleAttribute?e.title=e.properties[t.titleAttribute]:e.title="Feature #"+(r+1),e})})};var n={and:function(e,n){if(0==e.length)throw new Error("AND needs at least 1 argument");return e.map(function(e){var r=s(e,n);if(r)return"( "+r+" )"}).filter(function(e){return!!e}).join(" AND ")},or:function(e,n){if(0==e.length)throw new Error("OR needs at least 1 argument");return e.map(function(e){var r=s(e,n);if(r)return"( "+r+" )"}).filter(function(e){return!!e}).join(" OR ")},equals:function(e,r){if(2!=e.length)throw new Error("EQUALS needs exactly 2 arguments");var n=i(e[0],r),t=i(e[1],r);if(n&&t)return n+" = "+t},"less-than":function(e,r){if(2!=e.length)throw new Error("LESS-THAN needs exactly 2 arguments");var n=i(e[0],r),t=i(e[1],r);if(n&&t)return n+" < "+t},"greater-than":function(e,r){if(2!=e.length)throw new Error("GREATER-THAN needs exactly 2 arguments");var n=i(e[0],r),t=i(e[1],r);if(n&&t)return n+" > "+t},contains:function(e,r){if(2!=e.length)throw new Error("CONTAINS needs exactly 2 arguments");var n=i(e[0],r),t=i(e[1],r,!1);if(n&&t)return n+" LIKE '%"+t+"%'"},"starts-with":function(e,r){if(2!=e.length)throw new Error("STARTS-WITH needs exactly 2 arguments");var n=i(e[0],r),t=i(e[1],r,!1);if(n&&t)return n+" LIKE '"+t+"%'"},"ends-with":function(e,r){if(2!=e.length)throw new Error("ENDS-WITH needs exactly 2 arguments");var n=i(e[0],r),t=i(e[1],r,!1);if(n&&t)return n+" LIKE '%"+t+"'"},not:function(e,r){if(1!=e.length)throw new Error("NOT needs exactly 1 argument");var n=s(e[0],r);if(n)return"NOT "+n}};function i(e,r,n){if(!(e.operand in t))throw new Error("unknown operand: "+JSON.stringify(e));return t[e.operand](e,r,n)}var t={attribute:function(e,r,n){return!1===n?"' || "+e.name+" || '":e.name},parameter:function(e,r,n){var t=r[e.id].value;if(null!=t&&""!==t)return(!1===n?"":"'")+t+(!1===n?"":"'")}}});} }, { loader: "script", url: "smk/query/query-esri-feature.js", load: function () { console.debug( "[smk/query/query-esri-feature.js]" ); include.module("query.query-esri-feature-js",["query.query-js"],function(){"use strict";function e(){SMK.TYPE.Query.prototype.constructor.apply(this,arguments)}function a(e,r){if(!(e.operator in t))throw new Error("unknown operator: "+JSON.stringify(e));return t[e.operator](e.arguments,r)}$.extend(e.prototype,SMK.TYPE.Query.prototype),(SMK.TYPE.Query["esri-feature"]=e).prototype.fetchUniqueValues=function(e,r){var u=this,t=r.layerId[this.layerId].config,n=JSON.parse(t.dynamicLayers[0]),o=t.serviceUrl+"/query";return delete n.drawingInfo,SMK.UTIL.asyncReduce(function(t,n){return function(e,t,r,u){var n=e.filter(function(e){return null!=e}),o="(1=1)";e.length!=n.length&&(o="( "+u+" IS NOT NULL )");0=u.maxUniqueValues&&n(),r})},[])},e.prototype.queryLayer=function(e,r,t){var n=t.layerId[this.layerId].config,u=n.serviceUrl+"/query",o=a(this.predicate,e);if(!o)throw new Error("filter is empty");var i={f:"geojson",where:o,outFields:"*",inSR:4326,outSR:4326,returnGeometry:!0,returnZ:!1,returnM:!1,returnIdsOnly:!1,returnCountOnly:!1,returnDistinctValues:!1};return r.within&&(i.geometry=t.getView().extent.join(","),i.geometryType="esriGeometryEnvelope",i.spatialRel="esriSpatialRelIntersects"),SMK.UTIL.makePromise(function(e,r){$.ajax({url:u,method:"POST",data:i,dataType:"json"}).then(e,r)}).then(function(e){if(console.log(e),!e)throw new Error("no features");if(!e.features||0==e.features.length)throw new Error("no features");return e.features.map(function(e,r){return n.titleAttribute?e.title=e.properties[n.titleAttribute]:e.title="Feature #"+(r+1),e})})};var t={and:function(e,t){if(0==e.length)throw new Error("AND needs at least 1 argument");return e.map(function(e){var r=a(e,t);if(r)return"( "+r+" )"}).filter(function(e){return!!e}).join(" AND ")},or:function(e,t){if(0==e.length)throw new Error("OR needs at least 1 argument");return e.map(function(e){var r=a(e,t);if(r)return"( "+r+" )"}).filter(function(e){return!!e}).join(" OR ")},equals:function(e,r){if(2!=e.length)throw new Error("EQUALS needs exactly 2 arguments");var t=u(e[0],r),n=u(e[1],r);if(t&&n)return t+" = "+n},"less-than":function(e,r){if(2!=e.length)throw new Error("LESS-THAN needs exactly 2 arguments");var t=u(e[0],r),n=u(e[1],r);if(t&&n)return t+" < "+n},"greater-than":function(e,r){if(2!=e.length)throw new Error("GREATER-THAN needs exactly 2 arguments");var t=u(e[0],r),n=u(e[1],r);if(t&&n)return t+" > "+n},contains:function(e,r){if(2!=e.length)throw new Error("CONTAINS needs exactly 2 arguments");var t=u(e[0],r),n=u(e[1],r,!1);if(t&&n)return t+" LIKE '%"+n+"%'"},"starts-with":function(e,r){if(2!=e.length)throw new Error("STARTS-WITH needs exactly 2 arguments");var t=u(e[0],r),n=u(e[1],r,!1);if(t&&n)return t+" LIKE '"+n+"%'"},"ends-with":function(e,r){if(2!=e.length)throw new Error("ENDS-WITH needs exactly 2 arguments");var t=u(e[0],r),n=u(e[1],r,!1);if(t&&n)return t+" LIKE '%"+n+"'"},not:function(e,r){if(1!=e.length)throw new Error("NOT needs exactly 1 argument");var t=a(e[0],r);if(t)return"NOT "+t}};function u(e,r,t){if(!(e.operand in n))throw new Error("unknown operand: "+JSON.stringify(e));return n[e.operand](e,r,t)}var n={attribute:function(e,r,t){return!1===t?"' || "+e.name+" || '":e.name},parameter:function(e,r,t){var n=r[e.id].value;if(null!=n&&""!==n)return(!1===t?"":"'")+n+(!1===t?"":"'")}}});} }, - { loader: "script", url: "smk/query/query-place.js", load: function () { console.debug( "[smk/query/query-place.js]" ); include.module("query.query-place-js",["query.query-js"],function(){"use strict";function e(){SMK.TYPE.Query.prototype.constructor.apply(this,arguments),this.title="Location",this.parameters=[{id:"param1",type:"input",title:"Place or road name"}]}$.extend(e.prototype,SMK.TYPE.Query.prototype),(SMK.TYPE.Query.place=e).prototype.canUseWithExtent=function(e){return!1},e.prototype.queryLayer=function(e,t,r){var o={maxResults:20,outputSRS:4326,addressString:e.param1.value,autoComplete:!0};return SMK.UTIL.makePromise(function(e,t){$.ajax({timeout:1e4,dataType:"jsonp",url:"https://apps.gov.bc.ca/pub/geocoder/addresses.geojsonp",data:o}).then(e,t)}).then(function(e){if(!e)throw new Error("no features");if(!e.features||0==e.features.length)throw new Error("no features");var t=e.features.map(function(e){if(e.geometry.coordinates&&"BC"!=e.properties.fullAddress)return e.title=e.properties.fullAddress,e}).filter(function(e){return e});if(0==t.length)throw new Error("no features");return t})}});} }, + { loader: "script", url: "smk/query/query-place.js", load: function () { console.debug( "[smk/query/query-place.js]" ); include.module("query.query-place-js",["query.query-js"],function(){"use strict";function e(){SMK.TYPE.Query.prototype.constructor.apply(this,arguments),this.title="Location",this.parameters=[{id:"param1",type:"input",title:"Place or road name"}]}$.extend(e.prototype,SMK.TYPE.Query.prototype),(SMK.TYPE.Query.place=e).prototype.canUseWithExtent=function(e){return!1},e.prototype.queryLayer=function(e,t,r){var o={maxResults:20,outputSRS:4326,addressString:e.param1.value,autoComplete:!0};return SMK.UTIL.makePromise(function(e,t){$.ajax({timeout:1e4,dataType:"jsonp",url:"https://geocoder.api.gov.bc.ca/addresses.geojsonp",data:o}).then(e,t)}).then(function(e){if(!e)throw new Error("no features");if(!e.features||0==e.features.length)throw new Error("no features");var t=e.features.map(function(e){if(e.geometry.coordinates&&"BC"!=e.properties.fullAddress)return e.title=e.properties.fullAddress,e}).filter(function(e){return e});if(0==t.length)throw new Error("no features");return t})}});} }, { loader: "script", url: "smk/query/query-vector.js", load: function () { console.debug( "[smk/query/query-vector.js]" ); include.module("query.query-vector-js",["query.query-js"],function(){"use strict";function r(){SMK.TYPE.Query.prototype.constructor.apply(this,arguments)}function i(r,e){if(!(r.operator in t))throw new Error("unknown operator: "+JSON.stringify(r));return t[r.operator](r.arguments,e)}$.extend(r.prototype,SMK.TYPE.Query.prototype),(SMK.TYPE.Query.vector=r).prototype.canUseWithExtent=function(r){return!1},r.prototype.fetchUniqueValues=function(e,r){var t={},n=!1;return r.visibleLayer[this.layerId].eachLayer(function(r){null==r.feature.properties[e]?n=!0:t[r.feature.properties[e]]=!0}),SMK.UTIL.resolved(Object.keys(t).concat(n?[null]:[]))},r.prototype.queryLayer=function(r,e,t){var n=t.layerId[this.layerId].config,o=i(this.predicate,r);if(!o)throw new Error("test is empty");var u=[];return t.visibleLayer[this.layerId].eachLayer(function(r){o(r.feature.properties)&&u.push(r.feature)}),SMK.UTIL.resolved(u).then(function(r){if(!r||0==r.length)throw new Error("no results");return r.map(function(r,e){return n.titleAttribute?r.title=r.properties[n.titleAttribute]:r.title="Feature #"+(e+1),r})})};var t={and:function(r,e){if(0==r.length)throw new Error("AND needs 1 or more arguments");var t=r.map(function(r){return i(r,e)}).filter(function(r){return!!r});if(0!=t.length)return function(e){return t.every(function(r){return r(e)})}},or:function(r,e){if(0==r.length)throw new Error("OR needs 1 or more arguments");var t=r.map(function(r){return i(r,e)}).filter(function(r){return!!r});if(0!=t.length)return function(e){return t.some(function(r){return r(e)})}},equals:function(r,e){if(2!=r.length)throw new Error("EQUALS needs exactly 2 arguments");var t=o(r[0],e),n=o(r[1],e);if(t&&n)return function(r){return t(r)==n(r)}},"less-than":function(r,e){if(2!=r.length)throw new Error("LESS-THAN needs exactly 2 arguments");var t=o(r[0],e),n=o(r[1],e);if(t&&n)return function(r){return t(r)n(r)}},contains:function(r,e){if(2!=r.length)throw new Error("CONTAINS needs exactly 2 arguments");var t=o(r[0],e),n=o(r[1],e);if(t&&n)return function(r){return new RegExp(n(r),"i").test(t(r))}},"starts-with":function(r,e){if(2!=r.length)throw new Error("STARTS-WITH needs exactly 2 arguments");var t=o(r[0],e),n=o(r[1],e);if(t&&n)return function(r){return new RegExp("^"+n(r),"i").test(t(r))}},"ends-with":function(r,e){if(2!=r.length)throw new Error("ENDS-WITH needs exactly 2 arguments");var t=o(r[0],e),n=o(r[1],e);if(t&&n)return function(r){return new RegExp(n(r)+"$","i").test(t(r))}},not:function(r,e){if(1!=r.length)throw new Error("NOT needs exactly 1 argument");var t=i(r[0],e);if(t)return function(r){return!t(r)}}};function o(r,e){if(!(r.operand in n))throw new Error("unknown operand: "+JSON.stringify(r));return n[r.operand](r,e)}var n={attribute:function(e,r,t){return function(r){if(!(e.name in r))throw new Error('"'+e.name+'" is not a valid attribute');return r[e.name]}},parameter:function(r,e,t){if(!(r.id in e))throw new Error('"'+r.id+'" is not a valid parameter');var n=e[r.id].value;if(null!=n&&""!==n)return function(){return n}}}});} }, { loader: "script", url: "smk/query/query-wms.js", load: function () { console.debug( "[smk/query/query-wms.js]" ); include.module("query.query-wms-js",["query.query-js"],function(){"use strict";function e(){SMK.TYPE.Query.prototype.constructor.apply(this,arguments)}function u(e,r){if(!(e.operator in t))throw new Error("unknown operator: "+JSON.stringify(e));return t[e.operator](e.arguments,r)}$.extend(e.prototype,SMK.TYPE.Query.prototype),(SMK.TYPE.Query.wms=e).prototype.canUseWithExtent=function(e){return!!e.layerId[this.layerId].config.geometryAttribute},e.prototype.fetchUniqueValues=function(e,r){var o=this,t=r.layerId[this.layerId].config,i=t.layerName,u=t.serviceUrl;return SMK.UTIL.asyncReduce(function(t,n){return function(e,t,r,o){var n=e.filter(function(e){return null!=e}),i="(1=1)";e.length!=n.length&&(i="( "+o+" IS NOT NULL )");0=o.maxUniqueValues&&n(),r})},[])},e.prototype.queryLayer=function(e,r,t){var n=t.layerId[this.layerId].config,o=u(this.predicate,e);if(!o)throw new Error("filter is empty");var i=$.extend({service:"WFS",version:"1.1.0",request:"GetFeature",srsName:"EPSG:4326",typename:n.layerName,outputformat:"application/json",cql_filter:o},e.option);return r.within&&n.geometryAttribute&&(i.cql_filter="( "+i.cql_filter+" ) AND BBOX( "+n.geometryAttribute+", "+t.getView().extent.join(", ")+", 'EPSG:4326' )"),SMK.UTIL.makePromise(function(e,r){$.ajax({url:n.serviceUrl,method:"GET",data:i,dataType:"json"}).then(e,r)}).then(function(e){if(console.log(e),!e)throw new Error("no features");if(!e.features||0==e.features.length)throw new Error("no features");return e.features.map(function(e,r){return n.titleAttribute?e.title=e.properties[n.titleAttribute]:e.title="Feature #"+(r+1),e})})};var t={and:function(e,t){if(0==e.length)throw new Error("AND needs at least 1 argument");return e.map(function(e){var r=u(e,t);if(r)return"( "+r+" )"}).filter(function(e){return!!e}).join(" AND ")},or:function(e,t){if(0==e.length)throw new Error("OR needs at least 1 argument");return e.map(function(e){var r=u(e,t);if(r)return"( "+r+" )"}).filter(function(e){return!!e}).join(" OR ")},equals:function(e,r){if(2!=e.length)throw new Error("EQUALS needs exactly 2 arguments");var t=o(e[0],r),n=o(e[1],r);if(t&&n)return t+" = "+n},"less-than":function(e,r){if(2!=e.length)throw new Error("LESS-THAN needs exactly 2 arguments");var t=o(e[0],r),n=o(e[1],r);if(t&&n)return t+" < "+n},"greater-than":function(e,r){if(2!=e.length)throw new Error("GREATER-THAN needs exactly 2 arguments");var t=o(e[0],r),n=o(e[1],r);if(t&&n)return t+" > "+n},contains:function(e,r){if(2!=e.length)throw new Error("CONTAINS needs exactly 2 arguments");var t=o(e[0],r),n=o(e[1],r,!1);if(t&&n)return t+" ILIKE '%"+n+"%'"},"starts-with":function(e,r){if(2!=e.length)throw new Error("STARTS-WITH needs exactly 2 arguments");var t=o(e[0],r),n=o(e[1],r,!1);if(t&&n)return t+" ILIKE '"+n+"%'"},"ends-with":function(e,r){if(2!=e.length)throw new Error("ENDS-WITH needs exactly 2 arguments");var t=o(e[0],r),n=o(e[1],r,!1);if(t&&n)return t+" ILIKE '%"+n+"'"},not:function(e,r){if(1!=e.length)throw new Error("NOT needs exactly 1 argument");var t=u(e[0],r);if(t)return"NOT "+t}};function o(e,r,t){if(!(e.operand in n))throw new Error("unknown operand: "+JSON.stringify(e));return n[e.operand](e,r,t)}var n={attribute:function(e,r,t){return!1===t?"' || "+e.name+" || '":e.name},parameter:function(e,r,t){var n=r[e.id].value;if(null!=n&&""!==n)return(!1===t?"":"'")+n+(!1===t?"":"'")}}});} }, { loader: "script", url: "smk/query/query.js", load: function () { console.debug( "[smk/query/query.js]" ); include.module("query.query-js",["jquery","util","event"],function(){"use strict";var o=SMK.TYPE.Event.define([]);function t(t,e){o.prototype.constructor.call(this),Object.assign(this,e),this.layerId=t,this.id=this.layerId+"--"+this.id}function u(t,e){this.id=t.id+"--"+e.id,this.layerId=t.layerId,this.component="parameter-"+e.type,this.prop=$.extend(!0,{value:null,focus:0},e),this.initial=e.value}$.extend(t.prototype,o.prototype),t.prototype.maxUniqueValues=100,(SMK.TYPE.Query=t).prototype.getParameters=function(e){var o=this;return this.parameters.map(function(t){return new u[t.type](o,t,e)})},t.prototype.queryLayer=function(t){console.log("not implemented",t)},t.prototype.fetchUniqueValues=function(t,e){console.log("not implemented",t)},t.prototype.canUseWithExtent=function(t){return!0},u.prototype.mounted=function(){},u.prototype.focus=function(){},u.constant=function(){u.prototype.constructor.apply(this,arguments)},Object.assign(u.constant.prototype,u.prototype),u.input=function(){u.prototype.constructor.apply(this,arguments)},Object.assign(u.input.prototype,u.prototype),u.input.prototype.focus=function(){this.prop.focus+=1},u.select=function(){u.prototype.constructor.apply(this,arguments)},Object.assign(u.select.prototype,u.prototype),u["select-unique"]=function(t,e,o){var n=this;e.type="select";var i=e.uniqueAttribute;delete e.uniqueAttribute,u.prototype.constructor.call(this,t,e),this.mounted=function(){n.fetchUnique||(n.fetchUnique=t.fetchUniqueValues(i,o).then(function(t){Vue.set(n.prop,"choices",t.map(function(t){return{value:t}}).sort(function(t,e){return t.value>e.value?1:-1}))}).catch(function(t){console.warn(t),n.prop.useFallback=!0}))}},Object.assign(u["select-unique"].prototype,u.prototype)});} } @@ -723,7 +723,7 @@ u.rest=u.tail=u.drop=function(a,b,c){return m.call(a,null==b||c?1:b)},u.compact= { loader: "template", url: "smk/tool/search/panel-search.html", load:"\n \n\n
\n
\n
\n
\n {{ result.properties.intersectionName }}\n
\n
\n {{ result.properties.civicNumber }}\n {{ result.properties.streetName }}\n {{ result.properties.streetQualifier }}\n {{ result.properties.streetType }}\n
\n
\n {{ result.properties.localityName }}\n ({{ result.properties.localityType }})\n
\n
\n
\n\n speaker_notes\n
\n
" }, { loader: "template", url: "smk/tool/search/popup-search.html", load:"
\n
\n
\n
\n {{ feature.properties.intersectionName }}\n
\n
\n {{ feature.properties.civicNumber }}\n {{ feature.properties.streetName }}\n {{ feature.properties.streetQualifier }}\n {{ feature.properties.streetType }}\n
\n
\n {{ feature.properties.localityName }}\n ({{ feature.properties.localityType }})\n
\n
\n
\n\n
\n \n \n \n \n \n \n
\n\n
\n Directions to here\n
\n
\n" }, { loader: "style", url: "smk/tool/search/tool-search.css", load: "/* [smk/tool/search/tool-search.css] */\n.smk-tool-search .smk-toolbar{min-width:var(--panel-width)}.smk-search-panel .smk-search-result{font-size:12px;cursor:pointer;padding:5px;display:flex;flex-direction:row;justify-content:space-between;align-items:center}.smk-search-panel .smk-search-result.smk-highlighted{font-weight:700}.smk-search-panel .smk-search-result .smk-highlight{opacity:0;margin:-5px}.smk-search-panel .smk-search-result:hover .smk-highlight{opacity:.3}.smk-search-panel .smk-search-result.smk-highlighted .smk-highlight{opacity:1}.smk-tool.smk-search-tool{width:100%;display:flex;justify-content:flex-start;align-items:stretch;display:flex}.smk-tool.smk-search-tool input{border:0;align-self:stretch;padding-left:4px;margin:2px;border-radius:2px;width:100%}.smk-tool.smk-search-tool input:focus{outline:0}.smk-sidepanel .smk-search-location-panel .smk-body .smk-address{font-weight:700}.smk-sidepanel .smk-search-location-panel .smk-body .smk-coordinate{margin-top:5px}" }, - { loader: "script", url: "smk/tool/search/tool-search.js", load: function () { console.debug( "[smk/tool/search/tool-search.js]" ); include.module("tool-search",["tool","sidepanel","widgets","tool-search.widget-search-html","tool-search.panel-search-html"],function(e){"use strict";var a;function t(e){this.makePropWidget("icon"),this.makePropWidget("initialSearch",0),this.makePropPanel("results",[]),this.makePropPanel("highlightId",null),SMK.TYPE.PanelTool.prototype.constructor.call(this,$.extend({widgetComponent:"search-widget",panelComponent:"search-panel"},e))}return Vue.component("search-widget",{mixins:[e.widgets.emit],template:e["tool-search.widget-search-html"],props:["id","type","title","visible","enabled","active","icon","type","initialSearch"],data:function(){return{search:null}},watch:{initialSearch:function(){this.search=null}},computed:{classes:function(){var e={};return e["smk-"+this.type+"-tool"]=!0,Object.assign(e,{"smk-tool-active":this.active,"smk-tool-visible":this.visible,"smk-tool-enabled":this.enabled})}},methods:{focus:function(){this.active||this.$refs["search-input"].focus()}}}),Vue.component("search-panel",{extends:e.widgets.toolPanel,template:e["tool-search.panel-search-html"],props:["results","highlightId"],methods:{isEmpty:function(){return!this.results||0==this.results.length}},data:function(){return{search:null}}}),SMK.TYPE.SearchTool=t,$.extend(t.prototype,SMK.TYPE.PanelTool.prototype),(t.prototype.afterInitialize=[]).push(function(t){var i=this;t.$container.classList.add("smk-tool-search"),t.on(this.id,{activate:function(e){i.enabled&&(e.toggle?i.active=!i.active:i.active=!0)},"input-change":function(e){t.$viewer.searched.clear(),i.busy=!0,function(e){a&&a.abort();var t={maxResults:20,outputSRS:4326,addressString:e,autoComplete:!0};return SMK.UTIL.resolved().then(function(){return a=$.ajax({timeout:1e4,dataType:"jsonp",url:"https://apps.gov.bc.ca/pub/geocoder/addresses.geojsonp",data:t})}).then(function(e){return $.map(e.features,function(e){if(e.geometry.coordinates&&"BC"!=e.properties.fullAddress)return e})})}(e.text).then(function(e){i.active=!0,t.$viewer.searched.add("search",e,"fullAddress"),i.busy=!1}).catch(function(e){console.warn("search failure:",e)})},hover:function(e){t.$viewer.searched.highlight(e.result?[e.result.id]:[])},pick:function(e){t.$viewer.searched.pick(null),t.$viewer.searched.pick(e.result.id)},clear:function(e){t.$viewer.searched.clear(),i.initialSearch+=1}}),t.$viewer.searched.addedFeatures(function(e){i.results=e.features}),t.$viewer.searched.pickedFeature(function(e){i.highlightId=e.feature&&e.feature.id,"search-popup"==i.showFeatures&&(i.popupModel.feature=e.feature)}),t.$viewer.searched.clearedFeatures(function(e){i.results=[]})}),t});} }, + { loader: "script", url: "smk/tool/search/tool-search.js", load: function () { console.debug( "[smk/tool/search/tool-search.js]" ); include.module("tool-search",["tool","sidepanel","widgets","tool-search.widget-search-html","tool-search.panel-search-html"],function(e){"use strict";var a;function t(e){this.makePropWidget("icon"),this.makePropWidget("initialSearch",0),this.makePropPanel("results",[]),this.makePropPanel("highlightId",null),SMK.TYPE.PanelTool.prototype.constructor.call(this,$.extend({widgetComponent:"search-widget",panelComponent:"search-panel"},e))}return Vue.component("search-widget",{mixins:[e.widgets.emit],template:e["tool-search.widget-search-html"],props:["id","type","title","visible","enabled","active","icon","type","initialSearch"],data:function(){return{search:null}},watch:{initialSearch:function(){this.search=null}},computed:{classes:function(){var e={};return e["smk-"+this.type+"-tool"]=!0,Object.assign(e,{"smk-tool-active":this.active,"smk-tool-visible":this.visible,"smk-tool-enabled":this.enabled})}},methods:{focus:function(){this.active||this.$refs["search-input"].focus()}}}),Vue.component("search-panel",{extends:e.widgets.toolPanel,template:e["tool-search.panel-search-html"],props:["results","highlightId"],methods:{isEmpty:function(){return!this.results||0==this.results.length}},data:function(){return{search:null}}}),SMK.TYPE.SearchTool=t,$.extend(t.prototype,SMK.TYPE.PanelTool.prototype),(t.prototype.afterInitialize=[]).push(function(t){var i=this;t.$container.classList.add("smk-tool-search"),t.on(this.id,{activate:function(e){i.enabled&&(e.toggle?i.active=!i.active:i.active=!0)},"input-change":function(e){t.$viewer.searched.clear(),i.busy=!0,function(e){a&&a.abort();var t={maxResults:20,outputSRS:4326,addressString:e,autoComplete:!0};return SMK.UTIL.resolved().then(function(){return a=$.ajax({timeout:1e4,dataType:"jsonp",url:"https://geocoder.api.gov.bc.ca/addresses.geojsonp",data:t})}).then(function(e){return $.map(e.features,function(e){if(e.geometry.coordinates&&"BC"!=e.properties.fullAddress)return e})})}(e.text).then(function(e){i.active=!0,t.$viewer.searched.add("search",e,"fullAddress"),i.busy=!1}).catch(function(e){console.warn("search failure:",e)})},hover:function(e){t.$viewer.searched.highlight(e.result?[e.result.id]:[])},pick:function(e){t.$viewer.searched.pick(null),t.$viewer.searched.pick(e.result.id)},clear:function(e){t.$viewer.searched.clear(),i.initialSearch+=1}}),t.$viewer.searched.addedFeatures(function(e){i.results=e.features}),t.$viewer.searched.pickedFeature(function(e){i.highlightId=e.feature&&e.feature.id,"search-popup"==i.showFeatures&&(i.popupModel.feature=e.feature)}),t.$viewer.searched.clearedFeatures(function(e){i.results=[]})}),t});} }, { loader: "template", url: "smk/tool/search/widget-search.html", load:"
\n \n\n {{ icon }}\n \n
" } ] } );