jgis 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/2d/index.js +1 -1
- package/dist/2d/index.mjs +330 -275
- package/dist/2d/layer.d.ts +21 -2
- package/dist/2d/types.d.ts +9 -0
- package/dist/2d/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/2d/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var te=Object.defineProperty,re=Object.defineProperties;var ne=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var q=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,R=(e,t)=>{for(var r in t||(t={}))oe.call(t,r)&&q(e,r,t[r]);if(Z)for(var r of Z(t))se.call(t,r)&&q(e,r,t[r]);return e},k=(e,t)=>re(e,ne(t));var I=(e,t,r)=>new Promise((n,o)=>{var s=c=>{try{a(r.next(c))}catch(u){o(u)}},i=c=>{try{a(r.throw(c))}catch(u){o(u)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,i);a((r=r.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("ol"),L=require("ol/layer"),w=require("ol/source"),A=require("ol/format"),ae=require("ol/Overlay"),T=require("ol/geom"),ce=require("ol/Feature");require("ol/extent");const p=require("ol/style"),ie=require("ol/events/condition.js"),le=require("ol/interaction/Select");var g=63710088e-1,ue={centimeters:g*100,centimetres:g*100,degrees:360/(2*Math.PI),feet:g*3.28084,inches:g*39.37,kilometers:g/1e3,kilometres:g/1e3,meters:g,metres:g,miles:g/1609.344,millimeters:g*1e3,millimetres:g*1e3,nauticalmiles:g/1852,radians:1,yards:g*1.0936};function W(e,t,r={}){const n={type:"Feature"};return(r.id===0||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function C(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!G(e[0])||!G(e[1]))throw new Error("coordinates must contain numbers");return W({type:"Point",coordinates:e},t,r)}function fe(e,t,r={}){for(const o of e){if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(o[o.length-1].length!==o[0].length)throw new Error("First and last Position are not equivalent.");for(let s=0;s<o[o.length-1].length;s++)if(o[o.length-1][s]!==o[0][s])throw new Error("First and last Position are not equivalent.")}return W({type:"Polygon",coordinates:e},t,r)}function ye(e,t="kilometers"){const r=ue[t];if(!r)throw new Error(t+" units is invalid");return e/r}function $(e){return e%(2*Math.PI)*180/Math.PI}function j(e){return e%360*Math.PI/180}function G(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function ge(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function de(e,t,r,n={}){const o=ge(e),s=j(o[0]),i=j(o[1]),a=j(r),c=ye(t,n.units),u=Math.asin(Math.sin(i)*Math.cos(c)+Math.cos(i)*Math.sin(c)*Math.cos(a)),d=s+Math.atan2(Math.sin(a)*Math.sin(c)*Math.cos(i),Math.cos(c)-Math.sin(i)*Math.sin(u)),x=$(d),l=$(u);return o[2]!==void 0?C([x,l,o[2]],n.properties):C([x,l],n.properties)}function me(e,t,r={}){const n=r.steps||64,o=r.properties?r.properties:!Array.isArray(e)&&e.type==="Feature"&&e.properties?e.properties:{},s=[];for(let i=0;i<n;i++)s.push(de(e,t,i*-360/n,r).geometry.coordinates);return s.push(s[0]),fe([s],o)}function J(e){return e.lttd&&e.lgtd?[Number(e.lgtd),Number(e.lttd)]:e.jd&&e.wd?[Number(e.jd),Number(e.wd)]:e.latitude&&e.longitude?[Number(e.longitude),Number(e.latitude)]:e.lon&&e.lat?[Number(e.lon),Number(e.lat)]:[0,0]}function B(e,t){e.getLayers().getArray().forEach(n=>{n.get("name")==t&&("setSource"in n&&n.setSource(null),"dispose"in n&&n.dispose(),e.removeLayer(n))})}function we(e,t,r){const n=[];let o;const s=r.type||"Point";t.forEach(a=>{switch(s){case"Point":o=be(a);break;case"LineString":o=Me(a);break;case"MultiLineString":o=Se(a);break;case"MultiPolygon":o=Pe(a);break;case"Polygon":o=Ee(a);break}if(!o)return;const c=new ce({geometry:o,data:a});c.set("layerName",e),n.push(c)});const i=new w.Vector;return n.length>0&&i.addFeatures(n),i}function he(e,t){return t.cqlFilter&&(t.cqlFilter?t.CQL_FILTER+=` and ${t.cqlFilter}`:t.CQL_FILTER=t.cqlFilter),new w.TileWMS({url:t.url,params:{LAYERS:t.layers,CQL_FILTER:t.CQL_FILTER},serverType:"geoserver",crossOrigin:"anonymous"})}function be(e){const t=J(e);if(t)return new T.Point(t)}function Me(e){return new T.LineString(e.coordinates)}function Se(e){return new T.MultiLineString(e.coordinates)}function Pe(e){return new T.MultiPolygon(e.coordinates)}function Ee(e){return new T.Polygon(e.coordinates)}function N(e,t){let r=null;return t.style?r=t.style:t.getStyle?r=(n,o)=>t.getStyle(e,n,o):r=Le(),r}function Le(){return(t,r)=>new p.Style({image:new p.Circle({radius:5,fill:new p.Fill({color:"red"})})})}function xe(e,t={}){const r=t.token||"dadcbbdb5206b626a29ca739686b3087",n=t.baseType||"img",o=t.noteType||"cia",s=new L.Tile({className:"tdt-base-layer",source:new w.XYZ({url:`http://t0.tianditu.com/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${r}`,maxZoom:t.maxZoom||18,minZoom:t.minZoom||2}),zIndex:t.zIndex||1});s.set("name","tdt-base-layer");const i=new L.Tile({className:"tdt-base-layer",source:new w.XYZ({url:`http://t0.tianditu.com/DataServer?T=${o}_w&x={x}&y={y}&l={z}&tk=${r}`,maxZoom:t.maxZoom||18,minZoom:t.minZoom||2}),zIndex:t.zIndex?t.zIndex+1:2});return i.set("name","tdt-baseNote-layer"),e.addLayer(s),e.addLayer(i),s}function U(e,t,r,n){(!n||!n.type)&&(n=Object.assign({},r,n));const o=n.type||"Point";let s;switch(o){case"GeoJSON":s=Fe(t,r,e,n);break;case"Wms":s=Te(t,e,n);break;case"Point":case"LineString":case"MultiLineString":case"Polygon":case"MultiPolygon":s=Ie(t,r,e,n);break;case"Circle":s=Ae(t,r,e,n);break;case"Overlay":s=Oe(t,r,e,n);break}return s}function ve(e,t){Array.isArray(t)?t.forEach(r=>{B(e,r)}):B(e,t)}function Fe(e,t,r,n){console.log(typeof t,t);const o=new A.GeoJSON().readFeatures(t,{dataProjection:"EPSG:4326",featureProjection:"EPSG:4326"}),s=new w.Vector;s.addFeatures(o);const i=new L.Vector({source:s,style:N(e,n),zIndex:n.zIndex||10});return i.set("name",e),i.set("type","webgl"),r.addLayer(i),i}function Te(e,t,r){const n=new L.Tile({opacity:r.opacity||1,source:he(e,r),zIndex:r.zIndex||10});return n.set("name",e),t.addLayer(n),n}function Ie(e,t,r,n){if(!t||t.length===0)return null;const o=new L.Vector({source:we(e,t,n),style:N(e,n),zIndex:n.zIndex||10});return o.set("name",e),o.set("type","webgl"),r.addLayer(o),o}function Ae(e,t,r,n){const o=J(t),s=me(o,n.radius,{steps:300,units:"meters"}),i=new A.GeoJSON().readFeature(s,{dataProjection:"EPSG:4326",featureProjection:"EPSG:4490"}),a=new w.Vector({wrapX:!1});a.addFeature(i);const c=new L.Vector({source:a,style:N(e,n),zIndex:n.zIndex?n.zIndex:10});return c.set("name",e),c.set("type","webgl"),r.addLayer(c),c}function Oe(e,t,r,n){const o=document.createElement("div"),s=new ae({element:o,stopEvent:!1,positioning:n.positioning||"bottom-center"});return s.set("name",e),s.set("type","webgl"),r.addOverlay(s),{overlayer:s,content:o}}const F=new Map,E={},v={},Re=(e,t)=>{F.has(e)&&console.warn(`Map with target '${e}' already exists. Overwriting...`),F.set(e,t),E[e]&&(E[e].forEach(r=>r(t)),delete E[e]),v[e]&&(v[e].forEach(r=>r(t)),delete v[e])};function D(e){const t=F.get(e);return t?Promise.resolve(t):(console.warn(`Map '${e}' not found. Make sure useMap() is called first.`),new Promise(r=>{v[e]=v[e]||[],v[e].push(r)}))}const ke=e=>{F.has(e)&&(F.delete(e),delete E[e])},H=(e,t)=>{const r=F.get(e);if(r){t(r);return}E[e]||(E[e]=[]),E[e].push(t)};function pe(e,t={}){if(!e&&!e.target)throw new Error("请传入地图容器");arguments.length===1&&typeof e=="object"&&(t=e,e=t.target);const n=Object.assign({zoom:10,center:[104.064839,30.548857],minZoom:2,maxZoom:19,projection:"EPSG:4326"},t),o=new V.Map({target:e,layers:[],view:new V.View({projection:n.projection,center:n.center,zoom:n.zoom,minZoom:n.minZoom,maxZoom:n.maxZoom})});return o.targetId=e,o}function je(e,t,r,n){U(e,t,r,k(R({},n),{type:"Point"}))}function Q(e,t,r){return new Promise((n,o)=>{e.getView().animate({center:t,duration:r.duration||1e3,zoom:r.zoom||X(e),rotation:r.rotation||0,easing:r.easing},n)})}function Y(e,t){const r=(t.extend[0]+t.extend[2])/2,n=(t.extend[1]+t.extend[3])/2;return Q(e,[r,n],t)}function Ne(e,t,r){const n=t.getGeometry().getExtent();return Y(e,k(R({},r),{extend:n}))}function _e(e){return e.getView().getProjection()}function X(e){return e.getView().getZoom()}function ze(e,t){e.getView().setZoom(t)}function Ze(e,t){e.un("click",()=>{}),e.un("pointermove",()=>{}),ke(t)}let P=null;function qe(e,t={}){const r=new A.GeoJSON;P=new le({condition:ie.click,multi:t.multi||!1,style:a=>{if(typeof t.getStyle=="function"){const c=a.get("layerName");return t.getStyle(c,a)}else return t.style},layers:t.layers?a=>t.layers.includes(a):void 0}),e.addInteraction(P);const n=P.getFeatures(),o=a=>I(null,null,function*(){const c=(t.layers||e.getLayers().getArray()).filter(h=>{const b=h.getSource();return h.getVisible()&&(b instanceof w.TileWMS||b instanceof w.ImageWMS)});if(c.length===0)return;const u=e.getView(),d=c.map(h=>I(null,null,function*(){const f=h.getSource().getFeatureInfoUrl(a.coordinate,u.getResolution(),u.getProjection(),{INFO_FORMAT:"application/json",FEATURE_COUNT:1});if(f)try{const M=yield(yield fetch(f)).json();if(M.features&&M.features.length>0){const m=r.readFeatures(M);return m.forEach(y=>{y.set("wms_layer_source",h),y.set("wms_event_source",a),y.set("layerName",h.get("name"))}),m}}catch(S){console.warn(S)}return[]})),l=(yield Promise.all(d)).flat();l.length>0&&(t.multi,n.extend(l),P.dispatchEvent({type:"select",selected:l,deselected:[],mapBrowserEvent:a}))});e.on("singleclick",o);const s=new Set;P.on("select",a=>{const c=n.getArray();if(c.length>0){const u=c.map(d=>({feature:d,properties:d.getProperties(),layer:d.get("wms_layer_source")||P.getLayer(d),event:d.get("wms_event_source")||a}));i(u)}else i(null)});const i=a=>s.forEach(c=>c(a));return{onSelect:a=>(s.add(a),()=>s.delete(a)),clear:()=>{s.clear(),n.clear()},destroy:()=>{e.removeInteraction(P),e.un("singleclick",o),s.clear()}}}function Ve(e,t={}){var x;const r=new A.GeoJSON,n=(x=t.debounceTime)!=null?x:200,o=new w.Vector,s=new L.Vector({source:o,map:e,style:t.style,zIndex:1e4,properties:{title:"JG_HOVER_LAYER"}});let i=null,a=null;const c=new Set,u=(l,h,b)=>{const f=l[0];if(i!==f)if(i=f,o.clear(),f?(o.addFeature(f),t.cursor!==!1&&(e.getTargetElement().style.cursor="pointer")):t.cursor!==!1&&(e.getTargetElement().style.cursor=""),f){const S={feature:f,layer:h,properties:f.getProperties(),coordinate:b};c.forEach(M=>M([S]))}else c.forEach(S=>S(null))},d=l=>{if(l.dragging)return;const h=l.pixel,b=l.coordinate;let f=!1;if(e.forEachFeatureAtPixel(h,(m,y)=>{f||y!==s&&(t.layers&&!t.layers.includes(y)||(f=!0,a&&clearTimeout(a),u([m],y,b)))}),f)return;i&&(i=null,o.clear(),e.getTargetElement().style.cursor="",c.forEach(m=>m(null))),a&&clearTimeout(a);const M=(t.layers||e.getLayers().getArray()).filter(m=>{const y=m.getSource();return m.getVisible()&&(y instanceof w.TileWMS||y instanceof w.ImageWMS)});M.length!==0&&(a=setTimeout(()=>I(null,null,function*(){const m=e.getView();for(const y of M){const _=y.getSource().getFeatureInfoUrl(b,m.getResolution(),m.getProjection(),{INFO_FORMAT:"application/json",FEATURE_COUNT:1});if(_)try{const O=yield(yield fetch(_)).json();if(O.features&&O.features.length>0){const z=r.readFeatures(O);z.forEach(ee=>ee.set("wms_layer_source",y)),u(z,y,b);return}}catch(K){}}}),n))};return e.on("pointermove",d),{onHover:l=>(c.add(l),()=>c.delete(l)),clear:()=>{o.clear(),i=null},destroy:()=>{e.un("pointermove",d),e.removeLayer(s),c.clear(),a&&clearTimeout(a)}}}const Ce=(e,t)=>{const r=pe(e,t);xe(r,t.baseLayers);const n={targetId:e,instance:r,addMarker:(o,s,i)=>je(r,o,s,i),createLayer:(o,s,i)=>U(r,o,s,i),removeLayer:o=>ve(r,o),useSelect:o=>qe(r,o),useHover:o=>Ve(r,o),flyTo:(o,s)=>Q(r,o,s),flyToByExtent:o=>Y(r,o),flyToByFeature:(o,s)=>Ne(r,o,s),getProjection:()=>_e(r),getZoom:()=>X(r),setZoom:o=>ze(r,o),getMapContext:o=>D(o),onMapReady:(o,s)=>H(o,s),destroyMap:()=>Ze(r,e)};return Re(e,n),n};function $e(e,t){H(e,t)}function Ge(e){return D(e)}exports.getMapContext=Ge;exports.onMapReady=$e;exports.useMap=Ce;
|
|
1
|
+
"use strict";var oe=Object.defineProperty,se=Object.defineProperties;var ae=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var C=(e,t,r)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,N=(e,t)=>{for(var r in t||(t={}))ce.call(t,r)&&C(e,r,t[r]);if(V)for(var r of V(t))ie.call(t,r)&&C(e,r,t[r]);return e},p=(e,t)=>se(e,ae(t));var I=(e,t,r)=>new Promise((o,n)=>{var s=i=>{try{c(r.next(i))}catch(l){n(l)}},a=i=>{try{c(r.throw(i))}catch(l){n(l)}},c=i=>i.done?o(i.value):Promise.resolve(i.value).then(s,a);c((r=r.apply(e,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("ol"),L=require("ol/layer"),w=require("ol/source"),A=require("ol/format"),le=require("ol/Overlay"),T=require("ol/geom"),ue=require("ol/Feature");require("ol/extent");const j=require("ol/style"),ye=require("ol/events/condition.js"),fe=require("ol/interaction/Select");var g=63710088e-1,ge={centimeters:g*100,centimetres:g*100,degrees:360/(2*Math.PI),feet:g*3.28084,inches:g*39.37,kilometers:g/1e3,kilometres:g/1e3,meters:g,metres:g,miles:g/1609.344,millimeters:g*1e3,millimetres:g*1e3,nauticalmiles:g/1852,radians:1,yards:g*1.0936};function D(e,t,r={}){const o={type:"Feature"};return(r.id===0||r.id)&&(o.id=r.id),r.bbox&&(o.bbox=r.bbox),o.properties=t||{},o.geometry=e,o}function B(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!W(e[0])||!W(e[1]))throw new Error("coordinates must contain numbers");return D({type:"Point",coordinates:e},t,r)}function de(e,t,r={}){for(const n of e){if(n.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(n[n.length-1].length!==n[0].length)throw new Error("First and last Position are not equivalent.");for(let s=0;s<n[n.length-1].length;s++)if(n[n.length-1][s]!==n[0][s])throw new Error("First and last Position are not equivalent.")}return D({type:"Polygon",coordinates:e},t,r)}function me(e,t="kilometers"){const r=ge[t];if(!r)throw new Error(t+" units is invalid");return e/r}function G(e){return e%(2*Math.PI)*180/Math.PI}function z(e){return e%360*Math.PI/180}function W(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function we(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function he(e,t,r,o={}){const n=we(e),s=z(n[0]),a=z(n[1]),c=z(r),i=me(t,o.units),l=Math.asin(Math.sin(a)*Math.cos(i)+Math.cos(a)*Math.sin(i)*Math.cos(c)),d=s+Math.atan2(Math.sin(c)*Math.sin(i)*Math.cos(a),Math.cos(i)-Math.sin(a)*Math.sin(l)),P=G(d),u=G(l);return n[2]!==void 0?B([P,u,n[2]],o.properties):B([P,u],o.properties)}function be(e,t,r={}){const o=r.steps||64,n=r.properties?r.properties:!Array.isArray(e)&&e.type==="Feature"&&e.properties?e.properties:{},s=[];for(let a=0;a<o;a++)s.push(he(e,t,a*-360/o,r).geometry.coordinates);return s.push(s[0]),de([s],n)}function k(e){return e.lttd&&e.lgtd?[Number(e.lgtd),Number(e.lttd)]:e.jd&&e.wd?[Number(e.jd),Number(e.wd)]:e.latitude&&e.longitude?[Number(e.longitude),Number(e.latitude)]:e.lon&&e.lat?[Number(e.lon),Number(e.lat)]:[0,0]}function J(e,t){e.getLayers().getArray().forEach(o=>{o.get("name")==t&&("setSource"in o&&o.setSource(null),"dispose"in o&&o.dispose(),e.removeLayer(o))})}function U(e,t,r,o=!1){const n=o?r.style||r.getStyle(e,t):void 0,s=o?999:-1;n&&typeof n.setZIndex=="function"&&n.setZIndex(s),t.setStyle(n)}function Se(e,t,r){if(!t)return;const o=r.time||300;let n=Date.now(),s=!1,a=0;t.running=!0;function c(){if(!t.running)return;const i=Date.now();i-n>=o&&(s=!s,n=i,U(e,t,r,s),t.changed()),a=requestAnimationFrame(c)}c(),t.clearFlash=()=>{t.running=!1,cancelAnimationFrame(a),t.setStyle(void 0)}}function Le(e,t,r){var a,c;if(!r)return;let o=k(r);const n=(c=(a=H(e,t))==null?void 0:a.getFeatures)==null?void 0:c.call(a);return n?n.find(function(i){const l=i.getGeometry();return l&&l instanceof T.Geometry&&typeof l.intersectsCoordinate=="function"?l.intersectsCoordinate(o):!1}):void 0}function Fe(e,t,r){const o=[];let n;const s=r.type||"Point";t.forEach(c=>{switch(s){case"Point":n=xe(c);break;case"LineString":n=Pe(c);break;case"MultiLineString":n=ve(c);break;case"MultiPolygon":n=Ee(c);break;case"Polygon":n=Te(c);break}if(!n)return;const i=new ue({geometry:n,data:c});i.set("layerName",e),o.push(i)});const a=new w.Vector;return o.length>0&&a.addFeatures(o),a}function Me(e,t){return t.cqlFilter&&(t.cqlFilter?t.CQL_FILTER+=` and ${t.cqlFilter}`:t.CQL_FILTER=t.cqlFilter),new w.TileWMS({url:t.url,params:{LAYERS:t.layers,CQL_FILTER:t.CQL_FILTER},serverType:"geoserver",crossOrigin:"anonymous"})}function H(e,t){const r=Z(e,t);return r==null?void 0:r.getSource()}function xe(e){const t=k(e);if(t)return new T.Point(t)}function Pe(e){return new T.LineString(e.coordinates)}function ve(e){return new T.MultiLineString(e.coordinates)}function Ee(e){return new T.MultiPolygon(e.coordinates)}function Te(e){return new T.Polygon(e.coordinates)}function O(e,t){let r=null;return t.style?r=t.style:t.getStyle?r=(o,n)=>t.getStyle(e,o,n):r=Ie(),r}function Ie(){return(t,r)=>new j.Style({image:new j.Circle({radius:5,fill:new j.Fill({color:"red"})})})}function Ae(e,t={}){const r=t.token||"dadcbbdb5206b626a29ca739686b3087",o=t.baseType||"img",n=t.noteType||"cia",s=new L.Tile({className:"tdt-base-layer",source:new w.XYZ({url:`http://t0.tianditu.com/DataServer?T=${o}_w&x={x}&y={y}&l={z}&tk=${r}`,maxZoom:t.maxZoom||18,minZoom:t.minZoom||2}),zIndex:t.zIndex||1});s.set("name","tdt-base-layer");const a=new L.Tile({className:"tdt-base-layer",source:new w.XYZ({url:`http://t0.tianditu.com/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${r}`,maxZoom:t.maxZoom||18,minZoom:t.minZoom||2}),zIndex:t.zIndex?t.zIndex+1:2});return a.set("name","tdt-baseNote-layer"),e.addLayer(s),e.addLayer(a),s}function Q(e,t,r,o){(!o||!o.type)&&(o=Object.assign({},r,o));const n=o.type||"Point";let s;switch(n){case"GeoJSON":s=Oe(t,r,e,o);break;case"Wms":s=Re(t,e,o);break;case"Point":case"LineString":case"MultiLineString":case"Polygon":case"MultiPolygon":s=Ne(t,r,e,o);break;case"Circle":s=pe(t,r,e,o);break;case"Overlay":s=je(t,e,o);break}return s}function ke(e,t){Array.isArray(t)?t.forEach(r=>{J(e,r)}):J(e,t)}function Oe(e,t,r,o){console.log(typeof t,t);const n=new A.GeoJSON().readFeatures(t,{dataProjection:"EPSG:4326",featureProjection:"EPSG:4326"}),s=new w.Vector;s.addFeatures(n);const a=new L.Vector({source:s,style:O(e,o),zIndex:o.zIndex||10});return a.set("name",e),a.set("type","webgl"),r.addLayer(a),a}function Re(e,t,r){const o=new L.Tile({opacity:r.opacity||1,source:Me(e,r),zIndex:r.zIndex||10});return o.set("name",e),t.addLayer(o),o}function Ne(e,t,r,o){if(!t||t.length===0)return null;const n=new L.Vector({source:Fe(e,t,o),style:O(e,o),zIndex:o.zIndex||10});return n.set("name",e),n.set("type","webgl"),r.addLayer(n),n}function pe(e,t,r,o){const n=k(t),s=be(n,o.radius,{steps:300,units:"meters"}),a=new A.GeoJSON().readFeature(s,{dataProjection:"EPSG:4326",featureProjection:"EPSG:4490"}),c=new w.Vector({wrapX:!1});c.addFeature(a);const i=new L.Vector({source:c,style:O(e,o),zIndex:o.zIndex?o.zIndex:10});return i.set("name",e),i.set("type","webgl"),r.addLayer(i),i}function je(e,t,r){const o=document.createElement("div"),n=new le({element:o,stopEvent:!1,positioning:r.positioning||"bottom-center"});return n.set("name",e),n.set("type","webgl"),t.addOverlay(n),{overlayer:n,content:o}}function ze(e,t,r){const o=new L.Vector({source:new w.Vector({wrapX:!1}),zIndex:r.zIndex?r.zIndex:10,style:O(t,r)});return o.set("name",t),o.set("type","webgl"),e.addLayer(o),o}function Z(e,t){return e.getAllLayers().find(n=>n.get("name")===t)}function Ze(e,t,r){const o=Z(e,t);return o.setVisible(r),o}const E=new Map,x={},v={},_e=(e,t)=>{E.has(e)&&console.warn(`Map with target '${e}' already exists. Overwriting...`),E.set(e,t),x[e]&&(x[e].forEach(r=>r(t)),delete x[e]),v[e]&&(v[e].forEach(r=>r(t)),delete v[e])};function X(e){const t=E.get(e);return t?Promise.resolve(t):(console.warn(`Map '${e}' not found. Make sure useMap() is called first.`),new Promise(r=>{v[e]=v[e]||[],v[e].push(r)}))}const qe=e=>{E.has(e)&&(E.delete(e),delete x[e])},Y=(e,t)=>{const r=E.get(e);if(r){t(r);return}x[e]||(x[e]=[]),x[e].push(t)};function Ve(e,t={}){if(!e&&!e.target)throw new Error("请传入地图容器");arguments.length===1&&typeof e=="object"&&(t=e,e=t.target);const o=Object.assign({zoom:10,center:[104.064839,30.548857],minZoom:2,maxZoom:19,projection:"EPSG:4326"},t),n=new $.Map({target:e,layers:[],view:new $.View({projection:o.projection,center:o.center,zoom:o.zoom,minZoom:o.minZoom,maxZoom:o.maxZoom})});return n.targetId=e,n}function Ce(e,t,r,o){Q(e,t,r,p(N({},o),{type:"Point"}))}function K(e,t,r){return new Promise((o,n)=>{e.getView().animate({center:t,duration:r.duration||1e3,zoom:r.zoom||te(e),rotation:r.rotation||0,easing:r.easing},o)})}function ee(e,t){const r=(t.extend[0]+t.extend[2])/2,o=(t.extend[1]+t.extend[3])/2;return K(e,[r,o],t)}function $e(e,t,r){const o=t.getGeometry().getExtent();return ee(e,p(N({},r),{extend:o}))}function Be(e){return e.getView().getProjection()}function te(e){return e.getView().getZoom()}function Ge(e,t){e.getView().setZoom(t)}function We(e,t){e.un("click",()=>{}),e.un("pointermove",()=>{}),qe(t)}let M=null;function Je(e,t={}){const r=new A.GeoJSON;M=new fe({condition:ye.click,multi:t.multi||!1,style:c=>{if(typeof t.getStyle=="function"){const i=c.get("layerName");return t.getStyle(i,c)}else return t.style},layers:t.layers?c=>t.layers.includes(c):void 0}),e.addInteraction(M);const o=M.getFeatures(),n=c=>I(null,null,function*(){const i=(t.layers||e.getLayers().getArray()).filter(h=>{const b=h.getSource();return h.getVisible()&&(b instanceof w.TileWMS||b instanceof w.ImageWMS)});if(i.length===0)return;const l=e.getView(),d=i.map(h=>I(null,null,function*(){const y=h.getSource().getFeatureInfoUrl(c.coordinate,l.getResolution(),l.getProjection(),{INFO_FORMAT:"application/json",FEATURE_COUNT:1});if(y)try{const S=yield(yield fetch(y)).json();if(S.features&&S.features.length>0){const m=r.readFeatures(S);return m.forEach(f=>{f.set("wms_layer_source",h),f.set("wms_event_source",c),f.set("layerName",h.get("name"))}),m}}catch(F){console.warn(F)}return[]})),u=(yield Promise.all(d)).flat();u.length>0&&(t.multi,o.extend(u),M.dispatchEvent({type:"select",selected:u,deselected:[],mapBrowserEvent:c}))});e.on("singleclick",n);const s=new Set;M.on("select",c=>{const i=o.getArray();if(i.length>0){const l=i.map(d=>({feature:d,properties:d.getProperties(),layer:d.get("wms_layer_source")||M.getLayer(d),event:d.get("wms_event_source")||c}));a(l)}else a(null)});const a=c=>s.forEach(i=>i(c));return{onSelect:c=>(s.add(c),()=>s.delete(c)),clear:()=>{s.clear(),o.clear()},destroy:()=>{e.removeInteraction(M),e.un("singleclick",n),s.clear()}}}function De(e,t={}){var P;const r=new A.GeoJSON,o=(P=t.debounceTime)!=null?P:200,n=new w.Vector,s=new L.Vector({source:n,map:e,style:t.style,zIndex:1e4,properties:{title:"JG_HOVER_LAYER"}});let a=null,c=null;const i=new Set,l=(u,h,b)=>{const y=u[0];if(a!==y)if(a=y,n.clear(),y?(n.addFeature(y),t.cursor!==!1&&(e.getTargetElement().style.cursor="pointer")):t.cursor!==!1&&(e.getTargetElement().style.cursor=""),y){const F={feature:y,layer:h,properties:y.getProperties(),coordinate:b};i.forEach(S=>S([F]))}else i.forEach(F=>F(null))},d=u=>{if(u.dragging)return;const h=u.pixel,b=u.coordinate;let y=!1;if(e.forEachFeatureAtPixel(h,(m,f)=>{y||f!==s&&(t.layers&&!t.layers.includes(f)||(y=!0,c&&clearTimeout(c),l([m],f,b)))}),y)return;a&&(a=null,n.clear(),e.getTargetElement().style.cursor="",i.forEach(m=>m(null))),c&&clearTimeout(c);const S=(t.layers||e.getLayers().getArray()).filter(m=>{const f=m.getSource();return m.getVisible()&&(f instanceof w.TileWMS||f instanceof w.ImageWMS)});S.length!==0&&(c=setTimeout(()=>I(null,null,function*(){const m=e.getView();for(const f of S){const _=f.getSource().getFeatureInfoUrl(b,m.getResolution(),m.getProjection(),{INFO_FORMAT:"application/json",FEATURE_COUNT:1});if(_)try{const R=yield(yield fetch(_)).json();if(R.features&&R.features.length>0){const q=r.readFeatures(R);q.forEach(ne=>ne.set("wms_layer_source",f)),l(q,f,b);return}}catch(re){}}}),o))};return e.on("pointermove",d),{onHover:u=>(i.add(u),()=>i.delete(u)),clear:()=>{n.clear(),a=null},destroy:()=>{e.un("pointermove",d),e.removeLayer(s),i.clear(),c&&clearTimeout(c)}}}const Ue=(e,t)=>{const r=Ve(e,t);Ae(r,t.baseLayers);const o={targetId:e,instance:r,addMarker:(n,s,a)=>Ce(r,n,s,a),createLayer:(n,s,a)=>Q(r,n,s,a),createBlankLayer:(n,s)=>ze(r,n,s),visibleLayer:(n,s)=>Ze(r,n,s),removeLayer:n=>ke(r,n),getLonLat:n=>k(n),getLayerByName:n=>Z(r,n),getSourceByName:n=>H(r,n),useSelect:n=>Je(r,n),useHover:n=>De(r,n),queryFeature:(n,s)=>Le(r,n,s),lightFeature:(n,s,a,c)=>U(n,s,a,c),flashFeature:(n,s,a)=>Se(n,s,a),flyTo:(n,s)=>K(r,n,s),flyToByExtent:n=>ee(r,n),flyToByFeature:(n,s)=>$e(r,n,s),getProjection:()=>Be(r),getZoom:()=>te(r),setZoom:n=>Ge(r,n),getMapContext:n=>X(n),onMapReady:(n,s)=>Y(n,s),destroyMap:()=>We(r,e)};return _e(e,o),o};function He(e,t){Y(e,t)}function Qe(e){return X(e)}exports.getMapContext=Qe;exports.onMapReady=He;exports.useMap=Ue;
|
package/dist/2d/index.mjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var se = Object.defineProperty, ae = Object.defineProperties;
|
|
2
|
+
var ce = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var B = Object.getOwnPropertySymbols;
|
|
4
|
+
var ie = Object.prototype.hasOwnProperty, le = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var V = (e, t, r) => t in e ? se(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, R = (e, t) => {
|
|
6
6
|
for (var r in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var r of
|
|
10
|
-
|
|
7
|
+
ie.call(t, r) && V(e, r, t[r]);
|
|
8
|
+
if (B)
|
|
9
|
+
for (var r of B(t))
|
|
10
|
+
le.call(t, r) && V(e, r, t[r]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var s = (
|
|
12
|
+
}, O = (e, t) => ae(e, ce(t));
|
|
13
|
+
var T = (e, t, r) => new Promise((o, n) => {
|
|
14
|
+
var s = (i) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
} catch (
|
|
18
|
-
|
|
16
|
+
c(r.next(i));
|
|
17
|
+
} catch (l) {
|
|
18
|
+
n(l);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, a = (i) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
|
|
22
|
+
c(r.throw(i));
|
|
23
|
+
} catch (l) {
|
|
24
|
+
n(l);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, c = (i) => i.done ? o(i.value) : Promise.resolve(i.value).then(s, a);
|
|
27
|
+
c((r = r.apply(e, t)).next());
|
|
28
28
|
});
|
|
29
|
-
import { Map as
|
|
30
|
-
import { Tile as
|
|
31
|
-
import { Vector as
|
|
32
|
-
import { GeoJSON as
|
|
33
|
-
import
|
|
34
|
-
import { Polygon as
|
|
35
|
-
import
|
|
29
|
+
import { Map as ue, View as fe } from "ol";
|
|
30
|
+
import { Tile as N, Vector as E } from "ol/layer";
|
|
31
|
+
import { Vector as v, TileWMS as j, XYZ as G, ImageWMS as W } from "ol/source";
|
|
32
|
+
import { GeoJSON as I } from "ol/format";
|
|
33
|
+
import ye from "ol/Overlay";
|
|
34
|
+
import { Geometry as ge, Polygon as me, MultiPolygon as de, MultiLineString as we, LineString as he, Point as be } from "ol/geom";
|
|
35
|
+
import Le from "ol/Feature";
|
|
36
36
|
import "ol/extent";
|
|
37
|
-
import { Style as
|
|
37
|
+
import { Style as Fe, Circle as Se, Fill as xe } from "ol/style";
|
|
38
38
|
import { click as Me } from "ol/events/condition.js";
|
|
39
39
|
import Pe from "ol/interaction/Select";
|
|
40
40
|
var g = 63710088e-1, Ee = {
|
|
@@ -54,57 +54,57 @@ var g = 63710088e-1, Ee = {
|
|
|
54
54
|
radians: 1,
|
|
55
55
|
yards: g * 1.0936
|
|
56
56
|
};
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
return (r.id === 0 || r.id) && (
|
|
57
|
+
function H(e, t, r = {}) {
|
|
58
|
+
const o = { type: "Feature" };
|
|
59
|
+
return (r.id === 0 || r.id) && (o.id = r.id), r.bbox && (o.bbox = r.bbox), o.properties = t || {}, o.geometry = e, o;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function q(e, t, r = {}) {
|
|
62
62
|
if (!e)
|
|
63
63
|
throw new Error("coordinates is required");
|
|
64
64
|
if (!Array.isArray(e))
|
|
65
65
|
throw new Error("coordinates must be an Array");
|
|
66
66
|
if (e.length < 2)
|
|
67
67
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
68
|
-
if (!
|
|
68
|
+
if (!D(e[0]) || !D(e[1]))
|
|
69
69
|
throw new Error("coordinates must contain numbers");
|
|
70
|
-
return
|
|
70
|
+
return H({
|
|
71
71
|
type: "Point",
|
|
72
72
|
coordinates: e
|
|
73
73
|
}, t, r);
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
for (const
|
|
77
|
-
if (
|
|
75
|
+
function ve(e, t, r = {}) {
|
|
76
|
+
for (const n of e) {
|
|
77
|
+
if (n.length < 4)
|
|
78
78
|
throw new Error(
|
|
79
79
|
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
80
80
|
);
|
|
81
|
-
if (
|
|
81
|
+
if (n[n.length - 1].length !== n[0].length)
|
|
82
82
|
throw new Error("First and last Position are not equivalent.");
|
|
83
|
-
for (let s = 0; s <
|
|
84
|
-
if (
|
|
83
|
+
for (let s = 0; s < n[n.length - 1].length; s++)
|
|
84
|
+
if (n[n.length - 1][s] !== n[0][s])
|
|
85
85
|
throw new Error("First and last Position are not equivalent.");
|
|
86
86
|
}
|
|
87
|
-
return
|
|
87
|
+
return H({
|
|
88
88
|
type: "Polygon",
|
|
89
89
|
coordinates: e
|
|
90
90
|
}, t, r);
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function Te(e, t = "kilometers") {
|
|
93
93
|
const r = Ee[t];
|
|
94
94
|
if (!r)
|
|
95
95
|
throw new Error(t + " units is invalid");
|
|
96
96
|
return e / r;
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function $(e) {
|
|
99
99
|
return e % (2 * Math.PI) * 180 / Math.PI;
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function z(e) {
|
|
102
102
|
return e % 360 * Math.PI / 180;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function D(e) {
|
|
105
105
|
return !isNaN(e) && e !== null && !Array.isArray(e);
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function Ie(e) {
|
|
108
108
|
if (!e)
|
|
109
109
|
throw new Error("coord is required");
|
|
110
110
|
if (!Array.isArray(e)) {
|
|
@@ -117,64 +117,92 @@ function xe(e) {
|
|
|
117
117
|
return [...e];
|
|
118
118
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
const
|
|
122
|
-
Math.sin(
|
|
120
|
+
function pe(e, t, r, o = {}) {
|
|
121
|
+
const n = Ie(e), s = z(n[0]), a = z(n[1]), c = z(r), i = Te(t, o.units), l = Math.asin(
|
|
122
|
+
Math.sin(a) * Math.cos(i) + Math.cos(a) * Math.sin(i) * Math.cos(c)
|
|
123
123
|
), m = s + Math.atan2(
|
|
124
|
-
Math.sin(
|
|
125
|
-
Math.cos(
|
|
126
|
-
),
|
|
127
|
-
return
|
|
128
|
-
}
|
|
129
|
-
function
|
|
130
|
-
const
|
|
131
|
-
for (let
|
|
124
|
+
Math.sin(c) * Math.sin(i) * Math.cos(a),
|
|
125
|
+
Math.cos(i) - Math.sin(a) * Math.sin(l)
|
|
126
|
+
), x = $(m), u = $(l);
|
|
127
|
+
return n[2] !== void 0 ? q([x, u, n[2]], o.properties) : q([x, u], o.properties);
|
|
128
|
+
}
|
|
129
|
+
function Ae(e, t, r = {}) {
|
|
130
|
+
const o = r.steps || 64, n = r.properties ? r.properties : !Array.isArray(e) && e.type === "Feature" && e.properties ? e.properties : {}, s = [];
|
|
131
|
+
for (let a = 0; a < o; a++)
|
|
132
132
|
s.push(
|
|
133
|
-
|
|
133
|
+
pe(e, t, a * -360 / o, r).geometry.coordinates
|
|
134
134
|
);
|
|
135
|
-
return s.push(s[0]),
|
|
135
|
+
return s.push(s[0]), ve([s], n);
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function p(e) {
|
|
138
138
|
return e.lttd && e.lgtd ? [Number(e.lgtd), Number(e.lttd)] : e.jd && e.wd ? [Number(e.jd), Number(e.wd)] : e.latitude && e.longitude ? [Number(e.longitude), Number(e.latitude)] : e.lon && e.lat ? [Number(e.lon), Number(e.lat)] : [0, 0];
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
e.getLayers().getArray().forEach((
|
|
142
|
-
|
|
140
|
+
function U(e, t) {
|
|
141
|
+
e.getLayers().getArray().forEach((o) => {
|
|
142
|
+
o.get("name") == t && ("setSource" in o && o.setSource(null), "dispose" in o && o.dispose(), e.removeLayer(o));
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
const n =
|
|
147
|
-
|
|
145
|
+
function J(e, t, r, o = !1) {
|
|
146
|
+
const n = o ? r.style || r.getStyle(e, t) : void 0, s = o ? 999 : -1;
|
|
147
|
+
n && typeof n.setZIndex == "function" && n.setZIndex(s), t.setStyle(n);
|
|
148
|
+
}
|
|
149
|
+
function ke(e, t, r) {
|
|
150
|
+
if (!t) return;
|
|
151
|
+
const o = r.time || 300;
|
|
152
|
+
let n = Date.now(), s = !1, a = 0;
|
|
153
|
+
t.running = !0;
|
|
154
|
+
function c() {
|
|
155
|
+
if (!t.running) return;
|
|
156
|
+
const i = Date.now();
|
|
157
|
+
i - n >= o && (s = !s, n = i, J(e, t, r, s), t.changed()), a = requestAnimationFrame(c);
|
|
158
|
+
}
|
|
159
|
+
c(), t.clearFlash = () => {
|
|
160
|
+
t.running = !1, cancelAnimationFrame(a), t.setStyle(void 0);
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function Re(e, t, r) {
|
|
164
|
+
var a, c;
|
|
165
|
+
if (!r) return;
|
|
166
|
+
let o = p(r);
|
|
167
|
+
const n = (c = (a = Q(e, t)) == null ? void 0 : a.getFeatures) == null ? void 0 : c.call(a);
|
|
168
|
+
return n ? n.find(function(i) {
|
|
169
|
+
const l = i.getGeometry();
|
|
170
|
+
return l && l instanceof ge && typeof l.intersectsCoordinate == "function" ? l.intersectsCoordinate(o) : !1;
|
|
171
|
+
}) : void 0;
|
|
172
|
+
}
|
|
173
|
+
function Oe(e, t, r) {
|
|
174
|
+
const o = [];
|
|
175
|
+
let n;
|
|
148
176
|
const s = r.type || "Point";
|
|
149
|
-
t.forEach((
|
|
177
|
+
t.forEach((c) => {
|
|
150
178
|
switch (s) {
|
|
151
179
|
case "Point":
|
|
152
|
-
|
|
180
|
+
n = Ne(c);
|
|
153
181
|
break;
|
|
154
182
|
case "LineString":
|
|
155
|
-
|
|
183
|
+
n = je(c);
|
|
156
184
|
break;
|
|
157
185
|
case "MultiLineString":
|
|
158
|
-
|
|
186
|
+
n = Ze(c);
|
|
159
187
|
break;
|
|
160
188
|
case "MultiPolygon":
|
|
161
|
-
|
|
189
|
+
n = _e(c);
|
|
162
190
|
break;
|
|
163
191
|
case "Polygon":
|
|
164
|
-
|
|
192
|
+
n = Ce(c);
|
|
165
193
|
break;
|
|
166
194
|
}
|
|
167
|
-
if (!
|
|
168
|
-
const
|
|
169
|
-
geometry:
|
|
170
|
-
data:
|
|
195
|
+
if (!n) return;
|
|
196
|
+
const i = new Le({
|
|
197
|
+
geometry: n,
|
|
198
|
+
data: c
|
|
171
199
|
});
|
|
172
|
-
|
|
200
|
+
i.set("layerName", e), o.push(i);
|
|
173
201
|
});
|
|
174
|
-
const
|
|
175
|
-
return
|
|
202
|
+
const a = new v();
|
|
203
|
+
return o.length > 0 && a.addFeatures(o), a;
|
|
176
204
|
}
|
|
177
|
-
function
|
|
205
|
+
function ze(e, t) {
|
|
178
206
|
return t.cqlFilter && (t.cqlFilter ? t.CQL_FILTER += ` and ${t.cqlFilter}` : t.CQL_FILTER = t.cqlFilter), new j({
|
|
179
207
|
url: t.url,
|
|
180
208
|
params: {
|
|
@@ -185,255 +213,274 @@ function pe(e, t) {
|
|
|
185
213
|
crossOrigin: "anonymous"
|
|
186
214
|
});
|
|
187
215
|
}
|
|
188
|
-
function
|
|
189
|
-
const
|
|
216
|
+
function Q(e, t) {
|
|
217
|
+
const r = Z(e, t);
|
|
218
|
+
return r == null ? void 0 : r.getSource();
|
|
219
|
+
}
|
|
220
|
+
function Ne(e) {
|
|
221
|
+
const t = p(e);
|
|
190
222
|
if (t)
|
|
191
|
-
return new
|
|
223
|
+
return new be(t);
|
|
192
224
|
}
|
|
193
|
-
function
|
|
194
|
-
return new
|
|
225
|
+
function je(e) {
|
|
226
|
+
return new he(e.coordinates);
|
|
195
227
|
}
|
|
196
|
-
function
|
|
197
|
-
return new
|
|
228
|
+
function Ze(e) {
|
|
229
|
+
return new we(e.coordinates);
|
|
198
230
|
}
|
|
199
|
-
function
|
|
200
|
-
return new
|
|
231
|
+
function _e(e) {
|
|
232
|
+
return new de(e.coordinates);
|
|
201
233
|
}
|
|
202
|
-
function
|
|
203
|
-
return new
|
|
234
|
+
function Ce(e) {
|
|
235
|
+
return new me(e.coordinates);
|
|
204
236
|
}
|
|
205
|
-
function
|
|
237
|
+
function A(e, t) {
|
|
206
238
|
let r = null;
|
|
207
|
-
return t.style ? r = t.style : t.getStyle ? r = (
|
|
239
|
+
return t.style ? r = t.style : t.getStyle ? r = (o, n) => t.getStyle(e, o, n) : r = Be(), r;
|
|
208
240
|
}
|
|
209
|
-
function
|
|
210
|
-
return (t, r) => new
|
|
211
|
-
image: new
|
|
241
|
+
function Be() {
|
|
242
|
+
return (t, r) => new Fe({
|
|
243
|
+
image: new Se({
|
|
212
244
|
radius: 5,
|
|
213
|
-
fill: new
|
|
245
|
+
fill: new xe({ color: "red" })
|
|
214
246
|
})
|
|
215
247
|
});
|
|
216
248
|
}
|
|
217
|
-
function
|
|
218
|
-
const r = t.token || "dadcbbdb5206b626a29ca739686b3087",
|
|
249
|
+
function Ve(e, t = {}) {
|
|
250
|
+
const r = t.token || "dadcbbdb5206b626a29ca739686b3087", o = t.baseType || "img", n = t.noteType || "cia", s = new N({
|
|
219
251
|
className: "tdt-base-layer",
|
|
220
|
-
source: new
|
|
221
|
-
url: `http://t0.tianditu.com/DataServer?T=${
|
|
252
|
+
source: new G({
|
|
253
|
+
url: `http://t0.tianditu.com/DataServer?T=${o}_w&x={x}&y={y}&l={z}&tk=${r}`,
|
|
222
254
|
maxZoom: t.maxZoom || 18,
|
|
223
255
|
minZoom: t.minZoom || 2
|
|
224
256
|
}),
|
|
225
257
|
zIndex: t.zIndex || 1
|
|
226
258
|
});
|
|
227
259
|
s.set("name", "tdt-base-layer");
|
|
228
|
-
const
|
|
260
|
+
const a = new N({
|
|
229
261
|
className: "tdt-base-layer",
|
|
230
|
-
source: new
|
|
231
|
-
url: `http://t0.tianditu.com/DataServer?T=${
|
|
262
|
+
source: new G({
|
|
263
|
+
url: `http://t0.tianditu.com/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${r}`,
|
|
232
264
|
maxZoom: t.maxZoom || 18,
|
|
233
265
|
minZoom: t.minZoom || 2
|
|
234
266
|
}),
|
|
235
267
|
zIndex: t.zIndex ? t.zIndex + 1 : 2
|
|
236
268
|
});
|
|
237
|
-
return
|
|
269
|
+
return a.set("name", "tdt-baseNote-layer"), e.addLayer(s), e.addLayer(a), s;
|
|
238
270
|
}
|
|
239
|
-
function
|
|
240
|
-
(!
|
|
241
|
-
const
|
|
271
|
+
function X(e, t, r, o) {
|
|
272
|
+
(!o || !o.type) && (o = Object.assign({}, r, o));
|
|
273
|
+
const n = o.type || "Point";
|
|
242
274
|
let s;
|
|
243
|
-
switch (
|
|
275
|
+
switch (n) {
|
|
244
276
|
case "GeoJSON":
|
|
245
|
-
s =
|
|
277
|
+
s = qe(t, r, e, o);
|
|
246
278
|
break;
|
|
247
279
|
case "Wms":
|
|
248
|
-
s =
|
|
280
|
+
s = $e(t, e, o);
|
|
249
281
|
break;
|
|
250
282
|
case "Point":
|
|
251
283
|
case "LineString":
|
|
252
284
|
case "MultiLineString":
|
|
253
285
|
case "Polygon":
|
|
254
286
|
case "MultiPolygon":
|
|
255
|
-
s =
|
|
287
|
+
s = De(t, r, e, o);
|
|
256
288
|
break;
|
|
257
289
|
case "Circle":
|
|
258
|
-
s =
|
|
290
|
+
s = Ue(t, r, e, o);
|
|
259
291
|
break;
|
|
260
292
|
case "Overlay":
|
|
261
|
-
s =
|
|
293
|
+
s = We(t, e, o);
|
|
262
294
|
break;
|
|
263
295
|
}
|
|
264
296
|
return s;
|
|
265
297
|
}
|
|
266
|
-
function
|
|
298
|
+
function Ge(e, t) {
|
|
267
299
|
Array.isArray(t) ? t.forEach((r) => {
|
|
268
|
-
|
|
269
|
-
}) :
|
|
300
|
+
U(e, r);
|
|
301
|
+
}) : U(e, t);
|
|
270
302
|
}
|
|
271
|
-
function
|
|
303
|
+
function qe(e, t, r, o) {
|
|
272
304
|
console.log(typeof t, t);
|
|
273
|
-
const
|
|
305
|
+
const n = new I().readFeatures(t, {
|
|
274
306
|
dataProjection: "EPSG:4326",
|
|
275
307
|
featureProjection: "EPSG:4326"
|
|
276
308
|
// 或 'EPSG:3857',看你的地图
|
|
277
|
-
}), s = new
|
|
278
|
-
s.addFeatures(
|
|
279
|
-
const
|
|
309
|
+
}), s = new v();
|
|
310
|
+
s.addFeatures(n);
|
|
311
|
+
const a = new E({
|
|
280
312
|
source: s,
|
|
281
|
-
style:
|
|
282
|
-
zIndex:
|
|
313
|
+
style: A(e, o),
|
|
314
|
+
zIndex: o.zIndex || 10
|
|
283
315
|
});
|
|
284
|
-
return
|
|
316
|
+
return a.set("name", e), a.set("type", "webgl"), r.addLayer(a), a;
|
|
285
317
|
}
|
|
286
|
-
function
|
|
287
|
-
const
|
|
318
|
+
function $e(e, t, r) {
|
|
319
|
+
const o = new N({
|
|
288
320
|
opacity: r.opacity || 1,
|
|
289
|
-
source:
|
|
321
|
+
source: ze(e, r),
|
|
290
322
|
zIndex: r.zIndex || 10
|
|
291
323
|
});
|
|
292
|
-
return
|
|
324
|
+
return o.set("name", e), t.addLayer(o), o;
|
|
293
325
|
}
|
|
294
|
-
function
|
|
326
|
+
function De(e, t, r, o) {
|
|
295
327
|
if (!t || t.length === 0) return null;
|
|
296
|
-
const
|
|
297
|
-
source:
|
|
298
|
-
style:
|
|
299
|
-
zIndex:
|
|
328
|
+
const n = new E({
|
|
329
|
+
source: Oe(e, t, o),
|
|
330
|
+
style: A(e, o),
|
|
331
|
+
zIndex: o.zIndex || 10
|
|
300
332
|
});
|
|
301
|
-
return
|
|
333
|
+
return n.set("name", e), n.set("type", "webgl"), r.addLayer(n), n;
|
|
302
334
|
}
|
|
303
|
-
function
|
|
304
|
-
const
|
|
335
|
+
function Ue(e, t, r, o) {
|
|
336
|
+
const n = p(t), s = Ae(n, o.radius, { steps: 300, units: "meters" }), a = new I().readFeature(s, {
|
|
305
337
|
dataProjection: "EPSG:4326",
|
|
306
338
|
featureProjection: "EPSG:4490"
|
|
307
|
-
}),
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
source:
|
|
311
|
-
style:
|
|
312
|
-
zIndex:
|
|
339
|
+
}), c = new v({ wrapX: !1 });
|
|
340
|
+
c.addFeature(a);
|
|
341
|
+
const i = new E({
|
|
342
|
+
source: c,
|
|
343
|
+
style: A(e, o),
|
|
344
|
+
zIndex: o.zIndex ? o.zIndex : 10
|
|
313
345
|
});
|
|
314
|
-
return
|
|
346
|
+
return i.set("name", e), i.set("type", "webgl"), r.addLayer(i), i;
|
|
315
347
|
}
|
|
316
|
-
function
|
|
317
|
-
const o = document.createElement("div"),
|
|
348
|
+
function We(e, t, r) {
|
|
349
|
+
const o = document.createElement("div"), n = new ye({
|
|
318
350
|
element: o,
|
|
319
351
|
stopEvent: !1,
|
|
320
|
-
positioning:
|
|
352
|
+
positioning: r.positioning || "bottom-center"
|
|
353
|
+
});
|
|
354
|
+
return n.set("name", e), n.set("type", "webgl"), t.addOverlay(n), { overlayer: n, content: o };
|
|
355
|
+
}
|
|
356
|
+
function He(e, t, r) {
|
|
357
|
+
const o = new E({
|
|
358
|
+
source: new v({ wrapX: !1 }),
|
|
359
|
+
zIndex: r.zIndex ? r.zIndex : 10,
|
|
360
|
+
style: A(t, r)
|
|
321
361
|
});
|
|
322
|
-
return
|
|
362
|
+
return o.set("name", t), o.set("type", "webgl"), e.addLayer(o), o;
|
|
323
363
|
}
|
|
324
|
-
|
|
325
|
-
|
|
364
|
+
function Z(e, t) {
|
|
365
|
+
return e.getAllLayers().find((n) => n.get("name") === t);
|
|
366
|
+
}
|
|
367
|
+
function Je(e, t, r) {
|
|
368
|
+
const o = Z(e, t);
|
|
369
|
+
return o.setVisible(r), o;
|
|
370
|
+
}
|
|
371
|
+
const P = /* @__PURE__ */ new Map(), S = {}, M = {}, Qe = (e, t) => {
|
|
372
|
+
P.has(e) && console.warn(`Map with target '${e}' already exists. Overwriting...`), P.set(e, t), S[e] && (S[e].forEach((r) => r(t)), delete S[e]), M[e] && (M[e].forEach((r) => r(t)), delete M[e]);
|
|
326
373
|
};
|
|
327
|
-
function
|
|
328
|
-
const t =
|
|
374
|
+
function Y(e) {
|
|
375
|
+
const t = P.get(e);
|
|
329
376
|
return t ? Promise.resolve(t) : (console.warn(`Map '${e}' not found. Make sure useMap() is called first.`), new Promise((r) => {
|
|
330
|
-
|
|
377
|
+
M[e] = M[e] || [], M[e].push(r);
|
|
331
378
|
}));
|
|
332
379
|
}
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
},
|
|
336
|
-
const r =
|
|
380
|
+
const Xe = (e) => {
|
|
381
|
+
P.has(e) && (P.delete(e), delete S[e]);
|
|
382
|
+
}, K = (e, t) => {
|
|
383
|
+
const r = P.get(e);
|
|
337
384
|
if (r) {
|
|
338
385
|
t(r);
|
|
339
386
|
return;
|
|
340
387
|
}
|
|
341
|
-
|
|
388
|
+
S[e] || (S[e] = []), S[e].push(t);
|
|
342
389
|
};
|
|
343
|
-
function
|
|
390
|
+
function Ye(e, t = {}) {
|
|
344
391
|
if (!e && !e.target)
|
|
345
392
|
throw new Error("请传入地图容器");
|
|
346
393
|
arguments.length === 1 && typeof e == "object" && (t = e, e = t.target);
|
|
347
|
-
const
|
|
394
|
+
const o = Object.assign({
|
|
348
395
|
zoom: 10,
|
|
349
396
|
center: [104.064839, 30.548857],
|
|
350
397
|
minZoom: 2,
|
|
351
398
|
maxZoom: 19,
|
|
352
399
|
projection: "EPSG:4326"
|
|
353
|
-
}, t),
|
|
400
|
+
}, t), n = new ue({
|
|
354
401
|
//地图容器div的ID
|
|
355
402
|
target: e,
|
|
356
403
|
//地图容器中加载的图层
|
|
357
404
|
layers: [],
|
|
358
405
|
//地图视图设置
|
|
359
|
-
view: new
|
|
360
|
-
projection:
|
|
406
|
+
view: new fe({
|
|
407
|
+
projection: o.projection,
|
|
361
408
|
// 坐标系,有EPSG:4326和EPSG:3857
|
|
362
409
|
//地图初始中心点
|
|
363
|
-
center:
|
|
410
|
+
center: o.center,
|
|
364
411
|
// 坐标
|
|
365
412
|
//地图初始显示级别
|
|
366
|
-
zoom:
|
|
367
|
-
minZoom:
|
|
368
|
-
maxZoom:
|
|
413
|
+
zoom: o.zoom,
|
|
414
|
+
minZoom: o.minZoom,
|
|
415
|
+
maxZoom: o.maxZoom
|
|
369
416
|
})
|
|
370
417
|
});
|
|
371
|
-
return
|
|
418
|
+
return n.targetId = e, n;
|
|
372
419
|
}
|
|
373
|
-
function
|
|
374
|
-
|
|
420
|
+
function Ke(e, t, r, o) {
|
|
421
|
+
X(e, t, r, O(R({}, o), { type: "Point" }));
|
|
375
422
|
}
|
|
376
|
-
function
|
|
377
|
-
return new Promise((
|
|
423
|
+
function ee(e, t, r) {
|
|
424
|
+
return new Promise((o, n) => {
|
|
378
425
|
e.getView().animate(
|
|
379
426
|
{
|
|
380
427
|
center: t,
|
|
381
428
|
duration: r.duration || 1e3,
|
|
382
|
-
zoom: r.zoom ||
|
|
429
|
+
zoom: r.zoom || re(e),
|
|
383
430
|
rotation: r.rotation || 0,
|
|
384
431
|
easing: r.easing
|
|
385
432
|
},
|
|
386
|
-
|
|
433
|
+
o
|
|
387
434
|
);
|
|
388
435
|
});
|
|
389
436
|
}
|
|
390
|
-
function
|
|
391
|
-
const r = (t.extend[0] + t.extend[2]) / 2,
|
|
392
|
-
return
|
|
437
|
+
function te(e, t) {
|
|
438
|
+
const r = (t.extend[0] + t.extend[2]) / 2, o = (t.extend[1] + t.extend[3]) / 2;
|
|
439
|
+
return ee(e, [r, o], t);
|
|
393
440
|
}
|
|
394
|
-
function
|
|
395
|
-
const
|
|
396
|
-
return
|
|
441
|
+
function et(e, t, r) {
|
|
442
|
+
const o = t.getGeometry().getExtent();
|
|
443
|
+
return te(e, O(R({}, r), { extend: o }));
|
|
397
444
|
}
|
|
398
|
-
function
|
|
445
|
+
function tt(e) {
|
|
399
446
|
return e.getView().getProjection();
|
|
400
447
|
}
|
|
401
|
-
function
|
|
448
|
+
function re(e) {
|
|
402
449
|
return e.getView().getZoom();
|
|
403
450
|
}
|
|
404
|
-
function
|
|
451
|
+
function rt(e, t) {
|
|
405
452
|
e.getView().setZoom(t);
|
|
406
453
|
}
|
|
407
|
-
function
|
|
454
|
+
function nt(e, t) {
|
|
408
455
|
e.un("click", () => {
|
|
409
456
|
}), e.un("pointermove", () => {
|
|
410
|
-
}),
|
|
457
|
+
}), Xe(t);
|
|
411
458
|
}
|
|
412
|
-
let
|
|
413
|
-
function
|
|
414
|
-
const r = new
|
|
415
|
-
|
|
459
|
+
let F = null;
|
|
460
|
+
function ot(e, t = {}) {
|
|
461
|
+
const r = new I();
|
|
462
|
+
F = new Pe({
|
|
416
463
|
condition: Me,
|
|
417
464
|
multi: t.multi || !1,
|
|
418
|
-
style: (
|
|
465
|
+
style: (c) => {
|
|
419
466
|
if (typeof t.getStyle == "function") {
|
|
420
|
-
const
|
|
421
|
-
return t.getStyle(
|
|
467
|
+
const i = c.get("layerName");
|
|
468
|
+
return t.getStyle(i, c);
|
|
422
469
|
} else
|
|
423
470
|
return t.style;
|
|
424
471
|
},
|
|
425
472
|
// 高亮选中样式
|
|
426
473
|
// 过滤:只允许配置中的图层被选中 (仅对 Vector 有效)
|
|
427
|
-
layers: t.layers ? (
|
|
428
|
-
}), e.addInteraction(
|
|
429
|
-
const
|
|
430
|
-
const
|
|
474
|
+
layers: t.layers ? (c) => t.layers.includes(c) : void 0
|
|
475
|
+
}), e.addInteraction(F);
|
|
476
|
+
const o = F.getFeatures(), n = (c) => T(null, null, function* () {
|
|
477
|
+
const i = (t.layers || e.getLayers().getArray()).filter((w) => {
|
|
431
478
|
const h = w.getSource();
|
|
432
|
-
return w.getVisible() && (h instanceof j || h instanceof
|
|
479
|
+
return w.getVisible() && (h instanceof j || h instanceof W);
|
|
433
480
|
});
|
|
434
|
-
if (
|
|
435
|
-
const
|
|
436
|
-
const f = w.getSource().getFeatureInfoUrl(
|
|
481
|
+
if (i.length === 0) return;
|
|
482
|
+
const l = e.getView(), m = i.map((w) => T(null, null, function* () {
|
|
483
|
+
const f = w.getSource().getFeatureInfoUrl(c.coordinate, l.getResolution(), l.getProjection(), {
|
|
437
484
|
INFO_FORMAT: "application/json",
|
|
438
485
|
// 必须是 JSON 才能转 Feature
|
|
439
486
|
FEATURE_COUNT: 1
|
|
@@ -444,52 +491,52 @@ function Qe(e, t = {}) {
|
|
|
444
491
|
if (b.features && b.features.length > 0) {
|
|
445
492
|
const d = r.readFeatures(b);
|
|
446
493
|
return d.forEach((y) => {
|
|
447
|
-
y.set("wms_layer_source", w), y.set("wms_event_source",
|
|
494
|
+
y.set("wms_layer_source", w), y.set("wms_event_source", c), y.set("layerName", w.get("name"));
|
|
448
495
|
}), d;
|
|
449
496
|
}
|
|
450
|
-
} catch (
|
|
451
|
-
console.warn(
|
|
497
|
+
} catch (L) {
|
|
498
|
+
console.warn(L);
|
|
452
499
|
}
|
|
453
500
|
return [];
|
|
454
|
-
})),
|
|
455
|
-
|
|
501
|
+
})), u = (yield Promise.all(m)).flat();
|
|
502
|
+
u.length > 0 && (t.multi, o.extend(u), F.dispatchEvent({
|
|
456
503
|
type: "select",
|
|
457
|
-
selected:
|
|
504
|
+
selected: u,
|
|
458
505
|
deselected: [],
|
|
459
|
-
mapBrowserEvent:
|
|
506
|
+
mapBrowserEvent: c
|
|
460
507
|
}));
|
|
461
508
|
});
|
|
462
|
-
e.on("singleclick",
|
|
509
|
+
e.on("singleclick", n);
|
|
463
510
|
const s = /* @__PURE__ */ new Set();
|
|
464
|
-
|
|
465
|
-
const
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
511
|
+
F.on("select", (c) => {
|
|
512
|
+
const i = o.getArray();
|
|
513
|
+
if (i.length > 0) {
|
|
514
|
+
const l = i.map((m) => ({
|
|
468
515
|
feature: m,
|
|
469
516
|
properties: m.getProperties(),
|
|
470
517
|
// 如果是 WMS 注入的,我们在上面 set 过了;如果是 Vector,用 native 方法获取
|
|
471
|
-
layer: m.get("wms_layer_source") ||
|
|
472
|
-
event: m.get("wms_event_source") ||
|
|
518
|
+
layer: m.get("wms_layer_source") || F.getLayer(m),
|
|
519
|
+
event: m.get("wms_event_source") || c
|
|
473
520
|
}));
|
|
474
|
-
|
|
521
|
+
a(l);
|
|
475
522
|
} else
|
|
476
|
-
|
|
523
|
+
a(null);
|
|
477
524
|
});
|
|
478
|
-
const
|
|
525
|
+
const a = (c) => s.forEach((i) => i(c));
|
|
479
526
|
return {
|
|
480
|
-
onSelect: (
|
|
527
|
+
onSelect: (c) => (s.add(c), () => s.delete(c)),
|
|
481
528
|
clear: () => {
|
|
482
|
-
s.clear(),
|
|
529
|
+
s.clear(), o.clear();
|
|
483
530
|
},
|
|
484
531
|
destroy: () => {
|
|
485
|
-
e.removeInteraction(
|
|
532
|
+
e.removeInteraction(F), e.un("singleclick", n), s.clear();
|
|
486
533
|
}
|
|
487
534
|
};
|
|
488
535
|
}
|
|
489
|
-
function
|
|
490
|
-
var
|
|
491
|
-
const r = new
|
|
492
|
-
source:
|
|
536
|
+
function st(e, t = {}) {
|
|
537
|
+
var x;
|
|
538
|
+
const r = new I(), o = (x = t.debounceTime) != null ? x : 200, n = new v(), s = new E({
|
|
539
|
+
source: n,
|
|
493
540
|
map: e,
|
|
494
541
|
style: t.style,
|
|
495
542
|
// 直接透传用户的样式配置
|
|
@@ -498,33 +545,33 @@ function Ye(e, t = {}) {
|
|
|
498
545
|
properties: { title: "JG_HOVER_LAYER" }
|
|
499
546
|
// 标记一下,防止自己拾取自己
|
|
500
547
|
});
|
|
501
|
-
let
|
|
502
|
-
const
|
|
503
|
-
const f =
|
|
504
|
-
if (
|
|
505
|
-
if (
|
|
506
|
-
const
|
|
548
|
+
let a = null, c = null;
|
|
549
|
+
const i = /* @__PURE__ */ new Set(), l = (u, w, h) => {
|
|
550
|
+
const f = u[0];
|
|
551
|
+
if (a !== f)
|
|
552
|
+
if (a = f, n.clear(), f ? (n.addFeature(f), t.cursor !== !1 && (e.getTargetElement().style.cursor = "pointer")) : t.cursor !== !1 && (e.getTargetElement().style.cursor = ""), f) {
|
|
553
|
+
const L = {
|
|
507
554
|
feature: f,
|
|
508
555
|
layer: w,
|
|
509
556
|
properties: f.getProperties(),
|
|
510
557
|
coordinate: h
|
|
511
558
|
};
|
|
512
|
-
|
|
559
|
+
i.forEach((b) => b([L]));
|
|
513
560
|
} else
|
|
514
|
-
|
|
515
|
-
}, m = (
|
|
516
|
-
if (
|
|
517
|
-
const w =
|
|
561
|
+
i.forEach((L) => L(null));
|
|
562
|
+
}, m = (u) => {
|
|
563
|
+
if (u.dragging) return;
|
|
564
|
+
const w = u.pixel, h = u.coordinate;
|
|
518
565
|
let f = !1;
|
|
519
566
|
if (e.forEachFeatureAtPixel(w, (d, y) => {
|
|
520
|
-
f || y !== s && (t.layers && !t.layers.includes(y) || (f = !0,
|
|
567
|
+
f || y !== s && (t.layers && !t.layers.includes(y) || (f = !0, c && clearTimeout(c), l([d], y, h)));
|
|
521
568
|
}), f) return;
|
|
522
|
-
|
|
569
|
+
a && (a = null, n.clear(), e.getTargetElement().style.cursor = "", i.forEach((d) => d(null))), c && clearTimeout(c);
|
|
523
570
|
const b = (t.layers || e.getLayers().getArray()).filter((d) => {
|
|
524
571
|
const y = d.getSource();
|
|
525
|
-
return d.getVisible() && (y instanceof j || y instanceof
|
|
572
|
+
return d.getVisible() && (y instanceof j || y instanceof W);
|
|
526
573
|
});
|
|
527
|
-
b.length !== 0 && (
|
|
574
|
+
b.length !== 0 && (c = setTimeout(() => T(null, null, function* () {
|
|
528
575
|
const d = e.getView();
|
|
529
576
|
for (const y of b) {
|
|
530
577
|
const _ = y.getSource().getFeatureInfoUrl(h, d.getResolution(), d.getProjection(), {
|
|
@@ -533,59 +580,67 @@ function Ye(e, t = {}) {
|
|
|
533
580
|
});
|
|
534
581
|
if (_)
|
|
535
582
|
try {
|
|
536
|
-
const
|
|
537
|
-
if (
|
|
538
|
-
const
|
|
539
|
-
|
|
583
|
+
const k = yield (yield fetch(_)).json();
|
|
584
|
+
if (k.features && k.features.length > 0) {
|
|
585
|
+
const C = r.readFeatures(k);
|
|
586
|
+
C.forEach((oe) => oe.set("wms_layer_source", y)), l(C, y, h);
|
|
540
587
|
return;
|
|
541
588
|
}
|
|
542
|
-
} catch (
|
|
589
|
+
} catch (ne) {
|
|
543
590
|
}
|
|
544
591
|
}
|
|
545
|
-
}),
|
|
592
|
+
}), o));
|
|
546
593
|
};
|
|
547
594
|
return e.on("pointermove", m), {
|
|
548
|
-
onHover: (
|
|
595
|
+
onHover: (u) => (i.add(u), () => i.delete(u)),
|
|
549
596
|
clear: () => {
|
|
550
|
-
|
|
597
|
+
n.clear(), a = null;
|
|
551
598
|
},
|
|
552
599
|
destroy: () => {
|
|
553
|
-
e.un("pointermove", m), e.removeLayer(s),
|
|
600
|
+
e.un("pointermove", m), e.removeLayer(s), i.clear(), c && clearTimeout(c);
|
|
554
601
|
}
|
|
555
602
|
};
|
|
556
603
|
}
|
|
557
|
-
const
|
|
558
|
-
const r =
|
|
559
|
-
|
|
560
|
-
const
|
|
604
|
+
const Lt = (e, t) => {
|
|
605
|
+
const r = Ye(e, t);
|
|
606
|
+
Ve(r, t.baseLayers);
|
|
607
|
+
const o = {
|
|
561
608
|
targetId: e,
|
|
562
609
|
instance: r,
|
|
563
610
|
// 暴露原始实例以备不时之需
|
|
564
|
-
addMarker: (
|
|
565
|
-
createLayer: (
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
611
|
+
addMarker: (n, s, a) => Ke(r, n, s, a),
|
|
612
|
+
createLayer: (n, s, a) => X(r, n, s, a),
|
|
613
|
+
createBlankLayer: (n, s) => He(r, n, s),
|
|
614
|
+
visibleLayer: (n, s) => Je(r, n, s),
|
|
615
|
+
removeLayer: (n) => Ge(r, n),
|
|
616
|
+
getLonLat: (n) => p(n),
|
|
617
|
+
getLayerByName: (n) => Z(r, n),
|
|
618
|
+
getSourceByName: (n) => Q(r, n),
|
|
619
|
+
useSelect: (n) => ot(r, n),
|
|
620
|
+
useHover: (n) => st(r, n),
|
|
621
|
+
queryFeature: (n, s) => Re(r, n, s),
|
|
622
|
+
lightFeature: (n, s, a, c) => J(n, s, a, c),
|
|
623
|
+
flashFeature: (n, s, a) => ke(n, s, a),
|
|
624
|
+
flyTo: (n, s) => ee(r, n, s),
|
|
625
|
+
flyToByExtent: (n) => te(r, n),
|
|
626
|
+
flyToByFeature: (n, s) => et(r, n, s),
|
|
627
|
+
getProjection: () => tt(r),
|
|
628
|
+
getZoom: () => re(r),
|
|
629
|
+
setZoom: (n) => rt(r, n),
|
|
630
|
+
getMapContext: (n) => Y(n),
|
|
631
|
+
onMapReady: (n, s) => K(n, s),
|
|
632
|
+
destroyMap: () => nt(r, e)
|
|
578
633
|
};
|
|
579
|
-
return
|
|
634
|
+
return Qe(e, o), o;
|
|
580
635
|
};
|
|
581
|
-
function
|
|
582
|
-
|
|
636
|
+
function Ft(e, t) {
|
|
637
|
+
K(e, t);
|
|
583
638
|
}
|
|
584
|
-
function
|
|
585
|
-
return
|
|
639
|
+
function St(e) {
|
|
640
|
+
return Y(e);
|
|
586
641
|
}
|
|
587
642
|
export {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
643
|
+
St as getMapContext,
|
|
644
|
+
Ft as onMapReady,
|
|
645
|
+
Lt as useMap
|
|
591
646
|
};
|
package/dist/2d/layer.d.ts
CHANGED
|
@@ -60,11 +60,30 @@ export declare function createVectorLayer(layerName: string, data: any[], Map: M
|
|
|
60
60
|
* @returns {TileLayer} 矢量图层
|
|
61
61
|
*/
|
|
62
62
|
export declare function createBufferCircle(layerName: string, data: any, Map: MapInstance, options: LayerOptions): VectorLayer;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
/**
|
|
64
|
+
* 创建Overlay图层
|
|
65
|
+
* @param layerName 图层名称
|
|
66
|
+
* @param Map 地图实例
|
|
67
|
+
* @param options 图层配置
|
|
68
|
+
* @returns OverlayResult
|
|
69
|
+
*/
|
|
70
|
+
export declare function createOverlayLayer(layerName: string, Map: MapInstance, options: LayerOptions): OverlayResult;
|
|
71
|
+
/**
|
|
72
|
+
* 创建空白图层
|
|
73
|
+
* @param layerName 图层名
|
|
74
|
+
* @param options 配置项
|
|
75
|
+
* @returns VectorLayer
|
|
76
|
+
*/
|
|
77
|
+
export declare function createBlankLayer(map: Map, layerName: string, options: LayerOptions): VectorLayer;
|
|
65
78
|
/**
|
|
66
79
|
* 根据图层名称获取图层
|
|
67
80
|
* @param map 地图实例
|
|
68
81
|
* @param layerName 图层名称
|
|
69
82
|
*/
|
|
70
83
|
export declare function getLayerByName(map: Map, layerName: string): any;
|
|
84
|
+
/**
|
|
85
|
+
* 根据图层名称获取图层
|
|
86
|
+
* @param map 地图实例
|
|
87
|
+
* @param layerName 图层名称
|
|
88
|
+
*/
|
|
89
|
+
export declare function visibleLayer(map: Map, layerName: string, visible: boolean): Layer;
|
package/dist/2d/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { StyleLike, default as Style } from 'ol/style/Style';
|
|
|
3
3
|
import { Layer } from 'ol/layer';
|
|
4
4
|
import { FeatureLike } from 'ol/Feature';
|
|
5
5
|
import { HoverOptions, SelectOptions, UseHoverResult, UseSelectResult } from './interaction';
|
|
6
|
+
import { Source } from 'ol/source';
|
|
6
7
|
export interface BaseLayerOptions {
|
|
7
8
|
token?: string;
|
|
8
9
|
maxZoom?: number;
|
|
@@ -66,6 +67,14 @@ export interface MapContext {
|
|
|
66
67
|
addMarker: (layerName: string, data: any, options?: LayerOptions) => void;
|
|
67
68
|
createLayer: (layerName: string, data: any, options?: LayerOptions) => Layer;
|
|
68
69
|
removeLayer: (layerName: string) => void;
|
|
70
|
+
visibleLayer: (layerName: string, visible: boolean) => Layer;
|
|
71
|
+
getLayerByName: (layerName: string) => Layer;
|
|
72
|
+
getSourceByName: (layerName: string) => Source;
|
|
73
|
+
getLonLat: (data: any) => [number, number];
|
|
74
|
+
createBlankLayer: (layerName: string, options: LayerOptions) => Layer;
|
|
75
|
+
lightFeature: (layerName: string, feature: FeatureLike, options: HighLightOptions, zoomFlag: boolean) => void;
|
|
76
|
+
flashFeature: (layerName: string, feature: FeatureLike & customFeature, options: FlashOptions) => void;
|
|
77
|
+
queryFeature: (layerName: string, properties: any) => FeatureLike;
|
|
69
78
|
useSelect: (options: SelectOptions) => UseSelectResult;
|
|
70
79
|
useHover: (options: HoverOptions) => UseHoverResult;
|
|
71
80
|
flyTo: (coordinate: [number, number], options: flyOptions) => void;
|
package/dist/2d/utils.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare function flashFeature(layerName: string, feature: FeatureLike & c
|
|
|
47
47
|
* @param properties 数据
|
|
48
48
|
* @returns Feature 要素
|
|
49
49
|
*/
|
|
50
|
-
export declare function
|
|
50
|
+
export declare function queryFeature(map: Map, layerName: string, properties: any): FeatureLike;
|
|
51
51
|
export declare function getSelectedFtByEvt(event: any): {
|
|
52
52
|
layerName?: string;
|
|
53
53
|
feature?: FeatureLike;
|