@biodiv-platform/naksha-maplibre-layers 5.0.8 → 5.0.9
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/LICENSE +201 -0
- package/dist/index.cjs +2301 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2285 -1
- package/package.json +16 -13
package/dist/index.cjs
CHANGED
|
@@ -1 +1,2301 @@
|
|
|
1
|
-
"use strict";var Er=Object.create;var Me=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var _r=Object.getOwnPropertyNames;var Br=Object.getPrototypeOf,Ar=Object.prototype.hasOwnProperty;var Gr=(e,t)=>{for(var o in t)Me(e,o,{get:t[o],enumerable:!0})},Bt=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _r(t))!Ar.call(e,n)&&n!==o&&Me(e,n,{get:()=>t[n],enumerable:!(r=Rr(t,n))||r.enumerable});return e};var C=(e,t,o)=>(o=e!=null?Er(Br(e)):{},Bt(t||!e||!e.__esModule?Me(o,"default",{value:e,enumerable:!0}):o,e)),Or=e=>Bt(Me({},"__esModule",{value:!0}),e);var en={};Gr(en,{NakshaMaplibreLayers:()=>Qr});module.exports=Or(en);var gr=require("@biodiv-platform/naksha-commons"),hr=C(require("react"),1),br=require("react-map-gl/maplibre"),Lr=require("twind");var At={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var Gt={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var Ot={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var Dt={en:At,fr:Gt,hi:Ot};var fr=require("@biodiv-platform/naksha-commons"),We=require("react"),de=C(require("react-map-gl/maplibre"),1),yr=require("twind");var _e=require("@biodiv-platform/naksha-commons"),b=C(require("react"),1),oo=require("react-map-gl/maplibre");var jt=C(require("colorbrewer"),1),F=C(require("redaxios"),1);var et=C(require("boundingbox"),1),Re=require("geohash");var Ne=require("@biodiv-platform/naksha-commons"),zt={defaultViewState:Ne.defaultViewState,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:Ne.MapStyles.MAP_STREETS,layers:[],selectedLayers:[]},Ht="data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E",Xe={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},$t={...Xe,WebkitLineClamp:2},R="ogc_fid",Ee={ACTIVE:"Active",PENDING:"Pending"},_={TOP:"layer_selection_top",ALL:"layer_selection_all"};var qt=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],Qe="0123456789bcdefghjkmnpqrstuvwxyz",$r=(e,t,o)=>{o=o||16/2**(1-e.length&1)/4**t;let r=e.slice(0,-1),n=~~(Qe.indexOf(e.slice(-1))/o);return[r+Qe[o*n],r+Qe[o*(n+1)-1]]},qr=function(e,t){var o=new Map,r=new Map;let n=[];for(let[a,s]of Object.entries(e)){let[i,u]=$r(a,t);r.set(i,u),o.has(i)||o.set(i,0),o.set(i,o.get(i)+s)}return o.forEach((a,s)=>{let i=Re.GeoHash.decodeGeoHash(s),u=Re.GeoHash.decodeGeoHash(r.get(s)),d=new et.default({minlat:i.latitude[0],minlon:i.longitude[0],maxlat:u.latitude[1],maxlon:u.longitude[1]}).toGeoJSON();n.push({...d,properties:{count:a,[R]:s}})}),n},Fr=e=>{let t=[];for(let[o,r]of Object.entries(e)){let n=Re.GeoHash.decodeGeoHash(o),a=new et.default({minlat:n.latitude[0],minlon:n.longitude[0],maxlat:n.latitude[1],maxlon:n.longitude[1]}).toGeoJSON();t.push({...a,properties:{count:r,[R]:o}})}return t},Ft=(e,t)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:t===-1?Fr(e):qr(e,t)}),Vt=(e,t)=>{let o=Object.values(e).sort((a,s)=>a-s),r=Math.floor(o.length/t),n=new Array(t-1).fill(0).map((a,s)=>o[r*(s+1)]);return n.push(o[o.length-1]),n};var Wt=require("immer");var Zt=async(e,t,o,r)=>{let n=[];for(let a of e){let s=r.includes(a.name),i={...a,id:a.name,thumbnail:t+a.thumbnail,source:{type:a.layerType.toLowerCase()==="raster"?"raster":"vector",scheme:"tms",tiles:[`${o.endpoint}/gwc/service/tms/1.0.0/${o.workspace}:${a.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:s};if(s){let u=await tt(i,0,t,o);n.push({...i,data:u})}else n.push(i)}return n},tt=async(e,t,o,r)=>(0,Wt.produce)(e.data,async a=>{if(a.styles.length===0){let{success:s,data:i}=await Yt(e.id,o);s&&(a.layerName=i.layerName,a.styles=i.styles,a.summaryColumn=i.summaryColumn,a.titleColumn=i.titleColumn,a.propertyMap=Object.fromEntries(i.styles.map(u=>[u.styleName,u.styleTitle])))}a.styles[t]&&!a.styles[t]?.colors&&(a.styles[t].colors=await Ut(e.id,r?.workspace,a.styles[t].styleName,o)),a.styleIndex=t});var Jt=async(e,t,o,r)=>{try{let n=await F.default.get(`${t}/layer/all`,{headers:{Authorization:e}});return await Zt(n.data,t,o,r)}catch(n){return console.error(n),[]}},Yt=async(e,t)=>{try{let{data:o}=await F.default.get(`${t}/layer/onClick/${e}`);return{success:!0,data:o}}catch(o){return console.error(o),{success:!1}}},Kt=async(e,t,o)=>{let r={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(await F.default.get(`${e}/${t}/wms`,{params:{...o,...r}})).data}}catch(n){return console.error(n),{success:!1,data:[]}}},Xt=async(e,t,o,r)=>{try{return await F.default.put(`${t}/layer/${r?"active":"pending"}/${o}`,{},{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},Qt=async(e,t,o)=>{try{return await F.default.delete(`${t}/layer/${o}`,{headers:{Authorization:e}}),!0}catch(r){return console.error(r),!1}},Ut=async(e,t,o,r)=>{try{return(await F.default.get(`${r}/geoserver/workspaces/${t}/styles/${e}_${o}.mbstyle`)).data?.layers?.[0]}catch(n){return console.error(n),{}}},eo=async(e,t,o,r=6,n="YlOrRd")=>{try{let[a,s,i]=qt(o),{_ne:u,_sw:d}=t,h={top:u.lat,left:d.lng,bottom:d.lat,right:u.lng,geoAggegationPrecision:a},L=await e(h),P=Ft(L,s),z=Vt(L,r).map((Y,pe)=>[Y,jt.default[n][r][pe]]);return{success:!0,geojson:P,paint:{"fill-color":{property:"count",default:"yellow",stops:z},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:z,squareSize:i}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},to=async(e,t,o,r)=>{try{await F.default.post(`${e}/layer/download`,{layerName:o,layerTitle:r,attributeList:[],filterArray:[]},{headers:{Authorization:t}})}catch(n){console.error(n)}};var ao=require("react/jsx-runtime"),ro=(0,b.createContext)({}),no=({mp:e,children:t})=>{let[o,r]=(0,b.useState)(e),{mapl:n}=(0,oo.useMap)(),[a,s]=(0,b.useState)(""),i=(0,_e.useDebounce)(a,500),u=o.mapStyles&&o.mapStyles.length>0?o.mapStyles:_e.defaultMapStyles,[d,h]=(0,b.useState)(u[o?.mapStyle||0]?.style),[L,P]=(0,b.useState)(u[o?.mapStyle||0]?.maxZoom),[k,z]=(0,b.useState)(_.TOP),[q,Y]=(0,b.useState)({}),[pe,Ze]=(0,b.useState)(!0),[H,vr]=(0,b.useState)(),[T,Ye]=(0,b.useState)(e.layers||[]),[w,ue]=(0,b.useState)(o.selectedLayers||[]),[Pt,Tt]=(0,b.useState)(),[Ue,Mt]=(0,b.useState)(),xr=(0,b.useMemo)(()=>{let p={};for(let m of Ue||[])p[m.sourceLayer]=[...p[m.sourceLayer]||[],m?.properties?.[R]];return Object.keys(p).length?p:void 0},[Ue]),je=b.default.useMemo(()=>{let p=T.filter(f=>w.includes(f.id)),m=new Array(w.length);for(let f of p){let x=w.findIndex(S=>f.id===S);x>-1&&(m[x]=f)}return m},[T,w]),Te=p=>T.findIndex(m=>m.id===p),Nt=(p,m)=>{Ye(f=>f.map(x=>x.id===p?{...x,...m}:x))},Et=async(p,m,f)=>{let x=T[p],S=await tt(x,m,o.nakshaApiEndpoint,o.geoserver);Nt(x.id,{data:S}),f&&n?.fitBounds(x.bbox,{padding:40,duration:1e3})},Sr=async(p,m)=>{let f=Te(p);Et(f,m,!1)},wr=async p=>{if(!(!w.length||!n))try{let m=w[0],f=n.queryRenderedFeatures(p.point,{layers:[m]});if(f.length){let x=f[0]?.id||f[0]?.properties?.[R];if(x===Pt?.id)return;let S=T[Te(m)],_t=S?.data?.summaryColumn.map($=>[S.data?.propertyMap?.[$]||$,f[0].properties?.[$]]);Tt({id:x,title:S.title,data:_t})}else Tt(void 0)}catch{}},Ir=async({layerId:p,add:m,styleIndex:f=0,focus:x=!0})=>{if(!m){ue(w.filter($=>p!==$));return}let S=Te(p);T[S]?.source.type==="grid"?(ue($=>[p,...$.filter(Ke=>Ke!==p)]),x&&T[S]?.bbox&&setTimeout(()=>{n?.fitBounds(T[S].bbox,{padding:40,duration:1e3})},100)):(await Et(S,f,x),ue($=>[p,...$.filter(Ke=>Ke!==p)]))},kr=async()=>ue([]),Cr=(p,m)=>{r({...o,[p]:m})},Pr=(p,m)=>{let f=m===Ee.PENDING;Xt(o.nakshaEndpointToken,o.nakshaApiEndpoint,p,f),Nt(p,{layerStatus:f?Ee.ACTIVE:Ee.PENDING})},Tr=async(p,m)=>{confirm(m)&&(Qt(o.nakshaEndpointToken,o.nakshaApiEndpoint,p),Ye(T.filter(f=>f.id!==p)))},Mr=p=>{let m=Te(p),f=T[m];n?.fitBounds(f.bbox,{padding:40,duration:1e3})},Rt=()=>[H.lng,H.lat,H.lng+.1,H.lat+.1],Nr=p=>{z(p),p===_.TOP&&Je(p)},Je=p=>{if(H)try{let m=n?.project([H.lng,H.lat]),f=n?.queryRenderedFeatures(m,{layers:k===_.TOP?[w[0]]:w});if((p||k)===_.ALL){let x=je.filter(S=>S.layerType=="RASTER").map(S=>({sourceLayer:S.id,layerType:"raster",bbox:Rt()}));f=[...f,...x]}Mt(je?.[0].layerType==="RASTER"&&k!==_.ALL?w.length&&f?.length?f:[{sourceLayer:w[0],layerType:"raster",bbox:Rt()}]:f)}catch(m){console.error(m)}};return(0,b.useEffect)(()=>{o.onSelectedLayersChange&&o.onSelectedLayersChange(w)},[w]),(0,b.useEffect)(()=>{setTimeout(Je,300)},[H,k,w]),(0,ao.jsx)(ro.Provider,{value:{mp:o,updateMP:Cr,layer:{mapStyle:d,featuresAtLatLng:Je,setMapStyle:h,maxZoom:L,setMaxZoom:P,mapStyles:u,all:T,setAll:Ye,selectedIds:w,handleSelectStyle:Nr,setSelectedIds:ue,selectedLayers:je,clearAll:kr,toggle:Ir,updateStyle:Sr,selectedFeatures:Ue,selectedFeaturesId:xr,setSelectedFeatures:Mt,togglePublish:Pr,delete:Tr,selectionStyle:k,setSelectionStyle:z,zoomToExtent:Mr,gridLegends:q,setGridLegends:Y},query:{term:i,setTerm:s,clickedLngLat:H,setClickedLngLat:vr},isInfoBarOpen:pe,setIsInfoBarOpen:Ze,hover:{onHover:wr,features:Pt}},children:t})};function c(){return(0,b.useContext)(ro)}var xo=C(require("react"),1),fe=require("twind");var so=require("twind"),l=require("react/jsx-runtime"),lo=()=>(0,l.jsx)("svg",{fill:"none",className:so.tw`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),me=()=>(0,l.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,l.jsx)("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),(0,l.jsx)("path",{d:"M2 17L12 22 22 17"}),(0,l.jsx)("path",{d:"M2 12L12 17 22 12"})]}),Be=()=>(0,l.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,l.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,l.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),io=()=>(0,l.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,l.jsx)("path",{d:"M4 21L4 14"}),(0,l.jsx)("path",{d:"M4 10L4 3"}),(0,l.jsx)("path",{d:"M12 21L12 12"}),(0,l.jsx)("path",{d:"M12 8L12 3"}),(0,l.jsx)("path",{d:"M20 21L20 16"}),(0,l.jsx)("path",{d:"M20 12L20 3"}),(0,l.jsx)("path",{d:"M1 14L7 14"}),(0,l.jsx)("path",{d:"M9 8L15 8"}),(0,l.jsx)("path",{d:"M17 16L23 16"})]});function ot(){return(0,l.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,l.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function co(){return(0,l.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,l.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function po(){return(0,l.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,l.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function uo(){return(0,l.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:(0,l.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function mo(){return(0,l.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:(0,l.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function fo(){return(0,l.jsx)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:(0,l.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function yo(){return(0,l.jsx)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,l.jsx)("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function go(){return(0,l.jsxs)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[(0,l.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,l.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,l.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,l.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,l.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function ho(){return(0,l.jsx)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:(0,l.jsx)("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function bo(){return(0,l.jsxs)("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,l.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,l.jsx)("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),(0,l.jsx)("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),(0,l.jsx)("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),(0,l.jsx)("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function Lo(){return(0,l.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,l.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function vo(){return(0,l.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,l.jsx)("polyline",{points:"18 15 12 9 6 15"})})}var U=require("react/jsx-runtime"),V=xo.default.forwardRef((e,t)=>(0,U.jsx)("button",{ref:t,type:"button",className:fe.tw`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`,...e}));var Ae=e=>(0,U.jsx)("button",{className:fe.tw`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715",...e}),So=e=>(0,U.jsx)("button",{className:fe.tw`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:(0,U.jsx)(me,{})}),wo=e=>(0,U.jsx)("button",{className:fe.tw`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:(0,U.jsx)(Be,{})});var j=require("twind");var I=require("react/jsx-runtime");var Q=e=>(0,I.jsxs)("div",{children:[e.label&&(0,I.jsx)("label",{className:j.tw`text-gray-700`,htmlFor:e.name,children:e.label}),(0,I.jsx)("select",{id:e.name,name:e.name,className:j.tw`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"},...e})]}),Io=e=>(0,I.jsxs)("div",{className:"relative",children:[(0,I.jsx)("span",{className:j.tw`absolute inset-y-0 left-0 flex items-center pl-3`,children:(0,I.jsx)(lo,{})}),(0,I.jsx)("input",{type:"search",className:j.tw`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`,...e})]}),ko=e=>e.isLoading?(0,I.jsx)("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:j.tw`inline text-gray-200 animate-spin dark:text-gray-600`,children:(0,I.jsx)("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:(0,I.jsx)("g",{fill:"#212121",fillRule:"nonzero",children:(0,I.jsx)("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):(0,I.jsx)("input",{type:"checkbox",className:j.tw`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});var J=require("@bumaga/tabs"),Co=C(require("clsx"),1),ye=require("twind"),ee=require("react/jsx-runtime"),Ge=({children:e,icon:t})=>{let{onClick:o,isActive:r}=(0,J.useTabState)(),n=(0,Co.default)(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":r,"text-gray-700 border-gray-300 hover:border-gray-400":!r}]);return(0,ee.jsxs)("button",{className:(0,ye.tw)(n),onClick:o,children:[t,(0,ee.jsx)("span",{className:ye.tw`ml-2 text-base`,children:e})]})},Oe=({children:e})=>(0,J.usePanelState)()?(0,ee.jsx)("div",{className:ye.tw`w-full flex flex-grow-1 overflow-auto`,children:e}):null,Po=({children:e})=>(0,ee.jsx)("div",{className:ye.tw`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});var No=require("@biodiv-platform/naksha-commons"),Le=require("twind");var To=require("@biodiv-platform/naksha-commons");var rt=require("react/jsx-runtime");function ge({hideLabel:e}){let{layer:{selectionStyle:t,handleSelectStyle:o}}=c(),{t:r}=(0,To.useT)(),n=a=>{o(a.target.value)};return(0,rt.jsx)(Q,{name:"layer_selection",label:e?null:r("layer_selection"),defaultValue:t,onChange:n,children:Object.values(_).map(a=>(0,rt.jsx)("option",{value:a,children:r(a)},a))})}var Mo=C(require("clsx"),1),be=require("react"),he=require("twind");var B=require("react/jsx-runtime");function nt({data:e}){let[t,o]=(0,be.useState)(!0),[r,n]=(0,be.useState)({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:i}}=c(),u=async()=>{let d,h=a.selectedLayers.find(L=>L.id===(e.sourceLayer||e.source));if(h.layerType.toLowerCase()==="raster"){let{data:L}=await Kt(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${h.id}`,layers:`${s.geoserver?.workspace}:${h.id}`});d=L?.features[0]?Object.entries(L.features[0]?.properties).map(([P,k])=>[k||"-"]):[]}else d=Object.entries(h?.data?.propertyMap||{}).map(([L,P])=>[P,e?.properties?.[L]]);n({title:h.title,properties:d})};return(0,be.useEffect)(()=>{u()},[i]),(0,B.jsxs)("div",{className:he.tw`bg-gray-100 rounded-lg`,children:[(0,B.jsxs)("button",{className:(0,he.tw)((0,Mo.default)(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":t,"rounded-lg":!t}])),onClick:()=>o(!t),children:[r.title," ",t?(0,B.jsx)(vo,{}):(0,B.jsx)(Lo,{})]}),t&&(0,B.jsx)("div",{className:he.tw`px-4 py-3 flex flex-col gap-3`,children:r.properties.map(([d,h],L)=>(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:he.tw`text-gray-600`,children:d}),(0,B.jsx)("div",{children:h})]},d+h+L))})]})}var M=require("react/jsx-runtime");function at({onClose:e}){let{layer:{selectedFeatures:t,selectedLayers:o,selectionStyle:r}}=c(),{t:n}=(0,No.useT)();return(0,M.jsxs)("div",{className:Le.tw`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,children:[(0,M.jsxs)("div",{className:"flex w-full",children:[(0,M.jsxs)("div",{className:Le.tw`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[(0,M.jsx)(bo,{})," ",n("infobar")]}),(0,M.jsx)(Ae,{onClick:e})]}),(0,M.jsx)("div",{className:Le.tw`bg-gray-100 p-4 flex-shrink-0 rt`,children:(0,M.jsx)(ge,{hideLabel:!0})}),(0,M.jsx)("div",{className:Le.tw`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:t.flat(1)?.map(a=>(0,M.jsx)(nt,{data:a},o?.[0]?.source.type==="raster"||r===_.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[R]))})]})}var st=require("react/jsx-runtime");function lt(){let{layer:e,isInfoBarOpen:t,setIsInfoBarOpen:o}=c();if(!e.selectedFeatures?.length)return null;let r=()=>o(!t);return t?(0,st.jsx)(at,{onClose:r}):(0,st.jsx)(wo,{onClick:r})}var qe=require("react"),nr=require("react-map-gl/maplibre");var rr=require("@biodiv-platform/naksha-commons"),ht=require("twind");var Jo=require("twind");var $e=C(require("react"),1),Wo=require("react-virtual"),Zo=require("react-virtualized-auto-sizer"),dt=require("twind");var Fo=require("@biodiv-platform/naksha-commons"),xe=require("react"),Vo=require("react-web-share"),O=require("twind");var W=require("react/jsx-runtime"),Eo=({text:e="",highlight:t=""})=>{if(!t.trim())return(0,W.jsx)(W.Fragment,{children:e});let o=new RegExp(`(${t})`,"gi"),r=e.split(o);return(0,W.jsx)(W.Fragment,{children:r.filter(n=>n).map((n,a)=>o.test(n)?(0,W.jsx)("mark",{children:n},a):(0,W.jsx)("span",{children:n},a))})};var Ao=require("twind");var Ro=require("@biodiv-platform/naksha-commons"),_o=require("react"),Bo=require("twind"),De=require("react/jsx-runtime");function ve({children:e}){let[t,o]=(0,_o.useState)(!1),{t:r}=(0,Ro.useT)();return(0,De.jsxs)("div",{children:[t&&e,(0,De.jsx)("button",{onClick:()=>o(!t),className:Bo.tw`text-blue-600 focus:outline-none focus:outline focus:ring`,children:r(t?"less":"legend")})]})}var A=require("react/jsx-runtime");function it({item:e}){let{layer:t}=c(),o=t.gridLegends[e.id];return o?(0,A.jsx)(ve,{children:(0,A.jsxs)("ul",{style:{margin:0,padding:0},children:[o?.stops.map(([r,n],a,s)=>{let i=(s[a-1]||[0])[0];return i===r?(0,A.jsx)("div",{},n):(0,A.jsxs)("li",{className:Ao.tw`flex gap-2 items-center mb-1`,children:[(0,A.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,A.jsx)("circle",{cx:"12",fill:n,cy:"12",r:"12",stroke:"none"})}),(0,A.jsxs)("div",{children:[i," - ",r]})]},n)}),(0,A.jsxs)("li",{children:["1 Square = ",o?.squareSize," x ",o?.squareSize," km"]})]})}):null}var ze=require("@biodiv-platform/naksha-commons"),Go=require("react"),Oo=require("react-tiny-popover"),oe=require("twind");var g=require("react/jsx-runtime"),te=({icon:e,name:t,title:o,link:r,children:n})=>{let a=(0,g.jsx)("span",{children:n||"-"});return(0,g.jsxs)("div",{className:oe.tw`flex gap-3 text-sm text-gray-600 break-all`,title:t&&o&&`${t}: ${o}`,children:[(0,g.jsx)("div",{children:e}),r?(0,g.jsx)("a",{className:oe.tw`text-blue-700 focus:outline-none focus:ring`,target:"_blank",rel:"noopener",href:r,children:a}):a]})};function Vr({item:e,containerStyle:t}){let{t:o}=(0,ze.useT)(),{layer:r,mp:n}=c(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),i=e.tags?.join(", ");return(0,g.jsxs)("div",{className:oe.tw`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:t,children:[n.managePublishing&&e.layerStatus&&(0,g.jsxs)(te,{icon:(0,g.jsx)(uo,{}),name:o("visiblity"),title:e.layerStatus,children:[e.layerStatus,(0,g.jsx)("button",{className:oe.tw`text-blue-600 focus:outline-none ml-4`,onClick:()=>r.togglePublish(e.id,e?.layerStatus),children:o("toggle")}),(0,g.jsx)("button",{className:oe.tw`text-red-600 focus:outline-none ml-4`,onClick:()=>r.delete(e.id,o("are_you_sure")),children:o("delete")})]}),(0,g.jsx)(te,{icon:(0,g.jsx)(ot,{}),link:e.url,name:o("uploader"),title:e.createdBy,children:e.createdBy}),(0,g.jsx)(te,{icon:(0,g.jsx)(ot,{}),link:e.url,name:o("created_by"),title:e.attribution,children:e.attribution}),(0,g.jsx)(te,{icon:(0,g.jsx)(mo,{}),name:o("created_on"),title:s,children:s}),(0,g.jsx)(te,{icon:(0,g.jsx)(co,{}),name:o("tags"),title:i,children:i}),(0,g.jsx)(te,{name:o("license"),title:a,link:a&&ze.LICENSES[a],icon:(0,g.jsx)(po,{}),children:a})]})}var Do=({item:e})=>{let[t,o]=(0,Go.useState)(!1),r=()=>o(!t);return(0,g.jsx)(Oo.Popover,{isOpen:t,padding:10,positions:["right"],containerStyle:{zIndex:99},onClickOutside:r,content:(0,g.jsx)(Vr,{item:e}),children:(0,g.jsx)(V,{onClick:r,children:(0,g.jsx)(Be,{}),title:"Information"})})};var qo=require("twind");var He=require("react"),zo=require("@biodiv-platform/naksha-commons"),Ho=require("twind");var G=require("react/jsx-runtime");function $o({item:e}){let[t,o]=(0,He.useState)(!0),{mp:r}=c(),{t:n}=(0,zo.useT)(),a=(0,He.useMemo)(()=>e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["fill-color"]?.stops||e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["circle-color"]?.stops||[],[e]),s=()=>a.map(([i,u])=>(0,G.jsxs)("li",{className:Ho.tw`flex gap-2 items-center mb-1`,children:[(0,G.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,G.jsx)("circle",{cx:"12",fill:u,cy:"12",r:"12",stroke:"none"})}),(0,G.jsx)("div",{children:i})]},u));return(0,G.jsx)("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():t?(0,G.jsx)("li",{children:(0,G.jsx)("img",{style:{margin:"5px"},onError:()=>o(!1),src:`${r?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):(0,G.jsx)("div",{children:n("raster_style_not_found")})})}var K=require("react/jsx-runtime");function ct({item:e}){if(!e.data?.styles)return null;let{layer:t}=c(),o=r=>{t.updateStyle(e.id,Number(r.target.value))};return(0,K.jsxs)("div",{className:qo.tw`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&(0,K.jsx)(Q,{onChange:o,children:e.data?.styles.map((r,n)=>(0,K.jsx)("option",{value:n,children:r.styleTitle},n))}),(0,K.jsx)(ve,{children:(0,K.jsx)($o,{item:e})})]})}var y=require("react/jsx-runtime");function Wr({dragHandleProps:e}){return(0,y.jsx)("div",{className:O.tw`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:(0,y.jsx)(ho,{})})}function Se({item:e,extended:t,dragHandleProps:o}){let{t:r}=(0,Fo.useT)(),{layer:n,query:a,mp:s,query:{setClickedLngLat:i},setIsInfoBarOpen:u}=c(),[d,h]=(0,xe.useState)(n.selectedIds.includes(e.id)),[L,P]=(0,xe.useState)(!1),k=(0,xe.useMemo)(()=>s.canLayerShare?{url:`${window.location.href.split("?")[0]}?layers=${e.id}`,title:e.title}:void 0,[e.id]),z=async()=>{P(!0),u(!0),n.setSelectedFeatures([]),i(null),await n.toggle({layerId:e.id,add:!d}),h(!d),P(!1)},q=async()=>{await to(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},Y=()=>n.zoomToExtent(e.id);return(0,y.jsxs)("div",{className:O.tw`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[(0,y.jsxs)("div",{className:O.tw`flex gap-3`,children:[(0,y.jsxs)("div",{className:O.tw`flex-shrink-0`,children:[(0,y.jsx)(ko,{name:e.id,checked:d,onChange:z,isLoading:L}),t&&(0,y.jsx)(Wr,{dragHandleProps:o})]}),(0,y.jsx)("img",{className:O.tw`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||Ht}),(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{title:e.title,className:O.tw`mb-1 leading-tight`,style:Xe,children:(0,y.jsx)(Eo,{text:e.title,highlight:a.term})}),(0,y.jsx)("p",{title:e.description,className:O.tw`text-gray-600 text-sm`,style:$t,children:e.description})]})]}),(0,y.jsxs)("div",{className:O.tw`flex justify-between`,children:[(0,y.jsxs)(V,{onClick:q,disabled:!e.isDownloadable,children:[(0,y.jsx)(fo,{})," ",r("download")]}),(0,y.jsxs)("div",{className:O.tw`flex gap-3`,children:[k&&(0,y.jsx)(Vo.RWebShare,{data:k,children:(0,y.jsx)(V,{title:"Share",children:(0,y.jsx)(go,{})})}),t&&(0,y.jsx)(V,{onClick:Y,title:"Zoom To Extent",children:(0,y.jsx)(yo,{})}),(0,y.jsx)(Do,{item:e})]})]}),t&&(0,y.jsx)(ct,{item:e}),t&&e.source.type==="grid"&&(0,y.jsx)(it,{item:e})]})}var Z=require("react/jsx-runtime");function Yo(){let{layer:e,query:t}=c(),o=(0,$e.useMemo)(()=>t.term?e.all.filter(a=>a.title.toLowerCase().includes(t.term.toLowerCase())):e.all,[e.all,t.term]),r=$e.default.useRef(),n=(0,Wo.useVirtual)({size:o.length,parentRef:r});return(0,Z.jsx)("div",{className:dt.tw`flex-grow-1 relative`,children:(0,Z.jsx)(Zo.AutoSizer,{disableWidth:!0,children:a=>(0,Z.jsx)("div",{ref:r,className:"List",style:{height:a.height,overflow:"auto"},children:(0,Z.jsx)("div",{style:{height:n.totalSize,width:"100%",position:"relative"},children:n.virtualItems.map(s=>(0,Z.jsx)("div",{ref:s.measureRef,className:dt.tw`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:(0,Z.jsx)("div",{style:{height:146},children:(0,Z.jsx)(Se,{item:o[s.index]})})},s.index))})})})})}var Uo=require("@biodiv-platform/naksha-commons"),jo=require("twind");var pt=require("react/jsx-runtime");function ut(){let{t:e}=(0,Uo.useT)(),{query:t}=c(),o=r=>t.setTerm(r.target.value);return(0,pt.jsx)("div",{className:jo.tw`flex-shrink-0 border-b-2 p-4`,children:(0,pt.jsx)(Io,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:o})})}var we=require("react/jsx-runtime");function mt(){return(0,we.jsxs)("div",{className:Jo.tw`flex flex-col w-full`,children:[(0,we.jsx)(ut,{}),(0,we.jsx)(Yo,{})]})}function Zr(e,t,o){let r=t<0?e.length+t:t;if(r>=0&&r<e.length){let n=o<0?e.length+o:o,[a]=e.splice(t,1);e.splice(n,0,a)}}function Ko(e,t,o){return e=[...e],Zr(e,t,o),e}var D=require("@dnd-kit/core"),re=require("@dnd-kit/sortable"),Xo=require("@dnd-kit/utilities");var X=require("react/jsx-runtime");function Yr({item:e,extended:t}){let{attributes:o,listeners:r,setNodeRef:n,transform:a,transition:s,isDragging:i}=(0,re.useSortable)({id:e.id}),u={transform:Xo.CSS.Transform.toString(a),transition:s,opacity:i?.5:1};return(0,X.jsx)("div",{ref:n,style:u,children:(0,X.jsx)(Se,{item:e,extended:t,dragHandleProps:{...o,...r}})})}var Qo=({layerList:e,onSortEnd:t})=>{let o=(0,D.useSensors)((0,D.useSensor)(D.PointerSensor,{activationConstraint:{distance:4}}));return(0,X.jsx)(D.DndContext,{sensors:o,collisionDetection:D.closestCenter,onDragEnd:n=>{let{active:a,over:s}=n;if(s&&a.id!==s.id){let i=e.findIndex(d=>d.id===a.id),u=e.findIndex(d=>d.id===s.id);i!==-1&&u!==-1&&t({oldIndex:i,newIndex:u})}},children:(0,X.jsx)(re.SortableContext,{items:e.map(n=>n.id),strategy:re.verticalListSortingStrategy,children:(0,X.jsx)("div",{children:e.map(n=>(0,X.jsx)(Yr,{item:n,extended:!0},n.id))})})})};var er=require("@biodiv-platform/naksha-commons"),ft=require("twind"),ne=require("react/jsx-runtime");function yt(){let{layer:e}=c(),{t}=(0,er.useT)(),o=({oldIndex:r,newIndex:n})=>{e.setSelectedIds(Ko(e.selectedIds,r,n))};return(0,ne.jsxs)("div",{className:ft.tw`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&(0,ne.jsx)("div",{className:ft.tw`p-3 pb-0`,children:(0,ne.jsxs)(V,{onClick:()=>e.clearAll(),children:["\u2715 ",t("clear")]})}),(0,ne.jsx)(Qo,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:o})]})}var tr=require("@biodiv-platform/naksha-commons"),or=require("twind");var ae=require("react/jsx-runtime");function gt(){let{layer:e}=c(),{t}=(0,tr.useT)(),o=r=>{e.setMapStyle(r.target.value),e.setMaxZoom(e.mapStyles.find(n=>n.style===r.target.value)?.maxZoom)};return(0,ae.jsxs)("div",{className:or.tw`w-full p-4 flex flex-col gap-4`,children:[(0,ae.jsx)(Q,{name:"base_style",label:t("base_style"),defaultValue:e.mapStyle,onChange:o,children:e.mapStyles.map(r=>(0,ae.jsx)("option",{value:r.style,children:r.text},r.key))}),(0,ae.jsx)(ge,{})]})}var v=require("react/jsx-runtime");function bt({onClose:e}){let{t}=(0,rr.useT)();return(0,v.jsxs)("div",{className:ht.tw`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,children:[(0,v.jsx)(Ae,{onClick:e}),(0,v.jsx)("div",{className:ht.tw`flex flex-col h-full`,children:(0,v.jsxs)(J.Tabs,{children:[(0,v.jsxs)(Po,{children:[(0,v.jsx)(Ge,{icon:(0,v.jsx)(me,{}),children:t("layers")}),(0,v.jsx)(Ge,{icon:(0,v.jsx)(me,{}),children:t("selected")}),(0,v.jsx)(Ge,{icon:(0,v.jsx)(io,{}),children:t("settings")})]}),(0,v.jsx)(Oe,{children:(0,v.jsx)(mt,{})}),(0,v.jsx)(Oe,{children:(0,v.jsx)(yt,{})}),(0,v.jsx)(Oe,{children:(0,v.jsx)(gt,{})})]})})]})}var Lt=require("react/jsx-runtime");function vt(){let{mp:e,layer:t}=c(),[o,r]=(0,qe.useState)(e.showToC),{mapl:n}=(0,nr.useMap)(),a=()=>r(!o);async function s(){let i=await Jt(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),u=[...e.layers||[],...i];if(t.setAll(u),t.selectedIds.length){let d=u.find(h=>h.id===t.selectedIds[0]);d?.bbox&&n?.fitBounds(d.bbox,{padding:40,duration:1e3})}}return(0,qe.useEffect)(()=>{n&&e.loadToC&&s()},[n]),o?(0,Lt.jsx)(bt,{onClose:a}):(0,Lt.jsx)(So,{onClick:a})}var lr=require("react-map-gl/maplibre");var ar=C(require("@turf/bbox"),1),se=require("react"),le=require("react-map-gl/maplibre");var xt=require("react/jsx-runtime");function St({data:e,beforeId:t}){let{layer:o}=c(),{mapl:r}=(0,le.useMap)(),[n,a]=(0,se.useState)({geojson:{},paint:{}}),s=o.selectedIds.includes(e.id),i=o.selectedIds[0]===e.id,u=async(d=!1)=>{let{success:h,geojson:L,paint:P,stops:k,squareSize:z}=await eo(e.source.fetcher,r?.getBounds(),r?.getZoom());if(h){if(a({geojson:L,paint:P}),d&&i&&e.zoomToFit)try{let[q,Y,pe,Ze]=(0,ar.default)(L);r?.fitBounds([[q,Y],[pe,Ze]],{padding:40,animate:!0})}catch(q){console.warn("Failed to compute bbox",q)}o.setGridLegends({[e.id]:{stops:k,squareSize:z}})}};return(0,se.useEffect)(()=>{s&&i?u(!0):s&&u(!1)},[s,i]),(0,se.useEffect)(()=>{if(!s||!r)return;let d=()=>u(!1);return r.on("idle",d),()=>{r.off("idle",d)}},[s,r]),(0,se.useEffect)(()=>()=>{o.setGridLegends(d=>{let h={...d};return delete h[e.id],h})},[e.id]),(0,xt.jsx)(le.Source,{id:e.id,type:"geojson",data:n.geojson,children:(0,xt.jsx)(le.Layer,{beforeId:t,id:e.id,type:"fill",paint:n.paint})})}var sr=require("react"),Ie=require("react-map-gl/maplibre");var ke=require("react/jsx-runtime"),Ur={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function Fe({layer:e,beforeId:t}){let{layer:o}=c(),r=(0,sr.useMemo)(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,o.selectedFeatures]),n=o.selectedFeaturesId?.[e.id];return(0,ke.jsxs)(Ie.Source,{...e.source,children:[r&&(0,ke.jsx)(Ie.Layer,{beforeId:t,...r}),n&&r&&(0,ke.jsx)(Ie.Layer,{...r,beforeId:t,id:`hl_${e.id}`,filter:["in",R,...n],type:r.type==="fill"?"line":r.type,paint:Ur[r.type]})]})}var Ve=require("react-map-gl/maplibre");var wt=require("react/jsx-runtime");function It({data:e,beforeId:t}){let{mp:o}=c();return(0,wt.jsx)(Ve.Source,{id:e.id,type:"raster",tiles:[`${o?.geoserver?.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:(0,wt.jsx)(Ve.Layer,{id:e.id,beforeId:t,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}var Ce=require("react/jsx-runtime");function ir({layer:e,beforeId:t}){let{mapl:o}=(0,lr.useMap)();if(!o)return null;switch(e.source.type){case"vector":return(0,Ce.jsx)(Fe,{beforeId:t,layer:e});case"grid":return(0,Ce.jsx)(St,{beforeId:t,data:e});case"raster":return(0,Ce.jsx)(It,{beforeId:t,data:e});default:return(0,Ce.jsx)(Fe,{beforeId:t,layer:e})}}var cr=require("react"),dr=require("react-map-gl/maplibre");var ie=require("react/jsx-runtime"),jr=dr.Marker,Jr=()=>{let{mp:e}=c(),t=(0,cr.useMemo)(()=>e.markers,[e.markers]);return(0,ie.jsx)(ie.Fragment,{children:t?.map(({latitude:o,longitude:r,colorHex:n},a)=>(0,ie.jsx)(jr,{latitude:o,longitude:r,children:(0,ie.jsx)("img",{style:{cursor:"pointer"},alt:"Marker",src:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},a))})},pr=Jr;var ur=C(require("clsx"),1),mr=require("react-map-gl/maplibre"),ce=require("twind");var N=require("react/jsx-runtime"),Kr=mr.Popup;function kt({coordinates:e}){let{hover:t}=c();return e?.lat&&t.features?(0,N.jsx)(Kr,{latitude:e.lat,longitude:e.lng,closeButton:!1,children:(0,N.jsxs)("table",{className:ce.tw`table-auto border`,children:[(0,N.jsx)("thead",{children:(0,N.jsx)("tr",{children:(0,N.jsx)("th",{className:ce.tw`bg-gray-200 py-1 px-2`,colSpan:2,children:t.features.title})})}),(0,N.jsx)("tbody",{children:t.features.data.map(([o,r],n)=>(0,N.jsxs)("tr",{className:(0,ce.tw)((0,ur.default)({"bg-gray-50":n%2===0,"border-gray-100 border-t":1})),children:[(0,N.jsx)("td",{className:ce.tw`py-1 px-2`,children:o}),(0,N.jsx)("td",{className:ce.tw`py-1 px-2 border-l border-gray-100`,children:r})]},o+r))})]})}):null}var E=require("react/jsx-runtime"),Xr=de.NavigationControl;function Ct(){let{mp:e,layer:t,hover:o,query:r}=c(),[n,a]=(0,We.useState)(),s=(0,We.useMemo)(()=>e.defaultViewState||fr.defaultViewState,[e.defaultViewState]),i=d=>r.setClickedLngLat(d.lngLat),u=d=>{a(d.lngLat),o.onHover(d)};return(0,E.jsxs)("div",{className:yr.tw`h-full w-full relative bg-gray-100`,children:[e.loadToC&&(0,E.jsx)(vt,{}),t.selectedFeatures?.length>0&&(0,E.jsx)(lt,{}),(0,E.jsxs)(de.default,{id:"mapl",cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:t.mapStyle,maxZoom:t.maxZoom,onClick:i,onMouseMove:u,children:[(0,E.jsx)(Xr,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&(0,E.jsx)(de.FullscreenControl,{position:"bottom-right"}),(0,E.jsx)(pr,{}),t.selectedLayers.map((d,h)=>{let L=h>0?t.selectedIds[h-1]:void 0;return(0,E.jsx)(ir,{layer:d,beforeId:L},d.id)}),(0,E.jsx)(kt,{coordinates:n},"popup")]})]})}var Pe=require("react/jsx-runtime");(0,Lr.setup)({preflight:!1});var Qr=e=>{let t=hr.default.useMemo(()=>({...zt,...e}),[e]);return(0,Pe.jsx)(br.MapProvider,{children:(0,Pe.jsx)(gr.TranslationProvider,{localeStrings:Dt,lang:t.lang,children:(0,Pe.jsx)(no,{mp:t,children:(0,Pe.jsx)(Ct,{})})})})};0&&(module.exports={NakshaMaplibreLayers});
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
NakshaMaplibreLayers: () => NakshaMaplibreLayers
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
var import_naksha_commons14 = require("@biodiv-platform/naksha-commons");
|
|
37
|
+
var import_react14 = __toESM(require("react"), 1);
|
|
38
|
+
var import_maplibre10 = require("react-map-gl/maplibre");
|
|
39
|
+
var import_twind21 = require("twind");
|
|
40
|
+
|
|
41
|
+
// locales/en.json
|
|
42
|
+
var en_default = {
|
|
43
|
+
are_you_sure: "Are you sure?",
|
|
44
|
+
base_style: "Base Style",
|
|
45
|
+
clear: "Clear Selection",
|
|
46
|
+
created_by: "Attribution",
|
|
47
|
+
created_on: "Created On",
|
|
48
|
+
delete: "Delete",
|
|
49
|
+
download: "Download",
|
|
50
|
+
find_layer_by_name: "Find layer by name",
|
|
51
|
+
infobar: "Attributes at Clicked Location",
|
|
52
|
+
information: "Information",
|
|
53
|
+
layer_selection: "Layer Selection",
|
|
54
|
+
layer_selection_all: "All Layers",
|
|
55
|
+
layer_selection_top: "Top Layer Only",
|
|
56
|
+
layers: "Layers",
|
|
57
|
+
legend: "Legend",
|
|
58
|
+
less: "Less",
|
|
59
|
+
license: "License",
|
|
60
|
+
list_layers: "List Layers",
|
|
61
|
+
pending: "Pending",
|
|
62
|
+
publish: "Publish",
|
|
63
|
+
raster_style_not_found: "Style not available for the given layer",
|
|
64
|
+
remove: "Remove",
|
|
65
|
+
selected: "Selected",
|
|
66
|
+
settings: "Settings",
|
|
67
|
+
square: "Square",
|
|
68
|
+
tags: "Tags",
|
|
69
|
+
toggle: "Toggle Publishing",
|
|
70
|
+
uploaded: "Uploaded",
|
|
71
|
+
uploader: "Uploader",
|
|
72
|
+
url: "URL",
|
|
73
|
+
visiblity: "Visiblity"
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// locales/fr.json
|
|
77
|
+
var fr_default = {
|
|
78
|
+
are_you_sure: "\xCAtes-vous s\xFBr?",
|
|
79
|
+
base_style: "Style de base",
|
|
80
|
+
clear: "Effacer la s\xE9lection",
|
|
81
|
+
created_by: "Attribution",
|
|
82
|
+
created_on: "Cr\xE9\xE9 sur",
|
|
83
|
+
delete: "Effacer",
|
|
84
|
+
download: "T\xE9l\xE9charger",
|
|
85
|
+
find_layer_by_name: "Trouver la couche par nom",
|
|
86
|
+
infobar: "Attributs \xE0 l'emplacement cliqu\xE9",
|
|
87
|
+
information: "Informations",
|
|
88
|
+
layer_selection_all: "Toutes les couches",
|
|
89
|
+
layer_selection_top: "Couche sup\xE9rieure uniquement",
|
|
90
|
+
layer_selection: "S\xE9lection de calque",
|
|
91
|
+
layers: "Couches",
|
|
92
|
+
legend: "L\xE9gende",
|
|
93
|
+
less: "Moins",
|
|
94
|
+
license: "Licence",
|
|
95
|
+
list_layers: "Liste des couches",
|
|
96
|
+
pending: "En attente",
|
|
97
|
+
publish: "Publier",
|
|
98
|
+
remove: "Supprimer",
|
|
99
|
+
selected: "Choisie",
|
|
100
|
+
settings: "Param\xE8tres",
|
|
101
|
+
square: "Carr\xE9",
|
|
102
|
+
toggle: "Basculer la publication",
|
|
103
|
+
uploaded: "T\xE9l\xE9charg\xE9",
|
|
104
|
+
url: "url"
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// locales/hi.json
|
|
108
|
+
var hi_default = {
|
|
109
|
+
are_you_sure: "\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",
|
|
110
|
+
base_style: "\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",
|
|
111
|
+
clear: "\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",
|
|
112
|
+
created_by: "\u0906\u0930\u094B\u092A\u0923",
|
|
113
|
+
created_on: "\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",
|
|
114
|
+
delete: "\u0939\u091F\u093E\u090F\u0902",
|
|
115
|
+
download: "\u0921\u093E\u0909\u0928\u0932\u094B\u0921",
|
|
116
|
+
find_layer_by_name: "\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",
|
|
117
|
+
infobar: "\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",
|
|
118
|
+
information: "\u091C\u093E\u0928\u0915\u093E\u0930\u0940",
|
|
119
|
+
layer_selection_all: "\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",
|
|
120
|
+
layer_selection_top: "\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",
|
|
121
|
+
layer_selection: "\u092A\u0930\u0924 \u091A\u092F\u0928",
|
|
122
|
+
layers: "\u092A\u0930\u0924\u0947\u0902",
|
|
123
|
+
legend: "\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",
|
|
124
|
+
less: "\u0915\u092E",
|
|
125
|
+
license: "\u0932\u093E\u0907\u0938\u0947\u0902\u0938",
|
|
126
|
+
list_layers: "\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",
|
|
127
|
+
pending: "\u0932\u0902\u092C\u093F\u0924",
|
|
128
|
+
publish: "\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",
|
|
129
|
+
remove: "\u0939\u091F\u093E\u0928\u093E",
|
|
130
|
+
selected: "\u091A\u092F\u0928\u093F\u0924",
|
|
131
|
+
settings: "\u0938\u092E\u093E\u092F\u094B\u091C\u0928",
|
|
132
|
+
square: "\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",
|
|
133
|
+
tags: "\u091F\u0948\u0917",
|
|
134
|
+
toggle: "\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",
|
|
135
|
+
uploaded: "\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",
|
|
136
|
+
url: "\u092F\u0942\u0906\u0930\u090F\u0932"
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// locales/index.ts
|
|
140
|
+
var locales_default = { en: en_default, fr: fr_default, hi: hi_default };
|
|
141
|
+
|
|
142
|
+
// src/components/map/index.tsx
|
|
143
|
+
var import_naksha_commons13 = require("@biodiv-platform/naksha-commons");
|
|
144
|
+
var import_react13 = require("react");
|
|
145
|
+
var import_maplibre9 = __toESM(require("react-map-gl/maplibre"), 1);
|
|
146
|
+
var import_twind20 = require("twind");
|
|
147
|
+
|
|
148
|
+
// src/hooks/use-layers.tsx
|
|
149
|
+
var import_naksha_commons2 = require("@biodiv-platform/naksha-commons");
|
|
150
|
+
var import_react = __toESM(require("react"), 1);
|
|
151
|
+
var import_maplibre = require("react-map-gl/maplibre");
|
|
152
|
+
|
|
153
|
+
// src/services/naksha.ts
|
|
154
|
+
var import_colorbrewer = __toESM(require("colorbrewer"), 1);
|
|
155
|
+
var import_redaxios = __toESM(require("redaxios"), 1);
|
|
156
|
+
|
|
157
|
+
// src/utils/grid.ts
|
|
158
|
+
var import_boundingbox = __toESM(require("boundingbox"), 1);
|
|
159
|
+
var import_geohash = require("geohash");
|
|
160
|
+
|
|
161
|
+
// src/static/constants.tsx
|
|
162
|
+
var import_naksha_commons = require("@biodiv-platform/naksha-commons");
|
|
163
|
+
var defaultNakshaProps = {
|
|
164
|
+
defaultViewState: import_naksha_commons.defaultViewState,
|
|
165
|
+
nakshaApiEndpoint: "/naksha-api/api",
|
|
166
|
+
geoserver: { endpoint: "/geoserver", workspace: "biodiv", store: "ibp" },
|
|
167
|
+
mapStyle: import_naksha_commons.MapStyles.MAP_STREETS,
|
|
168
|
+
layers: [],
|
|
169
|
+
selectedLayers: []
|
|
170
|
+
};
|
|
171
|
+
var FALLBACK_THUMB = "data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E";
|
|
172
|
+
var overflowStyle = {
|
|
173
|
+
display: "-webkit-box",
|
|
174
|
+
WebkitLineClamp: 1,
|
|
175
|
+
WebkitBoxOrient: "vertical",
|
|
176
|
+
overflow: "hidden",
|
|
177
|
+
wordBreak: "break-word"
|
|
178
|
+
};
|
|
179
|
+
var overflowStyle2 = {
|
|
180
|
+
...overflowStyle,
|
|
181
|
+
WebkitLineClamp: 2
|
|
182
|
+
};
|
|
183
|
+
var PROPERTY_ID = "ogc_fid";
|
|
184
|
+
var LAYER_STATUS = {
|
|
185
|
+
ACTIVE: "Active",
|
|
186
|
+
PENDING: "Pending"
|
|
187
|
+
};
|
|
188
|
+
var SELECTION_STYLE = {
|
|
189
|
+
TOP: "layer_selection_top",
|
|
190
|
+
ALL: "layer_selection_all"
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/utils/grid.ts
|
|
194
|
+
var getZoomConfig = (zoom) => {
|
|
195
|
+
if (zoom < 6) return [4, 1, 39.2];
|
|
196
|
+
else if (zoom < 7) return [5, 0, 19.6];
|
|
197
|
+
else if (zoom < 8) return [5, 1, 9.8];
|
|
198
|
+
else if (zoom < 9) return [5, -1, 4.9];
|
|
199
|
+
else if (zoom < 10) return [6, 0, 2.45];
|
|
200
|
+
else if (zoom < 11) return [6, 1, 1.225];
|
|
201
|
+
else if (zoom < 12) return [7, 0, 0.612];
|
|
202
|
+
else if (zoom < 13) return [7, 1, 0.306];
|
|
203
|
+
else if (zoom < 14) return [7, -1, 0.153];
|
|
204
|
+
else if (zoom < 15) return [8, 0, 0.077];
|
|
205
|
+
return [8, 1, 0.039];
|
|
206
|
+
};
|
|
207
|
+
var BASE32 = "0123456789bcdefghjkmnpqrstuvwxyz";
|
|
208
|
+
var aggregateGeohashKey = (key, level, binSize) => {
|
|
209
|
+
binSize = binSize || 16 / 2 ** (1 - key.length & 1) / 4 ** level;
|
|
210
|
+
const keyExceptLast = key.slice(0, -1);
|
|
211
|
+
const binnedCharAt = ~~(BASE32.indexOf(key.slice(-1)) / binSize);
|
|
212
|
+
return [
|
|
213
|
+
keyExceptLast + BASE32[binSize * binnedCharAt],
|
|
214
|
+
keyExceptLast + BASE32[binSize * (binnedCharAt + 1) - 1]
|
|
215
|
+
];
|
|
216
|
+
};
|
|
217
|
+
var processRectangles = function(data, level) {
|
|
218
|
+
var counts = /* @__PURE__ */ new Map();
|
|
219
|
+
var bins = /* @__PURE__ */ new Map();
|
|
220
|
+
const features = [];
|
|
221
|
+
for (const [hash, count] of Object.entries(data)) {
|
|
222
|
+
const [kStart, kEnd] = aggregateGeohashKey(hash, level);
|
|
223
|
+
bins.set(kStart, kEnd);
|
|
224
|
+
if (!counts.has(kStart)) {
|
|
225
|
+
counts.set(kStart, 0);
|
|
226
|
+
}
|
|
227
|
+
counts.set(kStart, counts.get(kStart) + count);
|
|
228
|
+
}
|
|
229
|
+
counts.forEach((count, hash) => {
|
|
230
|
+
const bboxStart = import_geohash.GeoHash.decodeGeoHash(hash);
|
|
231
|
+
const bboxEnd = import_geohash.GeoHash.decodeGeoHash(bins.get(hash));
|
|
232
|
+
const feature = new import_boundingbox.default({
|
|
233
|
+
minlat: bboxStart.latitude[0],
|
|
234
|
+
minlon: bboxStart.longitude[0],
|
|
235
|
+
maxlat: bboxEnd.latitude[1],
|
|
236
|
+
maxlon: bboxEnd.longitude[1]
|
|
237
|
+
}).toGeoJSON();
|
|
238
|
+
features.push({ ...feature, properties: { count, [PROPERTY_ID]: hash } });
|
|
239
|
+
});
|
|
240
|
+
return features;
|
|
241
|
+
};
|
|
242
|
+
var processSquares = (data) => {
|
|
243
|
+
const features = [];
|
|
244
|
+
for (const [hash, count] of Object.entries(data)) {
|
|
245
|
+
const bbox2 = import_geohash.GeoHash.decodeGeoHash(hash);
|
|
246
|
+
const feature = new import_boundingbox.default({
|
|
247
|
+
minlat: bbox2.latitude[0],
|
|
248
|
+
minlon: bbox2.longitude[0],
|
|
249
|
+
maxlat: bbox2.latitude[1],
|
|
250
|
+
maxlon: bbox2.longitude[1]
|
|
251
|
+
}).toGeoJSON();
|
|
252
|
+
features.push({ ...feature, properties: { count, [PROPERTY_ID]: hash } });
|
|
253
|
+
}
|
|
254
|
+
return features;
|
|
255
|
+
};
|
|
256
|
+
var geohashToJSON = (data, level) => ({
|
|
257
|
+
type: "FeatureCollection",
|
|
258
|
+
features: Object.keys(data).length === 0 ? [] : level === -1 ? processSquares(data) : processRectangles(data, level)
|
|
259
|
+
});
|
|
260
|
+
var getDataBins = (data, binCount) => {
|
|
261
|
+
const sortedData = Object.values(data).sort((a, b) => a - b);
|
|
262
|
+
const cutoff = Math.floor(sortedData.length / binCount);
|
|
263
|
+
const tBins = new Array(binCount - 1).fill(0).map((_, index) => sortedData[cutoff * (index + 1)]);
|
|
264
|
+
tBins.push(sortedData[sortedData.length - 1]);
|
|
265
|
+
return tBins;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// src/utils/naksha.ts
|
|
269
|
+
var import_immer = require("immer");
|
|
270
|
+
var parseGeoserverLayersXml = async (layers, nakshaApiEndpoint, geoserver, selectedLayers) => {
|
|
271
|
+
const parsedLayers = [];
|
|
272
|
+
for (const l of layers) {
|
|
273
|
+
const isAdded = selectedLayers.includes(l.name);
|
|
274
|
+
const _l = {
|
|
275
|
+
...l,
|
|
276
|
+
id: l.name,
|
|
277
|
+
thumbnail: nakshaApiEndpoint + l.thumbnail,
|
|
278
|
+
source: {
|
|
279
|
+
type: l.layerType.toLowerCase() === "raster" ? "raster" : "vector",
|
|
280
|
+
scheme: "tms",
|
|
281
|
+
tiles: [
|
|
282
|
+
`${geoserver.endpoint}/gwc/service/tms/1.0.0/${geoserver.workspace}:${l.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
data: { styles: [] },
|
|
286
|
+
isAdded
|
|
287
|
+
};
|
|
288
|
+
if (isAdded) {
|
|
289
|
+
const _ld = await getLayerStyle(_l, 0, nakshaApiEndpoint, geoserver);
|
|
290
|
+
parsedLayers.push({ ..._l, data: _ld });
|
|
291
|
+
} else {
|
|
292
|
+
parsedLayers.push(_l);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return parsedLayers;
|
|
296
|
+
};
|
|
297
|
+
var getLayerStyle = async (layer, styleIndex, nakshaApiEndpoint, geoserver) => {
|
|
298
|
+
const nextSl = (0, import_immer.produce)(layer.data, async (_draft) => {
|
|
299
|
+
if (_draft.styles.length === 0) {
|
|
300
|
+
const { success, data } = await axGetGeoserverLayerStyleList(
|
|
301
|
+
layer.id,
|
|
302
|
+
nakshaApiEndpoint
|
|
303
|
+
);
|
|
304
|
+
if (success) {
|
|
305
|
+
_draft.layerName = data.layerName;
|
|
306
|
+
_draft.styles = data.styles;
|
|
307
|
+
_draft.summaryColumn = data.summaryColumn;
|
|
308
|
+
_draft.titleColumn = data.titleColumn;
|
|
309
|
+
_draft.propertyMap = Object.fromEntries(
|
|
310
|
+
data.styles.map((o) => [o.styleName, o.styleTitle])
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (_draft.styles[styleIndex] && !_draft.styles[styleIndex]?.colors) {
|
|
315
|
+
_draft.styles[styleIndex].colors = await axGetGeoserverLayerStyle(
|
|
316
|
+
layer.id,
|
|
317
|
+
geoserver?.workspace,
|
|
318
|
+
_draft.styles[styleIndex].styleName,
|
|
319
|
+
nakshaApiEndpoint
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
_draft.styleIndex = styleIndex;
|
|
323
|
+
});
|
|
324
|
+
return nextSl;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// src/services/naksha.ts
|
|
328
|
+
var axGetGeoserverLayers = async (nakshaEndpointToken, nakshaApiEndpoint, geoserver, selectedLayers) => {
|
|
329
|
+
try {
|
|
330
|
+
const res = await import_redaxios.default.get(`${nakshaApiEndpoint}/layer/all`, {
|
|
331
|
+
headers: { Authorization: nakshaEndpointToken }
|
|
332
|
+
});
|
|
333
|
+
const finalLayers = await parseGeoserverLayersXml(
|
|
334
|
+
res.data,
|
|
335
|
+
nakshaApiEndpoint,
|
|
336
|
+
geoserver,
|
|
337
|
+
selectedLayers
|
|
338
|
+
);
|
|
339
|
+
return finalLayers;
|
|
340
|
+
} catch (e) {
|
|
341
|
+
console.error(e);
|
|
342
|
+
return [];
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
var axGetGeoserverLayerStyleList = async (id, endpoint) => {
|
|
346
|
+
try {
|
|
347
|
+
const { data } = await import_redaxios.default.get(`${endpoint}/layer/onClick/${id}`);
|
|
348
|
+
return { success: true, data };
|
|
349
|
+
} catch (e) {
|
|
350
|
+
console.error(e);
|
|
351
|
+
return { success: false };
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var axGexGetRasterInfoWithLonLat = async (endpoint, workspace, params) => {
|
|
355
|
+
const RasterInfoParams = {
|
|
356
|
+
service: "WMS",
|
|
357
|
+
version: "1.1.1",
|
|
358
|
+
request: "GetFeatureInfo",
|
|
359
|
+
info_format: "application/json",
|
|
360
|
+
width: 100,
|
|
361
|
+
height: 100,
|
|
362
|
+
x: 50,
|
|
363
|
+
y: 50,
|
|
364
|
+
srs: "EPSG:4326"
|
|
365
|
+
};
|
|
366
|
+
try {
|
|
367
|
+
const res = await import_redaxios.default.get(`${endpoint}/${workspace}/wms`, {
|
|
368
|
+
params: { ...params, ...RasterInfoParams }
|
|
369
|
+
});
|
|
370
|
+
return { success: true, data: res.data };
|
|
371
|
+
} catch (e) {
|
|
372
|
+
console.error(e);
|
|
373
|
+
return { success: false, data: [] };
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
var axToggleLayerPublishing = async (nakshaEndpointToken, nakshaApiEndpoint, layerId, isActive) => {
|
|
377
|
+
try {
|
|
378
|
+
await import_redaxios.default.put(
|
|
379
|
+
`${nakshaApiEndpoint}/layer/${isActive ? "active" : "pending"}/${layerId}`,
|
|
380
|
+
{},
|
|
381
|
+
{ headers: { Authorization: nakshaEndpointToken } }
|
|
382
|
+
);
|
|
383
|
+
return true;
|
|
384
|
+
} catch (e) {
|
|
385
|
+
console.error(e);
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
var axDeleteLayer = async (nakshaEndpointToken, nakshaApiEndpoint, layerId) => {
|
|
390
|
+
try {
|
|
391
|
+
await import_redaxios.default.delete(`${nakshaApiEndpoint}/layer/${layerId}`, {
|
|
392
|
+
headers: { Authorization: nakshaEndpointToken }
|
|
393
|
+
});
|
|
394
|
+
return true;
|
|
395
|
+
} catch (e) {
|
|
396
|
+
console.error(e);
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
var axGetGeoserverLayerStyle = async (layername, workspace, styleName, endpoint) => {
|
|
401
|
+
try {
|
|
402
|
+
const res = await import_redaxios.default.get(
|
|
403
|
+
`${endpoint}/geoserver/workspaces/${workspace}/styles/${layername}_${styleName}.mbstyle`
|
|
404
|
+
);
|
|
405
|
+
return res.data?.layers?.[0];
|
|
406
|
+
} catch (e) {
|
|
407
|
+
console.error(e);
|
|
408
|
+
return {};
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
var getGridLayerData = async (fetcher, bounds, zoom, binCount = 6, colorScheme = "YlOrRd") => {
|
|
412
|
+
try {
|
|
413
|
+
const [geoAggegationPrecision, level, squareSize] = getZoomConfig(zoom);
|
|
414
|
+
const { _ne, _sw } = bounds;
|
|
415
|
+
const params = {
|
|
416
|
+
top: _ne.lat,
|
|
417
|
+
left: _sw.lng,
|
|
418
|
+
bottom: _sw.lat,
|
|
419
|
+
right: _ne.lng,
|
|
420
|
+
geoAggegationPrecision
|
|
421
|
+
};
|
|
422
|
+
const data = await fetcher(params);
|
|
423
|
+
const geojson = geohashToJSON(data, level);
|
|
424
|
+
const bins = getDataBins(data, binCount);
|
|
425
|
+
const stops = bins.map((bin, index) => [
|
|
426
|
+
bin,
|
|
427
|
+
import_colorbrewer.default[colorScheme][binCount][index]
|
|
428
|
+
]);
|
|
429
|
+
const paint2 = {
|
|
430
|
+
"fill-color": {
|
|
431
|
+
property: "count",
|
|
432
|
+
default: "yellow",
|
|
433
|
+
stops
|
|
434
|
+
},
|
|
435
|
+
"fill-outline-color": "rgba(0,0,0,0.2)",
|
|
436
|
+
"fill-opacity": 0.7
|
|
437
|
+
};
|
|
438
|
+
return { success: true, geojson, paint: paint2, stops, squareSize };
|
|
439
|
+
} catch (e) {
|
|
440
|
+
console.error(e);
|
|
441
|
+
return { success: false, geojson: {}, paint: {}, stops: [], squareSize: 0 };
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
var axDownloadLayer = async (endpoint, token, layerName, layerTitle) => {
|
|
445
|
+
try {
|
|
446
|
+
await import_redaxios.default.post(
|
|
447
|
+
`${endpoint}/layer/download`,
|
|
448
|
+
{ layerName, layerTitle, attributeList: [], filterArray: [] },
|
|
449
|
+
{ headers: { Authorization: token } }
|
|
450
|
+
);
|
|
451
|
+
} catch (e) {
|
|
452
|
+
console.error(e);
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
// src/hooks/use-layers.tsx
|
|
457
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
458
|
+
var LayersContext = (0, import_react.createContext)(
|
|
459
|
+
{}
|
|
460
|
+
);
|
|
461
|
+
var LayersProvider = ({ mp: _mp, children }) => {
|
|
462
|
+
const [mp, setMP] = (0, import_react.useState)(_mp);
|
|
463
|
+
const { mapl } = (0, import_maplibre.useMap)();
|
|
464
|
+
const [queryTerm, setQueryTerm] = (0, import_react.useState)("");
|
|
465
|
+
const queryTermDebounced = (0, import_naksha_commons2.useDebounce)(queryTerm, 500);
|
|
466
|
+
const styles = mp.mapStyles && mp.mapStyles.length > 0 ? mp.mapStyles : import_naksha_commons2.defaultMapStyles;
|
|
467
|
+
const [mapStyle, setMapStyle] = (0, import_react.useState)(
|
|
468
|
+
styles[mp?.mapStyle || 0]?.style
|
|
469
|
+
);
|
|
470
|
+
const [maxZoom, setMaxZoom] = (0, import_react.useState)(
|
|
471
|
+
styles[mp?.mapStyle || 0]?.maxZoom
|
|
472
|
+
);
|
|
473
|
+
const [selectionStyle, setSelectionStyle] = (0, import_react.useState)(
|
|
474
|
+
SELECTION_STYLE.TOP
|
|
475
|
+
);
|
|
476
|
+
const [gridLegends, setGridLegends] = (0, import_react.useState)({});
|
|
477
|
+
const [isInfoBarOpen, setIsInfoBarOpen] = (0, import_react.useState)(true);
|
|
478
|
+
const [clickedLngLat, setClickedLngLat] = (0, import_react.useState)();
|
|
479
|
+
const [layers, setLayers] = (0, import_react.useState)(_mp.layers || []);
|
|
480
|
+
const [selectedLayerIds, setSelectedLayerIds] = (0, import_react.useState)(
|
|
481
|
+
mp.selectedLayers || []
|
|
482
|
+
);
|
|
483
|
+
const [hoverFeatures, setHoverFeatures] = (0, import_react.useState)();
|
|
484
|
+
const [selectedFeatures, setSelectedFeatures] = (0, import_react.useState)();
|
|
485
|
+
const selectedFeaturesId = (0, import_react.useMemo)(() => {
|
|
486
|
+
const meta = {};
|
|
487
|
+
for (const qr of selectedFeatures || []) {
|
|
488
|
+
meta[qr.sourceLayer] = [
|
|
489
|
+
...meta[qr.sourceLayer] || [],
|
|
490
|
+
qr?.properties?.[PROPERTY_ID]
|
|
491
|
+
];
|
|
492
|
+
}
|
|
493
|
+
return Object.keys(meta).length ? meta : void 0;
|
|
494
|
+
}, [selectedFeatures]);
|
|
495
|
+
const selectedLayers = import_react.default.useMemo(() => {
|
|
496
|
+
const unsortedLayers = layers.filter(
|
|
497
|
+
(_layer) => selectedLayerIds.includes(_layer.id)
|
|
498
|
+
);
|
|
499
|
+
const sortedLayers = new Array(selectedLayerIds.length);
|
|
500
|
+
for (const layerToSort of unsortedLayers) {
|
|
501
|
+
const idx = selectedLayerIds.findIndex((l) => layerToSort.id === l);
|
|
502
|
+
if (idx > -1) {
|
|
503
|
+
sortedLayers[idx] = layerToSort;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return sortedLayers;
|
|
507
|
+
}, [layers, selectedLayerIds]);
|
|
508
|
+
const getLayerIndexById = (layerId) => {
|
|
509
|
+
return layers.findIndex((layer) => layer.id === layerId);
|
|
510
|
+
};
|
|
511
|
+
const updateLayerById = (layerId, updatedLayer) => {
|
|
512
|
+
setLayers(
|
|
513
|
+
(_layers) => _layers.map((l) => l.id === layerId ? { ...l, ...updatedLayer } : l)
|
|
514
|
+
);
|
|
515
|
+
};
|
|
516
|
+
const toggleVectorLayer = async (layerIndex, styleIndex, focus) => {
|
|
517
|
+
const layer = layers[layerIndex];
|
|
518
|
+
const layerData = await getLayerStyle(
|
|
519
|
+
layer,
|
|
520
|
+
styleIndex,
|
|
521
|
+
mp.nakshaApiEndpoint,
|
|
522
|
+
mp.geoserver
|
|
523
|
+
);
|
|
524
|
+
updateLayerById(layer.id, { data: layerData });
|
|
525
|
+
focus && mapl?.fitBounds(layer.bbox, { padding: 40, duration: 1e3 });
|
|
526
|
+
};
|
|
527
|
+
const updateLayerStyle = async (layerId, styleIndex) => {
|
|
528
|
+
const layerIndex = getLayerIndexById(layerId);
|
|
529
|
+
toggleVectorLayer(layerIndex, styleIndex, false);
|
|
530
|
+
};
|
|
531
|
+
const onMapHover = async (e) => {
|
|
532
|
+
if (!selectedLayerIds.length || !mapl) return;
|
|
533
|
+
try {
|
|
534
|
+
const lastLayerId = selectedLayerIds[0];
|
|
535
|
+
const feats = mapl.queryRenderedFeatures(e.point, {
|
|
536
|
+
layers: [lastLayerId]
|
|
537
|
+
});
|
|
538
|
+
if (feats.length) {
|
|
539
|
+
const fId = feats[0]?.id || feats[0]?.properties?.[PROPERTY_ID];
|
|
540
|
+
if (fId === hoverFeatures?.id) return;
|
|
541
|
+
const layer = layers[getLayerIndexById(lastLayerId)];
|
|
542
|
+
const hoverProperties = layer?.data?.summaryColumn.map((sc) => [
|
|
543
|
+
layer.data?.propertyMap?.[sc] || sc,
|
|
544
|
+
feats[0].properties?.[sc]
|
|
545
|
+
]);
|
|
546
|
+
setHoverFeatures({
|
|
547
|
+
id: fId,
|
|
548
|
+
title: layer.title,
|
|
549
|
+
data: hoverProperties
|
|
550
|
+
});
|
|
551
|
+
} else {
|
|
552
|
+
setHoverFeatures(void 0);
|
|
553
|
+
}
|
|
554
|
+
} catch (e2) {
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
const toggleLayer = async ({
|
|
558
|
+
layerId,
|
|
559
|
+
add,
|
|
560
|
+
styleIndex = 0,
|
|
561
|
+
focus = true
|
|
562
|
+
}) => {
|
|
563
|
+
if (!add) {
|
|
564
|
+
setSelectedLayerIds(
|
|
565
|
+
selectedLayerIds.filter((_lyrId) => layerId !== _lyrId)
|
|
566
|
+
);
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const layerIndex = getLayerIndexById(layerId);
|
|
570
|
+
const sourceType = layers[layerIndex]?.source.type;
|
|
571
|
+
if (sourceType === "grid") {
|
|
572
|
+
setSelectedLayerIds((_slIds) => [
|
|
573
|
+
layerId,
|
|
574
|
+
..._slIds.filter((lid) => lid !== layerId)
|
|
575
|
+
]);
|
|
576
|
+
if (focus && layers[layerIndex]?.bbox) {
|
|
577
|
+
setTimeout(() => {
|
|
578
|
+
mapl?.fitBounds(layers[layerIndex].bbox, {
|
|
579
|
+
padding: 40,
|
|
580
|
+
duration: 1e3
|
|
581
|
+
});
|
|
582
|
+
}, 100);
|
|
583
|
+
}
|
|
584
|
+
} else {
|
|
585
|
+
await toggleVectorLayer(layerIndex, styleIndex, focus);
|
|
586
|
+
setSelectedLayerIds((_slIds) => [
|
|
587
|
+
layerId,
|
|
588
|
+
..._slIds.filter((lid) => lid !== layerId)
|
|
589
|
+
]);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
const clearAllLayers = async () => setSelectedLayerIds([]);
|
|
593
|
+
const updateMP = (key, value) => {
|
|
594
|
+
setMP({ ...mp, [key]: value });
|
|
595
|
+
};
|
|
596
|
+
const toggleLayerPublishing = (layerId, layerStatus) => {
|
|
597
|
+
const isActive = layerStatus === LAYER_STATUS.PENDING;
|
|
598
|
+
axToggleLayerPublishing(
|
|
599
|
+
mp.nakshaEndpointToken,
|
|
600
|
+
mp.nakshaApiEndpoint,
|
|
601
|
+
layerId,
|
|
602
|
+
isActive
|
|
603
|
+
);
|
|
604
|
+
updateLayerById(layerId, {
|
|
605
|
+
layerStatus: isActive ? LAYER_STATUS.ACTIVE : LAYER_STATUS.PENDING
|
|
606
|
+
});
|
|
607
|
+
};
|
|
608
|
+
const deleteLayer = async (layerId, message) => {
|
|
609
|
+
if (confirm(message)) {
|
|
610
|
+
axDeleteLayer(mp.nakshaEndpointToken, mp.nakshaApiEndpoint, layerId);
|
|
611
|
+
setLayers(layers.filter((l) => l.id !== layerId));
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
const zoomToExtent = (layerId) => {
|
|
615
|
+
const layerIndex = getLayerIndexById(layerId);
|
|
616
|
+
const layer = layers[layerIndex];
|
|
617
|
+
mapl?.fitBounds(layer.bbox, { padding: 40, duration: 1e3 });
|
|
618
|
+
};
|
|
619
|
+
const getBBoxFromLngLat = () => {
|
|
620
|
+
return [
|
|
621
|
+
clickedLngLat.lng,
|
|
622
|
+
clickedLngLat.lat,
|
|
623
|
+
clickedLngLat.lng + 0.1,
|
|
624
|
+
clickedLngLat.lat + 0.1
|
|
625
|
+
];
|
|
626
|
+
};
|
|
627
|
+
const handleSelectStyle = (value) => {
|
|
628
|
+
setSelectionStyle(value);
|
|
629
|
+
if (value === SELECTION_STYLE.TOP) {
|
|
630
|
+
featuresAtLatLng(value);
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
const featuresAtLatLng = (value) => {
|
|
634
|
+
if (!clickedLngLat) return;
|
|
635
|
+
try {
|
|
636
|
+
const finalXY = mapl?.project([clickedLngLat.lng, clickedLngLat.lat]);
|
|
637
|
+
let queryFeat = mapl?.queryRenderedFeatures(finalXY, {
|
|
638
|
+
layers: selectionStyle === SELECTION_STYLE.TOP ? [selectedLayerIds[0]] : selectedLayerIds
|
|
639
|
+
});
|
|
640
|
+
if ((value || selectionStyle) === SELECTION_STYLE.ALL) {
|
|
641
|
+
const rasterLayerFeat = selectedLayers.filter((item) => item.layerType == "RASTER").map((item) => ({
|
|
642
|
+
sourceLayer: item.id,
|
|
643
|
+
layerType: "raster",
|
|
644
|
+
bbox: getBBoxFromLngLat()
|
|
645
|
+
}));
|
|
646
|
+
queryFeat = [...queryFeat, ...rasterLayerFeat];
|
|
647
|
+
}
|
|
648
|
+
setSelectedFeatures(
|
|
649
|
+
// if fist layer is raster and select all in not set
|
|
650
|
+
// send a raster based feature object
|
|
651
|
+
selectedLayers?.[0].layerType === "RASTER" && selectionStyle !== SELECTION_STYLE.ALL ? selectedLayerIds.length && queryFeat?.length ? queryFeat : [
|
|
652
|
+
{
|
|
653
|
+
sourceLayer: selectedLayerIds[0],
|
|
654
|
+
layerType: "raster",
|
|
655
|
+
bbox: getBBoxFromLngLat()
|
|
656
|
+
}
|
|
657
|
+
] : queryFeat
|
|
658
|
+
);
|
|
659
|
+
} catch (e) {
|
|
660
|
+
console.error(e);
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
(0, import_react.useEffect)(() => {
|
|
664
|
+
if (mp.onSelectedLayersChange) {
|
|
665
|
+
mp.onSelectedLayersChange(selectedLayerIds);
|
|
666
|
+
}
|
|
667
|
+
}, [selectedLayerIds]);
|
|
668
|
+
(0, import_react.useEffect)(() => {
|
|
669
|
+
setTimeout(featuresAtLatLng, 300);
|
|
670
|
+
}, [clickedLngLat, selectionStyle, selectedLayerIds]);
|
|
671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
672
|
+
LayersContext.Provider,
|
|
673
|
+
{
|
|
674
|
+
value: {
|
|
675
|
+
mp,
|
|
676
|
+
updateMP,
|
|
677
|
+
layer: {
|
|
678
|
+
mapStyle,
|
|
679
|
+
featuresAtLatLng,
|
|
680
|
+
setMapStyle,
|
|
681
|
+
maxZoom,
|
|
682
|
+
setMaxZoom,
|
|
683
|
+
mapStyles: styles,
|
|
684
|
+
all: layers,
|
|
685
|
+
setAll: setLayers,
|
|
686
|
+
selectedIds: selectedLayerIds,
|
|
687
|
+
handleSelectStyle,
|
|
688
|
+
setSelectedIds: setSelectedLayerIds,
|
|
689
|
+
selectedLayers,
|
|
690
|
+
clearAll: clearAllLayers,
|
|
691
|
+
toggle: toggleLayer,
|
|
692
|
+
updateStyle: updateLayerStyle,
|
|
693
|
+
selectedFeatures,
|
|
694
|
+
selectedFeaturesId,
|
|
695
|
+
setSelectedFeatures,
|
|
696
|
+
togglePublish: toggleLayerPublishing,
|
|
697
|
+
delete: deleteLayer,
|
|
698
|
+
selectionStyle,
|
|
699
|
+
setSelectionStyle,
|
|
700
|
+
zoomToExtent,
|
|
701
|
+
gridLegends,
|
|
702
|
+
setGridLegends
|
|
703
|
+
},
|
|
704
|
+
query: {
|
|
705
|
+
term: queryTermDebounced,
|
|
706
|
+
setTerm: setQueryTerm,
|
|
707
|
+
clickedLngLat,
|
|
708
|
+
setClickedLngLat
|
|
709
|
+
},
|
|
710
|
+
isInfoBarOpen,
|
|
711
|
+
setIsInfoBarOpen,
|
|
712
|
+
hover: {
|
|
713
|
+
onHover: onMapHover,
|
|
714
|
+
features: hoverFeatures
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
children
|
|
718
|
+
}
|
|
719
|
+
);
|
|
720
|
+
};
|
|
721
|
+
function useLayers() {
|
|
722
|
+
return (0, import_react.useContext)(LayersContext);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// src/components/core/button.tsx
|
|
726
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
727
|
+
var import_twind2 = require("twind");
|
|
728
|
+
|
|
729
|
+
// src/components/core/icons.tsx
|
|
730
|
+
var import_twind = require("twind");
|
|
731
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
732
|
+
var SearchIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
733
|
+
"svg",
|
|
734
|
+
{
|
|
735
|
+
fill: "none",
|
|
736
|
+
className: import_twind.tw`w-5 h-5 text-gray-400`,
|
|
737
|
+
width: "24",
|
|
738
|
+
height: "24",
|
|
739
|
+
viewBox: "0 0 24 24",
|
|
740
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
741
|
+
"path",
|
|
742
|
+
{
|
|
743
|
+
stroke: "currentColor",
|
|
744
|
+
strokeLinecap: "round",
|
|
745
|
+
strokeLinejoin: "round",
|
|
746
|
+
strokeWidth: "2",
|
|
747
|
+
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
748
|
+
}
|
|
749
|
+
)
|
|
750
|
+
}
|
|
751
|
+
);
|
|
752
|
+
var LayersIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
753
|
+
"svg",
|
|
754
|
+
{
|
|
755
|
+
width: "18",
|
|
756
|
+
height: "18",
|
|
757
|
+
fill: "none",
|
|
758
|
+
stroke: "currentColor",
|
|
759
|
+
strokeLinecap: "round",
|
|
760
|
+
strokeLinejoin: "round",
|
|
761
|
+
strokeWidth: "2",
|
|
762
|
+
viewBox: "0 0 24 24",
|
|
763
|
+
children: [
|
|
764
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 2L2 7 12 12 22 7 12 2z" }),
|
|
765
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M2 17L12 22 22 17" }),
|
|
766
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M2 12L12 17 22 12" })
|
|
767
|
+
]
|
|
768
|
+
}
|
|
769
|
+
);
|
|
770
|
+
var InfoIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
771
|
+
"svg",
|
|
772
|
+
{
|
|
773
|
+
width: "16",
|
|
774
|
+
height: "16",
|
|
775
|
+
viewBox: "0 0 24 24",
|
|
776
|
+
fill: "none",
|
|
777
|
+
stroke: "currentColor",
|
|
778
|
+
strokeWidth: "2",
|
|
779
|
+
strokeLinecap: "round",
|
|
780
|
+
strokeLinejoin: "round",
|
|
781
|
+
children: [
|
|
782
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
783
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", y1: "16", x2: "12", y2: "12" }),
|
|
784
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })
|
|
785
|
+
]
|
|
786
|
+
}
|
|
787
|
+
);
|
|
788
|
+
var SlidersIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
789
|
+
"svg",
|
|
790
|
+
{
|
|
791
|
+
width: "18",
|
|
792
|
+
height: "18",
|
|
793
|
+
fill: "none",
|
|
794
|
+
stroke: "currentColor",
|
|
795
|
+
strokeLinecap: "round",
|
|
796
|
+
strokeLinejoin: "round",
|
|
797
|
+
strokeWidth: "2",
|
|
798
|
+
viewBox: "0 0 24 24",
|
|
799
|
+
children: [
|
|
800
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M4 21L4 14" }),
|
|
801
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M4 10L4 3" }),
|
|
802
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 21L12 12" }),
|
|
803
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 8L12 3" }),
|
|
804
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M20 21L20 16" }),
|
|
805
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M20 12L20 3" }),
|
|
806
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M1 14L7 14" }),
|
|
807
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M9 8L15 8" }),
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M17 16L23 16" })
|
|
809
|
+
]
|
|
810
|
+
}
|
|
811
|
+
);
|
|
812
|
+
function AttributionIcon() {
|
|
813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
814
|
+
"svg",
|
|
815
|
+
{
|
|
816
|
+
width: "14",
|
|
817
|
+
height: "14",
|
|
818
|
+
viewBox: "0 0 16 16",
|
|
819
|
+
style: { display: "inline-block" },
|
|
820
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
821
|
+
"path",
|
|
822
|
+
{
|
|
823
|
+
fillRule: "evenodd",
|
|
824
|
+
fill: "currentColor",
|
|
825
|
+
d: "M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"
|
|
826
|
+
}
|
|
827
|
+
)
|
|
828
|
+
}
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
function TagIcon() {
|
|
832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
833
|
+
"svg",
|
|
834
|
+
{
|
|
835
|
+
width: "14",
|
|
836
|
+
height: "14",
|
|
837
|
+
viewBox: "0 0 16 16",
|
|
838
|
+
style: { display: "inline-block" },
|
|
839
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
840
|
+
"path",
|
|
841
|
+
{
|
|
842
|
+
fillRule: "evenodd",
|
|
843
|
+
fill: "currentColor",
|
|
844
|
+
d: "M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"
|
|
845
|
+
}
|
|
846
|
+
)
|
|
847
|
+
}
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
function LicenseIcon() {
|
|
851
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
852
|
+
"svg",
|
|
853
|
+
{
|
|
854
|
+
width: "14",
|
|
855
|
+
height: "14",
|
|
856
|
+
viewBox: "0 0 16 16",
|
|
857
|
+
style: { display: "inline-block" },
|
|
858
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
859
|
+
"path",
|
|
860
|
+
{
|
|
861
|
+
fillRule: "evenodd",
|
|
862
|
+
fill: "currentColor",
|
|
863
|
+
d: "M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"
|
|
864
|
+
}
|
|
865
|
+
)
|
|
866
|
+
}
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
function EyeIcon() {
|
|
870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
871
|
+
"svg",
|
|
872
|
+
{
|
|
873
|
+
viewBox: "0 0 16 16",
|
|
874
|
+
width: "14",
|
|
875
|
+
height: "14",
|
|
876
|
+
style: { display: "inline-block" },
|
|
877
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
878
|
+
"path",
|
|
879
|
+
{
|
|
880
|
+
fillRule: "evenodd",
|
|
881
|
+
fill: "currentColor",
|
|
882
|
+
d: "M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"
|
|
883
|
+
}
|
|
884
|
+
)
|
|
885
|
+
}
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
function ClockIcon() {
|
|
889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
890
|
+
"svg",
|
|
891
|
+
{
|
|
892
|
+
viewBox: "0 0 16 16",
|
|
893
|
+
width: "14",
|
|
894
|
+
height: "14",
|
|
895
|
+
style: { display: "inline-block" },
|
|
896
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
897
|
+
"path",
|
|
898
|
+
{
|
|
899
|
+
fillRule: "evenodd",
|
|
900
|
+
fill: "currentColor",
|
|
901
|
+
d: "M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"
|
|
902
|
+
}
|
|
903
|
+
)
|
|
904
|
+
}
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
function DownloadIcon() {
|
|
908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
909
|
+
"svg",
|
|
910
|
+
{
|
|
911
|
+
viewBox: "0 0 16 16",
|
|
912
|
+
width: "16",
|
|
913
|
+
height: "16",
|
|
914
|
+
style: { display: "inline-block" },
|
|
915
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
916
|
+
"path",
|
|
917
|
+
{
|
|
918
|
+
fillRule: "evenodd",
|
|
919
|
+
fill: "currentColor",
|
|
920
|
+
d: "M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"
|
|
921
|
+
}
|
|
922
|
+
)
|
|
923
|
+
}
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
function ZoomExtentIcon() {
|
|
927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
928
|
+
"svg",
|
|
929
|
+
{
|
|
930
|
+
viewBox: "0 0 24 24",
|
|
931
|
+
width: "16",
|
|
932
|
+
height: "16",
|
|
933
|
+
fill: "none",
|
|
934
|
+
stroke: "currentColor",
|
|
935
|
+
strokeWidth: "2",
|
|
936
|
+
strokeLinecap: "round",
|
|
937
|
+
strokeLinejoin: "round",
|
|
938
|
+
style: { display: "inline-block" },
|
|
939
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" })
|
|
940
|
+
}
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
function ShareIcon() {
|
|
944
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
945
|
+
"svg",
|
|
946
|
+
{
|
|
947
|
+
viewBox: "0 0 24 24",
|
|
948
|
+
width: "16",
|
|
949
|
+
height: "16",
|
|
950
|
+
fill: "none",
|
|
951
|
+
stroke: "currentColor",
|
|
952
|
+
strokeWidth: "2",
|
|
953
|
+
strokeLinecap: "round",
|
|
954
|
+
strokeLinejoin: "round",
|
|
955
|
+
style: { display: "inline-block" },
|
|
956
|
+
children: [
|
|
957
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "18", cy: "5", r: "3" }),
|
|
958
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "6", cy: "12", r: "3" }),
|
|
959
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "18", cy: "19", r: "3" }),
|
|
960
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "8.59", y1: "13.51", x2: "15.42", y2: "17.49" }),
|
|
961
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "15.41", y1: "6.51", x2: "8.59", y2: "10.49" })
|
|
962
|
+
]
|
|
963
|
+
}
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
function GrabberIcon() {
|
|
967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
968
|
+
"svg",
|
|
969
|
+
{
|
|
970
|
+
viewBox: "0 0 16 16",
|
|
971
|
+
width: "16",
|
|
972
|
+
height: "16",
|
|
973
|
+
style: { display: "inline-block" },
|
|
974
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
975
|
+
"path",
|
|
976
|
+
{
|
|
977
|
+
fillRule: "evenodd",
|
|
978
|
+
d: "M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"
|
|
979
|
+
}
|
|
980
|
+
)
|
|
981
|
+
}
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
function CrossHairIcon() {
|
|
985
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
986
|
+
"svg",
|
|
987
|
+
{
|
|
988
|
+
style: { display: "inline-block" },
|
|
989
|
+
width: "18",
|
|
990
|
+
height: "18",
|
|
991
|
+
viewBox: "0 0 24 24",
|
|
992
|
+
fill: "none",
|
|
993
|
+
stroke: "currentColor",
|
|
994
|
+
strokeWidth: "2",
|
|
995
|
+
strokeLinecap: "round",
|
|
996
|
+
strokeLinejoin: "round",
|
|
997
|
+
children: [
|
|
998
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
999
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "22", y1: "12", x2: "18", y2: "12" }),
|
|
1000
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "6", y1: "12", x2: "2", y2: "12" }),
|
|
1001
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", y1: "6", x2: "12", y2: "2" }),
|
|
1002
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "12", y1: "22", x2: "12", y2: "18" })
|
|
1003
|
+
]
|
|
1004
|
+
}
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
function DownIcon() {
|
|
1008
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1009
|
+
"svg",
|
|
1010
|
+
{
|
|
1011
|
+
width: "18",
|
|
1012
|
+
height: "18",
|
|
1013
|
+
viewBox: "0 0 24 24",
|
|
1014
|
+
fill: "none",
|
|
1015
|
+
stroke: "currentColor",
|
|
1016
|
+
strokeWidth: "2",
|
|
1017
|
+
strokeLinecap: "round",
|
|
1018
|
+
strokeLinejoin: "round",
|
|
1019
|
+
style: { display: "inline-block" },
|
|
1020
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "6 9 12 15 18 9" })
|
|
1021
|
+
}
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
function UpIcon() {
|
|
1025
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1026
|
+
"svg",
|
|
1027
|
+
{
|
|
1028
|
+
width: "18",
|
|
1029
|
+
height: "18",
|
|
1030
|
+
viewBox: "0 0 24 24",
|
|
1031
|
+
fill: "none",
|
|
1032
|
+
stroke: "currentColor",
|
|
1033
|
+
strokeWidth: "2",
|
|
1034
|
+
strokeLinecap: "round",
|
|
1035
|
+
strokeLinejoin: "round",
|
|
1036
|
+
style: { display: "inline-block" },
|
|
1037
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "18 15 12 9 6 15" })
|
|
1038
|
+
}
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// src/components/core/button.tsx
|
|
1043
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1044
|
+
var Button = import_react2.default.forwardRef((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1045
|
+
"button",
|
|
1046
|
+
{
|
|
1047
|
+
ref,
|
|
1048
|
+
type: "button",
|
|
1049
|
+
className: import_twind2.tw`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`,
|
|
1050
|
+
...props
|
|
1051
|
+
}
|
|
1052
|
+
));
|
|
1053
|
+
var CloseButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1054
|
+
"button",
|
|
1055
|
+
{
|
|
1056
|
+
className: import_twind2.tw`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,
|
|
1057
|
+
children: "\u2715",
|
|
1058
|
+
...props
|
|
1059
|
+
}
|
|
1060
|
+
);
|
|
1061
|
+
var LayersButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1062
|
+
"button",
|
|
1063
|
+
{
|
|
1064
|
+
className: import_twind2.tw`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,
|
|
1065
|
+
...props,
|
|
1066
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LayersIcon, {})
|
|
1067
|
+
}
|
|
1068
|
+
);
|
|
1069
|
+
var InfobarButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1070
|
+
"button",
|
|
1071
|
+
{
|
|
1072
|
+
className: import_twind2.tw`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,
|
|
1073
|
+
...props,
|
|
1074
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InfoIcon, {})
|
|
1075
|
+
}
|
|
1076
|
+
);
|
|
1077
|
+
|
|
1078
|
+
// src/components/core/input.tsx
|
|
1079
|
+
var import_twind3 = require("twind");
|
|
1080
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1081
|
+
var SelectInput = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
1082
|
+
props.label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { className: import_twind3.tw`text-gray-700`, htmlFor: props.name, children: props.label }),
|
|
1083
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1084
|
+
"select",
|
|
1085
|
+
{
|
|
1086
|
+
id: props.name,
|
|
1087
|
+
name: props.name,
|
|
1088
|
+
className: import_twind3.tw`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,
|
|
1089
|
+
style: {
|
|
1090
|
+
backgroundImage: `url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,
|
|
1091
|
+
backgroundPosition: "right 0.75rem center",
|
|
1092
|
+
backgroundSize: "16px 12px",
|
|
1093
|
+
backgroundRepeat: "no-repeat"
|
|
1094
|
+
},
|
|
1095
|
+
...props
|
|
1096
|
+
}
|
|
1097
|
+
)
|
|
1098
|
+
] });
|
|
1099
|
+
var SearchInput = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "relative", children: [
|
|
1100
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: import_twind3.tw`absolute inset-y-0 left-0 flex items-center pl-3`, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SearchIcon, {}) }),
|
|
1101
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1102
|
+
"input",
|
|
1103
|
+
{
|
|
1104
|
+
type: "search",
|
|
1105
|
+
className: import_twind3.tw`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`,
|
|
1106
|
+
...props
|
|
1107
|
+
}
|
|
1108
|
+
)
|
|
1109
|
+
] });
|
|
1110
|
+
var CheckboxInput = (props) => props.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1111
|
+
"svg",
|
|
1112
|
+
{
|
|
1113
|
+
width: "20px",
|
|
1114
|
+
height: "20px",
|
|
1115
|
+
viewBox: "0 0 20 20",
|
|
1116
|
+
version: "1.1",
|
|
1117
|
+
className: import_twind3.tw`inline text-gray-200 animate-spin dark:text-gray-600`,
|
|
1118
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("g", { stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("g", { fill: "#212121", fillRule: "nonzero", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z" }) }) })
|
|
1119
|
+
}
|
|
1120
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1121
|
+
"input",
|
|
1122
|
+
{
|
|
1123
|
+
type: "checkbox",
|
|
1124
|
+
className: import_twind3.tw`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,
|
|
1125
|
+
name: props.name,
|
|
1126
|
+
checked: props.checked,
|
|
1127
|
+
onChange: props.onChange
|
|
1128
|
+
}
|
|
1129
|
+
);
|
|
1130
|
+
|
|
1131
|
+
// src/components/core/tabs.tsx
|
|
1132
|
+
var import_tabs = require("@bumaga/tabs");
|
|
1133
|
+
var import_clsx = __toESM(require("clsx"), 1);
|
|
1134
|
+
var import_twind4 = require("twind");
|
|
1135
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1136
|
+
var IconTab = ({ children, icon }) => {
|
|
1137
|
+
const { onClick, isActive } = (0, import_tabs.useTabState)();
|
|
1138
|
+
const classes = (0, import_clsx.default)([
|
|
1139
|
+
"flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",
|
|
1140
|
+
{
|
|
1141
|
+
"text-blue-600 border-blue-500": isActive,
|
|
1142
|
+
"text-gray-700 border-gray-300 hover:border-gray-400": !isActive
|
|
1143
|
+
}
|
|
1144
|
+
]);
|
|
1145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", { className: (0, import_twind4.tw)(classes), onClick, children: [
|
|
1146
|
+
icon,
|
|
1147
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: import_twind4.tw`ml-2 text-base`, children })
|
|
1148
|
+
] });
|
|
1149
|
+
};
|
|
1150
|
+
var Panel = ({ children }) => {
|
|
1151
|
+
const isActive = (0, import_tabs.usePanelState)();
|
|
1152
|
+
return isActive ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: import_twind4.tw`w-full flex flex-grow-1 overflow-auto`, children }) : null;
|
|
1153
|
+
};
|
|
1154
|
+
var TabHeader = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1155
|
+
"div",
|
|
1156
|
+
{
|
|
1157
|
+
className: import_twind4.tw`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,
|
|
1158
|
+
children
|
|
1159
|
+
}
|
|
1160
|
+
);
|
|
1161
|
+
|
|
1162
|
+
// src/components/infobar/content.tsx
|
|
1163
|
+
var import_naksha_commons4 = require("@biodiv-platform/naksha-commons");
|
|
1164
|
+
var import_twind6 = require("twind");
|
|
1165
|
+
|
|
1166
|
+
// src/components/sidebar/settings/layer-selection.tsx
|
|
1167
|
+
var import_naksha_commons3 = require("@biodiv-platform/naksha-commons");
|
|
1168
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1169
|
+
function LayerSelection({ hideLabel }) {
|
|
1170
|
+
const {
|
|
1171
|
+
layer: { selectionStyle, handleSelectStyle }
|
|
1172
|
+
} = useLayers();
|
|
1173
|
+
const { t } = (0, import_naksha_commons3.useT)();
|
|
1174
|
+
const handleOnSelectionStyleChange = (e) => {
|
|
1175
|
+
handleSelectStyle(e.target.value);
|
|
1176
|
+
};
|
|
1177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1178
|
+
SelectInput,
|
|
1179
|
+
{
|
|
1180
|
+
name: "layer_selection",
|
|
1181
|
+
label: hideLabel ? null : t("layer_selection"),
|
|
1182
|
+
defaultValue: selectionStyle,
|
|
1183
|
+
onChange: handleOnSelectionStyleChange,
|
|
1184
|
+
children: Object.values(SELECTION_STYLE).map((ss) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: ss, children: t(ss) }, ss))
|
|
1185
|
+
}
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// src/components/infobar/infobar-panel.tsx
|
|
1190
|
+
var import_clsx2 = __toESM(require("clsx"), 1);
|
|
1191
|
+
var import_react3 = require("react");
|
|
1192
|
+
var import_twind5 = require("twind");
|
|
1193
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1194
|
+
function InfoBarPanel({ data: payload }) {
|
|
1195
|
+
const [isOpen, setIsOpen] = (0, import_react3.useState)(true);
|
|
1196
|
+
const [layerInfo, setLayerInfo] = (0, import_react3.useState)({
|
|
1197
|
+
title: payload.sourceLayer,
|
|
1198
|
+
properties: []
|
|
1199
|
+
});
|
|
1200
|
+
const {
|
|
1201
|
+
layer,
|
|
1202
|
+
mp,
|
|
1203
|
+
query: { clickedLngLat }
|
|
1204
|
+
} = useLayers();
|
|
1205
|
+
const getPropertyData = async () => {
|
|
1206
|
+
let properties;
|
|
1207
|
+
const currentLayer = layer.selectedLayers.find(
|
|
1208
|
+
(l) => l.id === (payload.sourceLayer || payload.source)
|
|
1209
|
+
);
|
|
1210
|
+
if (currentLayer.layerType.toLowerCase() === "raster") {
|
|
1211
|
+
const { data } = await axGexGetRasterInfoWithLonLat(
|
|
1212
|
+
mp.geoserver?.endpoint,
|
|
1213
|
+
mp.geoserver?.workspace,
|
|
1214
|
+
{
|
|
1215
|
+
bbox: payload.bbox.toString(),
|
|
1216
|
+
query_layers: `${mp.geoserver?.workspace}:${currentLayer.id}`,
|
|
1217
|
+
layers: `${mp.geoserver?.workspace}:${currentLayer.id}`
|
|
1218
|
+
}
|
|
1219
|
+
);
|
|
1220
|
+
properties = data?.features[0] ? Object.entries(data.features[0]?.properties).map(([v, k]) => [
|
|
1221
|
+
k || "-"
|
|
1222
|
+
]) : [];
|
|
1223
|
+
} else {
|
|
1224
|
+
properties = Object.entries(currentLayer?.data?.propertyMap || {}).map(
|
|
1225
|
+
([k, v]) => [v, payload?.properties?.[k]]
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
setLayerInfo({ title: currentLayer.title, properties });
|
|
1229
|
+
};
|
|
1230
|
+
(0, import_react3.useEffect)(() => {
|
|
1231
|
+
getPropertyData();
|
|
1232
|
+
}, [clickedLngLat]);
|
|
1233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: import_twind5.tw`bg-gray-100 rounded-lg`, children: [
|
|
1234
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1235
|
+
"button",
|
|
1236
|
+
{
|
|
1237
|
+
className: (0, import_twind5.tw)(
|
|
1238
|
+
(0, import_clsx2.default)([
|
|
1239
|
+
`px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring`,
|
|
1240
|
+
{ "bg-gray-200 rounded-t-lg": isOpen, "rounded-lg": !isOpen }
|
|
1241
|
+
])
|
|
1242
|
+
),
|
|
1243
|
+
onClick: () => setIsOpen(!isOpen),
|
|
1244
|
+
children: [
|
|
1245
|
+
layerInfo.title,
|
|
1246
|
+
" ",
|
|
1247
|
+
isOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(UpIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DownIcon, {})
|
|
1248
|
+
]
|
|
1249
|
+
}
|
|
1250
|
+
),
|
|
1251
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_twind5.tw`px-4 py-3 flex flex-col gap-3`, children: layerInfo.properties.map(([k, v], index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
|
|
1252
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: import_twind5.tw`text-gray-600`, children: k }),
|
|
1253
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: v })
|
|
1254
|
+
] }, k + v + index)) })
|
|
1255
|
+
] });
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
// src/components/infobar/content.tsx
|
|
1259
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1260
|
+
function InfoBarContent({ onClose }) {
|
|
1261
|
+
const {
|
|
1262
|
+
layer: { selectedFeatures, selectedLayers, selectionStyle }
|
|
1263
|
+
} = useLayers();
|
|
1264
|
+
const { t } = (0, import_naksha_commons4.useT)();
|
|
1265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1266
|
+
"div",
|
|
1267
|
+
{
|
|
1268
|
+
className: import_twind6.tw`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,
|
|
1269
|
+
children: [
|
|
1270
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex w-full", children: [
|
|
1271
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1272
|
+
"div",
|
|
1273
|
+
{
|
|
1274
|
+
className: import_twind6.tw`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,
|
|
1275
|
+
children: [
|
|
1276
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CrossHairIcon, {}),
|
|
1277
|
+
" ",
|
|
1278
|
+
t("infobar")
|
|
1279
|
+
]
|
|
1280
|
+
}
|
|
1281
|
+
),
|
|
1282
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CloseButton, { onClick: onClose })
|
|
1283
|
+
] }),
|
|
1284
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: import_twind6.tw`bg-gray-100 p-4 flex-shrink-0 rt`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LayerSelection, { hideLabel: true }) }),
|
|
1285
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: import_twind6.tw`flex flex-col flex-grow overflow-auto gap-3 p-4`, children: selectedFeatures.flat(1)?.map((data) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1286
|
+
InfoBarPanel,
|
|
1287
|
+
{
|
|
1288
|
+
data
|
|
1289
|
+
},
|
|
1290
|
+
selectedLayers?.[0]?.source.type === "raster" || selectionStyle === SELECTION_STYLE.ALL ? data?.sourceLayer : data?.sourceLayer + data?.properties[PROPERTY_ID]
|
|
1291
|
+
)) })
|
|
1292
|
+
]
|
|
1293
|
+
}
|
|
1294
|
+
);
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
// src/components/infobar/index.tsx
|
|
1298
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1299
|
+
function InfoBar() {
|
|
1300
|
+
const { layer, isInfoBarOpen, setIsInfoBarOpen } = useLayers();
|
|
1301
|
+
if (!layer.selectedFeatures?.length) return null;
|
|
1302
|
+
const toggleOpen = () => setIsInfoBarOpen(!isInfoBarOpen);
|
|
1303
|
+
return isInfoBarOpen ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InfoBarContent, { onClose: toggleOpen }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InfobarButton, { onClick: toggleOpen });
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
// src/components/sidebar/index.tsx
|
|
1307
|
+
var import_react9 = require("react");
|
|
1308
|
+
var import_maplibre2 = require("react-map-gl/maplibre");
|
|
1309
|
+
|
|
1310
|
+
// src/components/sidebar/tabs.tsx
|
|
1311
|
+
var import_naksha_commons12 = require("@biodiv-platform/naksha-commons");
|
|
1312
|
+
var import_twind18 = require("twind");
|
|
1313
|
+
|
|
1314
|
+
// src/components/sidebar/layers/index.tsx
|
|
1315
|
+
var import_twind15 = require("twind");
|
|
1316
|
+
|
|
1317
|
+
// src/components/sidebar/layers/layer-list.tsx
|
|
1318
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
1319
|
+
var import_react_virtual = require("react-virtual");
|
|
1320
|
+
var import_react_virtualized_auto_sizer = require("react-virtualized-auto-sizer");
|
|
1321
|
+
var import_twind13 = require("twind");
|
|
1322
|
+
|
|
1323
|
+
// src/components/sidebar/common/layer-item.tsx
|
|
1324
|
+
var import_naksha_commons8 = require("@biodiv-platform/naksha-commons");
|
|
1325
|
+
var import_react7 = require("react");
|
|
1326
|
+
var import_react_web_share = require("react-web-share");
|
|
1327
|
+
var import_twind12 = require("twind");
|
|
1328
|
+
|
|
1329
|
+
// src/components/core/highlighter.tsx
|
|
1330
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1331
|
+
var Highlighted = ({ text = "", highlight = "" }) => {
|
|
1332
|
+
if (!highlight.trim()) {
|
|
1333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: text });
|
|
1334
|
+
}
|
|
1335
|
+
const regex = new RegExp(`(${highlight})`, "gi");
|
|
1336
|
+
const parts = text.split(regex);
|
|
1337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: parts.filter((part) => part).map(
|
|
1338
|
+
(part, i) => regex.test(part) ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("mark", { children: part }, i) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: part }, i)
|
|
1339
|
+
) });
|
|
1340
|
+
};
|
|
1341
|
+
|
|
1342
|
+
// src/components/sidebar/common/grid-legend.tsx
|
|
1343
|
+
var import_twind8 = require("twind");
|
|
1344
|
+
|
|
1345
|
+
// src/components/sidebar/common/moreless.tsx
|
|
1346
|
+
var import_naksha_commons5 = require("@biodiv-platform/naksha-commons");
|
|
1347
|
+
var import_react4 = require("react");
|
|
1348
|
+
var import_twind7 = require("twind");
|
|
1349
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1350
|
+
function MoreLess({ children }) {
|
|
1351
|
+
const [showMore, setShowMore] = (0, import_react4.useState)(false);
|
|
1352
|
+
const { t } = (0, import_naksha_commons5.useT)();
|
|
1353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
|
|
1354
|
+
showMore && children,
|
|
1355
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1356
|
+
"button",
|
|
1357
|
+
{
|
|
1358
|
+
onClick: () => setShowMore(!showMore),
|
|
1359
|
+
className: import_twind7.tw`text-blue-600 focus:outline-none focus:outline focus:ring`,
|
|
1360
|
+
children: showMore ? t("less") : t("legend")
|
|
1361
|
+
}
|
|
1362
|
+
)
|
|
1363
|
+
] });
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
// src/components/sidebar/common/grid-legend.tsx
|
|
1367
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1368
|
+
function GridLegend({ item }) {
|
|
1369
|
+
const { layer } = useLayers();
|
|
1370
|
+
const legendInfo = layer.gridLegends[item.id];
|
|
1371
|
+
if (!legendInfo) return null;
|
|
1372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MoreLess, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("ul", { style: { margin: 0, padding: 0 }, children: [
|
|
1373
|
+
legendInfo?.stops.map(([stop, color], index, stopsArr) => {
|
|
1374
|
+
const prevStop = (stopsArr[index - 1] || [0])[0];
|
|
1375
|
+
if (prevStop === stop) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", {}, color);
|
|
1376
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("li", { className: import_twind8.tw`flex gap-2 items-center mb-1`, children: [
|
|
1377
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { viewBox: "0 0 24 24", height: "14", width: "14", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1378
|
+
"circle",
|
|
1379
|
+
{
|
|
1380
|
+
cx: "12",
|
|
1381
|
+
fill: color,
|
|
1382
|
+
cy: "12",
|
|
1383
|
+
r: "12",
|
|
1384
|
+
stroke: "none"
|
|
1385
|
+
}
|
|
1386
|
+
) }),
|
|
1387
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
|
|
1388
|
+
prevStop,
|
|
1389
|
+
" - ",
|
|
1390
|
+
stop
|
|
1391
|
+
] })
|
|
1392
|
+
] }, color);
|
|
1393
|
+
}),
|
|
1394
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("li", { children: [
|
|
1395
|
+
"1 Square = ",
|
|
1396
|
+
legendInfo?.squareSize,
|
|
1397
|
+
" x ",
|
|
1398
|
+
legendInfo?.squareSize,
|
|
1399
|
+
" km"
|
|
1400
|
+
] })
|
|
1401
|
+
] }) });
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
// src/components/sidebar/common/info-popover.tsx
|
|
1405
|
+
var import_naksha_commons6 = require("@biodiv-platform/naksha-commons");
|
|
1406
|
+
var import_react5 = require("react");
|
|
1407
|
+
var import_react_tiny_popover = require("react-tiny-popover");
|
|
1408
|
+
var import_twind9 = require("twind");
|
|
1409
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1410
|
+
var LayerInfoLine = ({
|
|
1411
|
+
icon,
|
|
1412
|
+
name,
|
|
1413
|
+
title,
|
|
1414
|
+
link,
|
|
1415
|
+
children
|
|
1416
|
+
}) => {
|
|
1417
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: children || "-" });
|
|
1418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1419
|
+
"div",
|
|
1420
|
+
{
|
|
1421
|
+
className: import_twind9.tw`flex gap-3 text-sm text-gray-600 break-all`,
|
|
1422
|
+
title: name && title && `${name}: ${title}`,
|
|
1423
|
+
children: [
|
|
1424
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: icon }),
|
|
1425
|
+
link ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1426
|
+
"a",
|
|
1427
|
+
{
|
|
1428
|
+
className: import_twind9.tw`text-blue-700 focus:outline-none focus:ring`,
|
|
1429
|
+
target: "_blank",
|
|
1430
|
+
rel: "noopener",
|
|
1431
|
+
href: link,
|
|
1432
|
+
children: content
|
|
1433
|
+
}
|
|
1434
|
+
) : content
|
|
1435
|
+
]
|
|
1436
|
+
}
|
|
1437
|
+
);
|
|
1438
|
+
};
|
|
1439
|
+
function InfoPopover({ item, containerStyle }) {
|
|
1440
|
+
const { t } = (0, import_naksha_commons6.useT)();
|
|
1441
|
+
const { layer, mp } = useLayers();
|
|
1442
|
+
const license = item.license || "CC-BY";
|
|
1443
|
+
const createdOn = item?.createdDate && new Date(item.createdDate).toLocaleDateString();
|
|
1444
|
+
const tags = item.tags?.join(", ");
|
|
1445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1446
|
+
"div",
|
|
1447
|
+
{
|
|
1448
|
+
className: import_twind9.tw`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,
|
|
1449
|
+
style: containerStyle,
|
|
1450
|
+
children: [
|
|
1451
|
+
mp.managePublishing && item.layerStatus && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1452
|
+
LayerInfoLine,
|
|
1453
|
+
{
|
|
1454
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EyeIcon, {}),
|
|
1455
|
+
name: t("visiblity"),
|
|
1456
|
+
title: item.layerStatus,
|
|
1457
|
+
children: [
|
|
1458
|
+
item.layerStatus,
|
|
1459
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1460
|
+
"button",
|
|
1461
|
+
{
|
|
1462
|
+
className: import_twind9.tw`text-blue-600 focus:outline-none ml-4`,
|
|
1463
|
+
onClick: () => layer.togglePublish(item.id, item?.layerStatus),
|
|
1464
|
+
children: t("toggle")
|
|
1465
|
+
}
|
|
1466
|
+
),
|
|
1467
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1468
|
+
"button",
|
|
1469
|
+
{
|
|
1470
|
+
className: import_twind9.tw`text-red-600 focus:outline-none ml-4`,
|
|
1471
|
+
onClick: () => layer.delete(item.id, t("are_you_sure")),
|
|
1472
|
+
children: t("delete")
|
|
1473
|
+
}
|
|
1474
|
+
)
|
|
1475
|
+
]
|
|
1476
|
+
}
|
|
1477
|
+
),
|
|
1478
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1479
|
+
LayerInfoLine,
|
|
1480
|
+
{
|
|
1481
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AttributionIcon, {}),
|
|
1482
|
+
link: item.url,
|
|
1483
|
+
name: t("uploader"),
|
|
1484
|
+
title: item.createdBy,
|
|
1485
|
+
children: item.createdBy
|
|
1486
|
+
}
|
|
1487
|
+
),
|
|
1488
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1489
|
+
LayerInfoLine,
|
|
1490
|
+
{
|
|
1491
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AttributionIcon, {}),
|
|
1492
|
+
link: item.url,
|
|
1493
|
+
name: t("created_by"),
|
|
1494
|
+
title: item.attribution,
|
|
1495
|
+
children: item.attribution
|
|
1496
|
+
}
|
|
1497
|
+
),
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1499
|
+
LayerInfoLine,
|
|
1500
|
+
{
|
|
1501
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ClockIcon, {}),
|
|
1502
|
+
name: t("created_on"),
|
|
1503
|
+
title: createdOn,
|
|
1504
|
+
children: createdOn
|
|
1505
|
+
}
|
|
1506
|
+
),
|
|
1507
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1508
|
+
LayerInfoLine,
|
|
1509
|
+
{
|
|
1510
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TagIcon, {}),
|
|
1511
|
+
name: t("tags"),
|
|
1512
|
+
title: tags,
|
|
1513
|
+
children: tags
|
|
1514
|
+
}
|
|
1515
|
+
),
|
|
1516
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1517
|
+
LayerInfoLine,
|
|
1518
|
+
{
|
|
1519
|
+
name: t("license"),
|
|
1520
|
+
title: license,
|
|
1521
|
+
link: license && import_naksha_commons6.LICENSES[license],
|
|
1522
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LicenseIcon, {}),
|
|
1523
|
+
children: license
|
|
1524
|
+
}
|
|
1525
|
+
)
|
|
1526
|
+
]
|
|
1527
|
+
}
|
|
1528
|
+
);
|
|
1529
|
+
}
|
|
1530
|
+
var PopoverWrapper = ({ item }) => {
|
|
1531
|
+
const [isPopoverOpen, setIsPopoverOpen] = (0, import_react5.useState)(false);
|
|
1532
|
+
const togglePopover = () => setIsPopoverOpen(!isPopoverOpen);
|
|
1533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1534
|
+
import_react_tiny_popover.Popover,
|
|
1535
|
+
{
|
|
1536
|
+
isOpen: isPopoverOpen,
|
|
1537
|
+
padding: 10,
|
|
1538
|
+
positions: ["right"],
|
|
1539
|
+
containerStyle: { zIndex: 99 },
|
|
1540
|
+
onClickOutside: togglePopover,
|
|
1541
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(InfoPopover, { item }),
|
|
1542
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1543
|
+
Button,
|
|
1544
|
+
{
|
|
1545
|
+
onClick: togglePopover,
|
|
1546
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(InfoIcon, {}),
|
|
1547
|
+
title: "Information"
|
|
1548
|
+
}
|
|
1549
|
+
)
|
|
1550
|
+
}
|
|
1551
|
+
);
|
|
1552
|
+
};
|
|
1553
|
+
|
|
1554
|
+
// src/components/sidebar/common/layer-item-style.tsx
|
|
1555
|
+
var import_twind11 = require("twind");
|
|
1556
|
+
|
|
1557
|
+
// src/components/sidebar/common/style-legend.tsx
|
|
1558
|
+
var import_react6 = require("react");
|
|
1559
|
+
var import_naksha_commons7 = require("@biodiv-platform/naksha-commons");
|
|
1560
|
+
var import_twind10 = require("twind");
|
|
1561
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1562
|
+
function StyleLegend({ item }) {
|
|
1563
|
+
const [showImage, setShowImage] = (0, import_react6.useState)(true);
|
|
1564
|
+
const { mp } = useLayers();
|
|
1565
|
+
const { t } = (0, import_naksha_commons7.useT)();
|
|
1566
|
+
const legendStyles = (0, import_react6.useMemo)(
|
|
1567
|
+
() => item?.data?.styles?.[item.data.styleIndex]?.colors?.paint?.["fill-color"]?.stops || item?.data?.styles?.[item.data.styleIndex]?.colors?.paint?.["circle-color"]?.stops || [],
|
|
1568
|
+
[item]
|
|
1569
|
+
);
|
|
1570
|
+
const vectorLegend = () => {
|
|
1571
|
+
return legendStyles.map(([title, color]) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("li", { className: import_twind10.tw`flex gap-2 items-center mb-1`, children: [
|
|
1572
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("svg", { viewBox: "0 0 24 24", height: "14", width: "14", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "12", fill: color, cy: "12", r: "12", stroke: "none" }) }),
|
|
1573
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { children: title })
|
|
1574
|
+
] }, color));
|
|
1575
|
+
};
|
|
1576
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ul", { style: { margin: 0, padding: 0 }, children: item.layerType !== "RASTER" ? vectorLegend() : showImage ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1577
|
+
"img",
|
|
1578
|
+
{
|
|
1579
|
+
style: { margin: "5px" },
|
|
1580
|
+
onError: () => setShowImage(false),
|
|
1581
|
+
src: `${mp?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${item.id}`
|
|
1582
|
+
}
|
|
1583
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { children: t("raster_style_not_found") }) });
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
// src/components/sidebar/common/layer-item-style.tsx
|
|
1587
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1588
|
+
function LayerItemStyle({ item }) {
|
|
1589
|
+
if (!item.data?.styles) return null;
|
|
1590
|
+
const { layer } = useLayers();
|
|
1591
|
+
const onStyleChange = (e) => {
|
|
1592
|
+
layer.updateStyle(item.id, Number(e.target.value));
|
|
1593
|
+
};
|
|
1594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: import_twind11.tw`flex flex-col gap-4 pt-2`, children: [
|
|
1595
|
+
item.layerType !== "RASTER" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SelectInput, { onChange: onStyleChange, children: item.data?.styles.map((opt, idx) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: idx, children: opt.styleTitle }, idx)) }),
|
|
1596
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(MoreLess, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StyleLegend, { item }) })
|
|
1597
|
+
] });
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
// src/components/sidebar/common/layer-item.tsx
|
|
1601
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1602
|
+
function DragHandle({
|
|
1603
|
+
dragHandleProps
|
|
1604
|
+
}) {
|
|
1605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1606
|
+
"div",
|
|
1607
|
+
{
|
|
1608
|
+
className: import_twind12.tw`mt-1 w-6 text-center cursor-move`,
|
|
1609
|
+
style: { touchAction: "none" },
|
|
1610
|
+
...dragHandleProps,
|
|
1611
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(GrabberIcon, {})
|
|
1612
|
+
}
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
function LayerItem({
|
|
1616
|
+
item,
|
|
1617
|
+
extended,
|
|
1618
|
+
dragHandleProps
|
|
1619
|
+
}) {
|
|
1620
|
+
const { t } = (0, import_naksha_commons8.useT)();
|
|
1621
|
+
const {
|
|
1622
|
+
layer,
|
|
1623
|
+
query,
|
|
1624
|
+
mp,
|
|
1625
|
+
query: { setClickedLngLat },
|
|
1626
|
+
setIsInfoBarOpen
|
|
1627
|
+
} = useLayers();
|
|
1628
|
+
const [isAdded, setIsAdded] = (0, import_react7.useState)(layer.selectedIds.includes(item.id));
|
|
1629
|
+
const [isLoading, setIsLoading] = (0, import_react7.useState)(false);
|
|
1630
|
+
const shareData = (0, import_react7.useMemo)(
|
|
1631
|
+
() => mp.canLayerShare ? {
|
|
1632
|
+
url: `${window.location.href.split("?")[0]}?layers=${item.id}`,
|
|
1633
|
+
title: item.title
|
|
1634
|
+
} : void 0,
|
|
1635
|
+
[item.id]
|
|
1636
|
+
);
|
|
1637
|
+
const onToggleLayer = async () => {
|
|
1638
|
+
setIsLoading(true);
|
|
1639
|
+
setIsInfoBarOpen(true);
|
|
1640
|
+
layer.setSelectedFeatures([]);
|
|
1641
|
+
setClickedLngLat(null);
|
|
1642
|
+
await layer.toggle({ layerId: item.id, add: !isAdded });
|
|
1643
|
+
setIsAdded(!isAdded);
|
|
1644
|
+
setIsLoading(false);
|
|
1645
|
+
};
|
|
1646
|
+
const onDownloadLayer = async () => {
|
|
1647
|
+
await axDownloadLayer(
|
|
1648
|
+
mp.nakshaApiEndpoint,
|
|
1649
|
+
mp.nakshaEndpointToken,
|
|
1650
|
+
item.id,
|
|
1651
|
+
item.title
|
|
1652
|
+
);
|
|
1653
|
+
mp?.onLayerDownload(item.id);
|
|
1654
|
+
};
|
|
1655
|
+
const handleOnZoom = () => layer.zoomToExtent(item.id);
|
|
1656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1657
|
+
"div",
|
|
1658
|
+
{
|
|
1659
|
+
className: import_twind12.tw`z-20 p-3 bg-white`,
|
|
1660
|
+
style: { borderTop: "1px solid #e5e7eb" },
|
|
1661
|
+
children: [
|
|
1662
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: import_twind12.tw`flex gap-3`, children: [
|
|
1663
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: import_twind12.tw`flex-shrink-0`, children: [
|
|
1664
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1665
|
+
CheckboxInput,
|
|
1666
|
+
{
|
|
1667
|
+
name: item.id,
|
|
1668
|
+
checked: isAdded,
|
|
1669
|
+
onChange: onToggleLayer,
|
|
1670
|
+
isLoading
|
|
1671
|
+
}
|
|
1672
|
+
),
|
|
1673
|
+
extended && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DragHandle, { dragHandleProps })
|
|
1674
|
+
] }),
|
|
1675
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1676
|
+
"img",
|
|
1677
|
+
{
|
|
1678
|
+
className: import_twind12.tw`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,
|
|
1679
|
+
src: item.thumbnail || FALLBACK_THUMB
|
|
1680
|
+
}
|
|
1681
|
+
),
|
|
1682
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { children: [
|
|
1683
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1684
|
+
"div",
|
|
1685
|
+
{
|
|
1686
|
+
title: item.title,
|
|
1687
|
+
className: import_twind12.tw`mb-1 leading-tight`,
|
|
1688
|
+
style: overflowStyle,
|
|
1689
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Highlighted, { text: item.title, highlight: query.term })
|
|
1690
|
+
}
|
|
1691
|
+
),
|
|
1692
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1693
|
+
"p",
|
|
1694
|
+
{
|
|
1695
|
+
title: item.description,
|
|
1696
|
+
className: import_twind12.tw`text-gray-600 text-sm`,
|
|
1697
|
+
style: overflowStyle2,
|
|
1698
|
+
children: item.description
|
|
1699
|
+
}
|
|
1700
|
+
)
|
|
1701
|
+
] })
|
|
1702
|
+
] }),
|
|
1703
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: import_twind12.tw`flex justify-between`, children: [
|
|
1704
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Button, { onClick: onDownloadLayer, disabled: !item.isDownloadable, children: [
|
|
1705
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DownloadIcon, {}),
|
|
1706
|
+
" ",
|
|
1707
|
+
t("download")
|
|
1708
|
+
] }),
|
|
1709
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: import_twind12.tw`flex gap-3`, children: [
|
|
1710
|
+
shareData && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_web_share.RWebShare, { data: shareData, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { title: "Share", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ShareIcon, {}) }) }),
|
|
1711
|
+
extended && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1712
|
+
Button,
|
|
1713
|
+
{
|
|
1714
|
+
onClick: handleOnZoom,
|
|
1715
|
+
title: "Zoom To Extent",
|
|
1716
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ZoomExtentIcon, {})
|
|
1717
|
+
}
|
|
1718
|
+
),
|
|
1719
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PopoverWrapper, { item })
|
|
1720
|
+
] })
|
|
1721
|
+
] }),
|
|
1722
|
+
extended && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(LayerItemStyle, { item }),
|
|
1723
|
+
extended && item.source.type === "grid" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(GridLegend, { item })
|
|
1724
|
+
]
|
|
1725
|
+
}
|
|
1726
|
+
);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
// src/components/sidebar/layers/layer-list.tsx
|
|
1730
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1731
|
+
function LayerList() {
|
|
1732
|
+
const { layer, query } = useLayers();
|
|
1733
|
+
const filteredLayers = (0, import_react8.useMemo)(
|
|
1734
|
+
() => query.term ? layer.all.filter(
|
|
1735
|
+
(_l) => _l.title.toLowerCase().includes(query.term.toLowerCase())
|
|
1736
|
+
) : layer.all,
|
|
1737
|
+
[layer.all, query.term]
|
|
1738
|
+
);
|
|
1739
|
+
const parentRef = import_react8.default.useRef();
|
|
1740
|
+
const rowVirtualizer = (0, import_react_virtual.useVirtual)({
|
|
1741
|
+
size: filteredLayers.length,
|
|
1742
|
+
parentRef
|
|
1743
|
+
});
|
|
1744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: import_twind13.tw`flex-grow-1 relative`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_virtualized_auto_sizer.AutoSizer, { disableWidth: true, children: (p) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1745
|
+
"div",
|
|
1746
|
+
{
|
|
1747
|
+
ref: parentRef,
|
|
1748
|
+
className: "List",
|
|
1749
|
+
style: { height: p.height, overflow: "auto" },
|
|
1750
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1751
|
+
"div",
|
|
1752
|
+
{
|
|
1753
|
+
style: {
|
|
1754
|
+
height: rowVirtualizer.totalSize,
|
|
1755
|
+
width: "100%",
|
|
1756
|
+
position: "relative"
|
|
1757
|
+
},
|
|
1758
|
+
children: rowVirtualizer.virtualItems.map((virtualRow) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1759
|
+
"div",
|
|
1760
|
+
{
|
|
1761
|
+
ref: virtualRow.measureRef,
|
|
1762
|
+
className: import_twind13.tw`absolute top-0 left-0 w-full`,
|
|
1763
|
+
style: { transform: `translateY(${virtualRow.start}px)` },
|
|
1764
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { height: 146 }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(LayerItem, { item: filteredLayers[virtualRow.index] }) })
|
|
1765
|
+
},
|
|
1766
|
+
virtualRow.index
|
|
1767
|
+
))
|
|
1768
|
+
}
|
|
1769
|
+
)
|
|
1770
|
+
}
|
|
1771
|
+
) }) });
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// src/components/sidebar/layers/search.tsx
|
|
1775
|
+
var import_naksha_commons9 = require("@biodiv-platform/naksha-commons");
|
|
1776
|
+
var import_twind14 = require("twind");
|
|
1777
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1778
|
+
function LayerSearch() {
|
|
1779
|
+
const { t } = (0, import_naksha_commons9.useT)();
|
|
1780
|
+
const { query } = useLayers();
|
|
1781
|
+
const handleOnSearchChange = (e) => query.setTerm(e.target.value);
|
|
1782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: import_twind14.tw`flex-shrink-0 border-b-2 p-4`, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1783
|
+
SearchInput,
|
|
1784
|
+
{
|
|
1785
|
+
name: "lyr_search",
|
|
1786
|
+
placeholder: t("find_layer_by_name"),
|
|
1787
|
+
onChange: handleOnSearchChange
|
|
1788
|
+
}
|
|
1789
|
+
) });
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
// src/components/sidebar/layers/index.tsx
|
|
1793
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1794
|
+
function LayersTabPanel() {
|
|
1795
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: import_twind15.tw`flex flex-col w-full`, children: [
|
|
1796
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LayerSearch, {}),
|
|
1797
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LayerList, {})
|
|
1798
|
+
] });
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
// src/utils/array-move.ts
|
|
1802
|
+
function arrayMoveMutable(array, fromIndex, toIndex) {
|
|
1803
|
+
const startIndex = fromIndex < 0 ? array.length + fromIndex : fromIndex;
|
|
1804
|
+
if (startIndex >= 0 && startIndex < array.length) {
|
|
1805
|
+
const endIndex = toIndex < 0 ? array.length + toIndex : toIndex;
|
|
1806
|
+
const [item] = array.splice(fromIndex, 1);
|
|
1807
|
+
array.splice(endIndex, 0, item);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
function arrayMoveImmutable(array, fromIndex, toIndex) {
|
|
1811
|
+
array = [...array];
|
|
1812
|
+
arrayMoveMutable(array, fromIndex, toIndex);
|
|
1813
|
+
return array;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
// src/components/sidebar/selected/selected-item-list.tsx
|
|
1817
|
+
var import_core9 = require("@dnd-kit/core");
|
|
1818
|
+
var import_sortable = require("@dnd-kit/sortable");
|
|
1819
|
+
var import_utilities = require("@dnd-kit/utilities");
|
|
1820
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1821
|
+
function SortableSelectedItem({ item, extended }) {
|
|
1822
|
+
const {
|
|
1823
|
+
attributes,
|
|
1824
|
+
listeners,
|
|
1825
|
+
setNodeRef,
|
|
1826
|
+
transform,
|
|
1827
|
+
transition,
|
|
1828
|
+
isDragging
|
|
1829
|
+
} = (0, import_sortable.useSortable)({
|
|
1830
|
+
id: item.id
|
|
1831
|
+
});
|
|
1832
|
+
const style = {
|
|
1833
|
+
transform: import_utilities.CSS.Transform.toString(transform),
|
|
1834
|
+
transition,
|
|
1835
|
+
opacity: isDragging ? 0.5 : 1
|
|
1836
|
+
};
|
|
1837
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { ref: setNodeRef, style, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1838
|
+
LayerItem,
|
|
1839
|
+
{
|
|
1840
|
+
item,
|
|
1841
|
+
extended,
|
|
1842
|
+
dragHandleProps: { ...attributes, ...listeners }
|
|
1843
|
+
}
|
|
1844
|
+
) });
|
|
1845
|
+
}
|
|
1846
|
+
var SelectedItemList = ({
|
|
1847
|
+
layerList,
|
|
1848
|
+
onSortEnd
|
|
1849
|
+
}) => {
|
|
1850
|
+
const sensors = (0, import_core9.useSensors)(
|
|
1851
|
+
(0, import_core9.useSensor)(import_core9.PointerSensor, { activationConstraint: { distance: 4 } })
|
|
1852
|
+
);
|
|
1853
|
+
const handleDragEnd = (event) => {
|
|
1854
|
+
const { active, over } = event;
|
|
1855
|
+
if (over && active.id !== over.id) {
|
|
1856
|
+
const oldIndex = layerList.findIndex((item) => item.id === active.id);
|
|
1857
|
+
const newIndex = layerList.findIndex((item) => item.id === over.id);
|
|
1858
|
+
if (oldIndex !== -1 && newIndex !== -1) {
|
|
1859
|
+
onSortEnd({ oldIndex, newIndex });
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1864
|
+
import_core9.DndContext,
|
|
1865
|
+
{
|
|
1866
|
+
sensors,
|
|
1867
|
+
collisionDetection: import_core9.closestCenter,
|
|
1868
|
+
onDragEnd: handleDragEnd,
|
|
1869
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1870
|
+
import_sortable.SortableContext,
|
|
1871
|
+
{
|
|
1872
|
+
items: layerList.map((item) => item.id),
|
|
1873
|
+
strategy: import_sortable.verticalListSortingStrategy,
|
|
1874
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: layerList.map((item) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SortableSelectedItem, { item, extended: true }, item.id)) })
|
|
1875
|
+
}
|
|
1876
|
+
)
|
|
1877
|
+
}
|
|
1878
|
+
);
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
// src/components/sidebar/selected/index.tsx
|
|
1882
|
+
var import_naksha_commons10 = require("@biodiv-platform/naksha-commons");
|
|
1883
|
+
var import_twind16 = require("twind");
|
|
1884
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1885
|
+
function SelectedTabPanel() {
|
|
1886
|
+
const { layer } = useLayers();
|
|
1887
|
+
const { t } = (0, import_naksha_commons10.useT)();
|
|
1888
|
+
const onSortEnd = ({ oldIndex, newIndex }) => {
|
|
1889
|
+
layer.setSelectedIds(
|
|
1890
|
+
arrayMoveImmutable(layer.selectedIds, oldIndex, newIndex)
|
|
1891
|
+
);
|
|
1892
|
+
};
|
|
1893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: import_twind16.tw`flex flex-col gap-3 w-full`, children: [
|
|
1894
|
+
layer.selectedIds.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: import_twind16.tw`p-3 pb-0`, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Button, { onClick: () => layer.clearAll(), children: [
|
|
1895
|
+
"\u2715 ",
|
|
1896
|
+
t("clear")
|
|
1897
|
+
] }) }),
|
|
1898
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1899
|
+
SelectedItemList,
|
|
1900
|
+
{
|
|
1901
|
+
layerList: layer.selectedLayers,
|
|
1902
|
+
useDragHandle: true,
|
|
1903
|
+
onSortEnd
|
|
1904
|
+
}
|
|
1905
|
+
)
|
|
1906
|
+
] });
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
// src/components/sidebar/settings/index.tsx
|
|
1910
|
+
var import_naksha_commons11 = require("@biodiv-platform/naksha-commons");
|
|
1911
|
+
var import_twind17 = require("twind");
|
|
1912
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1913
|
+
function SettingsTabPanel() {
|
|
1914
|
+
const { layer } = useLayers();
|
|
1915
|
+
const { t } = (0, import_naksha_commons11.useT)();
|
|
1916
|
+
const handleOnStyleChange = (e) => {
|
|
1917
|
+
layer.setMapStyle(e.target.value);
|
|
1918
|
+
layer.setMaxZoom(
|
|
1919
|
+
layer.mapStyles.find((ms) => ms.style === e.target.value)?.maxZoom
|
|
1920
|
+
);
|
|
1921
|
+
};
|
|
1922
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: import_twind17.tw`w-full p-4 flex flex-col gap-4`, children: [
|
|
1923
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1924
|
+
SelectInput,
|
|
1925
|
+
{
|
|
1926
|
+
name: "base_style",
|
|
1927
|
+
label: t("base_style"),
|
|
1928
|
+
defaultValue: layer.mapStyle,
|
|
1929
|
+
onChange: handleOnStyleChange,
|
|
1930
|
+
children: layer.mapStyles.map((ms) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", { value: ms.style, children: ms.text }, ms.key))
|
|
1931
|
+
}
|
|
1932
|
+
),
|
|
1933
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(LayerSelection, {})
|
|
1934
|
+
] });
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
// src/components/sidebar/tabs.tsx
|
|
1938
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1939
|
+
function SidebarTabs({ onClose }) {
|
|
1940
|
+
const { t } = (0, import_naksha_commons12.useT)();
|
|
1941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1942
|
+
"div",
|
|
1943
|
+
{
|
|
1944
|
+
className: import_twind18.tw`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,
|
|
1945
|
+
children: [
|
|
1946
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CloseButton, { onClick: onClose }),
|
|
1947
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: import_twind18.tw`flex flex-col h-full`, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_tabs.Tabs, { children: [
|
|
1948
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(TabHeader, { children: [
|
|
1949
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(IconTab, { icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LayersIcon, {}), children: t("layers") }),
|
|
1950
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(IconTab, { icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LayersIcon, {}), children: t("selected") }),
|
|
1951
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(IconTab, { icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SlidersIcon, {}), children: t("settings") })
|
|
1952
|
+
] }),
|
|
1953
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LayersTabPanel, {}) }),
|
|
1954
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SelectedTabPanel, {}) }),
|
|
1955
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SettingsTabPanel, {}) })
|
|
1956
|
+
] }) })
|
|
1957
|
+
]
|
|
1958
|
+
}
|
|
1959
|
+
);
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
// src/components/sidebar/index.tsx
|
|
1963
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1964
|
+
function Sidebar() {
|
|
1965
|
+
const { mp, layer } = useLayers();
|
|
1966
|
+
const [isOpen, setIsOpen] = (0, import_react9.useState)(mp.showToC);
|
|
1967
|
+
const { mapl } = (0, import_maplibre2.useMap)();
|
|
1968
|
+
const toggleOpen = () => setIsOpen(!isOpen);
|
|
1969
|
+
async function loadToC() {
|
|
1970
|
+
const _layers = await axGetGeoserverLayers(
|
|
1971
|
+
mp.nakshaEndpointToken,
|
|
1972
|
+
mp.nakshaApiEndpoint,
|
|
1973
|
+
mp.geoserver,
|
|
1974
|
+
mp.selectedLayers
|
|
1975
|
+
);
|
|
1976
|
+
const _newLayers = [...mp.layers || [], ..._layers];
|
|
1977
|
+
layer.setAll(_newLayers);
|
|
1978
|
+
if (layer.selectedIds.length) {
|
|
1979
|
+
const _layer = _newLayers.find((l) => l.id === layer.selectedIds[0]);
|
|
1980
|
+
_layer?.bbox && mapl?.fitBounds(_layer.bbox, { padding: 40, duration: 1e3 });
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
(0, import_react9.useEffect)(() => {
|
|
1984
|
+
if (mapl && mp.loadToC) {
|
|
1985
|
+
loadToC();
|
|
1986
|
+
}
|
|
1987
|
+
}, [mapl]);
|
|
1988
|
+
return isOpen ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SidebarTabs, { onClose: toggleOpen }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(LayersButton, { onClick: toggleOpen });
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
// src/components/map/layers/index.tsx
|
|
1992
|
+
var import_maplibre6 = require("react-map-gl/maplibre");
|
|
1993
|
+
|
|
1994
|
+
// src/components/map/layers/grid/index.tsx
|
|
1995
|
+
var import_bbox = __toESM(require("@turf/bbox"), 1);
|
|
1996
|
+
var import_react10 = require("react");
|
|
1997
|
+
var import_maplibre3 = require("react-map-gl/maplibre");
|
|
1998
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1999
|
+
function GridLayer({
|
|
2000
|
+
data,
|
|
2001
|
+
beforeId
|
|
2002
|
+
}) {
|
|
2003
|
+
const { layer } = useLayers();
|
|
2004
|
+
const { mapl } = (0, import_maplibre3.useMap)();
|
|
2005
|
+
const [layerData, setLayerData] = (0, import_react10.useState)({ geojson: {}, paint: {} });
|
|
2006
|
+
const isSelected = layer.selectedIds.includes(data.id);
|
|
2007
|
+
const isLastSelected = layer.selectedIds[0] === data.id;
|
|
2008
|
+
const fetchGridData = async (shouldFitBounds = false) => {
|
|
2009
|
+
const { success, geojson, paint: paint2, stops, squareSize } = await getGridLayerData(
|
|
2010
|
+
data.source.fetcher,
|
|
2011
|
+
mapl?.getBounds(),
|
|
2012
|
+
mapl?.getZoom()
|
|
2013
|
+
);
|
|
2014
|
+
if (success) {
|
|
2015
|
+
setLayerData({ geojson, paint: paint2 });
|
|
2016
|
+
if (shouldFitBounds && isLastSelected && data.zoomToFit) {
|
|
2017
|
+
try {
|
|
2018
|
+
const [minLon, minLat, maxLon, maxLat] = (0, import_bbox.default)(geojson);
|
|
2019
|
+
mapl?.fitBounds(
|
|
2020
|
+
[
|
|
2021
|
+
[minLon, minLat],
|
|
2022
|
+
[maxLon, maxLat]
|
|
2023
|
+
],
|
|
2024
|
+
{ padding: 40, animate: true }
|
|
2025
|
+
);
|
|
2026
|
+
} catch (e) {
|
|
2027
|
+
console.warn("Failed to compute bbox", e);
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
layer.setGridLegends({
|
|
2031
|
+
[data.id]: { stops, squareSize }
|
|
2032
|
+
});
|
|
2033
|
+
}
|
|
2034
|
+
};
|
|
2035
|
+
(0, import_react10.useEffect)(() => {
|
|
2036
|
+
if (isSelected && isLastSelected) {
|
|
2037
|
+
fetchGridData(true);
|
|
2038
|
+
} else if (isSelected) {
|
|
2039
|
+
fetchGridData(false);
|
|
2040
|
+
}
|
|
2041
|
+
}, [isSelected, isLastSelected]);
|
|
2042
|
+
(0, import_react10.useEffect)(() => {
|
|
2043
|
+
if (!isSelected || !mapl) return;
|
|
2044
|
+
const handleIdle = () => fetchGridData(false);
|
|
2045
|
+
mapl.on("idle", handleIdle);
|
|
2046
|
+
return () => {
|
|
2047
|
+
mapl.off("idle", handleIdle);
|
|
2048
|
+
};
|
|
2049
|
+
}, [isSelected, mapl]);
|
|
2050
|
+
(0, import_react10.useEffect)(() => {
|
|
2051
|
+
return () => {
|
|
2052
|
+
layer.setGridLegends((prev) => {
|
|
2053
|
+
const newLegends = { ...prev };
|
|
2054
|
+
delete newLegends[data.id];
|
|
2055
|
+
return newLegends;
|
|
2056
|
+
});
|
|
2057
|
+
};
|
|
2058
|
+
}, [data.id]);
|
|
2059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_maplibre3.Source, { id: data.id, type: "geojson", data: layerData.geojson, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2060
|
+
import_maplibre3.Layer,
|
|
2061
|
+
{
|
|
2062
|
+
beforeId,
|
|
2063
|
+
id: data.id,
|
|
2064
|
+
type: "fill",
|
|
2065
|
+
paint: layerData.paint
|
|
2066
|
+
}
|
|
2067
|
+
) });
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
// src/components/map/layers/vector/index.tsx
|
|
2071
|
+
var import_react11 = require("react");
|
|
2072
|
+
var import_maplibre4 = require("react-map-gl/maplibre");
|
|
2073
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2074
|
+
var paint = {
|
|
2075
|
+
fill: {
|
|
2076
|
+
"line-color": "red",
|
|
2077
|
+
"line-width": 2
|
|
2078
|
+
},
|
|
2079
|
+
circle: {
|
|
2080
|
+
"circle-stroke-color": "red",
|
|
2081
|
+
"circle-stroke-width": 2,
|
|
2082
|
+
"circle-opacity": 0
|
|
2083
|
+
}
|
|
2084
|
+
};
|
|
2085
|
+
function VectorLayer({ layer: data, beforeId }) {
|
|
2086
|
+
const { layer } = useLayers();
|
|
2087
|
+
const layerProps = (0, import_react11.useMemo)(
|
|
2088
|
+
() => data.data?.styles?.[data.data?.styleIndex]?.colors,
|
|
2089
|
+
[data, layer.selectedFeatures]
|
|
2090
|
+
);
|
|
2091
|
+
const highlightData = layer.selectedFeaturesId?.[data.id];
|
|
2092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_maplibre4.Source, { ...data.source, children: [
|
|
2093
|
+
layerProps && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_maplibre4.Layer, { beforeId, ...layerProps }),
|
|
2094
|
+
highlightData && layerProps && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2095
|
+
import_maplibre4.Layer,
|
|
2096
|
+
{
|
|
2097
|
+
...layerProps,
|
|
2098
|
+
beforeId,
|
|
2099
|
+
id: `hl_${data.id}`,
|
|
2100
|
+
filter: ["in", PROPERTY_ID, ...highlightData],
|
|
2101
|
+
type: layerProps.type === "fill" ? "line" : layerProps.type,
|
|
2102
|
+
paint: paint[layerProps.type]
|
|
2103
|
+
}
|
|
2104
|
+
)
|
|
2105
|
+
] });
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
// src/components/map/layers/raster/index.tsx
|
|
2109
|
+
var import_maplibre5 = require("react-map-gl/maplibre");
|
|
2110
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2111
|
+
function RasterLayer({
|
|
2112
|
+
data,
|
|
2113
|
+
beforeId
|
|
2114
|
+
}) {
|
|
2115
|
+
const { mp } = useLayers();
|
|
2116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2117
|
+
import_maplibre5.Source,
|
|
2118
|
+
{
|
|
2119
|
+
id: data.id,
|
|
2120
|
+
type: "raster",
|
|
2121
|
+
tiles: [
|
|
2122
|
+
`${mp?.geoserver?.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${data.id}`
|
|
2123
|
+
],
|
|
2124
|
+
tileSize: 256,
|
|
2125
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2126
|
+
import_maplibre5.Layer,
|
|
2127
|
+
{
|
|
2128
|
+
id: data.id,
|
|
2129
|
+
beforeId,
|
|
2130
|
+
type: "raster",
|
|
2131
|
+
source: "biodiv",
|
|
2132
|
+
layout: { visibility: "visible" },
|
|
2133
|
+
paint: {}
|
|
2134
|
+
}
|
|
2135
|
+
)
|
|
2136
|
+
}
|
|
2137
|
+
);
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
// src/components/map/layers/index.tsx
|
|
2141
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2142
|
+
function MapLayer({
|
|
2143
|
+
layer,
|
|
2144
|
+
beforeId
|
|
2145
|
+
}) {
|
|
2146
|
+
const { mapl } = (0, import_maplibre6.useMap)();
|
|
2147
|
+
if (!mapl) {
|
|
2148
|
+
return null;
|
|
2149
|
+
}
|
|
2150
|
+
switch (layer.source.type) {
|
|
2151
|
+
case "vector":
|
|
2152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(VectorLayer, { beforeId, layer });
|
|
2153
|
+
case "grid":
|
|
2154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(GridLayer, { beforeId, data: layer });
|
|
2155
|
+
case "raster":
|
|
2156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(RasterLayer, { beforeId, data: layer });
|
|
2157
|
+
default:
|
|
2158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(VectorLayer, { beforeId, layer });
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
// src/components/map/markers-list/index.tsx
|
|
2163
|
+
var import_react12 = require("react");
|
|
2164
|
+
var import_maplibre7 = require("react-map-gl/maplibre");
|
|
2165
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2166
|
+
var Marker1 = import_maplibre7.Marker;
|
|
2167
|
+
var MarkersList = () => {
|
|
2168
|
+
const { mp } = useLayers();
|
|
2169
|
+
const markersMemoized = (0, import_react12.useMemo)(() => mp.markers, [mp.markers]);
|
|
2170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: markersMemoized?.map(
|
|
2171
|
+
({ latitude, longitude, colorHex, anchor = "bottom", iconUrl }, index) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2172
|
+
Marker1,
|
|
2173
|
+
{
|
|
2174
|
+
latitude,
|
|
2175
|
+
longitude,
|
|
2176
|
+
anchor,
|
|
2177
|
+
subpixelPositioning: true,
|
|
2178
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2179
|
+
"img",
|
|
2180
|
+
{
|
|
2181
|
+
style: {
|
|
2182
|
+
cursor: "pointer",
|
|
2183
|
+
display: "block",
|
|
2184
|
+
width: "25px",
|
|
2185
|
+
height: "41px"
|
|
2186
|
+
},
|
|
2187
|
+
width: 25,
|
|
2188
|
+
height: 41,
|
|
2189
|
+
alt: "Marker",
|
|
2190
|
+
src: iconUrl || "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"
|
|
2191
|
+
}
|
|
2192
|
+
)
|
|
2193
|
+
},
|
|
2194
|
+
index
|
|
2195
|
+
)
|
|
2196
|
+
) });
|
|
2197
|
+
};
|
|
2198
|
+
var markers_list_default = MarkersList;
|
|
2199
|
+
|
|
2200
|
+
// src/components/map/popup/index.tsx
|
|
2201
|
+
var import_clsx3 = __toESM(require("clsx"), 1);
|
|
2202
|
+
var import_maplibre8 = require("react-map-gl/maplibre");
|
|
2203
|
+
var import_twind19 = require("twind");
|
|
2204
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
2205
|
+
var Pop = import_maplibre8.Popup;
|
|
2206
|
+
function HoverPopup({ coordinates }) {
|
|
2207
|
+
const { hover } = useLayers();
|
|
2208
|
+
return coordinates?.lat && hover.features ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2209
|
+
Pop,
|
|
2210
|
+
{
|
|
2211
|
+
latitude: coordinates.lat,
|
|
2212
|
+
longitude: coordinates.lng,
|
|
2213
|
+
closeButton: false,
|
|
2214
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("table", { className: import_twind19.tw`table-auto border`, children: [
|
|
2215
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("th", { className: import_twind19.tw`bg-gray-200 py-1 px-2`, colSpan: 2, children: hover.features.title }) }) }),
|
|
2216
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("tbody", { children: hover.features.data.map(([k, v], idx) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
2217
|
+
"tr",
|
|
2218
|
+
{
|
|
2219
|
+
className: (0, import_twind19.tw)(
|
|
2220
|
+
(0, import_clsx3.default)({
|
|
2221
|
+
"bg-gray-50": idx % 2 === 0,
|
|
2222
|
+
"border-gray-100 border-t": 1
|
|
2223
|
+
})
|
|
2224
|
+
),
|
|
2225
|
+
children: [
|
|
2226
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("td", { className: import_twind19.tw`py-1 px-2`, children: k }),
|
|
2227
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("td", { className: import_twind19.tw`py-1 px-2 border-l border-gray-100`, children: v })
|
|
2228
|
+
]
|
|
2229
|
+
},
|
|
2230
|
+
k + v
|
|
2231
|
+
)) })
|
|
2232
|
+
] })
|
|
2233
|
+
}
|
|
2234
|
+
) : null;
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
// src/components/map/index.tsx
|
|
2238
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
2239
|
+
var NavControl = import_maplibre9.NavigationControl;
|
|
2240
|
+
function Map2() {
|
|
2241
|
+
const { mp, layer, hover, query } = useLayers();
|
|
2242
|
+
const [coordinates, setCoordinates] = (0, import_react13.useState)();
|
|
2243
|
+
const viewState = (0, import_react13.useMemo)(
|
|
2244
|
+
() => mp.defaultViewState || import_naksha_commons13.defaultViewState,
|
|
2245
|
+
[mp.defaultViewState]
|
|
2246
|
+
);
|
|
2247
|
+
const onMapClick = (e) => query.setClickedLngLat(e.lngLat);
|
|
2248
|
+
const handleOnMouseMove = (event) => {
|
|
2249
|
+
setCoordinates(event.lngLat);
|
|
2250
|
+
hover.onHover(event);
|
|
2251
|
+
};
|
|
2252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: import_twind20.tw`h-full w-full relative bg-gray-100`, children: [
|
|
2253
|
+
mp.loadToC && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Sidebar, {}),
|
|
2254
|
+
layer.selectedFeatures?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(InfoBar, {}),
|
|
2255
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
2256
|
+
import_maplibre9.default,
|
|
2257
|
+
{
|
|
2258
|
+
id: "mapl",
|
|
2259
|
+
cursor: "default",
|
|
2260
|
+
initialViewState: viewState,
|
|
2261
|
+
style: { width: "100%", height: "100%" },
|
|
2262
|
+
mapStyle: layer.mapStyle,
|
|
2263
|
+
maxZoom: layer.maxZoom,
|
|
2264
|
+
onClick: onMapClick,
|
|
2265
|
+
onMouseMove: handleOnMouseMove,
|
|
2266
|
+
children: [
|
|
2267
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2268
|
+
NavControl,
|
|
2269
|
+
{
|
|
2270
|
+
position: "bottom-right",
|
|
2271
|
+
showZoom: true,
|
|
2272
|
+
showCompass: true
|
|
2273
|
+
}
|
|
2274
|
+
),
|
|
2275
|
+
mp.showFullscreenControl && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_maplibre9.FullscreenControl, { position: "bottom-right" }),
|
|
2276
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(markers_list_default, {}),
|
|
2277
|
+
layer.selectedLayers.map((_l, index) => {
|
|
2278
|
+
const beforeId = index > 0 ? layer.selectedIds[index - 1] : void 0;
|
|
2279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(MapLayer, { layer: _l, beforeId }, _l.id);
|
|
2280
|
+
}),
|
|
2281
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(HoverPopup, { coordinates }, "popup")
|
|
2282
|
+
]
|
|
2283
|
+
}
|
|
2284
|
+
)
|
|
2285
|
+
] });
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
// src/index.tsx
|
|
2289
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
2290
|
+
(0, import_twind21.setup)({ preflight: false });
|
|
2291
|
+
var NakshaMaplibreLayers = (props) => {
|
|
2292
|
+
const mp = import_react14.default.useMemo(
|
|
2293
|
+
() => ({ ...defaultNakshaProps, ...props }),
|
|
2294
|
+
[props]
|
|
2295
|
+
);
|
|
2296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_maplibre10.MapProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_naksha_commons14.TranslationProvider, { localeStrings: locales_default, lang: mp.lang, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(LayersProvider, { mp, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Map2, {}) }) }) });
|
|
2297
|
+
};
|
|
2298
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2299
|
+
0 && (module.exports = {
|
|
2300
|
+
NakshaMaplibreLayers
|
|
2301
|
+
});
|