/** * 执行buffer * @param geometry */ function doBuffer(geometry) { var symbol = null; switch (geometry.type) { case "point": symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 7, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0,0,255]), 1 ), new Color([0,0,255]) ); break; case "polyline": symbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0,0,255]), 2 ); break; case "polygon": symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NONE, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0,0,255]), 2 ), new Color([0,0,255,0.25])); break; } var graphic = new Graphic(geometry, symbol); map.graphics.add(graphic);
//setup the buffer parameters var params = new BufferParameters(); params.distances = [distance]; params.bufferSpatialReference = map.spatialReference; params.outSpatialReference = map.spatialReference; params.unit = GeometryService["UNIT_KILOMETER"];
if (geometry.type === "polygon") { //if geometry is a polygon then simplify polygon. This will make the user drawn polygon topologically correct. gsvc.simplify([geometry], function(geometries) { params.geometries = geometries; gsvc.buffer(params, function(bfGeometry){ queryGraphicByPolygon(bfGeometry[0]); }); }); } else { params.geometries = [geometry]; gsvc.buffer(params, function(bfGeometry){ queryGraphicByPolygon(bfGeometry[0]); }); } }
在执行缓冲区分析的时候,会用到geometryservice。代码如下:
var gsvc = new GeometryService("http://localhost:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer");
当缓冲区分析完成或者面要素绘制完成以后的geometry都为polygon,此时,执行空间查询:
/** * 根据多边形进行查询 * @param geometry */ function queryGraphicByPolygon(geometry){ var graphics = chartLayer.graphics;
var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new Color([255,0,0]), 2), new Color([255,255,0,0.25]) ); var graphic = new Graphic(geometry,sfs); map.graphics.add(graphic);
Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ...
[详细]
Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ...
[详细]