JavaScript
通用配置集
https://developers.arcgis.com/downloads/#javascript
Front字体—MIME类型
.pbf application/octet-stream.ttf application/octet-stream.wasm application/wasm.woff application/font-woff.woff2 application/font-woff2.wsv application/octet-streamhttps://static.arcgis.com/fonts/arial-unicode-ms-regular/65280-65535.pbfesriConfig.fontsUrl = "http://127.0.0.1/arcgis_js_api/arial-unicode-ms-regular";
4.x
esri
Basemap
AMD:require([“esri/Basemap”], (Basemap) => { / code goes here / });
ESM:import Basemap from “@arcgis/core/Basemap”;
数据源类型:tiled services
服务来源:PortalItem 的 basemap ID(内置)、地图服务
var basemap = new Basemap({portalItem: {id: "8dda0e7b5e2d4fafa80132d59122268c" // WGS84 Streets Vector webmap},//引入Portal发布的服务baseLayers: [new WebTileLayer({url: "url to your dynamic MapServer",title: "Basemap"});],referenceLayers: [new WebTileLayer(...);],});
esri/tasks/GeometryService esri/tasks/support/AreasAndLengthsParameters 计算图形
Query查询
初始化
var spatialRef = new SpatialReference({wkid: view.spatialReference,});
3.x
ArcObject 10.x
获取图形节点
geometry.GeometryType == esriGeometryType.esriGeometryPolyline;geometry.GeometryType == esriGeometryType.esriGeometryPolygon;IGeometryCollection geoCol = (IGeometryCollection)geometry;int geomsize = geoCol.GeometryCount;for (int lgeom = 0; lgeom < geomsize; lgeom++){//从GeometryCollection得到SegmentCollectionISegmentCollection segCol = (ISegmentCollection)geoCol.get_Geometry(lgeom);IPath path = (IPath)geoCol.get_Geometry(lgeom);endPointCol.Add(path.FromPoint); //得到首尾节点endPointCol.Add(path.ToPoint);int segsize = segCol.SegmentCount;for (int lseg = 0; lseg < segsize; lseg++){ISegment segment = segCol.get_Segment(lseg); //从SegmentCollection得到SegmentscreenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);screenDisplay.SetSymbol((ISymbol)vertexMarkerSymbol);screenDisplay.DrawPoint(segment.FromPoint); //重画Segment的端点screenDisplay.DrawPoint(segment.ToPoint);screenDisplay.FinishDrawing();}}
释放资源
去除Z值
IZAware pZAware = pGeometry as IZAware;
pZAware.ZAware = false;
GP工具
Geoprocessor gp = new Geoprocessor();gp.OverwriteOutput = true;//筛选IFeatureClass ofc;IQueryFilter oqf;MakeFeatureLayer makeLayer = new MakeFeatureLayer();makeLayer.in_features = graphicClass;object outLayer = "out_layer";makeLayer.out_layer = outLayer;makeLayer.where_clause = "PID = '" + Pid + "'";IGeoProcessorResult pResult = (IGeoProcessorResult)gp.Execute(makeLayer, null);IGPUtilities gpUtils = new GPUtilitiesClass();gpUtils.DecodeFeatureLayer(pResult.GetOutput(0), out ofc, out oqf);//裁剪ESRI.ArcGIS.AnalysisTools.Clip pClip2018 = new ESRI.ArcGIS.AnalysisTools.Clip();pClip2018.in_features = dL2018Class as object;pClip2018.clip_features = outLayer;object outLayer2018 = Gdb + "\\DL_XJ" + DateTime.Now.ToString("yyyyMMddHHmmss");pClip2018.out_feature_class = outLayer2018;pResult= new GeoProcessorResultClass();pResult = (IGeoProcessorResult)gp.Execute(pClip2018, null);IFeatureClass outFeatureClass = gp.Open(pResult.ReturnValue) as IFeatureClass;//相交Intersect pIntersect = new Intersect();IGpValueTableObject gpValueTableObject = new GpValueTableObjectClass();gpValueTableObject.SetColumns(2);object inputfeature = dL2018Class;object obj = outLayer;gpValueTableObject.AddRow(ref obj);gpValueTableObject.AddRow(ref inputfeature);pIntersect.in_features = gpValueTableObject;object outLayer_Intersect = Gdb + "\\DL_XJ" + DateTime.Now.ToString("yyyyMMddHHmmss");pIntersect.out_feature_class = outLayer_Intersect;pIntersect.join_attributes = "All";pResult = new GeoProcessorResultClass();pResult = (IGeoProcessorResult)gp.Execute(pIntersect, null);IFeatureClass outFeatureClass = gp.Open(pResult.ReturnValue) as IFeatureClass;
负面积处理
public static void RepairGeometry(ref IGeometry geometry){switch (geometry.GeometryType){case esriGeometryType.esriGeometryPolygon:if (GeometryService.DirectionIsIncorrect(geometry)){IPolygon polygon = geometry as IPolygon;if (polygon != null){IGeometryCollection pGeoCollection = new PolygonClass();pGeoCollection = polygon as IGeometryCollection;if (pGeoCollection.GeometryCount > 1){IGeometryCollection pGeoCollection2 = new PolygonClass();object o = Type.Missing;// 遍历Ring集合for (int i = 0; i < pGeoCollection.GeometryCount; i++){// 向Polygon对象中添加Ring子对象pGeoCollection2.AddGeometry(pGeoCollection.get_Geometry(i) as IGeometry, ref o, ref o);}// QI至ITopologicalOperator ==> 确保添加子对象后的Polygon对象是有效的ITopologicalOperator pTopological = pGeoCollection2 as ITopologicalOperator;// 执行Simplify操作 ,防止出现子对象覆盖现象pTopological.Simplify();geometry = pGeoCollection2 as IPolygon;}else{polygon.ReverseOrientation();}}}break;case esriGeometryType.esriGeometryPolyline:IPolyline pl = geometry as IPolyline;pl.ReverseOrientation();break;default:break;}}
图形绘制方向有错
public static bool DirectionIsIncorrect(IGeometry geometry){if (geometry == null){return false;}if (geometry.IsEmpty){return false;}if (geometry is IPolygon){IArea area = geometry as IArea;return (area.Area < 0.0);}return ((geometry is IPolyline) && (((IPolyline)geometry).Length < 0.0));}
