12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527 |
- window.maps = {};
- window.panels = {};
- window.utils = {};
- window.Q = {};
- var allLayers = new Map();
- var map, crs, resultLayer, TempLayer;
- var mapLayer = null,lableLayer = null, subLayers , plotting, plottingLayer, drawMapControl, drawLayer;
- var url = URL_CONFIG.GX_Map_BaseUrl, dataUrl = URL_CONFIG.GX_Datas_BaseUrl, serverUrl = URL_CONFIG.GX_Plot_BaseUrl,
- spatialanalystUrl = URL_CONFIG.GX_Spatialanalyst_BaseUrl, drawType = "",
- transportationAnalystUrl = URL_CONFIG.GX_TransportationAnalyst_BaseUrl;
- $(document).ready(function() {
- layui.use(['layer'], function() {
- let layer = layui.layer;
- layer.config({
- extend: 'cool/cool.css'
- });
- });
- onload();
- $('#tool-clickQuery').click(function() {
- clearLays();
- clickQuery();
- });
- $('#tool-dis').click(function() {
- clearLays();
- measureDistance();
- });
- $('#tool-area').click(function() {
- clearLays();
- measureArea();
- });
- $('#tool-clear').click(function() {
- clearLays();
- });
- $('#tool-CircleQuery').click(function() {
- clearLays();
- drawCircle();
- });
- $('#tool-SquarenessQuery').click(function() {
- clearLays();
- drawRectangle();
- });
- $('#tool-ScopeQuery').click(function() {
- clearLays();
- drawPolygon();
- });
- $('#tool-layerCtrl').click(function(e) {
- clearLays();
- panels.openLayerTreePanel();
- });
- $('#tool-fullscreen').click(function() {
- toggleFullScreen();
- });
- $('#tool-dmfx').click(function() {
- clearLays();
- dmfx();
- });
- $('#tool-kwLine').click(function(e) {
- clearLays();
- pzfx();
- });
- $('#tool-ftfx').click(function(e) {
- clearLays();
- ftfx();
- });
- $('#tool-ltfx').click(function(e) {
- clearLays();
- ltfx();
- });
- $('#tool-layerEdit').click(function(e) {
- clearLays();
- layerEdit();
- });
- });
- function onload() {
- layui.use('element', function() {});
- panels.regEvents();
- panels.setDateTime();
- loadLayerTrees();
- $("#load_bg").remove(); //关闭加载动画
- $(".load_box").remove();
- }
- panels.setDateTime = function() {
- setInterval(() => {
- let dt = new Date();
- let yyyymmdd = dt.getFullYear() + " " + (dt.getMonth() + 1) + " " + dt.getDate();
- let sec = dt.getSeconds();
- sec = sec < 10 ? "0" + sec : sec + "";
- let time = (dt.getHours() < 12 ? "上午" : "下午") + " " + dt.getHours() + ":" + dt.getMinutes() + ":" + sec;
- $('.datetime .time').html(time);
- $('.datetime .date').html(yyyymmdd);
- }, 1000);
- }
- panels.menuLevel = {};
- panels.regEvents = function() {
- $('.query-type-enum div').click(function(e) {
- $('.query-type-enum div').removeClass("query-type-enum-select");
- $(this).addClass("query-type-enum-select");
- $("#queryType-subType").html('');
- if (panels.lastResultPanelIndex != undefined) {
- layui.layer.close(panels.lastResultPanelIndex);
- layui.layer.closeAll();
- }
- panels.menuLevel[panels.menuLevel.L1] = this;
- let id = $(this).find('span').attr('qs-name');
- if (id == undefined) return;
- $("#queryType-subType").html($(this).find('span').html());
- let htmlUrl = "/pipeline/bs/" + id + ".html";
- $.ajax({
- url: htmlUrl,
- success: function(htmlContext) {
- $('.queryConditionsContainer').html('');
- $('.queryConditionsContainer').html(htmlContext);
- layui.use(['form'], function() {
- let form = layui.form;
- form.render();
- });
- },
- error: function() {
- $('.queryConditionsContainer').html('');
- layui.layer.msg('功能未实现!', {
- icon: 7
- });
- }
- });
- });
- $('.head-menus span').click(function(e) {
- if (panels.lastResultPanelIndex != undefined) {
- layui.layer.close(panels.lastResultPanelIndex);
- layui.layer.closeAll();
- }
- $("#queryType-subType").html('未选择类型');
- $(".query-type-enum div").removeClass('query-type-enum-select ');
- let selected = $(this).hasClass('head-menus-menu-select');
- $('.head-menus span').removeClass('head-menus-menu-select');
- if (!selected) {
- $(this).addClass('head-menus-menu-select');
- $('.q-s-icon').removeClass('qs-hidden');
- } else {
- $('.q-s-icon').addClass('qs-hidden');
- $('.q-s-type').addClass('qs-hidden');
- }
- let qureyOrStatics = $(this).hasClass('qs-q');
- //点击了查询按钮
- if (qureyOrStatics) {
- panels.menuLevel.L1 = 2;
- $('.qs-q').removeClass('qs-hidden');
- $('.qs-s').addClass('qs-hidden');
- } else {
- panels.menuLevel.L1 = 1;
- $('.qs-s').removeClass('qs-hidden');
- $('.qs-q').addClass('qs-hidden');
- }
- if (panels.menuLevel[panels.menuLevel.L1] != undefined) {
- $(panels.menuLevel[panels.menuLevel.L1]).trigger('click');
- }
- $('.queryConditionsContainer').html('');
- });
- $("#cdts-ctrl").click(function(e) {
- var notDisplayCdts = $(this).find('img').eq(0).hasClass('qs-hidden');
- if (notDisplayCdts) {
- $(this).find('img').eq(0).removeClass('qs-hidden');
- $(this).find('img').eq(1).addClass('qs-hidden');
- $('.q-s-type').addClass('qs-hidden');
- } else {
- $(this).find('img').eq(1).removeClass('qs-hidden');
- $(this).find('img').eq(0).addClass('qs-hidden');
- $('.q-s-type').removeClass('qs-hidden');
- }
- });
- }
- function loadLayerTrees () {
- proj4.defs("EPSG:4549","+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
- // crs = L.Proj.CRS("EPSG:4549",{
- // bounds: L.bounds([384751.09,3977225.45], [558877.26,4071961.92]),
- // origin:[384751.09,4071961.92],
- // });
- // var pt = crs.unproject(L.point(395917.83 , 4060264.75));
- // map = L.map('cesiumContainer', {
- // preferCanvas: true,
- // crs: crs,
- // center:[pt.lat,pt.lng],
- // zoom: 5,
- // logoControl: false,
- // attributionControl: false
- // });
- // mapLayer = L.supermap.tiledMapLayer(url, {noWrap: true});
- // map.addLayer(mapLayer);
- // 添加地图服务
- crs = L.Proj.CRS("EPSG:4549");
- map = L.map('cesiumContainer', {
- preferCanvas: true,
- center: [45.507908,124.290565],
- zoom: 14,
- crs: L.CRS.TianDiTu_WGS84
- });
- mapLayer = L.supermap.tiandituTileLayer({
- key: "1d109683f4d84198e37a38c442d68311"
- });
- map.addLayer(mapLayer);
- lableLayer = L.supermap.tiandituTileLayer({
- isLabel: true,
- key: "1d109683f4d84198e37a38c442d68311"
- });
- map.addLayer(lableLayer);
- var thisLayer = {};
- thisLayer.layer = mapLayer;
- thisLayer.isShow = true;
- allLayers.set("baseMap",thisLayer)
- var lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- var lyrid = lyr.id;
- var dataSourceName = lyr.dataSourceName;
- var dataSetName = lyr.dataSetName;
- addLayerData(dataSourceName,dataSetName,lyrid,"");
- }
- // 添加鹰眼
- var osm2 = L.supermap.tiandituTileLayer({
- key: "1d109683f4d84198e37a38c442d68311"
- });
- // var osm2 = L.supermap.tiledMapLayer(url, {minZoom: 0, maxZoom: 13,noWrap: true});
- L.control.minimap(osm2, {mapOptions:{ logoControl: false},toggleDisplay: true}).addTo(map);
- // 添加比例尺
- L.control.scale().addTo(map);
- // 启动绘制功能
- InitDraw();
- map.on('zoomend', function(e) {
- var nowZoom = e.target.getZoom();
- var lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- var layId = lyr.id;
- var showZoom = lyr.showZoom;
- if(showZoom == undefined || showZoom == 0){
- continue;
- }
- var thisLayer = allLayers.get(layId);
- var isShow = thisLayer.isShow;
- var layTmp = thisLayer.layer;
- if(nowZoom >= showZoom){
- if(isShow && !map.hasLayer(layTmp)){
- map.addLayer(layTmp);
- }
- }
- else{
- if(isShow && map.hasLayer(layTmp)){
- map.removeLayer(layTmp);
- }
- }
- }
- });
- resultLayer = L.featureGroup().addTo(map);
- TempLayer = L.featureGroup().addTo(map);
- $('body').append("<div id='layerTree' ></div>");
- let openThePanel = function() {
- if ($("#layerTree").html().length > 0) {
- panels.loadLayerTreePanelByDom('layerTree');
- return;
- }
- panels.loadLayerTreePanelByDom('layerTree', function() {
- var allLayersTemp = [];
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- var nodeLayerInScene = {
- title: lyr.name,
- id: lyr.id,
- layer: lyr,
- checked: true
- };
- allLayersTemp.push(nodeLayerInScene);
- }
- var nodeLayerInScene = {
- title: "地图服务",
- id: "baseMap",
- layer: mapLayer,
- checked: true
- };
- allLayersTemp.push(nodeLayerInScene);
- layui.use('tree', function() {
- const tree = layui.tree;
- tree.render({
- elem: '#layerTree',
- data: allLayersTemp,
- showCheckbox: true,
- showLine: true,
- oncheck: function(obj) {
- var layId = obj.data.id;
- var thisLayer = allLayers.get(layId);
- var layTmp = thisLayer.layer;
- if(obj.checked){
- if(!map.hasLayer(layTmp)){
- map.addLayer(layTmp);
- thisLayer.isShow = true;
- allLayers.set(layId,thisLayer);
- if(layId == "baseMap" && lableLayer != null){
- map.addLayer(lableLayer);
- }
- }
- }
- else{
- if(map.hasLayer(layTmp)){
- map.removeLayer(layTmp);
- thisLayer.isShow = false;
- allLayers.set(layId,thisLayer);
- if(layId == "baseMap" && lableLayer != null){
- map.removeLayer(lableLayer);
- }
- }
- }
- // 重新指定一下中心点,解决不刷新图层的问题
- map.panTo(map.getCenter());
- }
- });
- });
- });
- }
- panels.openLayerTreePanel = openThePanel;
- }
- function addLayerData(dataSourceName,dataSetName,lyrid,showCss) {
- Q.queryBySql(dataSetName, dataSourceName, "SmID > 0", 0, 2000000, "", function(rs) {
- if (rs.result == undefined) return;
- var result = L.Util.transform(rs.result.features, crs, L.CRS.EPSG4326);
- var rsLayer;
- var thisLayer = {};
- if(lyrid == "waterLine"){
- rsLayer = L.geoJSON(result,{style:{color: "#070af3"}});
- map.addLayer(rsLayer);
- }
- else{
- var circleStyle = layerStyles.get(lyrid);
- var graphics = [];
- //设置每个点的经纬度和传入样式
- for(var i = 0; i < result.features.length; i++)
- {
- var feature = result.features[i];
- var coordinates = feature.geometry.coordinates;
- var pointVector = L.supermap.graphic({
- latLng: L.latLng(coordinates[1], coordinates[0]),
- style: circleStyle.getStyle()
- });
- graphics.push(pointVector)
- }
- //将管点要素画在地图上
- rsLayer = L.supermap.graphicLayer(graphics, {render: "canvas"});
- }
- thisLayer.layer = rsLayer;
- thisLayer.isShow = true;
- allLayers.set(lyrid,thisLayer);
- });
- }
- panels.loadLayerTreePanelByDom = function(domID, callback) {
- layui.use('layer', function() {
- const layer = layui.layer;
- panels.layerTreePanelIndex = layer.open({
- anim: 3,
- id: 'layerTreePanel',
- area: "280px",
- skin: 'layui-ext-coolskin',
- title: ["全部图层", 'font-size:14px;'],
- offset: ['65px', panels.SideWidth() + 5 + "px"],
- shade: 0,
- type: 1,
- content: $('#' + domID), //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function() {},
- success: function(layero, index) {}
- });
- if (callback != undefined) {
- callback();
- }
- });
- }
- panels.SideWidth = function() {
- return $(".layui-side").width();
- }
- /**
- * 点选查询
- */
- function clickQuery() {
- let lyrs = CONST_VALUES.GX_Datas;
- let lyrsSelect = '<div id="layers" class="layui-form queryConditionsContainer" lay-filter="lyrsSelectDiv"><div class="layui-form-item"><div class="layui-input-block" style="margin-left:30px">';
- let listStr = "<input type=\'checkbox\' name=\'THENAME\' title=\'THETITLE\' id=\'THEID\' lay-skin=\'primary\' dataSetName=\'THEDATASETNAME\' dataSourceName=\'THEWS\'>";
- for (let index = 0; index < lyrs.length; index++) {
- const lyr = lyrs[index];
- let dom = listStr.replace('THENAME', lyr.name);
- dom = dom.replace('THETITLE', lyr.name);
- dom = dom.replace('THEID', lyr.id);
- dom = dom.replace('THEWS', lyr.dataSourceName);
- dom = dom.replace('THEDATASETNAME', lyr.dataSetName);
- lyrsSelect += dom;
- }
- lyrsSelect += '</div></div></div>';
- layui.use('layer', function() {
- let layer = layui.layer;
- layer.open({
- id: "panel-layerSelect",
- type: 1,
- area: ["300px", "220px"],
- btn: ['确定'],
- title: "请选择图层",
- skin: 'layui-ext-coolskin',
- content: lyrsSelect, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function(index, layero) {
- layer.close(index);
- },
- yes: function(e) {
- var layers = $("#layers input:checked");
- if (layers.length == 0) {
- layer.msg('请至少选择一个图层!', {icon: 7});
- return;
- }
- layer.close(e);
- map.on('click', function (evt) {
- var pt = crs.project(evt.latlng);
- var _Point = L.marker([pt.y, pt.x]);
- for (var index = 0; index < layers.length; index++) {
- if(index == layers.length-1){
- map.off("click");
- }
- let checked = layers[index].checked;
- if (!checked)
- continue;
- var ws = layers[index].attributes.dataSourceName.value;
- var dataSetName = layers[index].attributes.dataSetName.value;
- var thatsubtitleP = layers[index].title;
- clicQueryProcess(thatsubtitleP, dataSetName, ws, _Point);
- }
- });
- }
- });
- layui.use(['form'], function() {
- let form = layui.form;
- form.render();
- });
- });
- }
- function clicQueryProcess(subtitle, dataSetName, ws, _Point) {
- Q.queryByGeometry(subtitle,undefined,dataSetName, ws, _Point, function(result) {
- if (result.result == undefined) return;
- panels.createResultPanelWithDataGrid({
- subTitle: subtitle,
- features: result.result.features.features,
- title: "点击查询结果",
- //count: count,
- dataSetName: dataSetName,
- dataSourceName: ws
- }, function() {
- });
- // 坐标系转换
- var result = L.Util.transform(result.result.features, crs, L.CRS.EPSG4326);
- L.geoJSON(result, {
- style:{color: "#ef5b9c"},
- onEachFeature: function (feature, layer) {
- let attributes = "";
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(ws == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- let attValue = feature.properties[colArr[0]];
- let attr = colArr[1] + ":" + attValue + "<br>";
- attributes += attr;
- }
- }
- break;
- }
- }
- layer.bindPopup(attributes);
- }
- }).addTo(resultLayer);
- });
- }
- /*距离测量*/
- function measureDistance() {
- map.off('click');
- map.off('dblclick');
- $("#tips").css('display', 'block');
- var isFirstPoint = true; //判断是否是起始点
- var latLngTemp = null;//存储上一点击点临时变量
- var resultDis = 0; //总距
- map.on('click', function(ev) {
- TempLayer.clearLayers();
- $("#tips").css('display', 'none');
- var polyLine;
- if(isFirstPoint) {
- L.marker([ev.latlng.lat, ev.latlng.lng]).addTo(resultLayer); //起始点
- var texticon = L.divIcon({ //定义图标
- html: "起点",
- iconSize: [30, 20],
- iconAnchor: [15, 0]
- });
- L.marker([ev.latlng.lat, ev.latlng.lng], {
- icon: texticon
- }).addTo(resultLayer); //marker实现文本框显示
- latLngTemp = ev.latlng; //存储上一点击点
- isFirstPoint = false;
- } else {
- if(!latLngTemp.equals(ev.latlng)) { //避免出现结束双击,导致距离为0
- polyLine = L.polyline([ //与上一点连线
- [latLngTemp.lat, latLngTemp.lng],
- [ev.latlng.lat, ev.latlng.lng]
- ], {
- color: "red"
- });
- resultLayer.addLayer(polyLine);
- L.marker([ev.latlng.lat, ev.latlng.lng]).addTo(resultLayer); // 最后点击点经纬度
- var from = turf.point([latLngTemp.lng, latLngTemp.lat]);
- var to = turf.point([ev.latlng.lng, ev.latlng.lat]);
- var options = {units: 'kilometers'};
- var jl11 = turf.distance(from, to, options) * 1000;
- latLngTemp = ev.latlng; //更新临时变量为新点
- resultDis += jl11;
- // 距离根据地图单位进行换算成米或者千米
- var content = "距上点:" + Number(jl11).toFixed(2) + "米" + "<br>总距:" + Number(resultDis).toFixed(2) + "米";
- var texticon = L.divIcon({
- html: content,
- iconSize: [110, 40],
- iconAnchor: [55, -5] //设置标签偏移避免遮盖
- });
- L.marker([ev.latlng.lat, ev.latlng.lng], {
- icon: texticon
- }).addTo(resultLayer);
- TempLayer.clearLayers();
- }
- }
- map.on("mousemove", function(ev) {
- TempLayer.clearLayers();
- var TempLine = L.polyline([ //虚线临时线段
- [latLngTemp.lat, latLngTemp.lng],
- [ev.latlng.lat, ev.latlng.lng]
- ], {
- color: "red",
- dashArray: "5,5"
- });
- TempLayer.addLayer(TempLine);
- // 对坐标系进行转换
- var pt1 = crs.project(latLngTemp);
- var pt2 = crs.project(ev.latlng);
- var TempLineDis = L.polyline([ //与上一点连线
- [pt1.y, pt1.x],
- [pt2.y, pt2.x]
- ]);
- var from = turf.point([latLngTemp.lng, latLngTemp.lat]);
- var to = turf.point([ev.latlng.lng, ev.latlng.lat]);
- var options = {units: 'kilometers'};
- var jl11 = turf.distance(from, to, options) * 1000;
- var texticon = L.divIcon({
- html: Number(jl11).toFixed(2) + "米",
- iconSize: 90,
- className: 'my-div-icon',
- iconAnchor: [45, -5]
- });
- L.marker([ev.latlng.lat, ev.latlng.lng], {
- icon: texticon
- }).addTo(TempLayer);
- });
- });
- map.on('dblclick', function(ev) {
- map.off('click');
- map.off('dblclick');
- map.off('mousemove');
- });
- }
- /*面积测量*/
- function measureArea() {
- drawType = "measureArea";
- // 创建绘制控件,并启用
- var handler = new L.Draw.Polygon(map);
- handler.enable();
- map.on(L.Draw.Event.CREATED,function (e) {
- if(drawType != "measureArea"){
- return;
- }
- var type = e.layerType,
- layer = e.layer;
- if (type === 'marker') {
- layer.bindPopup('A popup!');
- }
- //将图形信息传给下一步,进行查询功能
- var locationArray = e.layer.getLatLngs()[0];
- var polygonArray = Array();
- var turfPolygonArray = Array();
- var midArray = Array();
- var turfMidArray = Array();
- var firstX = locationArray[0].lat;
- var firstY = locationArray[0].lng;
- for(var i =0;i<locationArray.length;i++){
- var x = locationArray[i].lat;
- var y = locationArray[i].lng;
- midArray.push(x);
- midArray.push(y);
- turfMidArray.push(y);
- turfMidArray.push(x);
- polygonArray.push(midArray);
- turfPolygonArray.push(turfMidArray);
- midArray = Array();
- turfMidArray = Array();
- }
- midArray.push(firstX);
- midArray.push(firstY);
- turfMidArray.push(firstY);
- turfMidArray.push(firstX);
- polygonArray.push(midArray);
- turfPolygonArray.push(turfMidArray);
- var polygon = L.polygon(polygonArray, {color: "#00FF00"});
- var polygonTurf = turf.polygon([turfPolygonArray]);
- var area = turf.area(polygonTurf);
- resultLayer.addLayer(polygon);
- var content = "面积:" + Number(area).toFixed(2) + "平方米";
- polygon.bindPopup(content).openPopup(polygon.getCenter());
- });
- }
- /**
- * 清除量算
- */
- function clearLays() {
- resultLayer.clearLayers();
- TempLayer.clearLayers();
- plottingLayer.removeFeatures(drawLayer);
- }
- panels.createResultPanelWithDataGrid = function(params, callback) {
- layui.use('layer', function() {
- if (params.features.length == 0) {
- layui.layer.msg(params.title + "下" + params.subTitle + '查询无结果。<br>请重新设置查询条件!');
- return -1;
- }
- var layer = layui.layer;
- panels.createPanelBase(layer,params.title);
- panels.createPagesByFeatures(params);
- if (callback != undefined) {
- callback();
- }
- });
- }
- panels.createPanelBase = function(layer,title, resizeCb) {
- //兼容两个页面
- let pc = $("#panel-condition");
- let theTarget;
- if (pc.length > 0) {
- theTarget = pc.parent();
- } else {
- theTarget = $(".q-s-type");
- }
- const conditionLeft = parseInt(theTarget.css("left").replace('px', ''));
- const conditionWidth = parseInt(theTarget.width());
- const conditionHeight = parseInt(theTarget.height());
- const conditionTop = parseInt(theTarget.css("top").replace('px', ''));
- let x = conditionLeft + conditionWidth + 5 + "px";
- let y = conditionTop + conditionHeight + 10 + "px";
- let offset = ['65px'];
- if (pc.length === 0) {
- x = conditionLeft + "px";
- offset = [y, x]
- }
- panels.lastResultPanelIndex = layer.open({
- id: "panel-result",
- anim: 3,
- area: ['412px', '400px'],
- title: "<span class='q-title-in-Sub-img'></span><span class='q-title-in-Sub-title'>" + title + "</span>",
- skin: 'layui-ext-coolskin',
- offset: offset,
- shade: 0,
- type: 1,
- maxmin: true,
- resizing: function(layero) {
- if (resizeCb)
- resizeCb(layero);
- },
- full:function(layero){
- if (resizeCb)
- resizeCb(layero);
- },
- restore:function(layero){
- if (resizeCb)
- resizeCb(layero);
- },
- success: function(layero, index) {}
- });
- }
- panels.createPagesByFeatures = function(params) {
- panels.createMonitor();
- let subTitle = params.subTitle;
- let features = params.features;
- let dataSourceName = params.dataSourceName;
- let dataSetName = params.dataSetName;
- if (features.length == 0) return;
- let tableNew = "<table id='THETABLEID' lay-filter='THETABLEID'></table>";
- const tableNewID = utils.guid();
- while (tableNew.indexOf('THETABLEID') > -1)
- tableNew = tableNew.replace('THETABLEID', tableNewID);
- let cols = [];
- var showZoom = 10;
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(dataSourceName == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- showZoom = lyr.showZoom;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- cols.push({ field: colArr[0], title: colArr[1], sort: true, width: 80 });
- }
- }
- break;
- }
- }
- if(cols.length == 0){
- for (const property in features[0].properties) {
- let tmpProperty = property.toUpperCase();
- if (tmpProperty.startsWith("SM") && tmpProperty != "SMID")
- continue;
- if (tmpProperty.startsWith("SS"))
- continue;
- cols.push({ field: property, title: property, sort: true });
- }
- }
- let datas = [];
- for (let i in features) {
- datas.push(features[i].properties);
- }
- let tabControl = "<div class='layui-tab' lay-filter='resultTabControl' id='THETABCONTROLID'>" +
- "<ul class='layui-tab-title'></ul>" +
- "<div class='layui-tab-content'></div></div>";
- let tabControlID = utils.guid();
- tabControl = tabControl.replace('THETABCONTROLID', tabControlID);
- if ($('div[lay-filter="resultTabControl"]').length == 0) {
- $(tabControl).appendTo($("#panel-result"));
- }
- layui.use('element', function() {
- let element = layui.element;
- element.render();
- let tabID = utils.guid();
- element.tabAdd('resultTabControl', {
- title: subTitle,
- content: tableNew //支持传入html
- ,
- id: tabID
- });
- layui.use('table', function() {
- let table = layui.table;
- table.render({
- elem: '#' + tableNewID,
- data: datas,
- page: true,
- "lay-size": 'sm',
- limit: 6,
- done:function (res, curr, count){
- $("table").css("width", "100%");
- },
- cols: [cols],
- // toolbar: true,
- // totalrow: true,
- // title: '导出结果'
- });
- table.on('row(' + tableNewID + ')', function(obj) {
- Q.queryBySql(dataSetName, dataSourceName, "SMID = " + obj.data.SMID, 0, 10, "", function(result) {
- if (result.result == undefined) return;
- // 坐标系转换
- var result = L.Util.transform(result.result.features, crs, L.CRS.EPSG4326);
- L.geoJSON(result, {
- style:{color: "#f80202"},
- onEachFeature: function (feature, layer) {
- if(feature.geometry.type == 'Point'){
- map.flyTo(layer._latlng, showZoom);
- }
- else{
- map.flyToBounds(layer._bounds);
- }
- let attributes = "";
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(dataSourceName == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- let attValue = feature.properties[colArr[0]];
- let attr = colArr[1] + ":" + attValue + "<br>";
- attributes += attr;
- }
- }
- break;
- }
- }
- layer.bindPopup(attributes);
- }
- }).addTo(resultLayer);
- });
- });
- });
- element.tabChange('resultTabControl', tabID);
- const thisTitle = $('.layui-layer-title');
- thisTitle.addClass("layui-layer-title-transparent");
- });
- }
- panels.createMonitor = function() {
- if (panels.createMonitor.created == true) return;
- panels.createMonitor.created = true;
- function imitateClick(oElement, iClientX, iClientY) {
- var oEvent;
- if (document.createEventObject) { //For IE
- oEvent = document.createEventObject();
- oEvent.clientX = iClientX;
- oEvent.clientY = iClientY;
- oElement.fireEvent("onclick", oEvent);
- } else {
- oEvent = document.createEvent("MouseEvents");
- oEvent.initMouseEvent("click", true, true, window, 0, 0, 0, iClientX, iClientY);
- oElement.dispatchEvent(oEvent);
- }
- }
- panels.createMonitor.moniter = imitateClick;
- }
- utils.guid = function() {
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
- let r = Math.random() * 16 | 0,
- v = c == 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- });
- }
- Q.queryBySql = function(datasetName, wsName, sql, fromIndex, toIndex, aggregations, callback) {
- let sqlParam = new SuperMap.GetFeaturesBySQLParameters({
- queryParameter: {
- name: datasetName + "@" + wsName,
- attributeFilter: sql
- },
- datasetNames: [wsName + ":" + datasetName],
- fromIndex: fromIndex,
- toIndex: toIndex,
- maxFeatures: toIndex
- });
- L.supermap.featureService(dataUrl).getFeaturesBySQL(sqlParam,
- function(serviceResult) {
- if (callback != undefined) {
- callback(serviceResult)
- }
- });
- }
- Q.queryByBounds = function(title,datasetName, wsName, bounds, callback) {
- var paramsTmp = {};
- paramsTmp.title = title;
- paramsTmp.dataSetName = datasetName;
- paramsTmp.dataSourceName = wsName;
- var geometryParam = new SuperMap.GetFeaturesByGeometryParameters({
- datasetNames: [wsName + ":" + datasetName],
- geometry: bounds,
- spatialQueryMode: "INTERSECT"
- });
- L.supermap
- .featureService(dataUrl)
- .getFeaturesByGeometry(geometryParam, function (serviceResult) {
- if (callback != undefined) {
- callback(serviceResult,paramsTmp)
- }
- });
- }
- Q.queryByGeometry = function(title,distanceTmp,datasetName, wsName, geometry, callback) {
- var paramsTmp = {};
- paramsTmp.title = title;
- paramsTmp.dataSetName = datasetName;
- paramsTmp.dataSourceName = wsName;
- if(distanceTmp == undefined){
- distanceTmp = CONST_VALUES.QUERY_BufferDistance;
- }
- var bufferParam = new SuperMap.GetFeaturesByBufferParameters({
- datasetNames: [wsName + ":" + datasetName],
- bufferDistance: distanceTmp,
- geometry: geometry
- });
- L.supermap
- .featureService(dataUrl)
- .getFeaturesByBuffer(bufferParam, function (serviceResult) {
- if (callback != undefined) {
- callback(serviceResult,paramsTmp)
- }
- });
- }
- function InitDraw() {
- // 创建一个名为“plottingLayer”的标绘图层。
- plottingLayer = L.supermap.plotting.plottingLayer("plot", serverUrl);
- // 向map中添加标绘图层
- plottingLayer.addTo(map);
- // 标绘控件
- drawMapControl = L.supermap.plotting.drawControl(plottingLayer);
- drawMapControl.addTo(map);
- plotting = L.supermap.plotting.getControl(map, serverUrl);
- drawMapControl.on(SuperMap.Plot.Event.featureadded, function (event) {
- drawLayer = event.feature;
- var symbolType = drawLayer.symbolType;
- if (symbolType === SuperMap.Plot.SymbolType.ARBITRARYPOLYGONSYMBOL) {
- }
- else if (symbolType === SuperMap.Plot.SymbolType.CIRCLESYMBOL) {
- var latLngs = drawLayer.getLatLngs();
- var pt = crs.project(latLngs[0]);
- var _Point = L.marker([pt.y, pt.x]);
- var dataSourceName = CONST_VALUES.GX_DataSourceName;
- var dataSetName = CONST_VALUES.GX_DataSetName;
- var bufferParam = new SuperMap.GetFeaturesByBufferParameters({
- datasetNames: [dataSourceName + ":" + dataSetName],
- bufferDistance: CONST_VALUES.QUERY_BufferDistance,
- geometry: _Point
- });
- // 判断点击的点是否在管线上
- L.supermap
- .featureService(dataUrl)
- .getFeaturesByBuffer(bufferParam, function (result) {});
- }
- else if (symbolType === SuperMap.Plot.SymbolType.RECTANGLESYMBOL) {
- }
- // 覆土分析
- if(drawType == "FTFX"){
- ftfxProcess(drawLayer);
- }
- else{
- let lyrs = CONST_VALUES.GX_Datas;
- let lyrsSelect = '<div id="layers" class="layui-form queryConditionsContainer" lay-filter="lyrsSelectDiv"><div class="layui-form-item"><div class="layui-input-block" style="margin-left:30px">';
- let listStr = "<input type=\'checkbox\' name=\'THENAME\' title=\'THETITLE\' id=\'THEID\' lay-skin=\'primary\' dataSetName=\'THEDATASETNAME\' dataSourceName=\'THEWS\'>";
- for (let index = 0; index < lyrs.length; index++) {
- const lyr = lyrs[index];
- let dom = listStr.replace('THENAME', lyr.name);
- dom = dom.replace('THETITLE', lyr.name);
- dom = dom.replace('THEID', lyr.id);
- dom = dom.replace('THEWS', lyr.dataSourceName);
- dom = dom.replace('THEDATASETNAME', lyr.dataSetName);
- lyrsSelect += dom;
- }
- lyrsSelect += '</div></div></div>';
- layui.use('layer', function() {
- let layer = layui.layer;
- layer.open({
- id: "panel-layerSelect",
- type: 1,
- area: ["300px", "220px"],
- btn: ['确定'],
- title: "请选择图层",
- skin: 'layui-ext-coolskin',
- content: lyrsSelect, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function(index, layero) {
- layer.close(index);
- },
- yes: function(e) {
- var layers = $("#layers input:checked");
- if (layers.length == 0) {
- layer.msg('请至少选择一个图层!', {
- icon: 7
- });
- return;
- }
- layer.close(e);
- // 矩形查询
- if (symbolType === SuperMap.Plot.SymbolType.RECTANGLESYMBOL) {
- var rectangleTemp = L.Util.transform(drawLayer._bounds, L.CRS.EPSG4326, crs);
- var ptArrayTemp = rectangleTemp.geometry.coordinates[0];
- var ptArray = Array();
- for(var i = 0; i < ptArrayTemp.length; i++) {
- var tempArr = ptArrayTemp[i];
- var ptTemp = Array();
- ptTemp.push(tempArr[1]);
- ptTemp.push(tempArr[0]);
- ptArray.push(ptTemp);
- }
- var polygonTmp = L.polygon(ptArray);
- for (var index = 0; index < layers.length; index++) {
- let checked = layers[index].checked;
- if (!checked)
- continue;
- var ws = layers[index].attributes.dataSourceName.value;
- var dataSetName = layers[index].attributes.dataSetName.value;
- var thatsubtitleP = layers[index].title;
- Q.queryByBounds(thatsubtitleP, dataSetName, ws, polygonTmp, function(result,titleTmp) {
- if (result.result == undefined) return;
- panels.createResultPanelWithDataGrid({
- subTitle: titleTmp.title,
- features: result.result.features.features,
- title: "范围查询结果",
- //count: count,
- dataSetName: titleTmp.dataSetName,
- dataSourceName: titleTmp.dataSourceName
- }, function() {
- //debugger;
- });
- // 坐标系转换
- // var result = L.Util.transform(result.result.features, crs, L.CRS.EPSG4326);
- //
- // L.geoJSON(result, {
- // style:{color: "red"},
- // onEachFeature: function (feature, layer) {
- // let attributes = "";
- // let lyrs = CONST_VALUES.GX_Datas;
- // for (var index = 0; index < lyrs.length; index++) {
- // var lyr = lyrs[index];
- // if(ws == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- // var showCols = lyr.cols;
- // if(showCols != undefined && showCols != ""){
- // var colsArr = showCols.split(",");
- // for(var i = 0; i < colsArr.length; i++){
- // var colArr = colsArr[i].split(":");
- // let attValue = feature.properties[colArr[0]];
- // let attr = colArr[1] + ":" + attValue + "<br>";
- // attributes += attr;
- // }
- // }
- // break;
- // }
- // }
- // layer.bindPopup(attributes);
- // }
- // }).addTo(resultLayer);
- });
- }
- }
- else if (symbolType === SuperMap.Plot.SymbolType.CIRCLESYMBOL) {
- var latLngs = drawLayer.getLatLngs();
- var from = turf.point([latLngs[0].lng, latLngs[0].lat]);
- var to = turf.point([latLngs[1].lng, latLngs[1].lat]);
- var options = {units: 'kilometers'};
- var jl11 = turf.distance(from, to, options) * 1000;
- var pt = crs.project(latLngs[0]);
- var _Point = L.marker([pt.y, pt.x]);
- var radius = Math.sqrt(Math.pow((latLngs[1].lng - latLngs[0].lng)*1000, 2) + Math.pow((latLngs[1].lat - latLngs[0].lat)*1000, 2));
- for (var index = 0; index < layers.length; index++) {
- let checked = layers[index].checked;
- if (!checked)
- continue;
- var ws = layers[index].attributes.dataSourceName.value;
- var dataSetName = layers[index].attributes.dataSetName.value;
- var thatsubtitleP = layers[index].title;
- var bufferParam = new SuperMap.GetFeaturesByBufferParameters({
- datasetNames: [ws + ":" + dataSetName],
- bufferDistance: jl11,
- geometry: _Point
- });
- Q.queryByGeometry(thatsubtitleP, jl11, dataSetName, ws, _Point, function(result,titleTmp) {
- if (result.result == undefined) return;
- panels.createResultPanelWithDataGrid({
- subTitle: titleTmp.title,
- features: result.result.features.features,
- title: "范围查询结果",
- //count: count,
- dataSetName: titleTmp.dataSetName,
- dataSourceName: titleTmp.dataSourceName
- }, function() {
- });
- // 坐标系转换
- // var result = L.Util.transform(result.result.features, crs, L.CRS.EPSG4326);
- //
- // L.geoJSON(result, {
- // style:{color: "red"},
- // onEachFeature: function (feature, layer) {
- // let attributes = "";
- // let lyrs = CONST_VALUES.GX_Datas;
- // for (var index = 0; index < lyrs.length; index++) {
- // var lyr = lyrs[index];
- // if(ws == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- // var showCols = lyr.cols;
- // if(showCols != undefined && showCols != ""){
- // var colsArr = showCols.split(",");
- // for(var i = 0; i < colsArr.length; i++){
- // var colArr = colsArr[i].split(":");
- // let attValue = feature.properties[colArr[0]];
- // let attr = colArr[1] + ":" + attValue + "<br>";
- // attributes += attr;
- // }
- // }
- // break;
- // }
- // }
- // layer.bindPopup(attributes);
- // }
- // }).addTo(resultLayer);
- })
- }
- }
- }
- });
- layui.use(['form'], function() {
- let form = layui.form;
- form.render();
- });
- });
- }
- drawMapControl.handler.disable();
- });
- }
- function polygonQueryProcess(subtitle, dataSetName, ws, bounds) {
- Q.queryByBounds(subtitle, dataSetName, ws, bounds, function(result,titleTmp) {
- if (result.result == undefined) return;
- panels.createResultPanelWithDataGrid({
- subTitle: titleTmp.title,
- features: result.result.features.features,
- title: "范围查询结果",
- //count: count,
- dataSetName: titleTmp.dataSetName,
- dataSourceName: titleTmp.dataSourceName
- }, function() {
- });
- // 坐标系转换
- var result = L.Util.transform(result.result.features, crs, L.CRS.EPSG4326);
- L.geoJSON(result, {
- style:{color: "red"},
- onEachFeature: function (feature, layer) {
- let attributes = "";
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(ws == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- let attValue = feature.properties[colArr[0]];
- let attr = colArr[1] + ":" + attValue + "<br>";
- attributes += attr;
- }
- }
- break;
- }
- }
- layer.bindPopup(attributes);
- }
- }).addTo(resultLayer);
- });
- }
- // 范围查询
- function drawPolygon() {
- drawType = "drawPolygon";
- var handler = new L.Draw.Polygon(map);
- handler.enable();
- map.on(L.Draw.Event.CREATED,function (e) {
- if (drawType != "drawPolygon") {
- return;
- }
- //将图形信息传给下一步,进行查询功能
- var locationArray = e.layer.getLatLngs()[0];
- var polygonArray = Array();
- var midArray = Array();
- var polygonArrayTmp = Array();
- var midArrayTmp = Array();
- var firstX = locationArray[0].lat;
- var firstY = locationArray[0].lng;
- for (var i = 0; i < locationArray.length; i++) {
- var pt2 = crs.project(locationArray[i]);
- var x = locationArray[i].lat;
- var y = locationArray[i].lng;
- midArray.push(x);
- midArray.push(y);
- polygonArray.push(midArray);
- midArray = Array();
- midArrayTmp.push(pt2.y);
- midArrayTmp.push(pt2.x);
- polygonArrayTmp.push(midArrayTmp);
- midArrayTmp = Array();
- }
- midArray.push(firstX);
- midArray.push(firstY);
- polygonArray.push(midArray);
- var pt2 = crs.project(locationArray[0]);
- midArrayTmp.push(pt2.y);
- midArrayTmp.push(pt2.x);
- polygonArrayTmp.push(midArrayTmp);
- var polygonTmp = L.polygon(polygonArrayTmp);
- var polygon = L.polygon(polygonArray, {color: "#00FF00"});
- resultLayer.addLayer(polygon);
- let lyrs = CONST_VALUES.GX_Datas;
- //debugger;
- let lyrsSelect = '<div id="layers" class="layui-form queryConditionsContainer" lay-filter="lyrsSelectDiv"><div class="layui-form-item"><div class="layui-input-block" style="margin-left:30px">';
- let listStr = "<input type=\'checkbox\' name=\'THENAME\' title=\'THETITLE\' id=\'THEID\' lay-skin=\'primary\' dataSetName=\'THEDATASETNAME\' dataSourceName=\'THEWS\'>";
- for (let index = 0; index < lyrs.length; index++) {
- const lyr = lyrs[index];
- let dom = listStr.replace('THENAME', lyr.name);
- dom = dom.replace('THETITLE', lyr.name);
- dom = dom.replace('THEID', lyr.id);
- dom = dom.replace('THEWS', lyr.dataSourceName);
- dom = dom.replace('THEDATASETNAME', lyr.dataSetName);
- lyrsSelect += dom;
- }
- lyrsSelect += '</div></div></div>';
- layui.use('layer', function() {
- let layer = layui.layer;
- layer.open({
- id: "panel-layerSelect",
- type: 1,
- area: ["300px", "220px"],
- btn: ['确定'],
- title: "请选择图层",
- skin: 'layui-ext-coolskin',
- content: lyrsSelect, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function(index, layero) {
- layer.close(index);
- },
- yes: function(e) {
- var layers = $("#layers input:checked");
- if (layers.length == 0) {
- layer.msg('请至少选择一个图层!', {
- icon: 7
- });
- return;
- }
- layer.close(e);
- for (var index = 0; index < layers.length; index++) {
- let checked = layers[index].checked;
- if (!checked)
- continue;
- var ws = layers[index].attributes.dataSourceName.value;
- var dataSetName = layers[index].attributes.dataSetName.value;
- var thatsubtitleP = layers[index].title;
- Q.queryByBounds(thatsubtitleP,dataSetName, ws, polygonTmp, function(result,titleTmp) {
- if (result.result == undefined) return;
- panels.createResultPanelWithDataGrid({
- subTitle: titleTmp.title,
- features: result.result.features.features,
- title: "范围查询结果",
- //count: count,
- dataSetName: titleTmp.dataSetName,
- dataSourceName: titleTmp.dataSourceName
- }, function() {
- //debugger;
- });
- // 坐标系转换
- // var result = L.Util.transform(result.result.features, crs, L.CRS.EPSG4326);
- //
- // L.geoJSON(result, {
- // style:{color: "red"},
- // onEachFeature: function (feature, layer) {
- // let attributes = "";
- // let lyrs = CONST_VALUES.GX_Datas;
- // for (var index = 0; index < lyrs.length; index++) {
- // var lyr = lyrs[index];
- // if(ws == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- // var showCols = lyr.cols;
- // if(showCols != undefined && showCols != ""){
- // var colsArr = showCols.split(",");
- // for(var i = 0; i < colsArr.length; i++){
- // var colArr = colsArr[i].split(":");
- // let attValue = feature.properties[colArr[0]];
- // let attr = colArr[1] + ":" + attValue + "<br>";
- // attributes += attr;
- // }
- // }
- // break;
- // }
- // }
- // layer.bindPopup(attributes);
- // }
- // }).addTo(resultLayer);
- });
- }
- }
- });
- layui.use(['form'], function() {
- let form = layui.form;
- form.render();
- });
- });
- });
- }
- function drawCircle() {
- drawType = "";
- setDefualtStyle();
- drawMapControl.handler.disable();
- drawMapControl.handler.libID = 0;
- drawMapControl.handler.code = 29;
- drawMapControl.handler.serverUrl = serverUrl;
- drawMapControl.handler.enable();
- }
- function drawRectangle() {
- drawType = "";
- setDefualtStyle();
- drawMapControl.handler.disable();
- drawMapControl.handler.libID = 0;
- drawMapControl.handler.code = 26;
- drawMapControl.handler.serverUrl = serverUrl;
- drawMapControl.handler.enable();
- }
- //设置选择区域的线色
- function setDefualtStyle() {
- var defualtStyle = plotting.getDefaultStyle();
- defualtStyle.defaultFlag = true;
- defualtStyle.lineColor = "#00FF00";
- defualtStyle.fillSymbolID = 0;
- defualtStyle.fillColor = "#00FF00";
- }
- function processCompleted(result,selectTitle,gx) {
- var gxArr = gx.split(":");
- panels.createResultPanelWithDataGrid({
- subTitle: selectTitle,
- features: result.features,
- title: "按范围查询结果",
- count: result.features.length,
- dataSetName: gxArr[1],
- dataSourceName: gxArr[0]
- }, function() {
- });
- }
- function toggleFullScreen() {
- var el = document.body;
- var isFullscreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
- if (!isFullscreen) { //进入全屏,多重短路表达式
- (el.requestFullscreen && el.requestFullscreen()) ||
- (el.mozRequestFullScreen && el.mozRequestFullScreen()) ||
- (el.webkitRequestFullscreen && el.webkitRequestFullscreen()) || (el.msRequestFullscreen && el.msRequestFullscreen());
- }
- else { //退出全屏,三目运算符
- document.exitFullscreen ? document.exitFullscreen() :
- document.mozCancelFullScreen ? document.mozCancelFullScreen() :
- document.webkitExitFullscreen ? document.webkitExitFullscreen() : '';
- }
- }
- panels.createResultPanelWithChart = function(xAxis, groupBy, data, title, subTitle, xTypeName, yTypeName, typeOfECharts, callback) {
- layui.use('layer', function() {
- let chart;
- let resizeCb = function(layerno) {
- if (chart == undefined) return;
- var autoHeight = $("#panel-result").height() - 100;
- chart.getDom().style.height = autoHeight + "px";
- chart.getDom().childNodes[0].style.height = autoHeight + "px";
- chart.getDom().childNodes[0].childNodes[0].setAttribute("height",autoHeight);
- chart.getDom().childNodes[0].childNodes[0].style.height = autoHeight + "px";
- var autoWidth = $("#panel-result").width();
- chart.getDom().style.width = autoWidth + "px";
- chart.getDom().childNodes[0].style.width = autoWidth + "px";
- chart.getDom().childNodes[0].childNodes[0].setAttribute("width",autoWidth);
- chart.getDom().childNodes[0].childNodes[0].style.width = autoWidth + "px";
- chart.resize();
- }
- var layer = layui.layer;
- panels.createPanelBase(layer,title, resizeCb);
- chart = panels.createChart(xAxis, groupBy,data, title, subTitle, xTypeName, yTypeName, typeOfECharts);
- panels.createChartPages(xAxis, groupBy, data);
- if (callback != undefined) {
- callback();
- }
- });
- }
- panels.createChart = function(xAxis, groupBy, data, title, subTitle, xTypeName, yTypeName, typeOfECharts) {
- if (data.length == 0) return;
- let xAxisData = [];
- for (let val in data) {
- xAxisData.push(data[val][groupBy])
- }
- let seriesData = [];
- for (let i = 0; i < xAxis.length; i++) {
- let series = {};
- series.name = xAxis[i];
- series.type = typeOfECharts;
- series.data = [];
- for (let j = 0; j < data.length; j++) {
- series.data.push(parseFloat(data[j][xAxis[i]]));
- }
- seriesData.push(series);
- }
- const chartDivID = "statistics-Chart";
- const chartDom = "<div id='" + chartDivID + "'></div>";
- let tabControl = "<div class='layui-tab' lay-filter='resultTabControl' id='THETABCONTROLID'>" +
- "<ul class='layui-tab-title'></ul>" +
- "<div class='layui-tab-content'></div></div>";
- let tabControlID = utils.guid();
- tabControl = tabControl.replace('THETABCONTROLID', tabControlID);
- if ($('div[lay-filter="resultTabControl"]').length == 0) {
- $(tabControl).appendTo($("#panel-result"));
- }
- layui.use('element', function() {
- let element = layui.element;
- element.render();
- let tabID = utils.guid();
- element.tabAdd('resultTabControl', {
- title: "统计图",
- content: chartDom //支持传入html
- ,
- id: tabID
- });
- });
- const myChart = echarts.init(document.getElementById("statistics-Chart"), null);
- // 指定图表的配置项和数据
- const option = {
- tooltip: {},
- legend: {
- bottom: '0',
- left: 'right',
- data: xAxis,
- textStyle: {
- color: "#fffffb"
- }
- },
- toolbox: {
- feature: {
- magicType: {
- type: ['line', 'bar']
- },
- saveAsImage: { pixelRatio: 2 }
- },
- iconStyle: {
- color: "#fffffb"
- }
- },
- xAxis: {
- data: xAxisData,
- name: xTypeName,
- axisLabel: {
- interval: 0,
- rotate: 30,
- color: "#fffffb",
- formatter: function(value, index) {
- return value /* + 'mm'*/ ;
- }
- }
- },
- yAxis: {
- axisLine: {
- onZero: false,
- lineStyle: {
- color: "#fffffb"
- }
- },
- name: yTypeName
- },
- series: seriesData
- };
- // 使用刚指定的配置项和数据显示图表。
- myChart.setOption(option);
- var autoHeight = $("#panel-result").height() - 100;
- myChart.getDom().style.height = autoHeight + "px";
- myChart.getDom().childNodes[0].style.height = autoHeight + "px";
- myChart.getDom().childNodes[0].childNodes[0].setAttribute("height",autoHeight);
- myChart.getDom().childNodes[0].childNodes[0].style.height = autoHeight + "px";
- var autoWidth = $("#panel-result").width();
- myChart.getDom().style.width = autoWidth + "px";
- myChart.getDom().childNodes[0].style.width = autoWidth + "px";
- myChart.getDom().childNodes[0].childNodes[0].setAttribute("width",autoWidth);
- myChart.getDom().childNodes[0].childNodes[0].style.width = autoWidth + "px";
- myChart.resize();
- const thisTitle = $('.layui-layer-title');
- thisTitle.addClass("layui-layer-title-transparent");
- return myChart;
- }
- panels.createChartPages = function(xAxis, groupBy, data) {
- if (data.length == 0) return;
- let tableNew = "<table id='THETABLEID' lay-filter='THETABLEID'></table>";
- const tableNewID = utils.guid();
- while (tableNew.indexOf('THETABLEID') > -1)
- tableNew = tableNew.replace('THETABLEID', tableNewID);
- let cols = [{ field: groupBy, title: groupBy, sort: true }];
- for (let i = 0; i < xAxis.length; i++) {
- cols.push({ field: xAxis[i], title: xAxis[i], sort: true });
- }
- let datas = data;
- let tabControl = "<div class='layui-tab' lay-filter='resultTabControl' id='THETABCONTROLID'>" +
- "<ul class='layui-tab-title'></ul>" +
- "<div class='layui-tab-content'></div></div>";
- let tabControlID = utils.guid();
- tabControl = tabControl.replace('THETABCONTROLID', tabControlID);
- if ($('div[lay-filter="resultTabControl"]').length == 0) {
- $(tabControl).appendTo($("#panel-result"));
- }
- layui.use('element', function() {
- let element = layui.element;
- element.render();
- let tabID = utils.guid();
- element.tabAdd('resultTabControl', {
- title: "统计报表",
- content: tableNew //支持传入html
- ,
- id: tabID
- });
- layui.use('table', function() {
- let table = layui.table;
- table.render({
- elem: '#' + tableNewID,
- data: datas,
- page: true,
- "lay-size": 'sm',
- limit: 6,
- done: function (res, curr, count){
- $("table").css("width", "100%");
- },
- cols: [cols]
- });
- });
- element.tabChange('resultTabControl', tabID);
- const thisTitle = $('.layui-layer-title');
- thisTitle.addClass("layui-layer-title-transparent");
- });
- }
- function dmfx(){
- map.off('click');
- //map.off('dblclick');
- $("#tips").css('display', 'block');
- var isFirstPoint = true; //判断是否是起始点
- var latLngTemp = null;//存储上一点击点临时变量
- var resultDis = 0; //总距
- map.on('click', function(ev) {
- TempLayer.clearLayers();
- $("#tips").css('display', 'none');
- var polyLine;
- if(isFirstPoint) {
- L.marker([ev.latlng.lat, ev.latlng.lng]).addTo(resultLayer); //起始点
- latLngTemp = ev.latlng; //存储上一点击点
- isFirstPoint = false;
- } else {
- if(!latLngTemp.equals(ev.latlng)) { //避免出现结束双击,导致距离为0
- L.marker([ev.latlng.lat, ev.latlng.lng]).addTo(resultLayer); //终点
- map.off('click');
- map.off('mousemove');
- polyLine = L.polyline([ //与上一点连线
- [latLngTemp.lat, latLngTemp.lng],
- [ev.latlng.lat, ev.latlng.lng]
- ], {
- color: "#00FF00"
- });
- resultLayer.addLayer(polyLine);
- // 地图上画的线
- var line1 = turf.lineString([[latLngTemp.lng, latLngTemp.lat], [ev.latlng.lng, ev.latlng.lat]]);
- var pt1 = crs.project(latLngTemp);
- var pt2 = crs.project(ev.latlng);
- var polyLineTemp = L.polyline([ //与上一点连线
- [pt1.y, pt1.x],
- [pt2.y, pt2.x]
- ]);
- var dataSourceName = CONST_VALUES.GX_DataSourceName;
- var dataSetName = CONST_VALUES.GX_DataSetName;
- // 查询管线两端点对应的数据信息
- var geometryParam = new SuperMap.GetFeaturesByGeometryParameters({
- datasetNames: [dataSourceName + ":" + dataSetName],
- geometry: polyLineTemp,
- spatialQueryMode: "INTERSECT"
- });
- L.supermap
- .featureService(dataUrl)
- .getFeaturesByGeometry(geometryParam, function (serviceResult) {
- // 坐标系转换
- var result = L.Util.transform(serviceResult.result.features, crs, L.CRS.EPSG4326);
- L.geoJSON(result, {
- style:{color: "red"},
- onEachFeature: function (feature, layer) {
- let attributes = "";
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(dataSourceName == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- let attValue = feature.properties[colArr[0]];
- let attr = colArr[1] + ":" + attValue + "<br>";
- attributes += attr;
- }
- }
- break;
- }
- }
- layer.bindPopup(attributes);
- }
- }).addTo(resultLayer);
- if(result.features.length>0){
- dmfxProcess(line1,result);
- }
- });
- }
- }
- });
- map.on("mousemove", function(ev) {
- if(latLngTemp == null){ return }
- TempLayer.clearLayers();
- var TempLine = L.polyline([ //虚线临时线段
- [latLngTemp.lat, latLngTemp.lng],
- [ev.latlng.lat, ev.latlng.lng]
- ], {
- color: "red",
- dashArray: "5,5"
- });
- TempLayer.addLayer(TempLine);
- });
- }
- function dmfxProcess(drawLint,result){
- var pts = '';
- for(var i = 0; i < result.features.length; i++)
- {
- var feature = result.features[i];
- var coordinates = feature.geometry.coordinates;
- var QSDH = feature.properties["QSDH"]; // 起始点号
- var ZDDH = feature.properties["ZDDH"]; // 终点点号
- if(i < result.features.length-1){
- pts += "'" + QSDH + "','" + ZDDH + "',";
- }
- else{
- pts += "'" + QSDH + "','" + ZDDH + "'";
- }
- }
- var sqlTemp = "BSM in (" + pts + ")";
- var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
- queryParameter: {
- name: CONST_VALUES.JD_DataSetName + "@" + CONST_VALUES.JD_DataSourceName,
- attributeFilter: sqlTemp
- },
- datasetNames: [CONST_VALUES.JD_DataSourceName + ":" + CONST_VALUES.JD_DataSetName]
- });
- L.supermap.featureService(dataUrl).getFeaturesBySQL(sqlParam, function (serviceResult) {
- if(serviceResult.result.features.features.length > 0){
- var resultData = L.Util.transform(serviceResult.result.features, crs, L.CRS.EPSG4326);
- var allData = new Array();
- var allMaxGC = 0, allMinGC = 0;
- var preX = undefined;
- var preY = undefined;
- for(var i = 0; i < result.features.length; i++){
- var feature = result.features[i];
- var coordinates = feature.geometry.coordinates;
- var gdbh = feature.properties["BSM"]; // 管段编号
- var QSDH = feature.properties["QSDH"]; // 起始点号
- var ZDDH = feature.properties["ZDDH"]; // 终点点号
- var gj = feature.properties["GJ"]; // 管径
- var smid = feature.properties["SMID"];
- // 地图上划线查询到的管线
- var line2 = turf.lineString([[coordinates[0][0], coordinates[0][1]], [coordinates[1][0], coordinates[1][1]]]);
- // 交叉点
- var intersects = turf.lineIntersect(drawLint, line2);
- var pt1Data = undefined;
- var pt2Data = undefined;
- for(var j = 0; j < resultData.features.length; j++){
- var bsm = resultData.features[j].properties["BSM"];
- if(bsm == QSDH){
- pt1Data = resultData.features[j];
- }
- else if(bsm == ZDDH){
- pt2Data = resultData.features[j];
- }
- if(pt1Data != undefined && pt2Data != undefined){
- break;
- }
- }
- if(pt1Data == undefined || pt2Data == undefined){
- continue;
- }
- var dmgcPT1 = pt1Data.properties["DMGC"] * 1; // 地面高程
- var msPT1 = pt1Data.properties["MS"] * 1; // 埋深
- var xPT1 = pt1Data.geometry.coordinates[0]; // x坐标
- var yPT1 = pt1Data.geometry.coordinates[1]; // y坐标
- var dmgcPT2 = pt2Data.properties["DMGC"] * 1; // 地面高程
- var msPT2 = pt2Data.properties["MS"] * 1; // 埋深
- var xPT2 = pt2Data.geometry.coordinates[0]; // x坐标
- var yPT2 = pt2Data.geometry.coordinates[1]; // y坐标
- var xPtTmp = intersects.features[0].geometry.coordinates[0];
- var yPtTmp = intersects.features[0].geometry.coordinates[1]
- var dmgc = undefined; // 地面高程
- var ms = undefined; // 埋深
- var gxgc = undefined; // 管线高程
- var maxGC = undefined,minGC = undefined,jl=0;
- if(dmgcPT1 == dmgcPT2){
- dmgc = dmgcPT1;
- maxGC = dmgc + 1;
- }
- else if (dmgcPT1 > dmgcPT2){
- maxGC = dmgcPT1 + 1;
- dmgc = dmgcPT2 + (dmgcPT1 - dmgcPT2) * (Math.sqrt(Math.pow((xPtTmp - xPT2), 2) + Math.pow((yPtTmp - yPT2), 2))) / (Math.sqrt(Math.pow((xPT1 - xPT2), 2) + Math.pow((yPT1 - yPT2), 2)));
- }
- else {
- maxGC = dmgcPT2 + 1;
- dmgc = dmgcPT1 + (dmgcPT2 - dmgcPT1) * (Math.sqrt(Math.pow((xPtTmp - xPT1), 2) + Math.pow((yPtTmp - yPT1), 2))) / (Math.sqrt(Math.pow((xPT2 - xPT1), 2) + Math.pow((yPT2 - yPT1), 2)));
- }
- if(msPT1 == msPT2){
- ms = msPT1;
- }
- else if(msPT1 > msPT2){
- ms = msPT2 + (msPT1 - msPT2) * (Math.sqrt(Math.pow((xPtTmp - xPT2), 2) + Math.pow((yPtTmp - yPT2), 2))) / (Math.sqrt(Math.pow((xPT1 - xPT2), 2) + Math.pow((yPT1 - yPT2), 2)));
- }
- else{
- ms = msPT1 + (msPT2 - msPT1) * (Math.sqrt(Math.pow((xPtTmp - xPT1), 2) + Math.pow((yPtTmp - yPT1), 2))) / (Math.sqrt(Math.pow((xPT2 - xPT1), 2) + Math.pow((yPT2 - yPT1), 2)));
- }
- gxgc = dmgc.toFixed(2) - ms.toFixed(2);
- minGC = gxgc - 1;
- var markerTemp = L.marker([yPtTmp, xPtTmp]).addTo(resultLayer);
- var content = "地面高程(M):" + dmgc.toFixed(2) + "<br>管线高程(M):" + gxgc.toFixed(2) + "<br>埋深(M):" + ms.toFixed(2) + "<br>管径(MM):" + gj;
- markerTemp.bindPopup(content).openPopup(markerTemp.getLatLng());
- //drawDmfx(dmgc.toFixed(2),gxgc.toFixed(2),ms.toFixed(2),gj,jl,maxGC.toFixed(2),minGC.toFixed(2),i);
- if(allMaxGC < maxGC){
- allMaxGC = maxGC.toFixed(2);
- }
- if(allMinGC == 0 || allMinGC > minGC){
- allMinGC = minGC.toFixed(2);
- }
- if(preX != undefined && preY != undefined){
- var from = turf.point([preX, preY]);
- var to = turf.point([xPtTmp, yPtTmp]);
- var options = {units: 'kilometers'};
- jl = turf.distance(from, to, options) * 1000;
- }
- preX = xPtTmp;
- preY = yPtTmp;
- var entityData = {};
- entityData.smid = smid;
- entityData.gdbh = gdbh;
- entityData.dmgc = dmgc.toFixed(2);
- entityData.dmgc = dmgc.toFixed(2);
- entityData.gxgc = gxgc.toFixed(2);
- entityData.ms = ms.toFixed(2);
- entityData.gj = gj;
- entityData.jl = jl.toFixed(2);
- entityData.maxGC = maxGC.toFixed(2);
- entityData.minGC = minGC.toFixed(2);
- allData.push(entityData);
- }
- drawDmfx(allData,allMaxGC,allMinGC);
- }
- });
- }
- // 断面分析图
- function drawDmfx(allData,allMaxGC,allMinGC){
- let lyrsSelect = '<div class="q-title-in-Sub" style="margin-top: 5px;margin-bottom: 5px;"><span class="q-title-in-Sub-img"></span><span class="qs-q">管线横断面图</span></div>';
- lyrsSelect += '<canvas id="tutorial" width="800" height="600" style="border: 1px solid white;margin:0 auto;"></canvas>';
- lyrsSelect += '<div class="q-title-in-Sub" style="margin-top: 10px;"><span class="q-title-in-Sub-img"></span><span class="qs-q">管线纵刨面图</span></div>';
- lyrsSelect += '<div id="gxlb" class="query-type-enum">';
- for(var i = 0; i < allData.length; i++){
- lyrsSelect += '<div style="margin-left:18px" onclick="drawZpm(\'' + allData[i].smid +'\')"><span>' + allData[i].gdbh + '</span></div>';
- }
- lyrsSelect += '</div>';
- layui.use('layer', function() {
- let layer = layui.layer;
- layer.open({
- id: "panel-drawDmfx",
- type: 1,
- area: ["802px", "750px"],
- title: "城市地下管线断面分析",
- skin: 'layui-ext-coolskin',
- content: lyrsSelect, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function (index, layero) {
- layer.close(index);
- }
- });
- var canvas = document.getElementById('tutorial');
- drawCanvas(canvas,allData,allMaxGC,allMinGC);
- layui.use(['form'], function() {
- let form = layui.form;
- form.render();
- });
- });
- }
- // 管线纵刨面图
- function drawZpm(smid){
- let lyrsSelect = '<canvas id="tutorialZpm" width="800" height="600" style="border: 1px solid white;margin:0 auto;"></canvas>';
- layui.use('layer', function() {
- let layer = layui.layer;
- layer.open({
- id: "panel-drawZpm",
- type: 1,
- area: ["802px", "750px"],
- title: "城市地下管线纵刨面图",
- skin: 'layui-ext-coolskin',
- content: lyrsSelect, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function (index, layero) {
- layer.close(index);
- }
- });
- var canvas = document.getElementById('tutorialZpm');
- drawCanvasZpm(canvas,smid);
- layui.use(['form'], function() {
- let form = layui.form;
- form.render();
- });
- });
- }
- // 横断面
- function drawCanvas(canvas,allData,allMaxGC,allMinGC){
- // dmgc,gxgc,ms,gj,jl,maxGC,minGC
- if(!canvas.getContext) return;
- var ctx = canvas.getContext("2d");
- var start = 600;
- // 绘制下方表格
- drawTable(ctx,20,start,30, 0);
- // 绘制刻度线
- var rs = drawScale(ctx,allMaxGC,allMinGC);
- // 绘制管线及数据dmgc,gxgc,gxms,gj,jl,xyRs,maxGC,minGC
- drawGXData(ctx, rs, allData, allMaxGC,allMinGC);
- }
- // 纵剖面
- function drawCanvasZpm(canvas,smid){
- if(!canvas.getContext) return;
- var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
- queryParameter: {
- name: CONST_VALUES.GX_DataSetName + "@" + CONST_VALUES.GX_DataSourceName,
- attributeFilter: "SMID = " + smid
- },
- datasetNames: [CONST_VALUES.GX_DataSourceName + ":" + CONST_VALUES.GX_DataSetName]
- });
- L.supermap.featureService(dataUrl).getFeaturesBySQL(sqlParam, function (serviceResult) {
- if (serviceResult.result.features.features.length > 0) {
- var feature = serviceResult.result.features.features[0];
- var QSDH = feature.properties["QSDH"]; // 起始点号
- var ZDDH = feature.properties["ZDDH"]; // 终点点号
- var gj = feature.properties["GJ"]; // 管径
- var cd = (feature.properties["CD"] * 1).toFixed(2); // 长度
- var sqlTemp = "BSM in ('" + QSDH + "','" + ZDDH + "')";
- var sqlParamPt = new SuperMap.GetFeaturesBySQLParameters({
- queryParameter: {
- name: CONST_VALUES.JD_DataSetName + "@" + CONST_VALUES.JD_DataSourceName,
- attributeFilter: sqlTemp
- },
- datasetNames: [ CONST_VALUES.JD_DataSourceName + ":" + CONST_VALUES.JD_DataSetName]
- });
- L.supermap.featureService(dataUrl).getFeaturesBySQL(sqlParamPt, function (serviceResult) {
- if (serviceResult.result.features.features.length > 1) {
- var feature0 = serviceResult.result.features.features[0];
- var feature1 = serviceResult.result.features.features[1];
- var featureQ,featureZ;
- if(QSDH == feature0.properties["BSM"]){
- featureQ = feature0;
- featureZ = feature1;
- }
- else{
- featureQ = feature1;
- featureZ = feature0;
- }
- var dmgcQ = (featureQ.properties["DMGC"] * 1).toFixed(2); // 起点地面高程
- var gxmsQ = (featureQ.properties["MS"] * 1).toFixed(2); // 起点埋深
- var dmgcZ = (featureZ.properties["DMGC"] * 1).toFixed(2); // 终点地面高程
- var gxmsZ = (featureZ.properties["MS"] * 1).toFixed(2); // 终点埋深
- var gdgcQ = (dmgcQ-gxmsQ).toFixed(2); // 起点管顶高程
- var gdgcZ = (dmgcZ-gxmsZ).toFixed(2); // 终点管顶高程
- var maxGC = 0,minGC = 0;
- if(dmgcQ >= dmgcZ){
- maxGC = (dmgcQ * 1 + 1).toFixed(2);
- }
- else{
- maxGC = (dmgcZ * 1 + 1).toFixed(2);
- }
- if(gdgcQ >= gdgcZ){
- minGC = (gdgcZ * 1 - 1).toFixed(2);
- }
- else{
- minGC = (gdgcQ * 1 - 1).toFixed(2);
- }
- var ctx = canvas.getContext("2d");
- var start = 600;
- // 绘制下方表格
- drawTable(ctx,20,start,30, 1);
- // 绘制刻度线
- var xyRs = drawScale(ctx,maxGC,minGC);
- drawGXZpmData(ctx,dmgcQ,gxmsQ,gdgcQ,dmgcZ,gxmsZ,gdgcZ,gj,cd,xyRs,maxGC,minGC);
- }
- });
- }
- });
- }
- // 绘制下方表格
- function drawTable(ctx,startX,startY,rowHight,type){
- for(var i = 0; i<5;i++) {
- var y = startY - (i + 1 ) * rowHight;
- ctx.beginPath(); //新建一条path
- ctx.moveTo(startX, y); //把画笔移动到指定的坐标
- ctx.lineTo(780, y); //绘制一条从当前位置到指定坐标的直线.
- ctx.strokeStyle = "white";
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- ctx.font = "18px Arial";
- ctx.fillStyle ="white";
- var content = "";
- switch(i){
- case 4:
- content = "地面高程(M)";
- break;
- case 3:
- content = "管线高程(M)";
- break;
- case 2:
- content = "管线埋深(M)";
- break;
- case 1:
- content = "管 径(MM)";
- break;
- case 0:
- if(type==0){
- content = "距 离(M)";
- }else{
- content = "长 度(M)";
- }
- break;
- }
- ctx.fillText(content, startX + 10 , y+(rowHight*4/5));
- }
- ctx.beginPath(); //新建一条path
- ctx.moveTo(startX, 450); //把画笔移动到指定的坐标
- ctx.lineTo(startX, 800); //绘制一条从当前位置到指定坐标的直线.
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- ctx.beginPath(); //新建一条path
- ctx.moveTo(780, 450); //把画笔移动到指定的坐标
- ctx.lineTo(780, 800); //绘制一条从当前位置到指定坐标的直线.
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- }
- // 绘制刻度线
- function drawScale(ctx,maxGC,minGC){
- ctx.beginPath(); //新建一条path
- ctx.moveTo(150, 20); //把画笔移动到指定的坐标
- ctx.lineTo(150, 800); //绘制一条从当前位置到指定坐标的直线.
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- var rs = [];
- for(var i = 0; i<5;i++){
- var y = 70 + i*70;
- ctx.beginPath(); //新建一条path
- ctx.moveTo(150, y); //把画笔移动到指定的坐标
- ctx.lineTo(150-10, y); //绘制一条从当前位置到指定坐标的直线.
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- if(i==0 || i == 4){
- rs.push(y);
- }
- ctx.font = "18px Arial"
- var content = maxGC - i*(maxGC-minGC)/4;
- ctx.fillText(content.toFixed(2), 150 - 60 , y+20);
- }
- return rs;
- }
- // 绘制管线及数据
- function drawGXData(ctx, xyRs, allData, maxGC, minGC){
- var dataNum = allData.length;
- for(var i = 0; i < dataNum; i++){
- var entityData = allData[i];
- var x = 150 + (800 - 150 - 20) / (dataNum + 1) * (i+1);
- var gdbh = entityData.gdbh;
- var dmgc = entityData.dmgc;
- var gxgc = entityData.gxgc;
- var gxms = entityData.ms;
- var gj = entityData.gj;
- var jl = entityData.jl;
- var y = xyRs[1] - (gxgc-minGC)*(xyRs[1]-xyRs[0])/(maxGC-minGC);
- var pyl = gj / 10 / 2;
- ctx.beginPath();
- ctx.arc(x,y+pyl,pyl,0,2*Math.PI);
- ctx.setLineDash([10, 0]); // [实线长度, 间隙长度]
- ctx.strokeStyle = "#ed1941";
- ctx.stroke();
- ctx.beginPath(); //新建一条path
- ctx.moveTo(x, y+pyl*2); //把画笔移动到指定的坐标
- ctx.lineTo(x, 800); //绘制一条从当前位置到指定坐标的直线.
- ctx.setLineDash([10, 5]); // [实线长度, 间隙长度]
- ctx.strokeStyle = "#2AC2FC";
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- ctx.fillText(gdbh, x, y - 5);
- ctx.fillText(dmgc, x + 5, 450+25);
- ctx.fillText(gxgc, x + 5, 450+55);
- ctx.fillText(gxms, x + 5, 450+85);
- ctx.fillText(gj, x + 5, 450+115);
- ctx.fillText(jl == 0 ? "" : jl, x + 5 , 450+145);
- }
- }
- // 绘制管线纵剖面图及数据
- function drawGXZpmData(ctx,dmgcQ,gxmsQ,gdgcQ,dmgcZ,gxmsZ,gdgcZ,gj,cd,xyRs,maxGC,minGC){
- var xQ = 200,xZ = 730;
- var yGDQ = xyRs[1] - (gdgcQ-minGC)*(xyRs[1]-xyRs[0])/(maxGC-minGC);
- var yGDZ = xyRs[1] - (gdgcZ-minGC)*(xyRs[1]-xyRs[0])/(maxGC-minGC);
- var yDMQ = xyRs[1] - (dmgcQ-minGC)*(xyRs[1]-xyRs[0])/(maxGC-minGC);
- var yDMZ = xyRs[1] - (dmgcZ-minGC)*(xyRs[1]-xyRs[0])/(maxGC-minGC);
- var pyl = gj / 10;
- // 画管线上沿
- ctx.beginPath(); //新建一条path
- ctx.moveTo(xQ, yGDQ); //把画笔移动到指定的坐标
- ctx.lineTo(xZ, yGDZ); //绘制一条从当前位置到指定坐标的直线.
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- // 画管线下沿
- ctx.beginPath(); //新建一条path
- ctx.moveTo(xQ, yGDQ + pyl); //把画笔移动到指定的坐标
- ctx.lineTo(xZ, yGDZ + pyl); //绘制一条从当前位置到指定坐标的直线.
- //ctx.strokeStyle = "#009ad6";
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- // 画地面线
- ctx.beginPath(); //新建一条path
- ctx.moveTo(xQ, yDMQ); //把画笔移动到指定的坐标
- ctx.lineTo(xZ, yDMZ); //绘制一条从当前位置到指定坐标的直线.
- ctx.strokeStyle = "#2AC2FC";
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- // 画起点竖线
- ctx.beginPath(); //新建一条path
- ctx.moveTo(xQ, yDMQ); //把画笔移动到指定的坐标
- ctx.lineTo(xQ, yGDQ + pyl); //绘制一条从当前位置到指定坐标的直线.
- ctx.strokeStyle = "#2AC2FC";
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- // 画终点竖线
- ctx.beginPath(); //新建一条path
- ctx.moveTo(xZ, yDMZ); //把画笔移动到指定的坐标
- ctx.lineTo(xZ, yGDZ + pyl); //绘制一条从当前位置到指定坐标的直线.
- ctx.strokeStyle = "#2AC2FC";
- //闭合路径。会拉一条从当前点到path起始点的直线。如果当前点与起始点重合,则什么都不做
- ctx.closePath();
- ctx.stroke(); //绘制路径。
- // 起点
- ctx.fillText(dmgcQ, xQ , 450+25);
- ctx.fillText(gdgcQ, xQ , 450+55);
- ctx.fillText(gxmsQ, xQ , 450+85);
- // 终点
- ctx.fillText(dmgcZ, xZ - 40 , 450+25);
- ctx.fillText(gdgcZ, xZ - 40 , 450+55);
- ctx.fillText(gxmsZ, xZ - 40 , 450+85);
- ctx.fillText(gj, 460 , 450+115);
- ctx.fillText(cd == 0 ? "" : cd, 460 , 450+145);
- }
- // 碰撞分析(包括垂直净距和水平净距分析)
- function pzfx(){
- map.on('click', function (evt) {
- var infoX = evt.containerPoint.x;
- var infoY = evt.containerPoint.y;
- var winX = evt.target._size.x;
- var winY = evt.target._size.y;
- var pt = crs.project(evt.latlng);
- var _Point = L.marker([pt.y, pt.x]);
- var dataSourceName = CONST_VALUES.GX_DataSourceName;
- var dataSetName = CONST_VALUES.GX_DataSetName;
- var bufferParam = new SuperMap.GetFeaturesByBufferParameters({
- datasetNames: [dataSourceName + ":" + dataSetName],
- bufferDistance: CONST_VALUES.QUERY_BufferDistance,
- geometry: _Point
- });
- // 判断点击的点是否在管线上
- L.supermap
- .featureService(dataUrl)
- .getFeaturesByBuffer(bufferParam, function (result) {
- if(result.result.features.features.length > 0){
- // 坐标系转换
- var result = L.Util.transform(result.result.features, crs, L.CRS.EPSG4326);
- L.geoJSON(result, {
- style:{color: "#ef5b9c"},
- onEachFeature: function (feature, layer) {
- let attributes = "";
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(dataSourceName == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- let attValue = feature.properties[colArr[0]];
- let attr = colArr[1] + ":" + attValue + "<br>";
- attributes += attr;
- }
- }
- break;
- }
- }
- layer.bindPopup(attributes);
- }
- }).addTo(resultLayer);
- var feature = result.features[0];
- var sourceCoordinates = feature.geometry.coordinates;
- var QSDH = feature.properties["QSDH"]; // 起始点号
- var ZDDH = feature.properties["ZDDH"]; // 终点点号
- var gj = feature.properties["GJ"]; // 管径
- var gxSmid = feature.properties["SMID"];
- var bsm = feature.properties["BSM"];
- var fldm = feature.properties["FLDM"];
- var sqlTemp = "BSM in ('" + QSDH + "','" + ZDDH + "')";
- var sqlParamPt = new SuperMap.GetFeaturesBySQLParameters({
- queryParameter: {
- name: CONST_VALUES.JD_DataSetName + "@" + CONST_VALUES.JD_DataSourceName,
- attributeFilter: sqlTemp
- },
- datasetNames: [ CONST_VALUES.JD_DataSourceName + ":" + CONST_VALUES.JD_DataSetName]
- });
- L.supermap.featureService(dataUrl).getFeaturesBySQL(sqlParamPt, function (serviceResult) {
- if (serviceResult.result.features.features.length > 1) {
- var feature0 = serviceResult.result.features.features[0];
- var feature1 = serviceResult.result.features.features[1];
- var featureQ, featureZ;
- if (QSDH == feature0.properties["BSM"]) {
- featureQ = feature0;
- featureZ = feature1;
- } else {
- featureQ = feature1;
- featureZ = feature0;
- }
- var xQ = featureQ.properties["X"]; // X坐标
- var yQ = featureQ.properties["Y"]; // Y坐标
- var dmgcQ = (featureQ.properties["DMGC"] * 1).toFixed(2); // 起点地面高程
- var gxmsQ = (featureQ.properties["MS"] * 1).toFixed(2); // 起点埋深
- var xZ = featureZ.properties["X"]; // X坐标
- var yZ = featureZ.properties["Y"]; // Y坐标
- var dmgcZ = (featureZ.properties["DMGC"] * 1).toFixed(2); // 终点地面高程
- var gxmsZ = (featureZ.properties["MS"] * 1).toFixed(2); // 终点埋深
- let lyrsSelect = '<div class="layui-form" lay-filter="lyrsSelectDiv"><div class="layui-form-item"><div class="layui-input-block" style="margin-left:20px;">';
- lyrsSelect += '<input type="radio" checked name="fxType" value="0" title="碰撞分析" />';
- lyrsSelect += '<input type="radio" name="fxType" value="1" title="水平净距分析" />';
- lyrsSelect += '<input type="radio" name="fxType" value="2" title="垂直净距分析" />';
- lyrsSelect += '</div></div></div>';
- lyrsSelect += '<div style="margin-left:30px;color: #ffffff;">';
- lyrsSelect += "<div style='margin-bottom: 5px;'>管线类型:" + fldm + "</div>";
- lyrsSelect += "<div style='margin-bottom: 5px;'>起点X坐标值:" + xQ + "</div>";
- lyrsSelect += "<div style='margin-bottom: 5px;'>起点Y坐标值:" + yQ + "</div>";
- lyrsSelect += "<div style='margin-bottom: 5px;'>起点高程值:" + (dmgcQ-gxmsQ) + "</div>";
- lyrsSelect += "<div style='margin-bottom: 5px;'>终点X坐标值:" + xZ + "</div>";
- lyrsSelect += "<div style='margin-bottom: 5px;'>终点Y坐标值:" + yZ + "</div>";
- lyrsSelect += "<div style='margin-bottom: 5px;'>终点高程值:" + (dmgcZ - gxmsZ) + "</div>";
- lyrsSelect += "<div style='margin-bottom: 5px;'>管径(MM):" + gj + "</div>";
- lyrsSelect += '</div>';
- lyrsSelect += '<div style="margin-left:30px;margin-top:25px;color: #2ac2fc;">';
- lyrsSelect += "分析半径(M):<input id='radius' type='text' value='2'/>";
- lyrsSelect += '</div>';
- layui.use('layer', function() {
- let layer = layui.layer;
- layer.open({
- id: "panel-layerSelect",
- type: 1,
- area: ["500px", "400px"],
- btn: ['确定','取消'],
- title: "管线净距分析",
- skin: 'layui-ext-coolskin',
- content: lyrsSelect, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function (index, layero) {
- layer.close(index);
- },
- yes: function(index, layero){
- var radius = $("#radius").val();
- let fxType = $('input[name="fxType"]:checked')[0].value; // 0碰撞;1水平;2垂直
- //按钮【按钮一】的回调
- var dsBufferAnalystService = L.supermap.spatialAnalystService(spatialanalystUrl);
- var dsBufferAnalystParameters = new SuperMap.DatasetBufferAnalystParameters({
- dataset: CONST_VALUES.GX_DataSetName + "@" + CONST_VALUES.GX_DataSourceName,
- filterQueryParameter: new SuperMap.FilterParameter({
- attributeFilter: "SMID=" + gxSmid
- }),
- bufferSetting: new SuperMap.BufferSetting({
- endType: SuperMap.BufferEndType.ROUND,
- leftDistance: {value: radius},
- rightDistance: {value: radius},
- semicircleLineSegment: 10
- })
- });
- dsBufferAnalystService.bufferAnalysis(dsBufferAnalystParameters, function (serviceResult) {
- var ptArrayTemp = serviceResult.result.recordset.features.features[0].geometry.coordinates[0][0];
- var ptArray = Array();
- for(var i = 0; i < ptArrayTemp.length; i++) {
- var tempArr = ptArrayTemp[i];
- var ptTemp = Array();
- ptTemp.push(tempArr[1]);
- ptTemp.push(tempArr[0]);
- ptArray.push(ptTemp);
- }
- var dataSourceName = CONST_VALUES.GX_DataSourceName;
- var dataSetName = CONST_VALUES.GX_DataSetName;
- var boundsParam = new SuperMap.GetFeaturesByBoundsParameters({
- datasetNames: [dataSourceName + ":" + dataSetName],
- fromIndex: 0,
- toIndex: 100000,
- maxFeatures: 100000,
- bounds: L.polygon(ptArray).getBounds()
- });
- // 查询范围内的所有管线
- L.supermap.featureService(dataUrl)
- .getFeaturesByBounds(boundsParam, function (result) {
- if (result.result.features.features.length > 0) {
- // 坐标系转换
- var result = L.Util.transform(result.result.features, crs, L.CRS.EPSG4326);
- L.geoJSON(result, {
- style:{color: "#ef5b9c"},
- onEachFeature: function (feature, layer) {
- let attributes = "";
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(dataSourceName == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- let attValue = feature.properties[colArr[0]];
- let attr = colArr[1] + ":" + attValue + "<br>";
- attributes += attr;
- }
- }
- break;
- }
- }
- layer.bindPopup(attributes);
- }
- }).addTo(resultLayer);
- pzfxProcess(sourceCoordinates,result,fxType,QSDH,ZDDH,bsm,fldm);
- }
- });
- // 坐标系转换
- var result = L.Util.transform(serviceResult.result.recordset.features, crs, L.CRS.EPSG4326);
- //var result = serviceResult.result;
- L.geoJSON(result, {color: "#00FF00"}).addTo(resultLayer);
- });
- },
- btn2: function(index, layero){
- layer.close(index);
- }
- });
- layui.use(['form'], function() {
- let form = layui.form;
- form.render();
- });
- });
- }
- });
- }
- })
- });
- }
- function pzfxProcess(sourceCoordinates,result,fxType,QSDHSel,ZDDHSel,bsmSel,fldmSel){
- var pts = '';
- for(var i = 0; i < result.features.length; i++)
- {
- var feature = result.features[i];
- var QSDH = feature.properties["QSDH"]; // 起始点号
- var ZDDH = feature.properties["ZDDH"]; // 终点点号
- if(i < result.features.length-1){
- pts += "'" + QSDH + "','" + ZDDH + "',";
- }
- else{
- pts += "'" + QSDH + "','" + ZDDH + "'";
- }
- }
- var sqlTemp = "BSM in (" + pts + ")";
- var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
- queryParameter: {
- name: CONST_VALUES.JD_DataSetName + "@" + CONST_VALUES.JD_DataSourceName,
- attributeFilter: sqlTemp
- },
- datasetNames: [CONST_VALUES.JD_DataSourceName + ":" + CONST_VALUES.JD_DataSetName]
- });
- L.supermap.featureService(dataUrl).getFeaturesBySQL(sqlParam, function (serviceResult) {
- if(serviceResult.result.features.features.length > 0){
- var resultData = L.Util.transform(serviceResult.result.features, crs, L.CRS.EPSG4326);
- var rsList = new Array();
- // 选择的管线
- var line1 = turf.lineString([[sourceCoordinates[0][0], sourceCoordinates[0][1]], [sourceCoordinates[1][0], sourceCoordinates[1][1]]]);
- // 计算每条管线与选择管线的垂直和水平净距 两条线相交只要垂直净距,否则只有水平净距
- for(var i = 0; i < result.features.length; i++){
- var feature = result.features[i];
- var coordinates = feature.geometry.coordinates;
- var QSDHTemp = feature.properties["QSDH"]; // 起始点号
- var ZDDHTemp = feature.properties["ZDDH"]; // 终点点号
- var bsmTemp = feature.properties["BSM"];
- var fldmTemp = feature.properties["FLDM"];
- // 与选择管线连接的管线排除掉
- if(QSDHTemp == QSDHSel || QSDHTemp == ZDDHSel || ZDDHTemp == QSDHSel || ZDDHTemp == ZDDHSel){
- continue;
- }
- // 地图上划线查询到的管线
- var line2 = turf.lineString([[coordinates[0][0], coordinates[0][1]], [coordinates[1][0], coordinates[1][1]]]);
- // 交叉点
- var intersects = turf.lineIntersect(line1, line2);
- // 水平净距分析时如果有交叉点,则没有水平净距
- if(fxType == 1 && intersects.features.length > 0){
- continue;
- }
- // 垂直净距分析时如果没有交叉点,则没有垂直净距
- if(fxType == 2 && intersects.features.length == 0){
- continue;
- }
- var entityData = {};
- entityData.bsm = bsmSel;
- entityData.fldm = fldmSel;
- entityData.bsmTemp = bsmTemp;
- entityData.fldmTemp = fldmTemp;
- entityData.spjjMin = CONST_VALUES.SP_Min;
- entityData.czjjMin = CONST_VALUES.CZ_Min;
- // 有交叉点,则计算垂直净距
- if(fxType != 1 && intersects.features.length > 0) {
- var pt1Data = undefined;
- var pt2Data = undefined;
- var pt1DataSel = undefined;
- var pt2DataSel = undefined;
- for(var j = 0; j < resultData.features.length; j++){
- var bsm = resultData.features[j].properties["BSM"];
- if(bsm == QSDHTemp){
- pt1Data = resultData.features[j];
- }
- else if(bsm == ZDDHTemp){
- pt2Data = resultData.features[j];
- }
- if(bsm == QSDHSel){
- pt1DataSel = resultData.features[j];
- }
- else if(bsm == ZDDHSel){
- pt2DataSel = resultData.features[j];
- }
- if(pt1Data != undefined && pt2Data != undefined && pt1DataSel != undefined && pt2DataSel != undefined){
- break;
- }
- }
- if(pt1Data == undefined || pt2Data == undefined || pt1DataSel == undefined || pt2DataSel == undefined){
- continue;
- }
- var dmgcPT1 = pt1Data.properties["DMGC"] * 1; // 地面高程
- var msPT1 = pt1Data.properties["MS"] * 1; // 埋深
- var xPT1 = pt1Data.geometry.coordinates[0]; // x坐标
- var yPT1 = pt1Data.geometry.coordinates[1]; // y坐标
- var dmgcPT2 = pt2Data.properties["DMGC"] * 1; // 地面高程
- var msPT2 = pt2Data.properties["MS"] * 1; // 埋深
- var xPT2 = pt2Data.geometry.coordinates[0]; // x坐标
- var yPT2 = pt2Data.geometry.coordinates[1]; // y坐标
- var dmgcPT1Sel = pt1DataSel.properties["DMGC"] * 1; // 地面高程
- var msPT1Sel = pt1DataSel.properties["MS"] * 1; // 埋深
- var xPT1Sel = pt1DataSel.geometry.coordinates[0]; // x坐标
- var yPT1Sel = pt1DataSel.geometry.coordinates[1]; // y坐标
- var dmgcPT2Sel = pt2DataSel.properties["DMGC"] * 1; // 地面高程
- var msPT2Sel = pt2DataSel.properties["MS"] * 1; // 埋深
- var xPT2Sel = pt2DataSel.geometry.coordinates[0]; // x坐标
- var yPT2Sel = pt2DataSel.geometry.coordinates[1]; // y坐标
- var xPtTmp = intersects.features[0].geometry.coordinates[0];
- var yPtTmp = intersects.features[0].geometry.coordinates[1];
- var dmgc = undefined; // 地面高程
- var ms = undefined; // 埋深
- var gxgc = undefined; // 管线高程
- if(dmgcPT1 == dmgcPT2){
- dmgc = dmgcPT1;
- }
- else if (dmgcPT1 > dmgcPT2){
- dmgc = dmgcPT2 + (dmgcPT1 - dmgcPT2) * (Math.sqrt(Math.pow((xPtTmp - xPT2), 2) + Math.pow((yPtTmp - yPT2), 2))) / (Math.sqrt(Math.pow((xPT1 - xPT2), 2) + Math.pow((yPT1 - yPT2), 2)));
- }
- else {
- dmgc = dmgcPT1 + (dmgcPT2 - dmgcPT1) * (Math.sqrt(Math.pow((xPtTmp - xPT1), 2) + Math.pow((yPtTmp - yPT1), 2))) / (Math.sqrt(Math.pow((xPT2 - xPT1), 2) + Math.pow((yPT2 - yPT1), 2)));
- }
- if(msPT1 == msPT2){
- ms = msPT1;
- }
- else if(msPT1 > msPT2){
- ms = msPT2 + (msPT1 - msPT2) * (Math.sqrt(Math.pow((xPtTmp - xPT2), 2) + Math.pow((yPtTmp - yPT2), 2))) / (Math.sqrt(Math.pow((xPT1 - xPT2), 2) + Math.pow((yPT1 - yPT2), 2)));
- }
- else{
- ms = msPT1 + (msPT2 - msPT1) * (Math.sqrt(Math.pow((xPtTmp - xPT1), 2) + Math.pow((yPtTmp - yPT1), 2))) / (Math.sqrt(Math.pow((xPT2 - xPT1), 2) + Math.pow((yPT2 - yPT1), 2)));
- }
- gxgc = dmgc - ms;
- var dmgcSel = undefined; // 地面高程
- var msSel = undefined; // 埋深
- var gxgcSel = undefined; // 管线高程
- if(dmgcPT1Sel == dmgcPT2Sel){
- dmgcSel = dmgcPT1Sel;
- }
- else if (dmgcPT1Sel > dmgcPT2Sel){
- dmgcSel = dmgcPT2Sel + (dmgcPT1Sel - dmgcPT2Sel) * (Math.sqrt(Math.pow((xPtTmp - xPT2Sel), 2) + Math.pow((yPtTmp - yPT2Sel), 2))) / (Math.sqrt(Math.pow((xPT1Sel - xPT2Sel), 2) + Math.pow((yPT1Sel - yPT2Sel), 2)));
- }
- else {
- dmgcSel = dmgcPT1Sel + (dmgcPT2Sel - dmgcPT1Sel) * (Math.sqrt(Math.pow((xPtTmp - xPT1Sel), 2) + Math.pow((yPtTmp - yPT1Sel), 2))) / (Math.sqrt(Math.pow((xPT2Sel - xPT1Sel), 2) + Math.pow((yPT2Sel - yPT1Sel), 2)));
- }
- if(msPT1Sel == msPT2Sel){
- msSel = msPT1Sel;
- }
- else if(msPT1Sel > msPT2Sel){
- msSel = msPT2Sel + (msPT1Sel - msPT2Sel) * (Math.sqrt(Math.pow((xPtTmp - xPT2Sel), 2) + Math.pow((yPtTmp - yPT2Sel), 2))) / (Math.sqrt(Math.pow((xPT1Sel - xPT2Sel), 2) + Math.pow((yPT1Sel - yPT2Sel), 2)));
- }
- else{
- msSel = msPT1Sel + (msPT2Sel - msPT1Sel) * (Math.sqrt(Math.pow((xPtTmp - xPT1Sel), 2) + Math.pow((yPtTmp - yPT1Sel), 2))) / (Math.sqrt(Math.pow((xPT2Sel - xPT1Sel), 2) + Math.pow((yPT2Sel - yPT1Sel), 2)));
- }
- gxgcSel = dmgcSel - msSel;
- var distance = Math.abs(gxgcSel-gxgc).toFixed(2);
- entityData.spjj = "--";
- entityData.czjj = distance;
- if(distance < CONST_VALUES.CZ_Min){
- rsList.push(entityData);
- }
- }
- // 没有交叉点,则计算水平净距
- if(fxType != 2 && intersects.features.length == 0) {
- var pt1 = turf.point([sourceCoordinates[0][0], sourceCoordinates[0][1]]);
- var pt2 = turf.point([sourceCoordinates[1][0], sourceCoordinates[1][1]]);
- var pt3 = turf.point([coordinates[0][0], coordinates[0][1]]);
- var pt4 = turf.point([coordinates[1][0], coordinates[1][1]]);
- var distance1 = turf.pointToLineDistance(pt1, line2, {units: 'kilometers'});
- var distance2 = turf.pointToLineDistance(pt2, line2, {units: 'kilometers'});
- var distance3 = turf.pointToLineDistance(pt3, line1, {units: 'kilometers'});
- var distance4 = turf.pointToLineDistance(pt4, line1, {units: 'kilometers'});
- var distance = distance1;
- if(distance > distance1){
- distance = distance1;
- }
- if(distance > distance2){
- distance = distance2;
- }
- if(distance > distance3){
- distance = distance3;
- }
- if(distance > distance4){
- distance = distance4;
- }
- distance = distance * 1000;
- entityData.spjj = distance.toFixed(2);
- entityData.czjj = "--";
- if(distance < CONST_VALUES.SP_Min){
- rsList.push(entityData);
- }
- }
- }
- let tableNew = "<table id='THETABLEID' lay-filter='THETABLEID'></table>";
- const tableNewID = utils.guid();
- while (tableNew.indexOf('THETABLEID') > -1)
- tableNew = tableNew.replace('THETABLEID', tableNewID);
- layui.use('layer', function() {
- if (rsList.length == 0) {
- layui.layer.msg('分析结果中没法发现不符合标准的管线。');
- return -1;
- }
- var layer = layui.layer;
- layer.open({
- id: "panel-pzfx",
- type: 1,
- area: ["800px", "550px"],
- title: "碰撞分析结果",
- skin: 'layui-ext-coolskin',
- content: tableNew, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function (index, layero) {
- layer.close(index);
- }
- });
- });
- let cols = [];
- cols.push({ field: "bsm", title: "选中管线编号", sort: false, width: 120 });
- cols.push({ field: "fldm", title: "选中管线类型", sort: false, width: 120 });
- cols.push({ field: "bsmTemp", title: "分析管线编号", sort: false, width: 120 });
- cols.push({ field: "fldmTemp", title: "分析管线类型", sort: false, width: 120 });
- if(fxType != 2){
- cols.push({ field: "spjj", title: "水平净距", sort: false, width: 120 });
- cols.push({ field: "spjjMin", title: "标准水平净距", sort: false, width: 120 });
- }
- if(fxType != 1){
- cols.push({ field: "czjj", title: "垂直净距", sort: false, width: 120 });
- cols.push({ field: "czjjMin", title: "标准垂直净距", sort: false, width: 120 });
- }
- layui.use('table', function() {
- let table = layui.table;
- table.render({
- elem: '#' + tableNewID,
- data: rsList,
- "lay-size": 'sm',
- cols: [cols]
- });
- });
- }
- })
- }
- function ftfx(){
- drawType = "FTFX";
- setDefualtStyle();
- drawMapControl.handler.disable();
- drawMapControl.handler.libID = 0;
- drawMapControl.handler.code = 32;
- drawMapControl.handler.serverUrl = serverUrl;
- drawMapControl.handler.enable();
- }
- function ftfxProcess(drawLayer){
- var rectangleTemp = L.Util.transform(drawLayer._bounds, L.CRS.EPSG4326, crs);
- var ptArrayTemp = rectangleTemp.geometry.coordinates[0];
- var ptArray = Array();
- for(var i = 0; i < ptArrayTemp.length; i++) {
- var tempArr = ptArrayTemp[i];
- var ptTemp = Array();
- ptTemp.push(tempArr[1]);
- ptTemp.push(tempArr[0]);
- ptArray.push(ptTemp);
- }
- var dataSourceName = CONST_VALUES.GX_DataSourceName;
- var dataSetName = CONST_VALUES.GX_DataSetName;
- var boundsParam = new SuperMap.GetFeaturesByBoundsParameters({
- datasetNames: [dataSourceName + ":" + dataSetName],
- fromIndex: 0,
- toIndex: 100000,
- maxFeatures: 100000,
- bounds: L.polygon(ptArray).getBounds()
- });
- L.supermap
- .featureService(dataUrl)
- .getFeaturesByBounds(boundsParam, function (serviceResult) {
- // 坐标系转换
- var result = L.Util.transform(serviceResult.result.features, crs, L.CRS.EPSG4326);
- L.geoJSON(result, {
- style:{color: "red"},
- onEachFeature: function (feature, layer) {
- let attributes = "";
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(dataSourceName == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- let attValue = feature.properties[colArr[0]];
- let attr = colArr[1] + ":" + attValue + "<br>";
- attributes += attr;
- }
- }
- break;
- }
- }
- layer.bindPopup(attributes);
- }
- }).addTo(resultLayer);
- let tableNew = "<table id='THETABLEID' lay-filter='THETABLEID'></table>";
- const tableNewID = utils.guid();
- while (tableNew.indexOf('THETABLEID') > -1)
- tableNew = tableNew.replace('THETABLEID', tableNewID);
- layui.use('layer', function() {
- var layer = layui.layer;
- layer.open({
- id: "panel-pzfx",
- type: 1,
- area: ["800px", "550px"],
- title: "覆土分析",
- skin: 'layui-ext-coolskin',
- content: tableNew, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function (index, layero) {
- layer.close(index);
- }
- });
- });
- let cols = [];
- cols.push({ field: "SMID", title: "实体编码", sort: false, width: 100 });
- cols.push({ field: "fxRs", title: "分析结果", sort: false, width: 120 });
- cols.push({ field: "msMin", title: "标准埋深", sort: false, width: 100 });
- cols.push({ field: "QDMS", title: "起点埋深", sort: false, width: 100 });
- cols.push({ field: "ZDMS", title: "终点埋深", sort: false, width: 100 });
- cols.push({ field: "CZ", title: "材质", sort: false, width: 80 });
- cols.push({ field: "GJ", title: "管径", sort: false, width: 80 });
- cols.push({ field: "BSM", title: "管段编号", sort: false, width: 100 });
- cols.push({ field: "QSDH", title: "起始点号", sort: false, width: 100 });
- cols.push({ field: "ZDDH", title: "终点点号", sort: false, width: 100 });
- cols.push({ field: "MSFS", title: "埋设方式", sort: false, width: 100 });
- let datas = [];
- for (let i in result.features) {
- var entity = result.features[i].properties;
- var czTemp = entity["CZ"];
- var qdmsTemp = entity["QDMS"];
- var zdmsTemp = entity["ZDMS"];
- var msMin = FTFX_Mins.get(czTemp);
- entity["msMin"] = msMin;
- if(msMin <= qdmsTemp && msMin <= zdmsTemp){
- entity["fxRs"] = "符合标准";
- }
- else{
- entity["fxRs"] = "不符合标准";
- }
- datas.push(entity);
- }
- layui.use('table', function() {
- let table = layui.table;
- table.render({
- elem: '#' + tableNewID,
- data: datas,
- "lay-size": 'sm',
- cols: [cols]
- });
- });
- });
- }
- // 连通分析
- function ltfx(){
- map.off('click');
- var isFirstPoint = true; //判断是否是起始点
- var latLngTemp = null;//存储上一点击点临时变量
- map.on('click', function(ev) {
- TempLayer.clearLayers();
- $("#tips").css('display', 'none');
- var pt = crs.project(ev.latlng);
- var _Point = L.marker([pt.y, pt.x]);
- var dataSourceName = CONST_VALUES.GX_DataSourceName;
- var dataSetName = CONST_VALUES.GX_DataSetName;
- var bufferParam = new SuperMap.GetFeaturesByBufferParameters({
- datasetNames: [dataSourceName + ":" + dataSetName],
- bufferDistance: CONST_VALUES.QUERY_BufferDistance,
- geometry: _Point
- });
- // 判断点击的点是否在管线上
- L.supermap
- .featureService(dataUrl)
- .getFeaturesByBuffer(bufferParam, function (result) {
- if(result.result.features.features.length > 0){
- var texticon = L.divIcon({ //定义图标
- className: "leaflet-div-icon-new"
- });
- L.marker([ev.latlng.lat, ev.latlng.lng], {
- icon: texticon
- }).addTo(resultLayer); //marker实现文本框显示
- if(isFirstPoint) {
- latLngTemp = ev.latlng; //存储上一点击点
- isFirstPoint = false;
- } else {
- if(!latLngTemp.equals(ev.latlng)) { //避免出现结束双击,导致距离为0
- map.off('click');
- var findPathService = L.supermap.networkAnalystService(transportationAnalystUrl);
- //创建最佳路径分析参数实例
- var resultSetting = new SuperMap.TransportationAnalystResultSetting({
- returnEdgeFeatures: true,
- returnEdgeGeometry: true,
- returnEdgeIDs: true,
- returnNodeFeatures: true,
- returnNodeGeometry: true,
- returnNodeIDs: true,
- returnPathGuides: true,
- returnRoutes: true
- });
- var analystParameter = new SuperMap.TransportationAnalystParameter({
- resultSetting: resultSetting,
- //weightFieldName: "length"
- });
- var pt1 = L.point(pt.x, pt.y);
- var ptTemp = crs.project(latLngTemp);
- var pt2 = L.point(ptTemp.x, ptTemp.y);
- var findPathParameter = new SuperMap.FindPathParameters({
- isAnalyzeById: false,
- nodes: [pt1, pt2],
- parameter: analystParameter
- });
- //进行查找
- findPathService.findPath(findPathParameter, function (serviceResult) {
- if(serviceResult.type != "processFailed" && serviceResult.result.pathList[0].edgeFeatures.features.length > 0){
- var result = L.Util.transform(serviceResult.result.pathList[0].edgeFeatures, crs, L.CRS.EPSG4326);
- L.geoJSON(result, {
- style:{color: "red"},
- onEachFeature: function (feature, layer) {
- let attributes = "";
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(dataSourceName == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- let attValue = feature.properties[colArr[0]];
- let attr = colArr[1] + ":" + attValue + "<br>";
- attributes += attr;
- }
- }
- break;
- }
- }
- layer.bindPopup(attributes);
- }
- }).addTo(resultLayer);
- let tableNew = "<table id='THETABLEID' lay-filter='THETABLEID'></table>";
- const tableNewID = utils.guid();
- while (tableNew.indexOf('THETABLEID') > -1)
- tableNew = tableNew.replace('THETABLEID', tableNewID);
- layui.use('layer', function() {
- var layer = layui.layer;
- layer.open({
- id: "panel-ltfx",
- type: 1,
- area: ["800px", "550px"],
- title: "连通分析",
- skin: 'layui-ext-coolskin',
- content: tableNew, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function (index, layero) {
- layer.close(index);
- }
- });
- });
- let cols = [];
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(dataSourceName == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- cols.push({ field: colArr[0], title: colArr[1], sort: true, width: 100 });
- }
- }
- break;
- }
- }
- let datas = [];
- for (let i in result.features) {
- datas.push(result.features[i].properties);
- }
- layui.use('table', function() {
- let table = layui.table;
- table.render({
- elem: '#' + tableNewID,
- data: datas,
- "lay-size": 'sm',
- cols: [cols]
- });
- });
- }
- else {
- layui.layer.msg('所选位置不连通!');
- return -1;
- }
- });
- }
- }
- }
- });
- });
- }
- /**
- * 编辑管网
- */
- function layerEdit() {
- map.off('click');
- map.off('contextmenu');
- let lyrsSelect = '<div id="editTypes" class="layui-form" lay-filter="editTypesDiv"><div class="layui-form-item"><label class="layui-form-label">编辑类型</label><div class="layui-input-block" style="margin-left:30px">';
- lyrsSelect += "<input type='radio' name='editType' title='新增' value='0' id='editType_0' lay-skin='primary'>";
- lyrsSelect += "<input type='radio' name='editType' title='修改' value='1' id='editType_1' lay-skin='primary'>";
- lyrsSelect += "<input type='radio' name='editType' title='删除' value='2' id='editType_2' lay-skin='primary'>";
- lyrsSelect += '</div></div></div>';
- let lyrs = CONST_VALUES.GX_Datas;
- lyrsSelect += '<div id="layers" class="layui-form" lay-filter="lyrsSelectDiv"><div class="layui-form-item"><label class="layui-form-label">编辑图层</label><div class="layui-input-block" style="margin-left:30px">';
- let listStr = "<input type='radio' name='editLayer' title='THETITLE' id='THEID' lay-skin='primary' dataSetName='THEDATASETNAME' dataSourceName='THEWS' dataType='THETYPE' >";
- for (let index = 0; index < lyrs.length; index++) {
- const lyr = lyrs[index];
- let dom = listStr.replace('THETITLE', lyr.name);
- dom = dom.replace('THEID', lyr.id);
- dom = dom.replace('THEWS', lyr.dataSourceName);
- dom = dom.replace('THEDATASETNAME', lyr.dataSetName);
- dom = dom.replace('THETYPE', lyr.dataType);
- lyrsSelect += dom;
- }
- lyrsSelect += '</div></div></div>';
- layui.use('layer', function() {
- let layer = layui.layer;
- layer.open({
- id: "panel-editTypes",
- type: 1,
- area: ["500px", "300px"],
- btn: ['确定'],
- title: "请选择编辑类型",
- skin: 'layui-ext-coolskin',
- content: lyrsSelect, //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
- cancel: function(index, layero) {
- layer.close(index);
- },
- yes: function(e) {
- let editType = $('input[name="editType"]:checked').val();
- if (editType == undefined) {
- layer.msg('请选择编辑类型!', {
- icon: 7
- });
- return;
- }
- let editLayer = $('input[name="editLayer"]:checked').val();
- if (editLayer == undefined) {
- layer.msg('请选择编辑图层!', {
- icon: 7
- });
- return;
- }
- layer.close(e);
- var editTypeVal = $('input[name="editType"]:checked')[0].attributes.value.value;
- var dataSourceName = $('input[name="editLayer"]:checked')[0].attributes.dataSourceName.value;
- var dataSetName = $('input[name="editLayer"]:checked')[0].attributes.dataSetName.value;
- var dataType = $('input[name="editLayer"]:checked')[0].attributes.dataType.value;
- var editTypeMap
- if(editTypeVal==0){
- editTypeMap = SuperMap.EditType.ADD;
- }
- else if(editTypeVal == 1){
- editTypeMap = SuperMap.EditType.UPDATE;
- }
- else if(editTypeVal == 2){
- editTypeMap = SuperMap.EditType.DELETE;
- }
- map.on('contextmenu', function(evt){
- map.off('click');
- map.off('contextmenu');
- });
- // 新增
- if(editTypeVal == 0){
- // 添加管线
- if(dataType == "line"){
- var startPt;// 开始点击坐标
- var endPt; // 结束点击坐标
- var startGd;// 查询到开始管点
- var endGd;// 查询到结束管点
- var isFirst = true;
- map.on('click', function (evt) {
- var pt = crs.project(evt.latlng);
- var _Point = L.marker([pt.y, pt.x]);
- Q.queryByGeometry("",undefined,CONST_VALUES.JD_DataSetName, CONST_VALUES.JD_DataSourceName, _Point, function(result) {
- if (result.result == undefined || result.result.features.features.length == 0) {
- layui.layer.msg('附件没有发现管点信息,请重新选择!');
- return;
- }
- var rs = L.Util.transform(result.result.features, crs, L.CRS.EPSG4326);
- if(isFirst){
- isFirst = false;
- startPt = evt.latlng;
- startGd = rs.features[0];
- }
- else{
- endPt = evt.latlng;
- endGd = rs.features[0];
- if(!startPt.equals(endPt)){
- var newLine = L.polyline([ //与上一点连线
- [startGd.geometry.coordinates[1], startGd.geometry.coordinates[0]],
- [endGd.geometry.coordinates[1], endGd.geometry.coordinates[0]]
- ], {
- color: "#070af3"
- });
- newLine.addTo(map);
- var from = turf.point([startGd.geometry.coordinates[0], startGd.geometry.coordinates[1]]);
- var to = turf.point([endGd.geometry.coordinates[0], endGd.geometry.coordinates[1]]);
- var options = {units: 'kilometers'};
- var distance = (turf.distance(from, to, options) * 1000).toFixed(2);
- var aa = newLine.toGeoJSON();
- var bb = L.Util.transform(aa, L.CRS.EPSG4326, crs);
- $.ajax({
- url: '/static/maps/bs/create-line.html',
- success: function(htmlContext) {
- layui.use('layer', function(){
- var layer = layui.layer,laydate = layui.laydate,form = layui.form;
- layer.open({
- type: 1 //此处以iframe举例
- ,area: ["400px", "550px"]
- ,title: "添加管线信息"
- ,skin: 'layui-ext-coolskin'
- //,shade: 0.8
- ,maxmin: true
- ,content: htmlContext
- ,zIndex: layer.zIndex
- ,cancel: function (index, layero) {
- layer.close(index);
- map.removeLayer(newLine);
- }
- ,success: function(layero, index){
- $("#QSDH").val(startGd.properties["BSM"]);
- $("#ZDDH").val(endGd.properties["BSM"]);
- $("#QDMS").val(startGd.properties["MS"]);
- $("#ZDMS").val(endGd.properties["MS"]);
- $("#CD").val(distance);
- var nowTime = new Date().Format("yyyyMMddhhmmssS");
- $("#BSM").val(nowTime);
- //日期
- laydate.render({
- elem: '#LRRQ',
- });
- laydate.render({
- elem: '#MSRQ',
- });
- }
- ,btn: ['保存', '关闭']
- ,yes: function(){
- var data = form.val('createLine');
- bb.properties = data;
- var featuresParameters = new SuperMap.EditFeaturesParameters({
- dataSourceName: dataSourceName,
- dataSetName: dataSetName,
- features: [bb],
- editType: editTypeMap,
- returnContent: true
- });
- L.supermap.featureService(dataUrl)
- .editFeatures(featuresParameters,function(result){
- console.log(result);
- });
- layer.closeAll();
- }
- ,btn2: function(){
- layer.closeAll();
- map.removeLayer(newLine);
- }
- });
- })
- },
- error: function() {
- layui.layer.msg('功能未实现!', {
- icon: 7
- });
- }
- });
- isFirst = true;
- }
- }
- });
- });
- }
- else{
- map.on('click', function (evt) {
- var pt = crs.project(evt.latlng);
- var aaaaa = L.circleMarker(evt.latlng, {color: '#953716', radius: 3, fill: true, fillColor: 'green'}).addTo(map);
- var _Point = L.marker([pt.y, pt.x]);
- var aa = _Point.toGeoJSON();
- $.ajax({
- url: '/static/maps/bs/create-point.html',
- success: function(htmlContext) {
- layui.use('layer', function(){
- var layer = layui.layer,laydate = layui.laydate,form = layui.form;
- layer.open({
- type: 1 //此处以iframe举例
- ,area: ["390px", "550px"]
- ,title: "添加管点信息"
- ,skin: 'layui-ext-coolskin'
- //,shade: 0.8
- ,maxmin: true
- ,content: htmlContext
- ,zIndex: layer.zIndex
- ,cancel: function (index, layero) {
- layer.close(index);
- map.removeLayer(aaaaa);
- }
- ,success: function(layero, index){
- $("#X").val(aa.geometry.coordinates[0]);
- $("#Y").val(aa.geometry.coordinates[1]);
- var nowTime = new Date().Format("yyyyMMddhhmmssS");
- $("#BSM").val(nowTime);
- $("#WTH").val(nowTime);
- //日期
- laydate.render({
- elem: '#LRRQ',
- });
- laydate.render({
- elem: '#MSRQ',
- });
- }
- ,btn: ['保存', '关闭']
- ,yes: function(){
- var data = form.val('createPoint');
- aa.properties = data;
- var featuresParameters = new SuperMap.EditFeaturesParameters({
- dataSourceName: dataSourceName,
- dataSetName: dataSetName,
- features: [aa],
- editType: editTypeMap,
- returnContent: true
- });
- L.supermap.featureService(dataUrl)
- .editFeatures(featuresParameters,function(result){
- console.log(result);
- });
- layer.closeAll();
- }
- ,btn2: function(){
- layer.closeAll();
- map.removeLayer(aaaaa);
- }
- });
- })
- },
- error: function() {
- layui.layer.msg('功能未实现!', {
- icon: 7
- });
- }
- });
- });
- }
- }
- // 修改操作
- else if(editTypeVal == 1){
- map.on('click', function (evt) {
- var pt = crs.project(evt.latlng);
- var _Point = L.marker([pt.y, pt.x]);
- Q.queryByGeometry("",undefined,dataSetName, dataSourceName, _Point, function(result) {
- if (result.result == undefined || result.result.features.features.length < 1) return;
- // 坐标系转换
- //var result = L.Util.transform(result.result.features, crs, L.CRS.EPSG4326);
- var editFeature = result.result.features.features[0];
- var rsVal = editFeature.properties;
- if(dataType == "line"){
- $.ajax({
- url: '/static/maps/bs/create-line.html',
- success: function(htmlContext) {
- layui.use('layer', function(){
- var layer = layui.layer,laydate = layui.laydate,form = layui.form;
- layer.open({
- type: 1 //此处以iframe举例
- ,area: ["400px", "550px"]
- ,title: "编辑管线信息"
- ,skin: 'layui-ext-coolskin'
- //,shade: 0.8
- ,maxmin: true
- ,content: htmlContext
- ,zIndex: layer.zIndex
- ,cancel: function (index, layero) {
- layer.close(index);
- }
- ,success: function(layero, index){
- form.val('createLine', rsVal);
- //日期
- laydate.render({
- elem: '#LRRQ',
- });
- laydate.render({
- elem: '#MSRQ',
- });
- }
- ,btn: ['保存', '关闭']
- ,yes: function(){
- var data = form.val('createLine');
- editFeature.properties = data;
- var featuresParameters = new SuperMap.EditFeaturesParameters({
- dataSourceName: dataSourceName,
- dataSetName: dataSetName,
- features: [editFeature],
- editType: editTypeMap,
- returnContent: true
- });
- L.supermap.featureService(dataUrl)
- .editFeatures(featuresParameters,function(result){
- console.log(result);
- });
- layer.closeAll();
- }
- ,btn2: function(){
- layer.closeAll();
- }
- });
- })
- },
- error: function() {
- layui.layer.msg('功能未实现!', {
- icon: 7
- });
- }
- });
- }
- else{
- $.ajax({
- url: '/static/maps/bs/create-point.html',
- success: function(htmlContext) {
- layui.use('layer', function(){
- var layer = layui.layer,laydate = layui.laydate,form = layui.form;
- layer.open({
- type: 1 //此处以iframe举例
- ,area: ["390px", "550px"]
- ,title: "编辑管点信息"
- ,skin: 'layui-ext-coolskin'
- //,shade: 0.8
- ,maxmin: true
- ,content: htmlContext
- ,zIndex: layer.zIndex
- ,cancel: function (index, layero) {
- layer.close(index);
- }
- ,success: function(layero, index){
- form.val('createPoint', rsVal);
- //日期
- laydate.render({
- elem: '#LRRQ',
- });
- laydate.render({
- elem: '#MSRQ',
- });
- }
- ,btn: ['保存', '关闭']
- ,yes: function(){
- var data = form.val('createPoint');
- editFeature.properties = data;
- var featuresParameters = new SuperMap.EditFeaturesParameters({
- dataSourceName: dataSourceName,
- dataSetName: dataSetName,
- features: [editFeature],
- editType: editTypeMap,
- returnContent: true
- });
- L.supermap.featureService(dataUrl)
- .editFeatures(featuresParameters,function(result){
- console.log(result);
- });
- layer.closeAll();
- }
- ,btn2: function(){
- layer.closeAll();
- }
- });
- })
- },
- error: function() {
- layui.layer.msg('功能未实现!', {
- icon: 7
- });
- }
- });
- }
- L.geoJSON(result, {
- style:{color: "#ef5b9c"},
- onEachFeature: function (feature, layer) {
- let attributes = "";
- let lyrs = CONST_VALUES.GX_Datas;
- for (var index = 0; index < lyrs.length; index++) {
- var lyr = lyrs[index];
- if(ws == lyr.dataSourceName && dataSetName == lyr.dataSetName){
- var showCols = lyr.cols;
- if(showCols != undefined && showCols != ""){
- var colsArr = showCols.split(",");
- for(var i = 0; i < colsArr.length; i++){
- var colArr = colsArr[i].split(":");
- let attValue = feature.properties[colArr[0]];
- let attr = colArr[1] + ":" + attValue + "<br>";
- attributes += attr;
- }
- }
- break;
- }
- }
- layer.bindPopup(attributes);
- }
- }).addTo(resultLayer);
- });
- });
- }
- // 删除操作
- else if(editTypeVal == 2){
- drawType = "deletefeature";
- // 创建绘制控件,并启用
- var handler = new L.Draw.Polygon(map);
- handler.enable();
- map.on(L.Draw.Event.CREATED,function (e) {
- if(drawType != "deletefeature"){
- return;
- }
- var type = e.layerType,
- layer = e.layer;
- if (type === 'marker') {
- layer.bindPopup('A popup!');
- }
- //将图形信息传给下一步,进行查询功能
- var locationArray = e.layer.getLatLngs()[0];
- var polygonArray = Array();
- var midArray = Array();
- var polygonArrayTmp = Array();
- var midArrayTmp = Array();
- var firstX = locationArray[0].lat;
- var firstY = locationArray[0].lng;
- for(var i =0;i<locationArray.length;i++){
- var pt2 = crs.project(locationArray[i]);
- var x = locationArray[i].lat;
- var y = locationArray[i].lng;
- midArray.push(x);
- midArray.push(y);
- polygonArray.push(midArray);
- midArray = Array();
- midArrayTmp.push(pt2.y);
- midArrayTmp.push(pt2.x);
- polygonArrayTmp.push(midArrayTmp);
- midArrayTmp = Array();
- }
- midArray.push(firstX);
- midArray.push(firstY);
- polygonArray.push(midArray);
- var pt2 = crs.project(locationArray[0]);
- midArrayTmp.push(pt2.y);
- midArrayTmp.push(pt2.x);
- polygonArrayTmp.push(midArrayTmp);
- var polygonTmp = L.polygon(polygonArrayTmp);
- var polygon = L.polygon(polygonArray, {color: "#00FF00"});
- resultLayer.addLayer(polygon);
- Q.queryByBounds("",dataSetName, dataSourceName, polygonTmp, function(result,titleTmp) {
- if (result.result == undefined) return;
- var rs = result.result.features.features;
- var ids = new Array();
- for(var i = 0; i < rs.length; i++){
- ids.push(rs[i].properties["SMID"]);
- }
- if(ids.length > 0){
- layui.use('layer', function(){
- let lyrsTmp = '<div style="font-size: 14px; color: white;"><br/>您确定要删除选择的管网元素信息吗!</div>';
- var layer = layui.layer;
- layer.open({
- type: 1 //此处以iframe举例
- ,area: ["350px", "250px"]
- ,title: "提示"
- ,skin: 'layui-ext-coolskin'
- ,content: lyrsTmp
- ,zIndex: layer.zIndex
- ,cancel: function (index, layero) {
- layer.close(index);
- }
- ,btn: ['确定', '取消']
- ,yes: function(){
- var featuresParameters = new SuperMap.EditFeaturesParameters({
- dataSourceName: dataSourceName,
- dataSetName: dataSetName,
- editType: editTypeMap,
- returnContent: true,
- IDs: ids
- });
- L.supermap.featureService(dataUrl)
- .editFeatures(featuresParameters,function(result){
- clearLays();
- });
- layer.closeAll();
- }
- ,btn2: function(){
- layer.closeAll();
- clearLays();
- }
- });
- })
- }
- else {
- layui.layer.msg('选择的区域没有数据信息!', {
- icon: 7
- });
- }
- });
- });
- }
- }
- });
- layui.use(['form'], function() {
- let form = layui.form;
- form.render();
- });
- });
- }
- Date.prototype.Format = function (fmt) { // author: meizz
- var o = {
- "M+": this.getMonth() + 1, // 月份
- "d+": this.getDate(), // 日
- "h+": this.getHours(), // 小时
- "m+": this.getMinutes(), // 分
- "s+": this.getSeconds(), // 秒
- "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
- "S": this.getMilliseconds() // 毫秒
- };
- if (/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- }
|