Arcgis-js构建自定要素图层.docx
文本预览下载声明
function setFeatureLayer() { require([ esri/layers/FeatureLayer, esri/geometry/Polygon,esri/dijit/PopupTemplate, esri/symbols/SimpleFillSymbol,esri/symbols/SimpleLineSymbol,esri/graphic,esri/Color, ], function(FeatureLayer,Polygon, PopupTemplate,SimpleFillSymbol,SimpleLineSymbol) { var layerDefinition = {geometryType: esriGeometryPolygon,fields: [{name: ObjectID,alias: ObjectID,type: esriFieldTypeOID}, {name: name,alias: 名称,type: esriFieldTypeString}, {name: GT,alias: GT,type: esriFieldTypeInteger},{name: GD,alias: GD,type: esriFieldTypeInteger},{name: GC,alias: GC,type: esriFieldTypeInteger}]}var featureCollection = {layerDefinition: layerDefinition,featureSet: null};//define a popup template var popupTemplate = new PopupTemplate({ title: {name}, description: {name}, //description: {GT}:{GD}:{GC}, fieldInfos: [{ //define field infos so we can specify an alias fieldName: GT, label: GT },{ fieldName: GD, label: GD },{ fieldName: GC, label: GC }], mediaInfos:[{ //define the bar chart caption: , type:barchart, value:{ theme: Dollar, fields:[GT,GD,GC] } }, { // line chart caption: , type:linechart, value:{ theme: Dollar, fields:[GT,GD,GC] } } ] });//创建FeatureLayer图层 var featureLayer = new FeatureLayer(featureCollection, {id: HeatmapLayer,mode: FeatureLayer.MODE_SNAPSHOT,outFields: [*],opacity: 1,infoTemplate: popupTemplate});for (var x=0;xCnData.features.length;x++) {var attr = {};attr[id]=CnData[features][x][properties][id];attr[name]=CnData[features][x][properties][name];attr[GT]=CnData[features][x][properties][GT];attr[GD]=CnData[features][x][properties][GD];attr[GC]=CnData[features][x][properties][GC];var vCoordinates=CnData[features][x][geometry][coordinates];var polygonJson = {rings:vCoordinates,spatialReference:{wkid:4326 }}; var polygon = new Polygon(polygonJson);var Symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new esri.Color([0, 255, 255, 0.8]), 2
显示全部