| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- const options = {
- url: "/arcgisApi/4.7/init.js"
- };
- import * as esriLoader from 'esri-loader'
- import {queryLayer} from '../config/lyrConfig.js'
- export function xzqChange(_self,viewObject,mapObject,item,fullExtent){
- esriLoader.loadModules(["esri/layers/GraphicsLayer","esri/Graphic","esri/geometry/Polygon",
- "esri/tasks/support/Query","esri/tasks/QueryTask","dojo/domReady!"],options).then( (
- [GraphicsLayer,Graphic,Polygon,Query,QueryTask,]) => {
- var url,where,outFields;
- if(_self.currentAdCode.substring(2,12) == '0000000000'){//省级
- url = queryLayer.province;
- where = "prov_cd = '"+item.adCode+"'";
- outFields = ["prov_cd","prov_nm"];
- // var proBoundaryGraphicLayer = mapObject.findLayerById("proBoundaryGraphicLayer");
- // proBoundaryGraphicLayer.removeAll();
- // viewObject.extent = fullExtent;
- // return;
- }else if(_self.currentAdCode.substring(4,12) == '00000000'){//市级
- url = queryLayer.city;
- where = "dist_cd = '"+item.adCode+"'";
- outFields = ["dist_cd","dist_nm"];
- }else if(_self.currentAdCode.substring(6,12) == '000000'){//县级
- url = queryLayer.country;
- where = "cnty_cd = '"+item.adCode+"'";
- outFields = ["cnty_nm","cnty_cd"];
- }
- if(url){
- var queryTask = new QueryTask({
- url: url
- });
- var query = new Query();
- query.returnGeometry = true;
- query.outFields = outFields;
- query.where = where;
- queryTask.execute(query).then(function(results){
- var feature = results.features[0];
- var polygon = new Polygon({
- rings: feature.geometry.rings,
- spatialReference: { wkid: 4326 }
- });
- var symbol = {
- type: "simple-line", // autocasts as new SimpleLineSymbol()
- color: "#f02ee7",
- width: "2px",
- style: "short-dash-dot"
- };
- var gra = new Graphic({
- geometry:polygon,
- attributes:feature.attributes,
- symbol:symbol
- });
- var proBoundaryGraphicLayer = mapObject.findLayerById("proBoundaryGraphicLayer");
- proBoundaryGraphicLayer.removeAll();
- proBoundaryGraphicLayer.add(gra);
- viewObject.goTo(gra);
- });
- }
- }).catch(err => {
- console.error(err);
- });
- }
|