1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 大专栏 ArcGIS API For Javascript之影像服务分析7 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
<!DOCTYPE html> <html> <head> <title>index.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/library/3.17/3.17/dijit/themes/tundra/tundra.css"/> <link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/library/3.17/3.17/esri/css/esri.css" /> <script type="text/Javascript" src="http://localhost/arcgis_js_api/library/3.17/3.17/init.js"></script> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <style> .MapClass{ width:100%; height:500px; border:1px solid #000; } </style> <script> require(["esri/map","esri/layers/ArcGISImageServiceLayer","dojo/on", "dojo/dom","esri/toolbars/draw", "esri/tasks/ImageServiceIdentifyTask","esri/tasks/ImageServiceIdentifyParameters", "esri/symbols/SimpleLineSymbol","esri/graphic","esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleFillSymbol", "esri/layers/MosaicRule", "dojo/domReady!"],function(Map,ArcGISImageServiceLayer,on,dom,Draw,ImageServiceIdentifyTask, ImageServiceIdentifyParameters,SimpleLineSymbol, Graphic,SimpleMarkerSymbol,SimpleFillSymbol,MosaicRule){ var map=new Map("mapDiv")
//注意这里是影响服务 var layer=new ArcGISImageServiceLayer("http://192.168.0.112:6080/arcgis/rest/services/Test/Dem1/ImageServer") map.addLayer(layer); //用于绘制点 var toolbar =new Draw(map);
//创建影像分析对象 var task=new ImageServiceIdentifyTask("http://192.168.0.112:6080/arcgis/rest/services/Test/Dem1/ImageServer"); //创建影像分析参数对象 var params=new ImageServiceIdentifyParameters(); var lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASH, new dojo.Color([255, 0, 0]), 3); var marker= new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,10, lineSymbol, new dojo.Color([255, 0, 0])); var fill= new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, lineSymbol, new dojo.Color([255, 0, 0])); //给绘制折线按钮绑定事件 on(dom.byId("drawp"),"click",function(){ toolbar.activate(Draw.POINT, { showTooltips:true }) }) //给draw工具的绘制完成事件绑定函数 on(toolbar,"draw-complete", function (result) { map.graphics.clear(); var geometry=result.geometry; //给参数对象的几何属性赋值 params.geometry =geometry; graphic= new Graphic(geometry, marker); map.graphics.add(graphic); toolbar.deactivate();
})
on(dom.byId("btn"),"click",function(){ //设置掩膜规则 var mosaicRule=new MosaicRule(); mosaicRule.ascending=false; mosaicRule.method=MosaicRule.METHOD_CENTER params.mosaicRule=mosaicRule params.pixelSizeX=layer.pixelSizeX; params.pixelSizeY=layer.pixelSizeY; task.execute(params,function(result){ //弹出改点的高程值 alert(result.value) }) })
}); </script> </head>
<body> <div id="mapDiv" class="MapClass"></div> <button id="drawp">绘制点</button> <button id="btn">查询</button> </body> </html>
|