queryTask,geometryService操作,通过画矩形获得外接图形
来源:互联网 发布:淘宝店铺图片授权 编辑:程序博客网 时间:2024/06/03 13:21
<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>Convex Hull</title> <link rel="stylesheet" href="https://js.arcgis.com/3.18/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="https://js.arcgis.com/3.18/esri/css/esri.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } #mapu { padding:0; } #titlePane { width:200px; height:300px; } .claro .dijitTitlePaneTitle { background: #A4BDA7; font-weight:600; color:#33292B; } .dijitButtonNode { background-color: #A4BDA7 !important; border: 1px solid #646750 !important; color:#33292B !important; } </style> <script>var dojoConfig = {parseOnLoad: true};</script> <script src="https://js.arcgis.com/3.18/"></script> <script> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("dijit.TitlePane"); dojo.require("esri.map"); dojo.require("esri.layers.FeatureLayer"); dojo.require("esri.toolbars.draw"); dojo.require("esri.tasks.geometry"); var map; var toolbar; var geometryService; var featureLayer; function init() { //This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications esri.config.defaults.io.proxyUrl = "/proxy/"; esri.config.defaults.io.alwaysUseProxy = false; geometryService = new esri.tasks.GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); map = new esri.Map("map", { basemap: "topo", center: [-72.517, 42.372], zoom: 16 }); //add the census block points to the map featureLayer = new esri.layers.FeatureLayer("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0",{ mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ["POP2000","BLOCK"] }); //define a selection symbol for the feature layer var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 12, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([247, 0, 171, 0.9]), 2), new dojo.Color([247, 0, 171, 0.5])); featureLayer.setSelectionSymbol(symbol); map.infoWindow.resize(175,100); map.addLayer(featureLayer); dojo.connect(map, 'onLoad', function(theMap) { //create the draw toolbar toolbar = new esri.toolbars.Draw(map); dojo.connect(toolbar,"onDrawEnd",drawEndHandler); }); } function activateToolbar(){ toolbar.activate(esri.toolbars.Draw.EXTENT); } function drawEndHandler(geometry){ toolbar.deactivate(); map.graphics.clear(); //select the points within the extent var query = new esri.tasks.Query(); query.geometry = geometry; featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW,function(features){ //calculate the convex hull var points = dojo.map(features,function(feature){ return feature.geometry; }); geometryService.convexHull(points,function(result){ var symbol; switch(result.type){ case "point": symbol = new esri.symbol.SimpleMarkerSymbol(); break; case "polyline": symbol = new esri.symbol.SimpleLineSymbol(); break; case "polygon": symbol = new esri.symbol.SimpleFillSymbol(); break; } map.graphics.add(new esri.Graphic(result,symbol)); },function(error){ console.log("An error occured during convex hull calculation"); }); }); } dojo.ready(init); </script> </head> <body class="claro"> <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="gutters:'false',design:'headline'" style="width: 100%; height: 100%;"> <div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'" style="overflow:hidden;"> <div style="position:absolute; right:20px; top:10px; z-Index:999;"> <div id="titlePane" data-dojo-type="dijit.TitlePane" data-dojo-props="title:'Convex Hull', closable:'false', open:'true'"> <p style="padding:5px 2px;color:#33292B;">Draw a rectangle around a group of block points to calculate the minimum bounding polygon ("convex hull") of the selected points.</p> <button data-dojo-type="dijit.form.Button" data-dojo-props="onClick:activateToolbar">Draw</button> </div> </div> </div> </div> </body></html>
0 0
- queryTask,geometryService操作,通过画矩形获得外接图形
- 轮廓 画外接圆外接矩形
- 对每个边缘求最小外接矩形,通过最小矩形提取每个边缘
- 求解最小外接矩形
- cvMinAreaRect2外接矩形
- 求解最小外接矩形
- 最小外接矩形(MBR)
- OpenCV最小外接矩形
- 【opencv】轮廓外接矩形
- /*外接矩形部分*/
- Matlab 最小外接矩形
- matlab 提取一个图形对象的最小外接矩形 并计算出面积
- queryTask
- 凸多边形最小面积外接矩形
- 凸多边形最小周长外接矩形
- OpenCV最小外接正矩形
- 采用opencv计算外接矩形
- 最小外接矩形(ROI)
- 设置外部连接打开android应用
- Docker搭建 初步
- IE8定义文档兼容性
- xcode 代码自动排序/对齐快捷键
- mysql下载安装配置
- queryTask,geometryService操作,通过画矩形获得外接图形
- 72. Edit Distance
- 谷歌Cartographer学习(1)-快速安装测试
- window上使用放大镜功能时显示错误问题
- Arduino使用PN532注意问题#NFC
- HT350IntersactionOfTwoArrays2
- 删除文件夹下所有的.git文件
- Round B APAC Test 2017 Problem D. Sherlock and Permutation Sorting
- JavaScript个人笔记:面向对象设计二(继承)