1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
- <title>上海城地API</title>
- <style>
- html,
- body,
- #mapDiv {
- padding: 0;
- margin: 0;
- height: 100%;
- width: 100%;
- }
- /*自定义窗口样式*/
- .leaflet-popup-content-wrapper{
- background-color: rgba(0,0,0,0.8) !important;
- color:white !important;
- }
- .leaflet-popup-tip{
- background-color: rgba(0,0,0,0.8) !important;
- }
- .esri-view-surface--inset-outline:focus::after {
- outline: none !important;
- }
- </style>
- <script src="js/echarts.min.js"></script>
- <script src="jquery/jquery-2.2.3.min.js"></script>
- <script type="text/javascript" src="jquery/xml2json.js"></script>
- <script>
- var dojoConfig = {
- async: true,
- parseOnLoad: true,
- packages: [{
- name: "lib",
- location: location.pathname.replace(/\/[^/]+$/, "") + "/lib"
- }]
- };
- </script>
- <script src="Common/mapClass/corrugatedPoint/gl-matrix.js"></script>
- <!--<script src="http://172.16.28.83/arcgis_api/library/4.17/init.js"></script>-->
- <!--<link rel="stylesheet" href="http://172.16.28.83/arcgis_js_api/library/4.17/esri/themes/light/main.css">-->
- <script src="https://10.101.35.50/arcgis_js_api/library/4.17/init.js"></script>
- <link rel="stylesheet" href="https://10.101.35.50/arcgis_js_api/library/4.17/esri/themes/light/main.css">
- <link rel="stylesheet" href="css/echartsLayerCss.css">
- <!--系统自定义JS-->
- <script src="Common/dataClass/XMLUtil.js"></script> <!--XML操作功能-->
- <script src="Common/dataClass/ConfigManagertest.js"></script>
- <script src="Common/dataClass/DataCommonClass.js"></script>
- <script src="Common/dataClass/MD5.js"></script>
- <script src="Common/dataClass/Base64.js"></script>
- <script src="Common/mapClass/MapClass4.js"></script>
- <script src="Common/WsCommonClass.js"></script>
- <script src="Common/mapClass/GSFunction.js"></script>
- <script src="Common/mapClass/corrugatedPoint/corrugatedPoint.js"></script>
- <script>
- //监听message
- window.onmessage = function(e) {
- //alert(e.origin);
- //if (e.origin !== 'http://10.101.35.46/WJGisShare/')
- //return;
- var payload;
- try{
- payload= JSON.parse(e.data);
- }
- catch(e){
- return;
- }
- switch (payload.method) {
- case 'ZoomIn':
- //localStorage.setItem(payload.key, JSON.stringify(payload.data));
- ZoomIn(payload.data);
- break;
- case 'ZoomOut':
- ZoomOut(payload.data);
- break;
- case 'Clear':
- Clear(payload.data);
- break;
- case 'ViewChange':
- ViewChange();
- break;
- case 'fullExtent':
- toFullExtent();
- break;
- case 'doSetExtent':
- doSetExtent(parseInt(payload.data));
- break;
- case 'measureSquare':
- measureSquare();
- break;
- case 'measureLength':
- measureLength();
- break;
- case 'downLoadPicture':
- downLoadPicture();
- break;
- case 'doGetGraphicByJson':
- doGetGraphicByJson(payload.data[0],payload.data[1]);
- break;
- case 'drawSquare':
- drawSquare();
- break;
- case 'query':
- query(payload.data[0],payload.data[1]);
- break;
- case 'queryByWhereStr':
- querybyWhereStr(payload.data[0],payload.data[1]);
- break;
- case 'openFeatureLayer':
- OpenFeatureLayerByID(payload.data[0],payload.data[1]);
- break;
- case 'openFeatureLayerByName':
- // var isVisible=true;
- // if(parseInt(payload.data[1])==0)
- // {
- // isVisible=false;
- // }
- OpenMapImageLayerByName(payload.data[0],payload.data[1],payload.data[2]);
- break;
- case "CloseChangeLayer":{
- closeMapImageLayerByName();
- break;
- }
- case "doClusterByJson":{
- clusterByJson(payload.data[0]);
- break;
- }
- case 'openFeatureLayer0':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(0,isVisible);
- break;
- case 'openFeatureLayer1':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(1,isVisible);
- break;
- case 'openFeatureLayer2':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(2,isVisible);
- break;
- case 'openFeatureLayer3':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(3,isVisible);
- break;
- case 'openFeatureLayer4':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(4,isVisible);
- break;
- case 'openFeatureLayer5':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(5,isVisible);
- break;
- case 'openFeatureLayer6':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(6,isVisible);
- break;
- case 'openFeatureLayer7':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(7,isVisible);
- break;
- case 'openFeatureLayer8':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(8,isVisible);
- break;
- case 'openFeatureLayer9':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(9,isVisible);
- break;
- case 'openFeatureLayer10':
- var isVisible=true;
- if(parseInt(payload.data[0])==0)
- {
- isVisible=false;
- }
- OpenFeatureLayerByID1(10,isVisible);
- break;
- case 'setCenterExtent':
- setCenterExtent(payload.data[0],payload.data[1],payload.data[2]);
- break;
- case 'drawCircle':{
- drawCircle(payload.data[0]);
- break;
- }
- case 'queryByCircle':{
- queryByCircle(payload.data[0] ,payload.data[1] ,payload.data[2] ,payload.data[3] )
- break;
- }
- case 'doFlashStatus':{
- var flahLayerName=payload.data[0];
- switch(flahLayerName)
- {
- case "违章建筑":
- flashLayerStatus(fe0,"状态",1);
- break;
- case "电梯":
- flashLayerStatus(fe4,"状态",1);
- break;
- case "虹口烟感":
- flashLayerStatus(fe1,"状态",1);
- break;
- case "摄像头":
- flashLayerStatus(fe2,"状态",1);
- break;
- case "危险源":
- flashLayerStatus(fe3,"状态",1);
- break;
- case "门磁":
- flashLayerStatus(fe5,"状态",1);
- break;
- default:
- ClearLightLayerStatus();
- break;
- }
- break;
- }
- case "onLocation":{
- setPointBylonlat(payload.data[0],payload.data[1],payload.data[2],payload.data[3],payload.data[4],payload.data[5] ,payload.data[6]);
- break;
- }
- case "MeasureLengthByPoint":{
- //parent.eval(payload.backfun+"()");
- MeasureLengthByPoint(payload.data[0],payload.data[1],payload.data[2],payload.data[3],payload.backfun);
- break;
- }
- case "newQuery":{
- newQuerybyWhereStr(payload.data[0],payload.data[1],GetConfigDataByName("MYQueryLayer"),null,null,payload.data[2]);
- break;
- }
- case "onLocationforGrid" :{
- setPointBylonlatForGrid(payload.data[0],payload.data[1]);
- break;
- }
- case "onLocationforAddress":{
- setPointBylonlatForAddress(payload.data[0],payload.data[1]);
- break;
- }
- case "onQueryByPoint":{
- setPointBylonlatForGetBuffer(payload.data[0],payload.data[1],payload.data[2],payload.data[3],payload.data[4],payload.data[5]);
- break;
- }
- case "onQueryByGrid":{
- getGridGeometry(payload.data[0],payload.data[1]);
- break;
- }
- case "onMapCenter":{
- var mapcenter = m_view.center ;
- window.parent.postMessage(
- {
- method: "mapCenterCallback",
- data:[JSON.stringify(mapcenter).replace(/\"/g,'"')]
- },
- '*'
- );
- break;
- }
- case "onMapLevel":{
- var mapzoom = m_view.zoom;
- window.parent.postMessage(
- {
- method: "mapLevelCallback",
- data:[JSON.stringify(mapzoom).replace(/\"/g,'"')]
- },
- '*'
- );
- break;
- }
- case "onMapSetCenter":{
- goToZoom(payload.data[0],payload.data[1]);
- // setPointBylonlatForSetCenter(payload.data[0],payload.data[1]);
- break;
- }
- case "onGetXYbyAddress":{
- getXYbyAddress(payload.data[0]);
- break;
- }
- case "onSetInitExtentByStr":{
- // getXYbyAddress(payload.data[0]);
- if(payload.data[0] == "区县边界")
- queryForExtent(payload.data[0],"区县名称=" +"'"+ payload.data[1]+"'",100);
- else
- queryForExtent(payload.data[0], "街道名称=" +"'"+ payload.data[1]+"'",100);
- break;
- }
- case "onQueryByCondition":{
- newQuerybyWhereStr(payload.data[0],payload.data[1],GetConfigDataByName("MYQueryLayer"),null,payload.data[2],payload.data[3]);
- break;
- }
- case "openFeatureLayerByNameandWhere":{
- newOpenFeatureLayer(payload.data[0],payload.data[1],payload.data[2],payload.data[3],payload.data[4]);
- break;
- }
- case "onClickLocation":{
- m_mapClickdraw = true;
- m_mapAttribute = payload.data[0];
- m_mapToolTip = payload.data[1];
- m_mapImgUrl = payload.data[2];
- m_mapImgWidth = payload.data[3];
- m_mapImgHeight = payload.data[4];
- break;
- }
- case "onSetResizeType":{
- sj_type = payload.data[0];
- sj_radius = payload.data[1];
- sj_layername = payload.data[2];
- break;
- }
- case "onSetLayerCluster":{
- setLayerCluster(payload.data[0],payload.data[1]);
- break;
- }
- case "onShowPolygonandText":{
- var jsonarr = payload.data[0];
- for(var i=0;i<jsonarr.length;i++){
- var jsonStr = jsonarr[i];
- // var test = jsonStr;
- ShowPolygonandText(jsonStr.type,jsonStr.name,jsonStr.text);
- }
- // ShowPolygonandText(payload.data[0],payload.data[1],payload.data[2]);
- break;
- }
- case "onLocationGetLatLon":{
- var action = m_drawtool.create("point");
- require(["esri/geometry/Point","esri/Graphic"],
- function(Point,Graphic) {
- action.on("draw-complete",
- function(evt) {
- m_view.graphics.removeAll();
- GraphicsLayer_flyTipLayer.removeAll();
- var point = new Point({
- x: evt.coordinates[0],
- y: evt.coordinates[1],
- spatialReference: m_view.spatialReference
- });
- var markerSymbol = {
- type: "simple-marker",
- color: payload.data[0],
- style: "circle",
- size: 10
- }
- var pointGraphic = new Graphic({
- geometry: point,
- symbol: markerSymbol
- });
- GraphicsLayer_flyTipLayer.add(pointGraphic);
- window.parent.postMessage(
- {
- method: "onLocationGetLatLonbackfun",
- data: [evt.coordinates]
- },
- '*'
- );
- });
- });
- break;
- }
- case "onDrawPolygonCircle":{
- require(["esri/geometry/Polygon","esri/Graphic","esri/geometry/Point","esri/geometry/Circle"],
- function(Polygon,Graphic,Point,Circle) {
- m_view.graphics.removeAll();
- GraphicsLayer_flyTipLayer.removeAll();
- var action = m_drawtool.create("circle");
- // 获取焦点
- m_view.focus();
- //顶点移除事件
- action.on("vertex-remove", createCircle);
- // 鼠标移动事件
- action.on("cursor-update", createCircle);
- // 绘制完成事件
- action.on("draw-complete", createCirclecomplete);
- function createCircle(event) {
- //获取所有顶点
- var vertices = event.vertices;
- //少于一个点无法展示圆
- if(vertices.length<2){
- return
- }
- //清除之前绘制
- GraphicsLayer_flyTipLayer.removeAll();
- //生成绘制的图形,两点画圆
- var center=new Point({
- hasZ: false,
- hasM: false,
- x:vertices[0][0],
- y:vertices[0][1],
- spatialReference: m_view.spatialReference
- });
- var dis=center.distance(new Point({
- hasZ: false,
- hasM: false,
- x:vertices[1][0],
- y:vertices[1][1],
- spatialReference: m_view.spatialReference
- }));
- var graphic = new Graphic({
- geometry: new Circle({
- hasZ: false,
- hasM: false,
- center:center,
- radius:dis,
- spatialReference: m_view.spatialReference
- }),
- symbol: {
- type: "simple-fill", // autocasts as new SimpleFillSymbol()
- color: [ 51,51, 204, 0.9 ],
- style: "solid",
- outline: { // autocasts as new SimpleLineSymbol()
- color: "white",
- width: 1
- }
- }
- });
- // 将绘制的图形添加到view
- GraphicsLayer_flyTipLayer.add(graphic);
- }
- function createCirclecomplete(event) {
- //获取所有顶点
- var vertices = event.vertices;
- //少于一个点无法展示圆
- if(vertices.length<2){
- return
- }
- //清除之前绘制
- GraphicsLayer_flyTipLayer.removeAll();
- //生成绘制的图形,两点画圆
- var center=new Point({
- hasZ: false,
- hasM: false,
- x:vertices[0][0],
- y:vertices[0][1],
- spatialReference: m_view.spatialReference
- });
- var dis=center.distance(new Point({
- hasZ: false,
- hasM: false,
- x:vertices[1][0],
- y:vertices[1][1],
- spatialReference: m_view.spatialReference
- }));
- var graphic = new Graphic({
- geometry: new Circle({
- hasZ: false,
- hasM: false,
- center:center,
- radius:dis,
- spatialReference: m_view.spatialReference
- }),
- symbol: {
- type: "simple-fill", // autocasts as new SimpleFillSymbol()
- color: [ 51,51, 204, 0.9 ],
- style: "solid",
- outline: { // autocasts as new SimpleLineSymbol()
- color: "white",
- width: 1
- }
- }
- });
- // 将绘制的图形添加到view
- GraphicsLayer_flyTipLayer.add(graphic);
- window.parent.postMessage(
- {
- method: "onDrawPolygoncallbackfun",
- data: [graphic.geometry.rings]
- },
- '*'
- );
- }
- });
- break;
- }
- case "onLightArea":{
- highLightArea(payload.data[0],payload.data[1],payload.data[2],payload.data[3]);
- break;
- }
- case "onEchartsRoute":{
- echartsRoute(payload.data[0],payload.data[1],payload.data[2],payload.data[3]);
- break;
- }
- case "onPopupIn":{
- if(popupInfos.length>0){
- popupShowAll();
- }
- else{
- popupInit(payload.data[0],payload.data[1]);
- }
- break;
- }
- case "onPopupClose":{
- popupCloseAll();
- popupInfos=[];
-
- break;
- }
- case "doClusterByJson":{
- clusterByJson(payload.data[0]);
- break;
- }
- case "doCloseClusterByJson":{
- closeClusterByJson();
- break
- }
- case 'doDeletePointById':
- doDeletePointById(payload.data[0]);
- break;
- case "doShowAreaName":
- doShowAreaName(payload.data[0],payload.data[1],payload.data[2],payload.data[3],payload.data[4]);
- break;
- case "onDrawPolygonSquare":{
- require(["esri/geometry/Polygon","esri/Graphic","esri/geometry/Point","esri/geometry/Circle"],
- function(Polygon,Graphic,Point,Circle) {
- m_view.graphics.removeAll();
- GraphicsLayer_flyTipLayer.removeAll();
- var action = m_drawtool.create("rectangle", {
- mode: "click"//点击方式加点
- });
- // 获取焦点
- m_view.focus();
- //顶点移除事件
- action.on("vertex-remove", createRectangle);
- // 鼠标移动事件
- action.on("cursor-update", createRectangle);
- // 绘制完成事件
- action.on("draw-complete", createRectangleComplete);
- function createRectangle(event) {
- //获取所有顶点
- var vertices = event.vertices;
- //两点画矩形
- if(vertices.length<2){
- return
- }
- var rings=[vertices[0],[vertices[0][0],vertices[1][1]],vertices[1],[vertices[1][0],vertices[0][1]]];
- //清除之前绘制
- GraphicsLayer_flyTipLayer.removeAll();
- // 生成绘制的图形
- var graphic = new Graphic({
- geometry: new Polygon({
- hasZ: false,
- hasM: false,
- rings: [rings],
- spatialReference: m_view.spatialReference
- }),
- symbol: {
- type: "simple-fill", // autocasts as new SimpleFillSymbol()
- color: [ 51,51, 204, 0.9 ],
- style: "solid",
- outline: { // autocasts as new SimpleLineSymbol()
- color: "white",
- width: 1
- }
- }
- });
- // 将绘制的图形添加到view
- GraphicsLayer_flyTipLayer.add(graphic);
- }
- function createRectangleComplete(event) {
- //获取所有顶点
- var vertices = event.vertices;
- //两点画矩形
- if(vertices.length<2){
- return
- }
- var rings=[vertices[0],[vertices[0][0],vertices[1][1]],vertices[1],[vertices[1][0],vertices[0][1]]];
- //清除之前绘制
- GraphicsLayer_flyTipLayer.removeAll();
- // 生成绘制的图形
- var graphic = new Graphic({
- geometry: new Polygon({
- hasZ: false,
- hasM: false,
- rings: [rings],
- spatialReference: m_view.spatialReference
- }),
- symbol: {
- type: "simple-fill", // autocasts as new SimpleFillSymbol()
- color: [ 51,51, 204, 0.9 ],
- style: "solid",
- outline: { // autocasts as new SimpleLineSymbol()
- color: "white",
- width: 1
- }
- }
- });
- // 将绘制的图形添加到view
- GraphicsLayer_flyTipLayer.add(graphic);
- window.parent.postMessage(
- {
- method: "onDrawPolygoncallbackfun",
- data: [graphic.geometry.rings]
- },
- '*'
- );
- }
- });
- break;
- }
- case "doCorrugatedPointByOid":{
- doCorrugatedPointByOid(payload.data[0]);
- break;
- }
- case "doClearCorrugatedPoint":{
- doClearCorrugatedPoint();
- break;
- }
- case "doXyToStreetId":{
- doXyToStreetId(payload.data[0],payload.data[1]);
- break;
- }
- case "goToGraphic":{
-
- goToGraphic(payload.data[0], payload.data[1]);
- break;
- }
- case "doWaterRouteClick":{
- if(chartLayer){
- chartLayer.removeLayer();
- chartLayer=null;
- }
- if(chartLayer2){
- chartLayer2.removeLayer();
- chartLayer2=null;
- }
- if(chartLayer3){
- chartLayer3.removeLayer();
- chartLayer3=null;
- }
- queryResetNumByType(payload.data[0]);
- break
- }
- }
- };
- //初始化配置文件
- GetConfigData();
- require(["dojo/domReady!"
- ], function () {
- loadMap();
- });
- function loadMap() {
- //判断
- if (GetConfigDataByName("maptype") == "3D") {
- init3DScene();
- }
- else {
- initMap();
- }
- }
- function onMapLoadInfo(){
- console.log("test2")
- postToParentPageMethed("maploadCallback",[]);
- }
- function onMapLoaded()
- {
- removeLoadingDiv();
- // GetLayerMainRestInfo2(GetConfigDataByName("MYQueryLayer"));
- // var test = GetConfigDataByName("MYCXFeatureLayerLayer");
- // setPointBylonlat(121,30);
- //alert("加载完成");
- }
- //--------------- 按钮事件 -----------------
- //切换二三维地图
- function onViewTestClick() {
- ViewChange()
- }
- function ViewChange() {
- //m_view.container=null;
- // showLoadingDiv("正在切换地图,请稍后...");
- if (currentMapMode == "2D") {
- switchTo3DMap();
- }
- else {
- switchTo2DMap();
- }
- }
- //清空地图
- function btClear_Click() {
- //Clear();
- }
- function Clear(type) {
- require(["esri/layers/GraphicsLayer"],
- function ( GraphicsLayer) {
- switch (type) {
- case "all":
- {
- m_map.remove(GraphicsLayer_DrawLayer)
- GraphicsLayer_DrawLayer = new GraphicsLayer({id: "myDrawGLayer"});
- GraphicsLayer_DrawLayer.listMode = "hide";
- m_map.add(GraphicsLayer_DrawLayer);
- GraphicsLayer_myLayer.removeAll();
- isInLightArea = ""
- // GraphicsLayer_DrawLayer.removeAll();
- GraphicsLayer_flyTipLayer.removeAll();
- if (chartLayer) {
- chartLayer.removeLayer();
- chartLayer = null;
- }
- if (chartLayer2) {
- chartLayer2.removeLayer();
- chartLayer2 = null;
- }
- if (chartLayer3) {
- chartLayer3.removeLayer();
- chartLayer3 = null;
- }
- xmlQueryExtend = null;
- queryExtent = null;
- break;
- }
- case "drawLayer":
- {
- GraphicsLayer_DrawLayer.removeAll();
- GraphicsLayer_flyTipLayer.removeAll();
- xmlQueryExtend = null;
- queryExtent = null;
- break;
- }
- case "queryLayer":
- {
- GraphicsLayer_myLayer.removeAll();
- isInLightArea = ""
- GraphicsLayer_flyTipLayer.removeAll();
- xmlQueryExtend = null;
- queryExtent = null;
- break;
- }
- case "chartLayer":
- {
- if (chartLayer) {
- chartLayer.removeLayer();
- chartLayer = null;
- }
- if (chartLayer2) {
- chartLayer2.removeLayer();
- chartLayer2 = null;
- }
- if (chartLayer3) {
- chartLayer3.removeLayer();
- chartLayer3 = null;
- }
- break;
- }
- }
- })
- // var mtype = type | "all";
- }
- //查询
- function btSearch_Click() {
- // var dynamicLayerURL="https://services8.arcgis.com/wUIATpkD1eTGk5lC/arcgis/rest/services/CMRQTest2_WFL1/FeatureServer";
- // var QueryLayerID="13";
- var dynamicLayerURL ="http://139.196.105.31:6080/ArcGIS/rest/services/HKEMAP/MapServer";
- if(GetConfigDataByName("QueryLayer"))
- {
- dynamicLayerURL=GetConfigDataByName("QueryLayer");
- }
- var QueryLayerID = "13";
- var whereString = "";
- whereString = "HANDLE号 like '%" + document.getElementById("txtSearch").value + "%'";
- require([
- "esri/Graphic",
- "esri/tasks/QueryTask",
- "esri/tasks/support/Query",
- "esri/symbols/SimpleMarkerSymbol",
- "esri/symbols/SimpleLineSymbol",
- "esri/geometry/Point",
- "esri/geometry/Polyline",
- "esri/symbols/PointSymbol3D",
- "esri/renderers/SimpleRenderer",
- "esri/symbols/ObjectSymbol3DLayer",
- "esri/PopupTemplate",
- "dojo/_base/array"
- ], function (Graphic, QueryTask, Query, SimpleMarkerSymbol, SimpleLineSymbol, Point, Polyline, PointSymbol3D, SimpleRenderer, ObjectSymbol3DLayer, PopupTemplate, array) {
- var layerinfo = getLayerByLayerId(QueryLayerID);
- var queryTask = new QueryTask(dynamicLayerURL + "/" + QueryLayerID);
- var query = new Query();
- query.returnGeometry = true;
- query.outFields = ["*"];
- query.where = whereString;
- var defaultPointSymbol = new SimpleMarkerSymbol({
- color: [226, 119, 40],
- outline: { // autocasts as new SimpleLineSymbol()
- color: [255, 255, 255],
- width: 2
- }
- });
- var defaultLineSymbol = new SimpleLineSymbol({
- color: [255, 0, 255],
- width: 2
- });
- var objectSymbol = new PointSymbol3D({
- symbolLayers: [new ObjectSymbol3DLayer({
- width: 2,
- height: 3,
- resource: {
- primitive: "cone"
- },
- material: {
- color: "#FFD700"
- }
- })]
- });
- var objectSymbolRenderer = new SimpleRenderer({
- symbol: objectSymbol
- });
- //graphicsLayer.renderer = objectSymbolRenderer;
- queryTask.execute(query).then(function (results) {
- array.forEach(results.features, function (graphic, i) {
- var graphic2;
- var point2;
- switch (graphic.geometry.type) {
- case "point":
- {
- graphic.geometry.z = 1000;
- graphic.symbol = defaultPointSymbol;
- break;
- }
- case "polyline":
- var geo = Polyline(graphic.geometry);
- geo.hasZ = true;
- geo.hasM = false;
- var paths = geo.paths;
- for (var i = 0; i < paths.length; i++) {
- for (var j = 0; j < paths[i].length; j++) {
- paths[i][j] = [paths[i][j][0], paths[i][j][1], 50];
- }
- var middleNumber = Math.floor(paths[i].length / 2);
- point2 = new Point({
- x: paths[i][middleNumber][0],
- y: paths[i][middleNumber][1],
- z: 50,
- spatialReference: view.spatialReference
- });
- }
- graphic.symbol = defaultLineSymbol;
- graphic.geometry = geo;
- graphic2 = new Graphic();
- graphic2.attributes = graphic.attributes;
- graphic2.geometry = point2;
- graphic2.symbol = objectSymbol;
- graphic2.attributes = graphic.attributes;
- graphic2.popupTemplate = layerinfo.popupTemplate;
- graphic.popupTemplate = new PopupTemplate({
- title: "HANDLE号:{HANDLE号}"
- });
- break;
- }
- GraphicsLayer_myLayer.add(graphic);
- GraphicsLayer_myLayer.add(graphic2);
- });
- });
- })
- }
- var laylistshow=0;
- function layerOnOff() {
- if(laylistshow==0){
- laylistshow=1;
- m_view.ui.add(layerList, {
- position: "bottom-right"
- });
- }
- else
- {
- laylistshow=0;
- m_view.ui.remove(layerList);
- }
- }
- function doSetExtent(num) {
- var xmin,ymin,xmax,ymax;
- switch(num){
- case 1:
- xmin=-17221.816;
- ymin=-5450.66;
- xmax=-15189.445;
- ymax=-4297.402;
- break;
- case 2:
- xmin=-25930.782;
- ymin=-10527.042;
- xmax=-5599.259;
- ymax=647.995;
- break;
- case 3:
- xmin=-89836.648;
- ymin=-56485.216;
- xmax=70797.201;
- ymax=31738.557;
- break;
- }
- setExtent(xmin,ymin,xmax,ymax);
- }
- var myAttribute,myToolTip,myImgUrl,myImgWidth,myImgHeight;
- function setPointBylonlat(x,y,Attribute,ToolTip,ImgUrl,ImgWidth,ImgHeight){
- myAttribute = Attribute;
- myToolTip = ToolTip;
- myImgUrl = ImgUrl;
- myImgWidth = ImgWidth;
- myImgHeight=ImgHeight
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- WsCommonClass("ConvertLonLatToXY",["lon","lat"],[x,y],getXYbylonlat,null,url);
- }
- function getXYbylonlat(evt){
- if(evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- // console.log(evt[0].textContent);
- var point = evt[0].textContent;
- var jsonStr = '{"ExChangeRoot": {"Features": [' +
- ' { "type": "point", "featureName": "兴趣点", "Feature":[ { "Geometry": { "Points":[ { "Point": "'+point+'" } ]},' +
- '"Attribute": '+myAttribute+', "ToolTip": "'+myToolTip+'",' +
- '"ImgUrl":"'+myImgUrl +'" ,"ImgWidth":"'+ myImgWidth +'","ImgHeight":"'+myImgHeight +'" } ] } ]}}';
- doGetGraphicByJson(jsonStr,true);
- // console.log(jsonStr);
- }
- function setPointBylonlatForGrid(x,y){
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- WsCommonClass("ConvertLonLatToXY",["lon","lat"],[x,y],getXYbylonlatforGrid,null,url);
- }
- function getXYbylonlatforGrid(evt){
- if(evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- // console.log(evt[0].textContent);
- var point = evt[0].textContent;
- identifyTask(point,identifyTaskcallbackfun);
- }
- function identifyTaskcallbackfun(results){
- window.parent.postMessage(
- {
- method: "identifyTaskcallbackfun",
- data: [results]
- },
- '*'
- );
- }
- function setPointBylonlatForAddress(x,y){
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- WsCommonClass("ConvertLonLatToXY",["lon","lat"],[x,y],getXYbylonlatforAddress,null,url);
- }
- function getXYbylonlatforAddress(evt){
- if(evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- // console.log(evt[0].textContent);
- var point = evt[0].textContent;
- // var url = GetConfigDataByName("WebServiceExtraURL");
- // WsCommonClass("GetAddress",["x","y"],[point.split(',')[0],point.split(',')[1]],getAddressCallback,null,url);
- GetAddressByXY(point.split(',')[0],point.split(',')[1],50);
- }
- function getAddressCallback(evt){
- if(evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- var address = evt[0].textContent;
- window.parent.postMessage(
- {
- method: "addressdataCallback",
- data: [address]
- },
- '*'
- );
- }
- var m_radius;
- var m_layername;
- var m_showGraphic;
- function setPointBylonlatForGetBuffer(x,y,layername,radius,isshow,isGoTo){
- m_radius = radius;
- m_layername = layername;
- m_showGraphic = isshow;
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- WsCommonClass("ConvertLonLatToXY",["lon","lat"],[x-0,y-0],getXYbylonlatforBuffer,isGoTo,url);
- }
- function getXYbylonlatforBuffer(evt,isGoTo){
- if(evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- var point = evt[0].textContent;
- // var buffer = getBufferByPoint(point.split(',')[0],point.split(',')[1],m_radius);
- getBufferByPoint(point.split(',')[0],point.split(',')[1],m_radius,m_layername,m_showGraphic,isGoTo);
- //m_layername;
- // queryByGeometryAndLayer(buffer,m_layername);
- }
- function getGridGeometry(grid,layername){
- getGridGeometryByGridID(grid,layername);
- }
- function setPointBylonlatForSetCenter(x,y){
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- WsCommonClass("ConvertLonLatToXY",["lon","lat"],[x-0,y-0],getPointBylonlatForSetCenterr,null,url);
- }
- function getPointBylonlatForSetCenterr(evt){
- if(evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- var point = evt[0].textContent;
- m_view.center.x = point.split(',')[0]-0;
- m_view.center.y = point.split(',')[1]-0;
- m_view.goTo({
- target: m_view.center
- });
- // m_view.center = [point.split(',')[0]-0,point.split(',')[1]-0];
- }
- var callMeasureLengthfun;
- function MeasureLengthByPoint(x,y,x1,y1,fun){
- callMeasureLengthfun = fun;
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- var sql="121,31;121,31.1";
- sql = x+","+y+";"+x1+","+y1;
- WsCommonClass("ConvertLonLatToXYMass",["lonAndLatGroup"],[sql],getXYbylonlatMass,null,url);
- }
- function getXYbylonlatMass(evt){
- console.log(evt[0].textContent);
- var points = evt[0].textContent.split(';');
- var x = points[0].split(',')[0];
- var y = points[0].split(',')[1];
- var x1 = points[1].split(',')[0];
- var y1 = points[1].split(',')[1];
- var len = measurePolylineByPoint(x,y,x1,y1);
- // parent.eval(callMeasureLengthfun+"("+ len+")");
- window.parent.postMessage(
- {
- method: callMeasureLengthfun,
- data: [len]
- },
- '*'
- );
- }
- function getXYbyAddress(str){
- var url = GetConfigDataByName("WebServiceExtraURL");
- WsCommonClass("GetStreetInfo",["address"],[str],getXYbyAddressCallback,null,url);
- }
- function getXYbyAddressCallback(evt){
- if(evt[0] == null) {
- console.log("error");
- return;
- }
- // var jsonArray = $.xml2json(evt[0].textContent);
- var jsonArray = $.xml2json(evt[0].innerHTML);
- // var jsonArray = xmltojson(evt[0].textContent);
- //var jsonArray =JSON.parse(evt[0].textContent)[0].data;
- window.parent.postMessage(
- {
- method: "XYbyAddressCallback",
- data:[JSON.stringify(jsonArray).replace(/\"/g,'"')]
- },
- '*'
- );
- }
- function newOpenFeatureLayer(layername,type ,name,isGoTo,isOpen){
- newOpenLayer(layername,type ,name,isGoTo,isOpen);
- }
- function popupClick(json) {
- postToParentPageMethed("popupClickReturn",[json]);
- }
- function sqlReturn(evt,keyValue){
- require(["esri/geometry/Extent", "esri/Graphic"],
- function(Extent, Graphic) {
- var allCount;
- var pageIndex;
- var jsonArray ;
- if(evt[0] != null) {
- allCount =JSON.parse(evt[0].textContent)[0].AllCount;
- pageIndex=JSON.parse(evt[0].textContent)[0].pageIndex;
- jsonArray =JSON.parse(evt[0].textContent)[0].data;
- }else{
- jsonArray =[]
- }
- switch (keyValue){
- case "queryResetNumByType":{
- var TestData1 = [ ]; var TestData2 = [ ];
- for(var i=0;i<jsonArray.length;i++){
- TestData1.push( [{ name:jsonArray[i].water_source_name,xy:[jsonArray[i].x1,jsonArray[i].y1] },
- { name: jsonArray[i].water_work_name,xy:[jsonArray[i].x2,jsonArray[i].y2] }]);
- TestData2.push( [{ name:jsonArray[i].water_work_name,xy:[jsonArray[i].x2,jsonArray[i].y2] },
- { name: jsonArray[i].area_name,xy:[jsonArray[i].x3,jsonArray[i].y3] }]);
-
-
- }
- echartsWaterSourceToWorkRoute(TestData1,"#3581FF","",4);
- echartsWaterWorkToAreaRoute(TestData2,"#42ebff","",4);
- break;
- }
- }
-
- })
-
- }
-
- </script>
- </head>
- <body>
- <div id="mapDiv">
- <!--<div id="viewTest">-->
- <!--<button onclick="layerOnOff();">图层开关</button>-->
- <!--</div>-->
- </div>
- <div id="infoDialog" title="详细信息">
- <div id="divShowResult"></div>
- </div>
- </body>
- </html>
|