soe前端调用
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" /> <title>Simple Map</title> <link rel="stylesheet" href="http://localhost:90/4.11/esri/themes/light/main.css" /> <link rel="stylesheet" href="http://localhost:90/4.11//esri/css/main.css" /> <script src="http://localhost:90/4.11/init.js"></script> <script src="../../jquery-1.7.1.js" type="text/javascript" charset="utf-8"></script> <style> html, body { padding: 0; margin: 0; height: 100%; } #mapDiv{ width:800px; height: 800px; } #messages { background-color: #fff; box-shadow: 0 0 5px #888; font-size: 1.1em; max-width: 15em; padding: 0.5em; position: absolute; right: 20px; top: 300px; z-index: 40; } </style> <script> var mapview; var drawTool; require([ "esri/Map", "esri/views/MapView", "esri/layers/MapImageLayer", "esri/request", "esri/layers/GraphicsLayer", "esri/Graphic", "esri/symbols/SimpleMarkerSymbol","esri/symbols/SimpleFillSymbol", "esri/geometry/Polygon", "esri/geometry/Polyline", "esri/geometry/Point", "esri/geometry/SpatialReference", "esri/views/draw/Draw", "esri/config", "esri/Color","dojo/_base/array", "dojo/on", "dojo/dom", "dojo/domReady!" ], function ( Map, MapView, MapImageLayer, esriRequest, GraphicsLayer, Graphic, SimpleMarkerSymbol,SimpleFillSymbol, Polygon, Polyline, Point,SpatialReference, Draw, esriConfig, Color,arrayUtils,on, dom ) { // use a proxy page if a URL generated by this page is greater than 2000 characters // // this should not be needed as nearly all query & select functions are performed on the client //esriConfig.defaults.io.proxyUrl = "/proxy"; esriConfig.request.timeout = 600000; //600000 milliseconds var map = new Map({ basemap:"" }); mapview = new MapView({ container:"mapDiv", map:map }); var point = { type: "point", // autocasts as new Point() longitude: 113, latitude: 23 }; var markerSymbol = { type: "simple-marker", // autocasts as new SimpleMarkerSymbol() color: [226, 119, 40], outline: { // autocasts as new SimpleLineSymbol() color: [255, 255, 255], width: 2 } }; var pointGraphic = new Graphic({ geometry: point, symbol: markerSymbol }); console.log(JSON.stringify(pointGraphic.geometry)) var mapUrl = "http://localhost:6080/arcgis/rest/services/test/test/MapServer"; mapUrl = "http://localhost:6080/arcgis/rest/services/test/xztdTest/MapServer"; var soeUrl = "http://localhost:6080/arcgis/rest/services/test/test/MapServer/exts/RestSOE2/QueryBuffer"; //Takes a URL to a non cached map service. var dynamicMapServiceLayer = new MapImageLayer(mapUrl); map.add(dynamicMapServiceLayer); dynamicMapServiceLayer.when(function(e){ mapview.extent = e.extent; }) on(dom.byId("execute"), "click", function () { var WhereClause = dom.byId("WhereClause").value; var BufferRadius = dom.byId("BufferRadius").value; var content = { query:{ 'WhereClause': "BSM='"+WhereClause+"'", 'BufferRadius': BufferRadius, 'f': "json" } }; // content = { // 'WhereClause': "BSM='"+WhereClause+"'", // 'BufferRadius': BufferRadius, // // query: { // // f: "json" // // }, // responseType: "json" // }; soeUrl = "http://localhost:6080/arcgis/rest/services/test/test/MapServer/exts/RestSOE2/QueryBuffer" var url =soeUrl +'?WhereClause="'+WhereClause+'"&BufferRadius='+BufferRadius; var Request = esriRequest(soeUrl,content).then( function (result) { //map.removeAll(); console.log(result) resultAddgra(result); //mapview.extent = graphicslayer.extent; var wgs = mapview.spatialReference; },function(e){ console.log(e) }); }); // drawTool = new Draw({ // view: mapview // }); //container on(dom.byId("drawe"), "click", function () { drawTool = new Draw({ view: mapview }); var action = drawTool.create("polygon", { mode: "click" }); mapview.focus(); mapview.container.style.cursor = "crossHair"; action.on( [ "vertex-add", "vertex-remove", "cursor-update", "redo", "undo", "draw-complete" ], createPolygon ); }) on(dom.byId("drawIntersect"), "click", function () { drawTool = new Draw({ view: mapview }); var action = drawTool.create("polygon", { mode: "click" }); mapview.focus(); mapview.container.style.cursor = "crossHair"; action.on( [ "vertex-add", "vertex-remove", "cursor-update", "redo", "undo", "draw-complete" ], createPolygon ); }) function createPolygon(event){ var vertices = event.vertices; var fillSymbol = { type: "simple-fill", // autocasts as new SimpleFillSymbol() color: [255, 0, 0, 0.2], outline: { // autocasts as new SimpleLineSymbol() color: [255, 116, 3,0.1], width: 1 } }; mapview.graphics.removeAll(); var polygon = new Polygon({ rings: vertices, spatialReference:mapview.spatialReference }); var graphics = new Graphic({ geometry: polygon, symbol: fillSymbol }); mapview.graphics.add(graphics); if (event.type == "draw-complete") { mapview.container.style.cursor = "default"; console.log(JSON.stringify(graphics.geometry)) var content = { query:{ "geometry":JSON.stringify(graphics.geometry), 'f': "json" } } var url = "http://localhost:6080/arcgis/rest/services/test/test/MapServer/exts/RestSOE1/QueryIntersect" url = "http://localhost:6080/arcgis/rest/services/test/xztdTest/MapServer/exts/RestSOE1/AddPolygonLayer" esriRequest(url,content).then(function(res){ console.log(res) resultAddgra(res) },function(e){ console.log("error:"+e) }) } } //cut on(dom.byId("drawcut"), "click", function () { drawTool = new Draw({ view: mapview }); var action = drawTool.create("polyline", { mode: "click" }); mapview.focus(); mapview.container.style.cursor = "crossHair"; action.on( [ "vertex-add", "vertex-remove", "cursor-update", "redo", "undo", "draw-complete" ], createPolyline ); }) var drawline = new GraphicsLayer(); map.add(drawline); function createPolyline(event) { var graphic = null; var editGps = []; var vertices = event.vertices; drawline.removeAll(); //还未按下鼠标选定起点,鼠标移动的时候 if (vertices.length == 1) { console.log("111"); //addEditPt(this.graphicsLayer, event.vertices[0], 0); } //大于两个点,显示线 if (vertices.length >= 2) { //线 var line = new Polyline({ paths: vertices, spatialReference: mapview.spatialReference }); // 生成绘制的图形 graphic = new Graphic({ geometry: line, symbol: { type: "simple-line", // autocasts as new SimpleFillSymbol color: "#ff5502", width: 2, cap: "round", join: "round" } }); drawline.add(graphic); } //每次单击添加顶点时添加一个可移动的编辑节点 if (event.type == "vertex-add") { // var addGp = addEditPt( // _this.editLayer, // vertices[event.vertexIndex], // event.vertexIndex // ); // editGps.push(addGp); console.log(editGps); } if (event.type == "cursor-update") {} if (event.type == "draw-complete") { mapview.container.style.cursor = "default"; var content = { query:{ "geometry":JSON.stringify(graphic.geometry), 'f': "html" } } var url = "http://localhost:6080/arcgis/rest/services/test/test/MapServer/exts/RestSOE2/QueryCut" esriRequest(url,content).then(function(res){ console.log(res) resultAddgra(res,"cut") },function(e){ console.log("error:"+e) }) } } on(dom.byId("drawPolygon"), "click", function () { drawTool = new Draw({ view: mapview }); var action = drawTool.create("polygon", { mode: "click" }); mapview.focus(); mapview.container.style.cursor = "crossHair"; action.on( [ "vertex-add", "vertex-remove", "cursor-update", "redo", "undo", "draw-complete" ], createPolygon1 ); }) function createPolygon1(event){ var vertices = event.vertices; var fillSymbol = { type: "simple-fill", // autocasts as new SimpleFillSymbol() color: [255, 0, 0, 0.2], outline: { // autocasts as new SimpleLineSymbol() color: [255, 116, 3,0.1], width: 1 } }; mapview.graphics.removeAll(); var polygon = new Polygon({ rings: vertices, spatialReference:mapview.spatialReference }); var graphics = new Graphic({ geometry: polygon, symbol: fillSymbol }); mapview.graphics.add(graphics); if (event.type == "draw-complete") { mapview.container.style.cursor = "default"; console.log(JSON.stringify(graphics.geometry)) var content = { query:{ "geometry":JSON.stringify(graphics.geometry), 'f': "json" } } var url = "http://localhost:6080/arcgis/rest/services/test/test/MapServer/exts/RestSOE2/AddPolygonLayer" esriRequest(url,content).then(function(res){ console.log(res) resultAddgra(res) },function(e){ console.log("error:"+e) }) } } function resultAddgra(result,sign){ var symbol = { type: "simple-fill", // autocasts as new SimpleFillSymbol() color: [ 255,0, 0, 1 ], style: "solid", outline: { // autocasts as new SimpleLineSymbol() color: "red", width: 1 } }; var symbol1 = { type: "simple-fill", // autocasts as new SimpleFillSymbol() color: [ 255,255, 0, 0.8 ], style: "solid", outline: { // autocasts as new SimpleLineSymbol() color: "red", width: 1 } }; var symbol2 = { type: "simple-fill", // autocasts as new SimpleFillSymbol() color: [ 255,0, 255, 0.8 ], style: "solid", outline: { // autocasts as new SimpleLineSymbol() color: "yellow", width: 1 } }; var graphicslayer = new GraphicsLayer(); map.add(graphicslayer); for(var i=0;i<result.data.feature.length;i++){ var feature = result.data.feature[i]; var polygon = new Polygon({ hasZ: true, hasM: true, rings: feature.geometry.rings, spatialReference: feature.geometry.spatialReference }); var sysm = symbol; if(sign){ sysm = symbol2; if(i==0)sysm = symbol1; } var gra = new Graphic({ geometry:polygon, attributes:feature.attributes, symbol:sysm, popupTemplate:{title:"信息",content:'{*}'} }); graphicslayer.add(gra); } } //测试 on(dom.byId("getDoRes"), "click", function () { var WhereClause = dom.byId("WhereClause").value; var BufferRadius = dom.byId("BufferRadius").value; var content = { query:{ 'ProValue': "1=1", 'CGeometry': "", 'f': "json" } }; //mvn install:install-file -Dfile=E:\Program Files\ArcGIS\Desktop10.1\java\lib\arcobjects.jar -DgroupId=arcgis -DartifactId=arcobjects -Dversion=1.0 -Dpackaging=jar soeUrl = "http://localhost:6080/arcgis/rest/services/test/sss/MapServer/exts/RestSOE1/zbRule" soeUrl="http://localhost:6080/arcgis/rest/services/test/tt/MapServer/exts/RestSOE1/zbRule" var url =soeUrl +'?WhereClause="'+WhereClause+'"&BufferRadius='+BufferRadius; var Request = esriRequest(soeUrl,content).then( function (result) { //map.removeAll(); console.log(result) resultAddgra(result); //mapview.extent = graphicslayer.extent; var wgs = mapview.spatialReference; },function(e){ console.log(e) }); }); on(dom.byId("getDoRes3"), "click", function () { var gg = " 34516207.6405 2866930.0602, 34516206.7251 2866930.575099999, 34516203.6143 2866932.3248999994, 34516201.4915 2866933.5189999994, 34516192.604100004 2866938.518100001, 34516196.7426 2866952.062000001, 34516196.885 2866952.5284, 34516199.0866 2866959.7334000003, 34516200.2791 2866963.6361, 34516199.071 2866965.0637999997, 34516196.4639 2866968.1447, 34516194.1092 2866970.9274000004, 34516192.857 2866972.4071999993, 34516192.604100004 2866972.7062, 34516192.224 2866972.7305999994, 34516192.0589 2866972.7413999997, 34516193.5353 2866980.2007, 34516193.9021 2866985.4274000004, 34516186.9709 2866985.913899999, 34516186.6541 2866981.3993999995, 34516187.0723 2866973.0632000007, 34516184.6424 2866973.2203, 34516182.7251 2866973.3441000003, 34516179.695199996 2866973.5395, 34516170.9742 2866974.1021, 34516170.8051 2866974.1972000003, 34516169.398 2866974.9887000006, 34516166.441 2866976.6520000007, 34516165.6175 2866977.1152, 34516165.0173 2866977.4528, 34516164.9616 2866977.484099999, 34516159.4416 2866980.5890999995, 34516144.1338 2866989.1996999998, 34516137.4841 2866992.9400999993, 34516145.159099996 2867004.1041, 34516145.121 2867004.1312000006, 34516139.8674 2867007.8638000004, 34516138.1329 2867009.0961000007, 34516128.3705 2867016.032299999, 34516122.4856 2867020.2135000005, 34516122.0349 2867020.5337000005, 34516118.6451 2867022.9420999996, 34516136.0881 2867045.9671, 34516153.5312 2867068.9921000004, 34516158.7251 2867064.1230999995, 34516164.6951 2867058.5261000004, 34516174.9508 2867069.7589, 34516178.9985 2867074.1922999993, 34516179.3471 2867074.574100001, 34516174.2431 2867081.2091000006, 34516159.7539 2867100.0447000004, 34516158.4152 2867101.7851, 34516167.8346 2867111.901900001, 34516177.2541 2867122.019099999, 34516182.7251 2867116.6752000004, 34516187.7722 2867111.7453000005, 34516201.3663 2867098.467599999, 34516201.9468 2867097.900800001, 34516204.4454 2867095.4601000007, 34516205.236 2867094.688100001, 34516207.0185 2867092.9471000005, 34516207.2561 2867092.7150999997, 34516213.2721 2867100.8793, 34516217.0241 2867105.9712000005, 34516240.0753 2867096.9760999996, 34516245.6311 2867094.8081, 34516247.1168 2867097.944700001, 34516248.0679 2867099.9527000003, 34516249.3623 2867102.6853, 34516253.1953 2867110.7774, 34516257.4142 2867119.6841, 34516261.0396 2867127.3378999997, 34516264.4692 2867134.5781999994, 34516277.0725 2867130.500600001, 34516280.0709 2867129.5305000003, 34516283.2893 2867128.4892999995, 34516288.1921 2867126.9031000007, 34516286.368599996 2867118.7672000006, 34516286.2118 2867118.0677000005, 34516284.614 2867110.9386, 34516284.4467 2867110.192, 34516281.1101 2867095.3050999995, 34516280.6934 2867093.445800001, 34516279.337 2867087.3939999994, 34516279.1221 2867086.4352, 34516280.7959 2867086.2323000003, 34516295.5147 2867084.4487999994, 34516302.1471 2867083.6450999994, 34516301.7867 2867078.746200001, 34516301.2853 2867071.9266, 34516301.1554 2867070.1609000005, 34516298.6581 2867036.1992000006, 34516296.2023 2867023.9202999994, 34516295.6854 2867021.3357999995, 34516293.6551 2867011.1842, 34516293.4278 2867010.0478000008, 34516290.9831 2866997.825099999, 34516279.8201 2866987.359099999, 34516277.6981 2866979.2250999995, 34516273.5119 2866963.1785000004, 34516271.9456 2866957.1740000006, 34516271.4471 2866955.2632, 34516290.9831 2866948.2862, 34516286.0991 2866931.541099999, 34516258.9471 2866937.9893999994, 34516258.1974 2866938.1675000004, 34516254.7252 2866938.9922, 34516248.0659 2866940.5737999994, 34516243.5371 2866941.6494999994, 34516242.2275 2866941.9606, 34516231.117300004 2866944.5995000005, 34516230.2812 2866944.7981000002, 34516225.9119 2866939.4356999993, 34516214.931099996 2866925.9591000006, 34516207.6405 2866930.0602), (34516218.3144 2866961.999399999, 34516219.9495 2866969.4573, 34516215.3782 2866970.4595, 34516214.9238 2866970.5591, 34516211.5907 2866957.2167000007, 34516215.0263 2866956.1405999996, 34516216.7038 2866961.496200001, 34516218.3144 2866961.999399999), (34516271.2101 2866999.2975999992, 34516272.7682 2867000.9177, 34516273.7594 2867004.3871999998, 34516274.9955 2867009.2871000003, 34516275.8043 2867011.4470000006, 34516274.5859 2867013.8782, 34516274.2373 2867014.5737999994, 34516272.8875 2867014.7804000005, 34516266.9124 2867015.6948000006, 34516263.4891 2867016.7717000004, 34516262.9467 2867016.9422999993, 34516261.3344 2867011.4747, 34516259.1422 2867006.533500001, 34516259.9771 2867003.9464999996, 34516265.5136 2867000.5944, 34516269.6458 2866999.6536999997, 34516271.2101 2866999.2975999992), (34516213.632699996 2867082.9097000007, 34516216 2867081.5439999998, 34516217.6221 2867084.355900001, 34516215.2548 2867085.7215, 34516213.632699996 2867082.9097000007), (34516209.59 2867071.4825999998, 34516212.556 2867071.0352, 34516213.5789 2867077.2655999996, 34516210.7113 2867077.7364000008, 34516209.59 2867071.4825999998), (34516266.6178 2867041.7797999997, 34516269.2806 2867041.3299000002, 34516270.277 2867047.2279000003, 34516267.614199996 2867047.6777999997, 34516266.6178 2867041.7797999997), (34516233.5969 2867025.9800000004, 34516235.5148 2867025.7304999996, 34516235.6607 2867026.8521, 34516238.4225 2867026.4926999994, 34516238.6568 2867028.2937000003, 34516238.0215 2867028.3763999995, 34516238.3532 2867030.9250000007, 34516234.3089 2867031.451300001, 34516233.5969 2867025.9800000004), (34516268.4857 2866966.2573000006, 34516268.7014 2866966.2040999997, 34516269.9918 2866971.437000001, 34516269.9063 2866971.4581000004, 34516266.371 2866972.3299000002, 34516265.0805 2866967.097100001, 34516268.4857 2866966.2573000006), (34516202.538499996 2866992.8922000006, 34516199.3647 2866993.1777, 34516198.3228 2866990.8772, 34516198.1974 2866986.8018999994, 34516202.048 2866986.9804999996, 34516202.538499996 2866992.8922000006)), ((34532398.9899 2880956.3268999998, 34532403.0114 2880948.7709, 34532393.4857 2880940.7463000007, 34532396.934 2880936.6531000007, 34532391.5711 2880936.6531000007, 34532389.5873 2880936.6531000007, 34532381.1431 2880936.6531000007, 34532379.3121 2880936.7577, 34532370.0822 2880937.2851, 34532370.1929 2880940.549900001, 34532373.4904 2880943.0822, 34532395.8304 2880960.2377000004, 34532397.3071 2880958.7929999996, 34532399.4684 2880956.6786, 34532398.9899 2880956.3268999998)), ((34532605.832100004 2881130.7350999992, 34532593.0032 2881123.1703999992, 34532581.6962 2881152.714400001, 34532606.4891 2881162.2761000004, 34532615.1347 2881145.692, 34532617.9328 2881140.3246, 34532605.832100004 2881130.7350999992)), ((34532512.9217 2881127.3938999996, 34532485.4566 2881128.5534000006, 34532485.1562 2881132.3604000006, 34532484.7091 2881138.0272000004, 34532476.2975 2881137.7644999996, 34532471.1743 2881137.6045999993, 34532469.261199996 2881137.5449, 34532460.1391 2881137.2600999996, 34532460.1391 2881142.6860000007, 34532462.2889 2881142.7621, 34532464.9172 2881142.4981999993, 34532467.037200004 2881142.3428000007, 34532467.8283 2881142.545499999, 34532467.929 2881143.8356, 34532467.9273 2881144.6932999995, 34532467.9269 2881144.9000000004, 34532468.1023 2881149.7172, 34532468.1714 2881153.5032, 34532469.7157 2881156.3390999995, 34532469.685 2881159.7556999996, 34532470.9635 2881161.6664000005, 34532472.188 2881161.9630999994, 34532474.1238 2881162.3938999996, 34532487.6948 2881161.6743, 34532496.5182 2881158.5398999993, 34532496.2705 2881156.6987999994, 34532500.208399996 2881156.1689999998, 34532500.4833 2881158.212099999, 34532505.0877 2881157.2914000005, 34532510.9702 2881156.1468, 34532510.6042 2881151.4332999997, 34532510.13 2881149.3772, 34532508.3358 2881149.5113999993, 34532508.2554 2881148.4365999997, 34532493.9957 2881149.0337000005, 34532493.9028 2881145.1249, 34532501.9831 2881144.593699999, 34532501.9164 2881143.5787000004, 34532516.8568 2881140.6741000004, 34532520.279699996 2881141.008300001, 34532521.7124 2881137.539999999, 34532522.3306 2881137.2480999995, 34532525.7785 2881135.6197999995, 34532525.2129 2881133.6985, 34532524.8608 2881132.5273, 34532524.7346 2881132.1818000004, 34532513.0008 2881132.1762000006, 34532512.9785 2881130.8286000006, 34532512.9217 2881127.3938999996" var kk = gg.split(","); var newarr = [] kk.forEach((item)=>{ var tempaa = item.split(" ") newarr.push([parseFloat(tempaa[1]),parseFloat(tempaa[2])]) }) console.log(JSON.stringify(newarr)) var polygon = new Polygon({ hasZ: true, hasM: true, rings: [newarr], //spatialReference: mapview.spatialReference }); var sym = { type: "simple-fill", // autocasts as new SimpleFillSymbol() color: [ 255,0, 0, 1 ], style: "solid", outline: { // autocasts as new SimpleLineSymbol() color: "red", width: 1 } }; var gra = new Graphic({ geometry:polygon, symbol:sym, }); mapview.graphics.add(gra); mapview.goTo({center:gra.geometry.centroid}) }) }); </script> </head> <body> 查询条件 <input type="text" id="WhereClause" value="440112299100000012"> 缓冲区半径 <input type="text" id="BufferRadius" value="1500"> <input id="execute" type="button" value="执行查询"> <input id="drawe" type="button" value="画矩形"> <input id="drawIntersect" type="button" value="画矩形相交"> <input id="drawcut" type="button" value="切割"> <input id="drawPolygon" type="button" value="添加要素"> <input id="getDoRes" type="button" value="测试"> <input id="getDoRes1" type="button" value="测试1"> <input id="getDoRes2" type="button" value="测试2"> <input id="getDoRes3" type="button" value="测试3"> <div id="mapDiv"></div> <script> var lng = 113.23; var lat =23.23; var x = lng*20037508.34/180; console.log(x) //度分秒转米制单位 var ly = Math.log(Math.tan((90 + lat)*Math.PI/360))/(Math.PI/180); var y = ly *20037508.34/180; console.log(y) var x1=2659857.045726198; var y1=504938.85165974207; console.log(x1/20037508.34 * 180) var y2 = y1/20037508.34 * 180; var y3= 80 / Math.PI * (2 * Math.atan(Math.exp(y2 * Math.PI / 180)) - Math.PI / 2); console.log(y3) $("#getDoRes1").click(function(e){ var attr={ OBJECTID:961, XMMC:"test1", ID:123 } var datas = { 'attributes': JSON.stringify(attr), 'CGeometry': "", 'f': "json" } //var de = new Graphic(); // $.get("http://localhost:6080/arcgis/rest/services/test/sss/MapServer/exts/RestSOE1/zbRule",function(res,status){ // debugger; //localhost:6080/arcgis/rest/services/test/sss/MapServer/exts/RestSOE1/zbRule?ProValue // console.log(status) // }) $.ajax({ type:'post', url:"http://localhost:6080/arcgis/rest/services/test/xztdTest/MapServer/exts/RestSOE1/EditLayer", data:datas, success:function(res){ console.log("请求成功") },error:function(e){ console.log("失败") } }) }) $("#getDoRes2").click(function(e){ var datas = { 'WhereClause': "OBJECTID=961", 'f': "json" } $.ajax({ type:'post', url:"http://localhost:6080/arcgis/rest/services/test/xztdTest/MapServer/exts/RestSOE1/DelPolygonLayer", data:datas, success:function(res){ console.log("请求成功") },error:function(e){ console.log("失败") } }) }) $("#getDoRes3").click(function(e){ }) </script> </body> </html>