zhihao-ui 1.3.10 → 1.3.11
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.
|
@@ -1373,10 +1373,9 @@ const createMeasureTooltip$1 = () => {
|
|
|
1373
1373
|
var e;
|
|
1374
1374
|
return (e = getInstall()) == null ? void 0 : e.getLayers();
|
|
1375
1375
|
}, layerType = ref("vector"), getShowLayerType = () => layerType.value, setShowLayerType = (e) => {
|
|
1376
|
-
layerType.value
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
n.setVisible(n.className_ === e);
|
|
1376
|
+
if (e === layerType.value) return;
|
|
1377
|
+
getLayers().forEach((n) => {
|
|
1378
|
+
n.className_ === "vector" ? n.setVisible(e === "vector") : n.className_ === "satellite" && n.setVisible(e === "satellite");
|
|
1380
1379
|
});
|
|
1381
1380
|
}, showGreenTile = ref(), getGreenTileVisible = () => showGreenTile.value, setGreenTileVisible = (e) => {
|
|
1382
1381
|
if (e !== showGreenTile.value) {
|
package/dist/es/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { Z as B } from "./BaseInfo-Bhin5Xqy.js";
|
|
|
17
17
|
import { Z as g } from "./DetailHeader--0WANmGX.js";
|
|
18
18
|
import { Z as x } from "./DiyDataTable-GuaKFrG5.js";
|
|
19
19
|
import { D as V } from "./DiyDataTable-GuaKFrG5.js";
|
|
20
|
-
import { Z as G } from "./Map-
|
|
20
|
+
import { Z as G } from "./Map-Dhm6AjZp.js";
|
|
21
21
|
import { Z as M } from "./Table-DcnAnAAU.js";
|
|
22
22
|
import { Z as $ } from "./BaseItem-BoLcxB-U.js";
|
|
23
23
|
const A = [
|
package/dist/umd/index.umd.cjs
CHANGED
|
@@ -212,7 +212,7 @@ hooks.version="2.30.1",setHookCallback(createLocal),hooks.fn=proto,hooks.min=min
|
|
|
212
212
|
</clipPath>
|
|
213
213
|
</defs>
|
|
214
214
|
</svg>
|
|
215
|
-
`,i=()=>`data:image/svg+xml;utf8,${encodeURIComponent(r(n?"#FF5733":"#3370FF"))}`;return new Style({text:new Text({text:t.shortName,font:"12px sans-serif",fill:new Fill({color:n?"#ffffff":"#000000"}),backgroundFill:new Fill({color:n?"#FF5733":"#FFFFFF"}),offsetY:30}),image:new Icon({src:i(),scale:.5*e/10})})},clearPortList=()=>{if(selectedPortFeature$1){console.log("清除非选中的港口");const t=selectedPortFeature$1.get("portData").id;vectorSource$3.getFeatures().forEach(e=>{e.get("portData").id!==t&&vectorSource$3.removeFeature(e)})}else console.log("清除所有港口"),vectorSource$3.clear()},clearSelectedPort$1=()=>{const t=selectedPortFeature$1==null?void 0:selectedPortFeature$1.get("portData"),e=getZoom();t&&vectorSource$3.getFeatures().forEach(r=>{r.get("portData").id===t.id&&(r==null||r.setStyle(setPortStyle$1(t,e,!1)))}),selectedPortData=null,selectedPortFeature$1=null};let selectedPortFeature$1=null,selectedPortData=null;const selectedPort=t=>{t?(clearPrevSelectedPort$1(),addSelectedPortStyle$1(t)):clearSelectedPort$1()},clearPrevSelectedPort$1=()=>{if(selectedPortFeature$1){const t=selectedPortFeature$1==null?void 0:selectedPortFeature$1.get("portData"),e=getZoom();selectedPortFeature$1.setStyle(setPortStyle$1(t,e,!1))}},addSelectedPortStyle$1=t=>{const e=vectorSource$3.getFeatures();selectedPortData=t,selectedPortFeature$1=e.find(n=>n.get("portData").id===t.id)},handlePortHover=t=>{const e=getInstall(),n=e.forEachFeatureAtPixel(t,r=>r);n&&n.get("portData")&&(e.getTargetElement().style.cursor="pointer")},DrawEventType={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class DrawEvent extends BaseEvent{constructor(e,n){super(e),this.feature=n}}function getTraceTargets(t,e){const n=[];for(let r=0;r<e.length;++r){const g=e[r].getGeometry();appendGeometryTraceTargets(t,g,n)}return n}function getSquaredDistance(t,e){return squaredDistance$1(t[0],t[1],e[0],e[1])}function getCoordinate(t,e){const n=t.length;return e<0?t[e+n]:e>=n?t[e-n]:t[e]}function getCumulativeSquaredDistance(t,e,n){let r,i;e<n?(r=e,i=n):(r=n,i=e);const g=Math.ceil(r),y=Math.floor(i);if(g>y){const L=interpolateCoordinate(t,r),$=interpolateCoordinate(t,i);return getSquaredDistance(L,$)}let k=0;if(r<g){const L=interpolateCoordinate(t,r),$=getCoordinate(t,g);k+=getSquaredDistance(L,$)}if(y<i){const L=getCoordinate(t,y),$=interpolateCoordinate(t,i);k+=getSquaredDistance(L,$)}for(let L=g;L<y-1;++L){const $=getCoordinate(t,L),V=getCoordinate(t,L+1);k+=getSquaredDistance($,V)}return k}function appendGeometryTraceTargets(t,e,n){if(e instanceof LineString){appendTraceTarget(t,e.getCoordinates(),!1,n);return}if(e instanceof MultiLineString){const r=e.getCoordinates();for(let i=0,g=r.length;i<g;++i)appendTraceTarget(t,r[i],!1,n);return}if(e instanceof Polygon){const r=e.getCoordinates();for(let i=0,g=r.length;i<g;++i)appendTraceTarget(t,r[i],!0,n);return}if(e instanceof MultiPolygon){const r=e.getCoordinates();for(let i=0,g=r.length;i<g;++i){const y=r[i];for(let k=0,L=y.length;k<L;++k)appendTraceTarget(t,y[k],!0,n)}return}if(e instanceof GeometryCollection){const r=e.getGeometries();for(let i=0;i<r.length;++i)appendGeometryTraceTargets(t,r[i],n);return}}const sharedUpdateInfo={index:-1,endIndex:NaN};function getTraceTargetUpdate(t,e,n,r){const i=t[0],g=t[1];let y=1/0,k=-1,L=NaN;for(let z=0;z<e.targets.length;++z){const re=e.targets[z],oe=re.coordinates;let j=1/0,ie;for(let ae=0;ae<oe.length-1;++ae){const ue=oe[ae],de=oe[ae+1],pe=getPointSegmentRelationship(i,g,ue,de);pe.squaredDistance<j&&(j=pe.squaredDistance,ie=ae+pe.along)}j<y&&(y=j,re.ring&&e.targetIndex===z&&(re.endIndex>re.startIndex?ie<re.startIndex&&(ie+=oe.length):re.endIndex<re.startIndex&&ie>re.startIndex&&(ie-=oe.length)),L=ie,k=z)}const $=e.targets[k];let V=$.ring;if(e.targetIndex===k&&V){const z=interpolateCoordinate($.coordinates,L),re=n.getPixelFromCoordinate(z);distance$1(re,e.startPx)>r&&(V=!1)}if(V){const z=$.coordinates,re=z.length,oe=$.startIndex,j=L;if(oe<j){const ie=getCumulativeSquaredDistance(z,oe,j);getCumulativeSquaredDistance(z,oe,j-re)<ie&&(L-=re)}else{const ie=getCumulativeSquaredDistance(z,oe,j);getCumulativeSquaredDistance(z,oe,j+re)<ie&&(L+=re)}}return sharedUpdateInfo.index=k,sharedUpdateInfo.endIndex=L,sharedUpdateInfo}function appendTraceTarget(t,e,n,r){const i=t[0],g=t[1];for(let y=0,k=e.length-1;y<k;++y){const L=e[y],$=e[y+1],V=getPointSegmentRelationship(i,g,L,$);if(V.squaredDistance===0){const z=y+V.along;r.push({coordinates:e,ring:n,startIndex:z,endIndex:z});return}}}const sharedRel={along:0,squaredDistance:0};function getPointSegmentRelationship(t,e,n,r){const i=n[0],g=n[1],y=r[0],k=r[1],L=y-i,$=k-g;let V=0,z=i,re=g;return(L!==0||$!==0)&&(V=clamp(((t-i)*L+(e-g)*$)/(L*L+$*$),0,1),z+=L*V,re+=$*V),sharedRel.along=V,sharedRel.squaredDistance=toFixed(squaredDistance$1(t,e,z,re),10),sharedRel}function interpolateCoordinate(t,e){const n=t.length;let r=Math.floor(e);const i=e-r;r>=n?r-=n:r<0&&(r+=n);let g=r+1;g>=n&&(g-=n);const y=t[r],k=y[0],L=y[1],$=t[g],V=$[0]-k,z=$[1]-L;return[k+V*i,L+z*i]}class Draw extends PointerInteraction{constructor(e){const n=e;n.stopDown||(n.stopDown=FALSE),super(n),this.on,this.once,this.un,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=e.source?e.source:null,this.features_=e.features?e.features:null,this.snapTolerance_=e.snapTolerance?e.snapTolerance:12,this.type_=e.type,this.mode_=getMode(this.type_),this.stopClick_=!!e.stopClick,this.minPoints_=e.minPoints?e.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:e.maxPoints?e.maxPoints:1/0,this.finishCondition_=e.finishCondition?e.finishCondition:TRUE,this.geometryLayout_=e.geometryLayout?e.geometryLayout:"XY";let r=e.geometryFunction;if(!r){const i=this.mode_;if(i==="Circle")r=(g,y,k)=>{const L=y||new Circle([NaN,NaN]),$=fromUserCoordinate(g[0]),V=squaredDistance($,fromUserCoordinate(g[g.length-1]));return L.setCenterAndRadius($,Math.sqrt(V),this.geometryLayout_),L};else{let g;i==="Point"?g=Point:i==="LineString"?g=LineString:i==="Polygon"&&(g=Polygon),r=(y,k,L)=>(k?i==="Polygon"?y[0].length?k.setCoordinates([y[0].concat([y[0][0]])],this.geometryLayout_):k.setCoordinates([],this.geometryLayout_):k.setCoordinates(y,this.geometryLayout_):k=new g(y,this.geometryLayout_),k)}}this.geometryFunction_=r,this.dragVertexDelay_=e.dragVertexDelay!==void 0?e.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=e.clickTolerance?e.clickTolerance*e.clickTolerance:36,this.overlay_=new VectorLayer({source:new VectorSource({useSpatialIndex:!1,wrapX:e.wrapX?e.wrapX:!1}),style:e.style?e.style:getDefaultStyleFunction(),updateWhileInteracting:!0}),this.geometryName_=e.geometryName,this.condition_=e.condition?e.condition:noModifierKeys,this.freehandCondition_,e.freehand?this.freehandCondition_=always:this.freehandCondition_=e.freehandCondition?e.freehandCondition:shiftKeyOnly,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSource_=e.traceSource||e.source||null,this.addChangeListener(InteractionProperty.ACTIVE,this.updateState_)}setTrace(e){let n;e?e===!0?n=always:n=e:n=never,this.traceCondition_=n}setMap(e){super.setMap(e),this.updateState_()}getOverlay(){return this.overlay_}handleEvent(e){e.originalEvent.type===EventType.CONTEXTMENU&&e.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(e);let n=e.type===MapBrowserEventType.POINTERMOVE,r=!0;return!this.freehand_&&this.lastDragTime_&&e.type===MapBrowserEventType.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=e.pixel,this.shouldHandle_=!this.freehand_,n=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&e.type===MapBrowserEventType.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(e.coordinate),r=!1):this.freehand_&&e.type===MapBrowserEventType.POINTERDOWN?r=!1:n&&this.getPointerCount()<2?(r=e.type===MapBrowserEventType.POINTERMOVE,r&&this.freehand_?(this.handlePointerMove_(e),this.shouldHandle_&&e.originalEvent.preventDefault()):(e.originalEvent.pointerType==="mouse"||e.type===MapBrowserEventType.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(e)):e.type===MapBrowserEventType.DBLCLICK&&(r=!1),super.handleEvent(e)&&r}handleDownEvent(e){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=e.pixel,this.finishCoordinate_||this.startDrawing_(e.coordinate),!0):this.condition_(e)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new MapBrowserEvent(MapBrowserEventType.POINTERMOVE,e.map,e.originalEvent,!1,e.frameState))},this.dragVertexDelay_),this.downPx_=e.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_();return}const n=this.getMap(),r=n.getCoordinateFromPixel([e.pixel[0]-this.snapTolerance_,e.pixel[1]+this.snapTolerance_]),i=n.getCoordinateFromPixel([e.pixel[0]+this.snapTolerance_,e.pixel[1]-this.snapTolerance_]),g=boundingExtent([r,i]),y=this.traceSource_.getFeaturesInExtent(g);if(y.length===0)return;const k=getTraceTargets(e.coordinate,y);k.length&&(this.traceState_={active:!0,startPx:e.pixel.slice(),targets:k,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,n){const r=e.startIndex<=e.endIndex,i=e.startIndex<=n;r===i?r&&n>e.endIndex||!r&&n<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,n):(r&&n<e.endIndex||!r&&n>e.endIndex)&&this.removeTracedCoordinates_(n,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,n))}removeTracedCoordinates_(e,n){if(e===n)return;let r=0;if(e<n){const i=Math.ceil(e);let g=Math.floor(n);g===n&&(g-=1),r=g-i+1}else{const i=Math.floor(e);let g=Math.ceil(n);g===n&&(g+=1),r=i-g+1}r>0&&this.removeLastPoints_(r)}addTracedCoordinates_(e,n,r){if(n===r)return;const i=[];if(n<r){const g=Math.ceil(n);let y=Math.floor(r);y===r&&(y-=1);for(let k=g;k<=y;++k)i.push(getCoordinate(e.coordinates,k))}else{const g=Math.floor(n);let y=Math.ceil(r);y===r&&(y+=1);for(let k=g;k>=y;--k)i.push(getCoordinate(e.coordinates,k))}i.length&&this.appendCoordinates(i)}updateTrace_(e){const n=this.traceState_;if(!n.active||n.targetIndex===-1&&distance$1(n.startPx,e.pixel)<this.snapTolerance_)return;const r=getTraceTargetUpdate(e.coordinate,n,this.getMap(),this.snapTolerance_);if(n.targetIndex!==r.index){if(n.targetIndex!==-1){const L=n.targets[n.targetIndex];this.removeTracedCoordinates_(L.startIndex,L.endIndex)}const k=n.targets[r.index];this.addTracedCoordinates_(k,k.startIndex,r.endIndex)}else{const k=n.targets[n.targetIndex];this.addOrRemoveTracedCoordinates_(k,r.endIndex)}n.targetIndex=r.index;const i=n.targets[n.targetIndex];i.endIndex=r.endIndex;const g=interpolateCoordinate(i.coordinates,i.endIndex),y=this.getMap().getPixelFromCoordinate(g);e.coordinate=g,e.pixel=[Math.round(y[0]),Math.round(y[1])]}handleUpEvent(e){let n=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(e);const r=this.traceState_.active;if(this.toggleTraceState_(e),this.shouldHandle_){const i=!this.finishCoordinate_;i&&this.startDrawing_(e.coordinate),!i&&this.freehand_?this.finishDrawing():!this.freehand_&&(!i||this.mode_==="Point")&&(this.atFinish_(e.pixel,r)?this.finishCondition_(e)&&this.finishDrawing():this.addToDrawing_(e.coordinate)),n=!1}else this.freehand_&&this.abortDrawing()}return!n&&this.stopClick_&&e.preventDefault(),n}handlePointerMove_(e){if(this.pointerType_=e.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const n=this.downPx_,r=e.pixel,i=n[0]-r[0],g=n[1]-r[1],y=i*i+g*g;if(this.shouldHandle_=this.freehand_?y>this.squaredClickTolerance_:y<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(e.coordinate.slice());return}this.updateTrace_(e),this.modifyDrawing_(e.coordinate)}atFinish_(e,n){let r=!1;if(this.sketchFeature_){let i=!1,g=[this.finishCoordinate_];const y=this.mode_;if(y==="Point")r=!0;else if(y==="Circle")r=this.sketchCoords_.length===2;else if(y==="LineString")i=!n&&this.sketchCoords_.length>this.minPoints_;else if(y==="Polygon"){const k=this.sketchCoords_;i=k[0].length>this.minPoints_,g=[k[0][0],k[0][k[0].length-2]],n?g=[k[0][0]]:g=[k[0][0],k[0][k[0].length-2]]}if(i){const k=this.getMap();for(let L=0,$=g.length;L<$;L++){const V=g[L],z=k.getPixelFromCoordinate(V),re=e[0]-z[0],oe=e[1]-z[1],j=this.freehand_?1:this.snapTolerance_;if(r=Math.sqrt(re*re+oe*oe)<=j,r){this.finishCoordinate_=V;break}}}}return r}createOrUpdateSketchPoint_(e){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(e):(this.sketchPoint_=new Feature(new Point(e)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(e){this.sketchLine_||(this.sketchLine_=new Feature);const n=e.getLinearRing(0);let r=this.sketchLine_.getGeometry();r?(r.setFlatCoordinates(n.getLayout(),n.getFlatCoordinates()),r.changed()):(r=new LineString(n.getFlatCoordinates(),n.getLayout()),this.sketchLine_.setGeometry(r))}startDrawing_(e){const n=this.getMap().getView().getProjection(),r=getStrideForLayout(this.geometryLayout_);for(;e.length<r;)e.push(0);this.finishCoordinate_=e,this.mode_==="Point"?this.sketchCoords_=e.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[e.slice(),e.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[e.slice(),e.slice()],this.sketchLineCoords_&&(this.sketchLine_=new Feature(new LineString(this.sketchLineCoords_)));const i=this.geometryFunction_(this.sketchCoords_,void 0,n);this.sketchFeature_=new Feature,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(i),this.updateSketchFeatures_(),this.dispatchEvent(new DrawEvent(DrawEventType.DRAWSTART,this.sketchFeature_))}modifyDrawing_(e){const n=this.getMap(),r=this.sketchFeature_.getGeometry(),i=n.getView().getProjection(),g=getStrideForLayout(this.geometryLayout_);let y,k;for(;e.length<g;)e.push(0);this.mode_==="Point"?k=this.sketchCoords_:this.mode_==="Polygon"?(y=this.sketchCoords_[0],k=y[y.length-1],this.atFinish_(n.getPixelFromCoordinate(e))&&(e=this.finishCoordinate_.slice())):(y=this.sketchCoords_,k=y[y.length-1]),k[0]=e[0],k[1]=e[1],this.geometryFunction_(this.sketchCoords_,r,i),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(e),r.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(r):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(e){const n=this.sketchFeature_.getGeometry(),r=this.getMap().getView().getProjection();let i,g;const y=this.mode_;return y==="LineString"||y==="Circle"?(this.finishCoordinate_=e.slice(),g=this.sketchCoords_,g.length>=this.maxPoints_&&(this.freehand_?g.pop():i=!0),g.push(e.slice()),this.geometryFunction_(g,n,r)):y==="Polygon"&&(g=this.sketchCoords_[0],g.length>=this.maxPoints_&&(this.freehand_?g.pop():i=!0),g.push(e.slice()),i&&(this.finishCoordinate_=g[0]),this.geometryFunction_(this.sketchCoords_,n,r)),this.createOrUpdateSketchPoint_(e.slice()),this.updateSketchFeatures_(),i?this.finishDrawing():this.sketchFeature_}removeLastPoints_(e){if(!this.sketchFeature_)return;const n=this.sketchFeature_.getGeometry(),r=this.getMap().getView().getProjection(),i=this.mode_;for(let g=0;g<e;++g){let y;if(i==="LineString"||i==="Circle"){if(y=this.sketchCoords_,y.splice(-2,1),y.length>=2){this.finishCoordinate_=y[y.length-2].slice();const k=this.finishCoordinate_.slice();y[y.length-1]=k,this.createOrUpdateSketchPoint_(k)}this.geometryFunction_(y,n,r),n.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(n)}else if(i==="Polygon"){y=this.sketchCoords_[0],y.splice(-2,1);const k=this.sketchLine_.getGeometry();if(y.length>=2){const L=y[y.length-2].slice();y[y.length-1]=L,this.createOrUpdateSketchPoint_(L)}k.setCoordinates(y),this.geometryFunction_(this.sketchCoords_,n,r)}if(y.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const e=this.abortDrawing_();if(!e)return null;let n=this.sketchCoords_;const r=e.getGeometry(),i=this.getMap().getView().getProjection();return this.mode_==="LineString"?(n.pop(),this.geometryFunction_(n,r,i)):this.mode_==="Polygon"&&(n[0].pop(),this.geometryFunction_(n,r,i),n=r.getCoordinates()),this.type_==="MultiPoint"?e.setGeometry(new MultiPoint([n])):this.type_==="MultiLineString"?e.setGeometry(new MultiLineString([n])):this.type_==="MultiPolygon"&&e.setGeometry(new MultiPolygon([n])),this.dispatchEvent(new DrawEvent(DrawEventType.DRAWEND,e)),this.features_&&this.features_.push(e),this.source_&&this.source_.addFeature(e),e}abortDrawing_(){this.finishCoordinate_=null;const e=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),e}abortDrawing(){const e=this.abortDrawing_();e&&this.dispatchEvent(new DrawEvent(DrawEventType.DRAWABORT,e))}appendCoordinates(e){const n=this.mode_,r=!this.sketchFeature_;r&&this.startDrawing_(e[0]);let i;if(n==="LineString"||n==="Circle")i=this.sketchCoords_;else if(n==="Polygon")i=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;r&&i.shift(),i.pop();for(let y=0;y<e.length;y++)this.addToDrawing_(e[y]);const g=e[e.length-1];this.sketchFeature_=this.addToDrawing_(g),this.modifyDrawing_(g)}extend(e){const r=e.getGeometry();this.sketchFeature_=e,this.sketchCoords_=r.getCoordinates();const i=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=i.slice(),this.sketchCoords_.push(i.slice()),this.sketchPoint_=new Feature(new Point(i)),this.updateSketchFeatures_(),this.dispatchEvent(new DrawEvent(DrawEventType.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){const e=[];this.sketchFeature_&&e.push(this.sketchFeature_),this.sketchLine_&&e.push(this.sketchLine_),this.sketchPoint_&&e.push(this.sketchPoint_);const n=this.overlay_.getSource();n.clear(!0),n.addFeatures(e)}updateState_(){const e=this.getMap(),n=this.getActive();(!e||!n)&&this.abortDrawing(),this.overlay_.setMap(n?e:null)}}function getDefaultStyleFunction(){const t=createEditingStyle();return function(e,n){return t[e.getGeometry().getType()]}}function getMode(t){switch(t){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+t)}}const disableDoubleClickZoom=()=>{getInstall().getInteractions().forEach(e=>{e instanceof DoubleClickZoom&&e.setActive(!1)})},enableDoubleClickZoom=()=>{getInstall().getInteractions().forEach(e=>{e instanceof DoubleClickZoom&&e.setActive(!0)})},props=vue.ref(),setProps=t=>{props.value=t},getProps=()=>props.value,measureHistory=vue.ref([]),unit=vue.ref("km"),setUnit=t=>{unit.value=t};let helpTooltipElement$1;const state=vue.ref(!1),open$1=()=>{initMapLayer(),disableDoubleClickZoom(),changeCursor("pointer");const t=getInstall();t.on("pointermove",pointerMoveHandler$1),t.getViewport().addEventListener("mouseout",()=>{helpTooltipElement$1&&helpTooltipElement$1.classList.add("hidden")}),addInteraction(),state.value=!0};let vectorSource$2,vectorLayer$2;const initMapLayer=()=>{vectorSource$2=new VectorSource,vectorLayer$2=new VectorLayer({source:vectorSource$2,zIndex:1e3,style:{"fill-color":"rgba(255, 255, 255, 0.2)","stroke-color":"#ffcc33","stroke-width":2,"circle-radius":7,"circle-fill-color":"#ffcc33"}}),getInstall().addLayer(vectorLayer$2)};let sketch$1,helpTooltip;const pointerMoveHandler$1=t=>{if(t.dragging)return;let e="点击选择起点";sketch$1&&(e="单击继续,双击结束"),helpTooltipElement$1&&(helpTooltipElement$1.innerHTML=e,helpTooltip.setPosition(t.coordinate),helpTooltipElement$1.classList.remove("hidden"))},changeCursor=t=>{getInstall().getTargetElement().style.cursor=t};let draw$1;const addInteraction=()=>{draw$1=new Draw({source:vectorSource$2,type:"LineString",style:new Style({fill:new Fill({color:"rgba(255, 255, 255, 0.2)"}),stroke:new Stroke({color:"rgba(255,204,51)",lineDash:[10,10],width:2}),image:new CircleStyle({radius:5,stroke:new Stroke({color:"rgba(0, 0, 0, 0.7)"}),fill:new Fill({color:"rgba(255, 255, 255, 0.2)"})})}),condition:e=>e.originalEvent.target.tagName!=="DIV"}),getInstall().addInteraction(draw$1),createMeasureTooltip$1(),createHelpTooltip$1();let t;draw$1.on("drawstart",function(e){var r;sketch$1=e.feature,sketch$1.set("randomId",generateRandomId());let n;t=(r=sketch$1.getGeometry())==null?void 0:r.on("change",function(i){const g=i.target,y=computedDistance(g,unit.value);n=g.getLastCoordinate(),measureTooltipElement$1&&y&&(measureTooltipElement$1.innerHTML=y),measureTooltip$1.setPosition(n)})}),draw$1.on("drawend",function(){var e,n,r;if(measureTooltipElement$1&&(measureTooltipElement$1.className="ol-tooltip ol-tooltip-static ol-tooltip-measure"),measureTooltipElement$1!=null&&measureTooltipElement$1.innerHTML){const i=(sketch$1==null?void 0:sketch$1.get("randomId"))||generateRandomId();measureHistory.value.push({id:i,value:measureTooltipElement$1==null?void 0:measureTooltipElement$1.innerHTML}),measureTooltipElement$1.innerHTML=`${measureTooltipElement$1.innerHTML}<div class="ol-tooltip-delete-button" data-id="${i}"><i class="map-iconfont icon-delete"></i></div>`}(e=document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button"))==null||e.addEventListener("click",i=>{var y;i.preventDefault(),i.stopPropagation();const g=(y=i.target)==null?void 0:y.getAttribute("data-id");g&&deleteLine(g)}),measureTooltip$1.setOffset([0,-7]),sketch$1=null,measureTooltipElement$1=null,createMeasureTooltip$1(),t&&unByKey(t),(n=getProps())!=null&&n.lineDrawEnd&&((r=getProps())==null||r.lineDrawEnd(measureHistory.value))})},generateRandomId=()=>Math.random().toString(36).substring(2,9);let measureTooltipElement$1,measureTooltip$1;const createMeasureTooltip$1=()=>{measureTooltipElement$1!=null&&measureTooltipElement$1.parentNode&&measureTooltipElement$1.parentNode.removeChild(measureTooltipElement$1),measureTooltipElement$1=document.createElement("div"),measureTooltipElement$1.className="ol-tooltip ol-tooltip-measure",measureTooltip$1=new Overlay({element:measureTooltipElement$1,offset:[0,-15],positioning:"bottom-center",stopEvent:!1,insertFirst:!1}),getInstall().addOverlay(measureTooltip$1)},createHelpTooltip$1=()=>{helpTooltipElement$1!=null&&helpTooltipElement$1.parentNode&&helpTooltipElement$1.parentNode.removeChild(helpTooltipElement$1),helpTooltipElement$1=document.createElement("div"),helpTooltipElement$1.className="ol-tooltip hidden",helpTooltip=new Overlay({element:helpTooltipElement$1,offset:[15,0],positioning:"center-left"}),getInstall().addOverlay(helpTooltip)},close$1=()=>{measureHistory.value.forEach((t,e)=>{var i,g;const n=document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");n[e]&&((g=(i=n[e])==null?void 0:i.parentNode)==null||g.removeChild(n[e]));const r=vectorSource$2.getFeatures();r[e]&&vectorSource$2.removeFeature(r[e])}),removeInteraction(),enableDoubleClickZoom(),state.value=!1},deleteLine=t=>{var n,r,i,g;const e=measureHistory.value.findIndex(y=>y.id===t);if(e!==-1){measureHistory.value.splice(e,1);const y=document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");y[e]&&((r=(n=y[e])==null?void 0:n.parentNode)==null||r.removeChild(y[e]));const k=vectorSource$2.getFeatures();k[e]&&vectorSource$2.removeFeature(k[e])}(i=getProps())!=null&&i.lineDrawEnd&&((g=getProps())==null||g.lineDrawEnd(measureHistory.value))},computedDistance=(t,e)=>{const r=getLength(t);let i="";switch(e){case"m":i=`${Math.round(r*100)/100} m`;break;case"km":i=`${Math.round(r/1e3*100)/100} km`;break;case"nm":i=`${Math.round(r/1.852*100)/100} nm`;break}return i},removeInteraction=()=>{measureHistory.value=[],document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach(e=>{var n;(n=e==null?void 0:e.parentNode)==null||n.removeChild(e)}),vectorSource$2.clear();const t=getInstall();if(draw$1){const e=t.getInteractions().getArray().find(n=>getUid(n)===getUid(draw$1));e&&t.removeInteraction(e)}t.removeLayer(vectorLayer$2),helpTooltipElement$1!=null&&helpTooltipElement$1.parentNode&&helpTooltipElement$1.parentNode.removeChild(helpTooltipElement$1),measureTooltipElement$1!=null&&measureTooltipElement$1.parentNode&&measureTooltipElement$1.parentNode.removeChild(measureTooltipElement$1)},getState=()=>state.value,drawLine={open:open$1,close:close$1,deleteLine,setUnit,getState},mapInstance=vue.ref(),getInstall=()=>mapInstance.value,getView=()=>getInstall().getView(),getZoom=()=>{var t;return(t=getView())==null?void 0:t.getZoom()},setZoom=t=>{var e;(e=getView())==null||e.setZoom(t)},setCenter=(t,e)=>{var n;(n=getView())==null||n.setCenter(fromLonLat([t,e]))},getCenter=()=>{var e;const t=(e=getView())==null?void 0:e.getCenter();return toLonLat(t)},getSize=()=>{var t;return(t=getInstall())==null?void 0:t.getSize()},BASE_LAYER_MAP=new Map$2,initMap=t=>{setBaseLayerMap(t);const e={zoom:t.zoom,center:fromLonLat(t.center),minZoom:MAP_ZOOM.min,maxZoom:MAP_ZOOM.max,constrainResolution:!0,enableRotation:!1,multiWorld:!0},n=new Map$2({target:"map",controls:defaults$2({zoom:!1}),layers:[BASE_LAYER_MAP.get("vectorTile"),BASE_LAYER_MAP.get("vectorTileMark"),BASE_LAYER_MAP.get("satelliteImgTile"),BASE_LAYER_MAP.get("satelliteImgTileMark")],view:new View(e)});mapInstance.value=n,setBaseMapEvent(n,t)},setBaseLayerMap=t=>{BASE_LAYER_MAP.set("vectorTile",new TileLayer({source:new XYZ({url:BASE_MAP_LINK.vectorTile}),visible:t.layerType==="vector",zIndex:0,preload:1,className:"vector"})),BASE_LAYER_MAP.set("vectorTileMark",new TileLayer({source:new XYZ({url:BASE_MAP_LINK.vectorTileMark}),visible:t.layerType==="vector",zIndex:1,preload:1,className:"vector"})),BASE_LAYER_MAP.set("satelliteImgTile",new TileLayer({source:new XYZ({url:BASE_MAP_LINK.satelliteImgTile}),visible:t.layerType==="satellite",zIndex:0,preload:1,className:"satellite"})),BASE_LAYER_MAP.set("satelliteImgTileMark",new TileLayer({source:new XYZ({url:BASE_MAP_LINK.satelliteImgTileMark}),visible:t.layerType==="satellite",zIndex:1,preload:1,className:"satellite"})),BASE_LAYER_MAP.set("greenMark",new TileLayer({source:new XYZ({url:BASE_MAP_LINK.greenTile}),visible:t.showGreenLayer,zIndex:2,className:"greenTile"}))},setBaseMapEvent=(t,e)=>{t.on("moveend",()=>{var r;const n=getZoom();(r=e.mapMoveEnd)==null||r.call(e,n),reRenderTrackLine()}),t.on("pointermove",n=>{const r=t.getEventPixel(n.originalEvent),i=t.forEachFeatureAtPixel(r,g=>g);handleShipMapEvent(i,"hover"),handleTrackMapEvent(i,"hover",n),i&&handlePortHover(r)}),t.on("movestart",()=>{console.log("movestart-----------------------"),removeSelectedOverlay()}),t.on("click",debounce(n=>{if(console.log("1",drawLine.getState()),drawLine.getState())return;const r=t.getEventPixel(n.originalEvent),i=t.forEachFeatureAtPixel(r,g=>{if(g!=null&&g.get("shipData")||g!=null&&g.get("portData"))return g});if(console.log("2",i),!!i){if(n.preventDefault(),n.stopPropagation(),i.get("shipData"))handleShipMapEvent(i,"click",e==null?void 0:e.selectShip);else if(i.get("portData")){const g=i.get("portData");selectedPort(g),e==null||e.selectPort(g)}}},150))},_hoisted_1$8={id:"scale-line-container"},_sfc_main$9=vue.defineComponent({__name:"scaleLine",setup(t,{expose:e}){return e({setScaleLine:r=>{r||(r="metric");const i=new ScaleLine$1({units:r}),g=document.getElementById("scale-line-container");g&&(i.setTarget(g),getInstall().addControl(i))}}),(r,i)=>(vue.openBlock(),vue.createElementBlock("div",_hoisted_1$8))}}),ScaleLine=_export_sfc(_sfc_main$9,[["__scopeId","data-v-31ff8293"]]),_hoisted_1$7={class:"zoom"},_sfc_main$8=vue.defineComponent({__name:"zoomControl",setup(t){const e=()=>{if(!getInstall())return;const i=getZoom();i&&setZoom(i+1)},n=()=>{if(!getInstall())return;const i=getZoom();i&&setZoom(i-1)};return(r,i)=>(vue.openBlock(),vue.createElementBlock("div",_hoisted_1$7,[vue.createElementVNode("div",{class:"button big-button",onClick:e}," + "),vue.createElementVNode("div",{class:"button small-button",onClick:n}," - ")]))}}),ZoomControl=_export_sfc(_sfc_main$8,[["__scopeId","data-v-2b7e25f2"]]),getLayers=()=>{var t;return(t=getInstall())==null?void 0:t.getLayers()},layerType=vue.ref("vector"),getShowLayerType=()=>layerType.value,setShowLayerType=t=>{layerType.value=t;const e=getLayers();e&&e.getArray().forEach(n=>{n.setVisible(n.className_===t)})},showGreenTile=vue.ref(),getGreenTileVisible=()=>showGreenTile.value,setGreenTileVisible=t=>{if(t!==showGreenTile.value){if(t){const e=getLayers();if(!e.getArray().find(r=>r.className_==="greenTile")){const r=new TileLayer({source:new XYZ({url:BASE_MAP_LINK.greenTile}),visible:t,zIndex:2,className:"greenTile"});e.push(r)}}else{const e=getLayers(),n=e.getArray().find(r=>r.className_==="greenTile");n&&e.remove(n)}showGreenTile.value=t}};let storeFeature;const open=()=>{init()},init=()=>{initLayer(),createMeasureTooltip(),createHelpTooltip(),initDraw()};let vectorLayer$1=null,vectorSource$1=null;const initLayer=()=>{if(vectorLayer$1||vectorSource$1)return;const t=new VectorSource,e=new VectorLayer({source:t,style:new Style({stroke:new Stroke({color:"#fbcc33",width:2})})});vectorLayer$1=e,vectorSource$1=t;const n=getInstall();n.on("pointermove",pointerMoveHandler),n.addLayer(e),n.on(["dblclick"],function(r){draw&&(r.stopPropagation(),r.preventDefault())})};let sketch;const pointerMoveHandler=t=>{if(t.dragging)return;const e=sketch?"单击继续,双击结束":"点击选择起点";helpTooltipElement&&(helpTooltipElement.innerHTML=e,tipOverlay.setPosition(t.coordinate))};let draw,lineLimitError=!1;const initDraw=()=>{if(storeFeature){helpTooltipElement!=null&&helpTooltipElement.parentNode&&helpTooltipElement.parentNode.removeChild(helpTooltipElement);const e=storeFeature.getGeometry();if(!e)return;const n=computedArea(e,"nm");measureTooltipElement&&(measureTooltipElement.innerHTML=`
|
|
215
|
+
`,i=()=>`data:image/svg+xml;utf8,${encodeURIComponent(r(n?"#FF5733":"#3370FF"))}`;return new Style({text:new Text({text:t.shortName,font:"12px sans-serif",fill:new Fill({color:n?"#ffffff":"#000000"}),backgroundFill:new Fill({color:n?"#FF5733":"#FFFFFF"}),offsetY:30}),image:new Icon({src:i(),scale:.5*e/10})})},clearPortList=()=>{if(selectedPortFeature$1){console.log("清除非选中的港口");const t=selectedPortFeature$1.get("portData").id;vectorSource$3.getFeatures().forEach(e=>{e.get("portData").id!==t&&vectorSource$3.removeFeature(e)})}else console.log("清除所有港口"),vectorSource$3.clear()},clearSelectedPort$1=()=>{const t=selectedPortFeature$1==null?void 0:selectedPortFeature$1.get("portData"),e=getZoom();t&&vectorSource$3.getFeatures().forEach(r=>{r.get("portData").id===t.id&&(r==null||r.setStyle(setPortStyle$1(t,e,!1)))}),selectedPortData=null,selectedPortFeature$1=null};let selectedPortFeature$1=null,selectedPortData=null;const selectedPort=t=>{t?(clearPrevSelectedPort$1(),addSelectedPortStyle$1(t)):clearSelectedPort$1()},clearPrevSelectedPort$1=()=>{if(selectedPortFeature$1){const t=selectedPortFeature$1==null?void 0:selectedPortFeature$1.get("portData"),e=getZoom();selectedPortFeature$1.setStyle(setPortStyle$1(t,e,!1))}},addSelectedPortStyle$1=t=>{const e=vectorSource$3.getFeatures();selectedPortData=t,selectedPortFeature$1=e.find(n=>n.get("portData").id===t.id)},handlePortHover=t=>{const e=getInstall(),n=e.forEachFeatureAtPixel(t,r=>r);n&&n.get("portData")&&(e.getTargetElement().style.cursor="pointer")},DrawEventType={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class DrawEvent extends BaseEvent{constructor(e,n){super(e),this.feature=n}}function getTraceTargets(t,e){const n=[];for(let r=0;r<e.length;++r){const g=e[r].getGeometry();appendGeometryTraceTargets(t,g,n)}return n}function getSquaredDistance(t,e){return squaredDistance$1(t[0],t[1],e[0],e[1])}function getCoordinate(t,e){const n=t.length;return e<0?t[e+n]:e>=n?t[e-n]:t[e]}function getCumulativeSquaredDistance(t,e,n){let r,i;e<n?(r=e,i=n):(r=n,i=e);const g=Math.ceil(r),y=Math.floor(i);if(g>y){const L=interpolateCoordinate(t,r),$=interpolateCoordinate(t,i);return getSquaredDistance(L,$)}let k=0;if(r<g){const L=interpolateCoordinate(t,r),$=getCoordinate(t,g);k+=getSquaredDistance(L,$)}if(y<i){const L=getCoordinate(t,y),$=interpolateCoordinate(t,i);k+=getSquaredDistance(L,$)}for(let L=g;L<y-1;++L){const $=getCoordinate(t,L),V=getCoordinate(t,L+1);k+=getSquaredDistance($,V)}return k}function appendGeometryTraceTargets(t,e,n){if(e instanceof LineString){appendTraceTarget(t,e.getCoordinates(),!1,n);return}if(e instanceof MultiLineString){const r=e.getCoordinates();for(let i=0,g=r.length;i<g;++i)appendTraceTarget(t,r[i],!1,n);return}if(e instanceof Polygon){const r=e.getCoordinates();for(let i=0,g=r.length;i<g;++i)appendTraceTarget(t,r[i],!0,n);return}if(e instanceof MultiPolygon){const r=e.getCoordinates();for(let i=0,g=r.length;i<g;++i){const y=r[i];for(let k=0,L=y.length;k<L;++k)appendTraceTarget(t,y[k],!0,n)}return}if(e instanceof GeometryCollection){const r=e.getGeometries();for(let i=0;i<r.length;++i)appendGeometryTraceTargets(t,r[i],n);return}}const sharedUpdateInfo={index:-1,endIndex:NaN};function getTraceTargetUpdate(t,e,n,r){const i=t[0],g=t[1];let y=1/0,k=-1,L=NaN;for(let z=0;z<e.targets.length;++z){const re=e.targets[z],oe=re.coordinates;let j=1/0,ie;for(let ae=0;ae<oe.length-1;++ae){const ue=oe[ae],de=oe[ae+1],pe=getPointSegmentRelationship(i,g,ue,de);pe.squaredDistance<j&&(j=pe.squaredDistance,ie=ae+pe.along)}j<y&&(y=j,re.ring&&e.targetIndex===z&&(re.endIndex>re.startIndex?ie<re.startIndex&&(ie+=oe.length):re.endIndex<re.startIndex&&ie>re.startIndex&&(ie-=oe.length)),L=ie,k=z)}const $=e.targets[k];let V=$.ring;if(e.targetIndex===k&&V){const z=interpolateCoordinate($.coordinates,L),re=n.getPixelFromCoordinate(z);distance$1(re,e.startPx)>r&&(V=!1)}if(V){const z=$.coordinates,re=z.length,oe=$.startIndex,j=L;if(oe<j){const ie=getCumulativeSquaredDistance(z,oe,j);getCumulativeSquaredDistance(z,oe,j-re)<ie&&(L-=re)}else{const ie=getCumulativeSquaredDistance(z,oe,j);getCumulativeSquaredDistance(z,oe,j+re)<ie&&(L+=re)}}return sharedUpdateInfo.index=k,sharedUpdateInfo.endIndex=L,sharedUpdateInfo}function appendTraceTarget(t,e,n,r){const i=t[0],g=t[1];for(let y=0,k=e.length-1;y<k;++y){const L=e[y],$=e[y+1],V=getPointSegmentRelationship(i,g,L,$);if(V.squaredDistance===0){const z=y+V.along;r.push({coordinates:e,ring:n,startIndex:z,endIndex:z});return}}}const sharedRel={along:0,squaredDistance:0};function getPointSegmentRelationship(t,e,n,r){const i=n[0],g=n[1],y=r[0],k=r[1],L=y-i,$=k-g;let V=0,z=i,re=g;return(L!==0||$!==0)&&(V=clamp(((t-i)*L+(e-g)*$)/(L*L+$*$),0,1),z+=L*V,re+=$*V),sharedRel.along=V,sharedRel.squaredDistance=toFixed(squaredDistance$1(t,e,z,re),10),sharedRel}function interpolateCoordinate(t,e){const n=t.length;let r=Math.floor(e);const i=e-r;r>=n?r-=n:r<0&&(r+=n);let g=r+1;g>=n&&(g-=n);const y=t[r],k=y[0],L=y[1],$=t[g],V=$[0]-k,z=$[1]-L;return[k+V*i,L+z*i]}class Draw extends PointerInteraction{constructor(e){const n=e;n.stopDown||(n.stopDown=FALSE),super(n),this.on,this.once,this.un,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=e.source?e.source:null,this.features_=e.features?e.features:null,this.snapTolerance_=e.snapTolerance?e.snapTolerance:12,this.type_=e.type,this.mode_=getMode(this.type_),this.stopClick_=!!e.stopClick,this.minPoints_=e.minPoints?e.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:e.maxPoints?e.maxPoints:1/0,this.finishCondition_=e.finishCondition?e.finishCondition:TRUE,this.geometryLayout_=e.geometryLayout?e.geometryLayout:"XY";let r=e.geometryFunction;if(!r){const i=this.mode_;if(i==="Circle")r=(g,y,k)=>{const L=y||new Circle([NaN,NaN]),$=fromUserCoordinate(g[0]),V=squaredDistance($,fromUserCoordinate(g[g.length-1]));return L.setCenterAndRadius($,Math.sqrt(V),this.geometryLayout_),L};else{let g;i==="Point"?g=Point:i==="LineString"?g=LineString:i==="Polygon"&&(g=Polygon),r=(y,k,L)=>(k?i==="Polygon"?y[0].length?k.setCoordinates([y[0].concat([y[0][0]])],this.geometryLayout_):k.setCoordinates([],this.geometryLayout_):k.setCoordinates(y,this.geometryLayout_):k=new g(y,this.geometryLayout_),k)}}this.geometryFunction_=r,this.dragVertexDelay_=e.dragVertexDelay!==void 0?e.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=e.clickTolerance?e.clickTolerance*e.clickTolerance:36,this.overlay_=new VectorLayer({source:new VectorSource({useSpatialIndex:!1,wrapX:e.wrapX?e.wrapX:!1}),style:e.style?e.style:getDefaultStyleFunction(),updateWhileInteracting:!0}),this.geometryName_=e.geometryName,this.condition_=e.condition?e.condition:noModifierKeys,this.freehandCondition_,e.freehand?this.freehandCondition_=always:this.freehandCondition_=e.freehandCondition?e.freehandCondition:shiftKeyOnly,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSource_=e.traceSource||e.source||null,this.addChangeListener(InteractionProperty.ACTIVE,this.updateState_)}setTrace(e){let n;e?e===!0?n=always:n=e:n=never,this.traceCondition_=n}setMap(e){super.setMap(e),this.updateState_()}getOverlay(){return this.overlay_}handleEvent(e){e.originalEvent.type===EventType.CONTEXTMENU&&e.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(e);let n=e.type===MapBrowserEventType.POINTERMOVE,r=!0;return!this.freehand_&&this.lastDragTime_&&e.type===MapBrowserEventType.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=e.pixel,this.shouldHandle_=!this.freehand_,n=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&e.type===MapBrowserEventType.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(e.coordinate),r=!1):this.freehand_&&e.type===MapBrowserEventType.POINTERDOWN?r=!1:n&&this.getPointerCount()<2?(r=e.type===MapBrowserEventType.POINTERMOVE,r&&this.freehand_?(this.handlePointerMove_(e),this.shouldHandle_&&e.originalEvent.preventDefault()):(e.originalEvent.pointerType==="mouse"||e.type===MapBrowserEventType.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(e)):e.type===MapBrowserEventType.DBLCLICK&&(r=!1),super.handleEvent(e)&&r}handleDownEvent(e){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=e.pixel,this.finishCoordinate_||this.startDrawing_(e.coordinate),!0):this.condition_(e)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new MapBrowserEvent(MapBrowserEventType.POINTERMOVE,e.map,e.originalEvent,!1,e.frameState))},this.dragVertexDelay_),this.downPx_=e.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_();return}const n=this.getMap(),r=n.getCoordinateFromPixel([e.pixel[0]-this.snapTolerance_,e.pixel[1]+this.snapTolerance_]),i=n.getCoordinateFromPixel([e.pixel[0]+this.snapTolerance_,e.pixel[1]-this.snapTolerance_]),g=boundingExtent([r,i]),y=this.traceSource_.getFeaturesInExtent(g);if(y.length===0)return;const k=getTraceTargets(e.coordinate,y);k.length&&(this.traceState_={active:!0,startPx:e.pixel.slice(),targets:k,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,n){const r=e.startIndex<=e.endIndex,i=e.startIndex<=n;r===i?r&&n>e.endIndex||!r&&n<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,n):(r&&n<e.endIndex||!r&&n>e.endIndex)&&this.removeTracedCoordinates_(n,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,n))}removeTracedCoordinates_(e,n){if(e===n)return;let r=0;if(e<n){const i=Math.ceil(e);let g=Math.floor(n);g===n&&(g-=1),r=g-i+1}else{const i=Math.floor(e);let g=Math.ceil(n);g===n&&(g+=1),r=i-g+1}r>0&&this.removeLastPoints_(r)}addTracedCoordinates_(e,n,r){if(n===r)return;const i=[];if(n<r){const g=Math.ceil(n);let y=Math.floor(r);y===r&&(y-=1);for(let k=g;k<=y;++k)i.push(getCoordinate(e.coordinates,k))}else{const g=Math.floor(n);let y=Math.ceil(r);y===r&&(y+=1);for(let k=g;k>=y;--k)i.push(getCoordinate(e.coordinates,k))}i.length&&this.appendCoordinates(i)}updateTrace_(e){const n=this.traceState_;if(!n.active||n.targetIndex===-1&&distance$1(n.startPx,e.pixel)<this.snapTolerance_)return;const r=getTraceTargetUpdate(e.coordinate,n,this.getMap(),this.snapTolerance_);if(n.targetIndex!==r.index){if(n.targetIndex!==-1){const L=n.targets[n.targetIndex];this.removeTracedCoordinates_(L.startIndex,L.endIndex)}const k=n.targets[r.index];this.addTracedCoordinates_(k,k.startIndex,r.endIndex)}else{const k=n.targets[n.targetIndex];this.addOrRemoveTracedCoordinates_(k,r.endIndex)}n.targetIndex=r.index;const i=n.targets[n.targetIndex];i.endIndex=r.endIndex;const g=interpolateCoordinate(i.coordinates,i.endIndex),y=this.getMap().getPixelFromCoordinate(g);e.coordinate=g,e.pixel=[Math.round(y[0]),Math.round(y[1])]}handleUpEvent(e){let n=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(e);const r=this.traceState_.active;if(this.toggleTraceState_(e),this.shouldHandle_){const i=!this.finishCoordinate_;i&&this.startDrawing_(e.coordinate),!i&&this.freehand_?this.finishDrawing():!this.freehand_&&(!i||this.mode_==="Point")&&(this.atFinish_(e.pixel,r)?this.finishCondition_(e)&&this.finishDrawing():this.addToDrawing_(e.coordinate)),n=!1}else this.freehand_&&this.abortDrawing()}return!n&&this.stopClick_&&e.preventDefault(),n}handlePointerMove_(e){if(this.pointerType_=e.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const n=this.downPx_,r=e.pixel,i=n[0]-r[0],g=n[1]-r[1],y=i*i+g*g;if(this.shouldHandle_=this.freehand_?y>this.squaredClickTolerance_:y<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(e.coordinate.slice());return}this.updateTrace_(e),this.modifyDrawing_(e.coordinate)}atFinish_(e,n){let r=!1;if(this.sketchFeature_){let i=!1,g=[this.finishCoordinate_];const y=this.mode_;if(y==="Point")r=!0;else if(y==="Circle")r=this.sketchCoords_.length===2;else if(y==="LineString")i=!n&&this.sketchCoords_.length>this.minPoints_;else if(y==="Polygon"){const k=this.sketchCoords_;i=k[0].length>this.minPoints_,g=[k[0][0],k[0][k[0].length-2]],n?g=[k[0][0]]:g=[k[0][0],k[0][k[0].length-2]]}if(i){const k=this.getMap();for(let L=0,$=g.length;L<$;L++){const V=g[L],z=k.getPixelFromCoordinate(V),re=e[0]-z[0],oe=e[1]-z[1],j=this.freehand_?1:this.snapTolerance_;if(r=Math.sqrt(re*re+oe*oe)<=j,r){this.finishCoordinate_=V;break}}}}return r}createOrUpdateSketchPoint_(e){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(e):(this.sketchPoint_=new Feature(new Point(e)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(e){this.sketchLine_||(this.sketchLine_=new Feature);const n=e.getLinearRing(0);let r=this.sketchLine_.getGeometry();r?(r.setFlatCoordinates(n.getLayout(),n.getFlatCoordinates()),r.changed()):(r=new LineString(n.getFlatCoordinates(),n.getLayout()),this.sketchLine_.setGeometry(r))}startDrawing_(e){const n=this.getMap().getView().getProjection(),r=getStrideForLayout(this.geometryLayout_);for(;e.length<r;)e.push(0);this.finishCoordinate_=e,this.mode_==="Point"?this.sketchCoords_=e.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[e.slice(),e.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[e.slice(),e.slice()],this.sketchLineCoords_&&(this.sketchLine_=new Feature(new LineString(this.sketchLineCoords_)));const i=this.geometryFunction_(this.sketchCoords_,void 0,n);this.sketchFeature_=new Feature,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(i),this.updateSketchFeatures_(),this.dispatchEvent(new DrawEvent(DrawEventType.DRAWSTART,this.sketchFeature_))}modifyDrawing_(e){const n=this.getMap(),r=this.sketchFeature_.getGeometry(),i=n.getView().getProjection(),g=getStrideForLayout(this.geometryLayout_);let y,k;for(;e.length<g;)e.push(0);this.mode_==="Point"?k=this.sketchCoords_:this.mode_==="Polygon"?(y=this.sketchCoords_[0],k=y[y.length-1],this.atFinish_(n.getPixelFromCoordinate(e))&&(e=this.finishCoordinate_.slice())):(y=this.sketchCoords_,k=y[y.length-1]),k[0]=e[0],k[1]=e[1],this.geometryFunction_(this.sketchCoords_,r,i),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(e),r.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(r):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(e){const n=this.sketchFeature_.getGeometry(),r=this.getMap().getView().getProjection();let i,g;const y=this.mode_;return y==="LineString"||y==="Circle"?(this.finishCoordinate_=e.slice(),g=this.sketchCoords_,g.length>=this.maxPoints_&&(this.freehand_?g.pop():i=!0),g.push(e.slice()),this.geometryFunction_(g,n,r)):y==="Polygon"&&(g=this.sketchCoords_[0],g.length>=this.maxPoints_&&(this.freehand_?g.pop():i=!0),g.push(e.slice()),i&&(this.finishCoordinate_=g[0]),this.geometryFunction_(this.sketchCoords_,n,r)),this.createOrUpdateSketchPoint_(e.slice()),this.updateSketchFeatures_(),i?this.finishDrawing():this.sketchFeature_}removeLastPoints_(e){if(!this.sketchFeature_)return;const n=this.sketchFeature_.getGeometry(),r=this.getMap().getView().getProjection(),i=this.mode_;for(let g=0;g<e;++g){let y;if(i==="LineString"||i==="Circle"){if(y=this.sketchCoords_,y.splice(-2,1),y.length>=2){this.finishCoordinate_=y[y.length-2].slice();const k=this.finishCoordinate_.slice();y[y.length-1]=k,this.createOrUpdateSketchPoint_(k)}this.geometryFunction_(y,n,r),n.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(n)}else if(i==="Polygon"){y=this.sketchCoords_[0],y.splice(-2,1);const k=this.sketchLine_.getGeometry();if(y.length>=2){const L=y[y.length-2].slice();y[y.length-1]=L,this.createOrUpdateSketchPoint_(L)}k.setCoordinates(y),this.geometryFunction_(this.sketchCoords_,n,r)}if(y.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const e=this.abortDrawing_();if(!e)return null;let n=this.sketchCoords_;const r=e.getGeometry(),i=this.getMap().getView().getProjection();return this.mode_==="LineString"?(n.pop(),this.geometryFunction_(n,r,i)):this.mode_==="Polygon"&&(n[0].pop(),this.geometryFunction_(n,r,i),n=r.getCoordinates()),this.type_==="MultiPoint"?e.setGeometry(new MultiPoint([n])):this.type_==="MultiLineString"?e.setGeometry(new MultiLineString([n])):this.type_==="MultiPolygon"&&e.setGeometry(new MultiPolygon([n])),this.dispatchEvent(new DrawEvent(DrawEventType.DRAWEND,e)),this.features_&&this.features_.push(e),this.source_&&this.source_.addFeature(e),e}abortDrawing_(){this.finishCoordinate_=null;const e=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),e}abortDrawing(){const e=this.abortDrawing_();e&&this.dispatchEvent(new DrawEvent(DrawEventType.DRAWABORT,e))}appendCoordinates(e){const n=this.mode_,r=!this.sketchFeature_;r&&this.startDrawing_(e[0]);let i;if(n==="LineString"||n==="Circle")i=this.sketchCoords_;else if(n==="Polygon")i=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;r&&i.shift(),i.pop();for(let y=0;y<e.length;y++)this.addToDrawing_(e[y]);const g=e[e.length-1];this.sketchFeature_=this.addToDrawing_(g),this.modifyDrawing_(g)}extend(e){const r=e.getGeometry();this.sketchFeature_=e,this.sketchCoords_=r.getCoordinates();const i=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=i.slice(),this.sketchCoords_.push(i.slice()),this.sketchPoint_=new Feature(new Point(i)),this.updateSketchFeatures_(),this.dispatchEvent(new DrawEvent(DrawEventType.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){const e=[];this.sketchFeature_&&e.push(this.sketchFeature_),this.sketchLine_&&e.push(this.sketchLine_),this.sketchPoint_&&e.push(this.sketchPoint_);const n=this.overlay_.getSource();n.clear(!0),n.addFeatures(e)}updateState_(){const e=this.getMap(),n=this.getActive();(!e||!n)&&this.abortDrawing(),this.overlay_.setMap(n?e:null)}}function getDefaultStyleFunction(){const t=createEditingStyle();return function(e,n){return t[e.getGeometry().getType()]}}function getMode(t){switch(t){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+t)}}const disableDoubleClickZoom=()=>{getInstall().getInteractions().forEach(e=>{e instanceof DoubleClickZoom&&e.setActive(!1)})},enableDoubleClickZoom=()=>{getInstall().getInteractions().forEach(e=>{e instanceof DoubleClickZoom&&e.setActive(!0)})},props=vue.ref(),setProps=t=>{props.value=t},getProps=()=>props.value,measureHistory=vue.ref([]),unit=vue.ref("km"),setUnit=t=>{unit.value=t};let helpTooltipElement$1;const state=vue.ref(!1),open$1=()=>{initMapLayer(),disableDoubleClickZoom(),changeCursor("pointer");const t=getInstall();t.on("pointermove",pointerMoveHandler$1),t.getViewport().addEventListener("mouseout",()=>{helpTooltipElement$1&&helpTooltipElement$1.classList.add("hidden")}),addInteraction(),state.value=!0};let vectorSource$2,vectorLayer$2;const initMapLayer=()=>{vectorSource$2=new VectorSource,vectorLayer$2=new VectorLayer({source:vectorSource$2,zIndex:1e3,style:{"fill-color":"rgba(255, 255, 255, 0.2)","stroke-color":"#ffcc33","stroke-width":2,"circle-radius":7,"circle-fill-color":"#ffcc33"}}),getInstall().addLayer(vectorLayer$2)};let sketch$1,helpTooltip;const pointerMoveHandler$1=t=>{if(t.dragging)return;let e="点击选择起点";sketch$1&&(e="单击继续,双击结束"),helpTooltipElement$1&&(helpTooltipElement$1.innerHTML=e,helpTooltip.setPosition(t.coordinate),helpTooltipElement$1.classList.remove("hidden"))},changeCursor=t=>{getInstall().getTargetElement().style.cursor=t};let draw$1;const addInteraction=()=>{draw$1=new Draw({source:vectorSource$2,type:"LineString",style:new Style({fill:new Fill({color:"rgba(255, 255, 255, 0.2)"}),stroke:new Stroke({color:"rgba(255,204,51)",lineDash:[10,10],width:2}),image:new CircleStyle({radius:5,stroke:new Stroke({color:"rgba(0, 0, 0, 0.7)"}),fill:new Fill({color:"rgba(255, 255, 255, 0.2)"})})}),condition:e=>e.originalEvent.target.tagName!=="DIV"}),getInstall().addInteraction(draw$1),createMeasureTooltip$1(),createHelpTooltip$1();let t;draw$1.on("drawstart",function(e){var r;sketch$1=e.feature,sketch$1.set("randomId",generateRandomId());let n;t=(r=sketch$1.getGeometry())==null?void 0:r.on("change",function(i){const g=i.target,y=computedDistance(g,unit.value);n=g.getLastCoordinate(),measureTooltipElement$1&&y&&(measureTooltipElement$1.innerHTML=y),measureTooltip$1.setPosition(n)})}),draw$1.on("drawend",function(){var e,n,r;if(measureTooltipElement$1&&(measureTooltipElement$1.className="ol-tooltip ol-tooltip-static ol-tooltip-measure"),measureTooltipElement$1!=null&&measureTooltipElement$1.innerHTML){const i=(sketch$1==null?void 0:sketch$1.get("randomId"))||generateRandomId();measureHistory.value.push({id:i,value:measureTooltipElement$1==null?void 0:measureTooltipElement$1.innerHTML}),measureTooltipElement$1.innerHTML=`${measureTooltipElement$1.innerHTML}<div class="ol-tooltip-delete-button" data-id="${i}"><i class="map-iconfont icon-delete"></i></div>`}(e=document.querySelector(".ol-selectable:has(.ol-tooltip-delete-button):last-child .ol-tooltip-delete-button"))==null||e.addEventListener("click",i=>{var y;i.preventDefault(),i.stopPropagation();const g=(y=i.target)==null?void 0:y.getAttribute("data-id");g&&deleteLine(g)}),measureTooltip$1.setOffset([0,-7]),sketch$1=null,measureTooltipElement$1=null,createMeasureTooltip$1(),t&&unByKey(t),(n=getProps())!=null&&n.lineDrawEnd&&((r=getProps())==null||r.lineDrawEnd(measureHistory.value))})},generateRandomId=()=>Math.random().toString(36).substring(2,9);let measureTooltipElement$1,measureTooltip$1;const createMeasureTooltip$1=()=>{measureTooltipElement$1!=null&&measureTooltipElement$1.parentNode&&measureTooltipElement$1.parentNode.removeChild(measureTooltipElement$1),measureTooltipElement$1=document.createElement("div"),measureTooltipElement$1.className="ol-tooltip ol-tooltip-measure",measureTooltip$1=new Overlay({element:measureTooltipElement$1,offset:[0,-15],positioning:"bottom-center",stopEvent:!1,insertFirst:!1}),getInstall().addOverlay(measureTooltip$1)},createHelpTooltip$1=()=>{helpTooltipElement$1!=null&&helpTooltipElement$1.parentNode&&helpTooltipElement$1.parentNode.removeChild(helpTooltipElement$1),helpTooltipElement$1=document.createElement("div"),helpTooltipElement$1.className="ol-tooltip hidden",helpTooltip=new Overlay({element:helpTooltipElement$1,offset:[15,0],positioning:"center-left"}),getInstall().addOverlay(helpTooltip)},close$1=()=>{measureHistory.value.forEach((t,e)=>{var i,g;const n=document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");n[e]&&((g=(i=n[e])==null?void 0:i.parentNode)==null||g.removeChild(n[e]));const r=vectorSource$2.getFeatures();r[e]&&vectorSource$2.removeFeature(r[e])}),removeInteraction(),enableDoubleClickZoom(),state.value=!1},deleteLine=t=>{var n,r,i,g;const e=measureHistory.value.findIndex(y=>y.id===t);if(e!==-1){measureHistory.value.splice(e,1);const y=document.querySelectorAll(".ol-tooltip.ol-tooltip-static.ol-tooltip-measure");y[e]&&((r=(n=y[e])==null?void 0:n.parentNode)==null||r.removeChild(y[e]));const k=vectorSource$2.getFeatures();k[e]&&vectorSource$2.removeFeature(k[e])}(i=getProps())!=null&&i.lineDrawEnd&&((g=getProps())==null||g.lineDrawEnd(measureHistory.value))},computedDistance=(t,e)=>{const r=getLength(t);let i="";switch(e){case"m":i=`${Math.round(r*100)/100} m`;break;case"km":i=`${Math.round(r/1e3*100)/100} km`;break;case"nm":i=`${Math.round(r/1.852*100)/100} nm`;break}return i},removeInteraction=()=>{measureHistory.value=[],document.querySelectorAll(".ol-tooltip.ol-tooltip-static").forEach(e=>{var n;(n=e==null?void 0:e.parentNode)==null||n.removeChild(e)}),vectorSource$2.clear();const t=getInstall();if(draw$1){const e=t.getInteractions().getArray().find(n=>getUid(n)===getUid(draw$1));e&&t.removeInteraction(e)}t.removeLayer(vectorLayer$2),helpTooltipElement$1!=null&&helpTooltipElement$1.parentNode&&helpTooltipElement$1.parentNode.removeChild(helpTooltipElement$1),measureTooltipElement$1!=null&&measureTooltipElement$1.parentNode&&measureTooltipElement$1.parentNode.removeChild(measureTooltipElement$1)},getState=()=>state.value,drawLine={open:open$1,close:close$1,deleteLine,setUnit,getState},mapInstance=vue.ref(),getInstall=()=>mapInstance.value,getView=()=>getInstall().getView(),getZoom=()=>{var t;return(t=getView())==null?void 0:t.getZoom()},setZoom=t=>{var e;(e=getView())==null||e.setZoom(t)},setCenter=(t,e)=>{var n;(n=getView())==null||n.setCenter(fromLonLat([t,e]))},getCenter=()=>{var e;const t=(e=getView())==null?void 0:e.getCenter();return toLonLat(t)},getSize=()=>{var t;return(t=getInstall())==null?void 0:t.getSize()},BASE_LAYER_MAP=new Map$2,initMap=t=>{setBaseLayerMap(t);const e={zoom:t.zoom,center:fromLonLat(t.center),minZoom:MAP_ZOOM.min,maxZoom:MAP_ZOOM.max,constrainResolution:!0,enableRotation:!1,multiWorld:!0},n=new Map$2({target:"map",controls:defaults$2({zoom:!1}),layers:[BASE_LAYER_MAP.get("vectorTile"),BASE_LAYER_MAP.get("vectorTileMark"),BASE_LAYER_MAP.get("satelliteImgTile"),BASE_LAYER_MAP.get("satelliteImgTileMark")],view:new View(e)});mapInstance.value=n,setBaseMapEvent(n,t)},setBaseLayerMap=t=>{BASE_LAYER_MAP.set("vectorTile",new TileLayer({source:new XYZ({url:BASE_MAP_LINK.vectorTile}),visible:t.layerType==="vector",zIndex:0,preload:1,className:"vector"})),BASE_LAYER_MAP.set("vectorTileMark",new TileLayer({source:new XYZ({url:BASE_MAP_LINK.vectorTileMark}),visible:t.layerType==="vector",zIndex:1,preload:1,className:"vector"})),BASE_LAYER_MAP.set("satelliteImgTile",new TileLayer({source:new XYZ({url:BASE_MAP_LINK.satelliteImgTile}),visible:t.layerType==="satellite",zIndex:0,preload:1,className:"satellite"})),BASE_LAYER_MAP.set("satelliteImgTileMark",new TileLayer({source:new XYZ({url:BASE_MAP_LINK.satelliteImgTileMark}),visible:t.layerType==="satellite",zIndex:1,preload:1,className:"satellite"})),BASE_LAYER_MAP.set("greenMark",new TileLayer({source:new XYZ({url:BASE_MAP_LINK.greenTile}),visible:t.showGreenLayer,zIndex:2,className:"greenTile"}))},setBaseMapEvent=(t,e)=>{t.on("moveend",()=>{var r;const n=getZoom();(r=e.mapMoveEnd)==null||r.call(e,n),reRenderTrackLine()}),t.on("pointermove",n=>{const r=t.getEventPixel(n.originalEvent),i=t.forEachFeatureAtPixel(r,g=>g);handleShipMapEvent(i,"hover"),handleTrackMapEvent(i,"hover",n),i&&handlePortHover(r)}),t.on("movestart",()=>{console.log("movestart-----------------------"),removeSelectedOverlay()}),t.on("click",debounce(n=>{if(console.log("1",drawLine.getState()),drawLine.getState())return;const r=t.getEventPixel(n.originalEvent),i=t.forEachFeatureAtPixel(r,g=>{if(g!=null&&g.get("shipData")||g!=null&&g.get("portData"))return g});if(console.log("2",i),!!i){if(n.preventDefault(),n.stopPropagation(),i.get("shipData"))handleShipMapEvent(i,"click",e==null?void 0:e.selectShip);else if(i.get("portData")){const g=i.get("portData");selectedPort(g),e==null||e.selectPort(g)}}},150))},_hoisted_1$8={id:"scale-line-container"},_sfc_main$9=vue.defineComponent({__name:"scaleLine",setup(t,{expose:e}){return e({setScaleLine:r=>{r||(r="metric");const i=new ScaleLine$1({units:r}),g=document.getElementById("scale-line-container");g&&(i.setTarget(g),getInstall().addControl(i))}}),(r,i)=>(vue.openBlock(),vue.createElementBlock("div",_hoisted_1$8))}}),ScaleLine=_export_sfc(_sfc_main$9,[["__scopeId","data-v-31ff8293"]]),_hoisted_1$7={class:"zoom"},_sfc_main$8=vue.defineComponent({__name:"zoomControl",setup(t){const e=()=>{if(!getInstall())return;const i=getZoom();i&&setZoom(i+1)},n=()=>{if(!getInstall())return;const i=getZoom();i&&setZoom(i-1)};return(r,i)=>(vue.openBlock(),vue.createElementBlock("div",_hoisted_1$7,[vue.createElementVNode("div",{class:"button big-button",onClick:e}," + "),vue.createElementVNode("div",{class:"button small-button",onClick:n}," - ")]))}}),ZoomControl=_export_sfc(_sfc_main$8,[["__scopeId","data-v-2b7e25f2"]]),getLayers=()=>{var t;return(t=getInstall())==null?void 0:t.getLayers()},layerType=vue.ref("vector"),getShowLayerType=()=>layerType.value,setShowLayerType=t=>{if(t===layerType.value)return;getLayers().forEach(n=>{n.className_==="vector"?n.setVisible(t==="vector"):n.className_==="satellite"&&n.setVisible(t==="satellite")})},showGreenTile=vue.ref(),getGreenTileVisible=()=>showGreenTile.value,setGreenTileVisible=t=>{if(t!==showGreenTile.value){if(t){const e=getLayers();if(!e.getArray().find(r=>r.className_==="greenTile")){const r=new TileLayer({source:new XYZ({url:BASE_MAP_LINK.greenTile}),visible:t,zIndex:2,className:"greenTile"});e.push(r)}}else{const e=getLayers(),n=e.getArray().find(r=>r.className_==="greenTile");n&&e.remove(n)}showGreenTile.value=t}};let storeFeature;const open=()=>{init()},init=()=>{initLayer(),createMeasureTooltip(),createHelpTooltip(),initDraw()};let vectorLayer$1=null,vectorSource$1=null;const initLayer=()=>{if(vectorLayer$1||vectorSource$1)return;const t=new VectorSource,e=new VectorLayer({source:t,style:new Style({stroke:new Stroke({color:"#fbcc33",width:2})})});vectorLayer$1=e,vectorSource$1=t;const n=getInstall();n.on("pointermove",pointerMoveHandler),n.addLayer(e),n.on(["dblclick"],function(r){draw&&(r.stopPropagation(),r.preventDefault())})};let sketch;const pointerMoveHandler=t=>{if(t.dragging)return;const e=sketch?"单击继续,双击结束":"点击选择起点";helpTooltipElement&&(helpTooltipElement.innerHTML=e,tipOverlay.setPosition(t.coordinate))};let draw,lineLimitError=!1;const initDraw=()=>{if(storeFeature){helpTooltipElement!=null&&helpTooltipElement.parentNode&&helpTooltipElement.parentNode.removeChild(helpTooltipElement);const e=storeFeature.getGeometry();if(!e)return;const n=computedArea(e,"nm");measureTooltipElement&&(measureTooltipElement.innerHTML=`
|
|
216
216
|
<span class="text">面积:${n}${lineLimitError?'<span class="error pl-12">超出可以绘画的距离</span>':""}</span>
|
|
217
217
|
`),measureTooltipElement&&(measureTooltipElement.innerHTML+='<span class="delete-icon" ><i class="map-iconfont icon-delete" /></div>');const r=e.getCoordinates(),i=r[0][r[0].length-2];if(measureTooltip.setPosition(i),vectorLayer$1){const y=vectorLayer$1.getSource();y&&storeFeature&&(y.clear(),y.addFeature(storeFeature))}setTimeout(()=>{var y;(y=document.querySelector(".delete-icon"))==null||y.addEventListener("click",()=>{var k;console.log("delete"),reset(),(k=getProps())==null||k.areaDrawEnd([])})},0);const g=getCenter$1(storeFeature.getGeometry().getExtent());getInstall().getView().setCenter(g);return}draw=new Draw({type:"Polygon",source:vectorSource$1,trace:!0,style:[new Style({stroke:new Stroke({color:"rgba(255, 255, 255, 1)",width:1.5,lineDash:[10,10]}),fill:new Fill({color:"rgba(255, 255, 255, 0.25)"})}),new Style({image:new CircleStyle({radius:5,fill:new Fill({color:"rgb(51,112,255, 1)"})}),geometry:function(e){const n=e.getGeometry().getCoordinates();return new MultiPoint(n)}})]}),getInstall().addInteraction(draw);let t;draw.on("drawstart",e=>{var n;sketch=e.feature,t=(n=sketch.getGeometry())==null?void 0:n.on("change",r=>{const i=r.target,g=computedArea(i,"nm"),k=i.getCoordinates()[0],L=new LineString([k[k.length-2],k[k.length-1]]),$=computedDistance(L,"nm");if(lineLimitError=Number(getLength(L)/1e3)>150,!g)return;const V='<span class="error pl-4">超出可以绘画的距离</span>';measureTooltipElement&&(measureTooltipElement.innerHTML=`
|
|
218
218
|
<div class="text">
|