POST
|
I am a beginner with the angular framework. I need to populate a drop in my component. The elements will come from a feature layer. The drop down needs be populated in the beginning to work or I guess I could subscribe to a method. I created a service that should return a promise so and on the element I believe I am subscribing to the method. However I am having issues with returning a promise in the service. Can you guys tell me how I should change the service to return the promise I need or if there is a better way to do it? I am using Angular 9, and the esri loader I think it is the latest because I used the command npm install --save esri-loader to install it, although my package.json lists the 2.13.0 version. Thank you for any help! The Component: @Component({ selector: 'app-esri-map', templateUrl: './esri-map.component.html', styleUrls: ['./esri-map.component.css'] }) export class EsriMapComponent implements OnInit { // this is needed to be able to create the MapView at the DOM element in this component @ViewChild('mapViewNode', { static: true }) mapViewEl: ElementRef; // @ViewChild('economicimpactfactorsselect', { static: false }) economicimpactsselect: ElementRef; attributesarray; constructor(private esriMapService: EsriMapService) { } public ngOnInit() { this.esriMapService.loadMap(this.mapViewEl).then(attrarray => this.attributesarray = attrarray) } // ngOnInit } The Service: import {ElementRef, Injectable, ViewChild} from '@angular/core'; import { loadModules } from 'esri-loader'; import esri = __esri; @Injectable() export class EsriMapService { mapView; constructor() { } loadMap(mapContainer: ElementRef) { const promise = new Promise((resolve, reject) => { loadModules([ 'esri/Map', 'esri/views/MapView', "esri/layers/FeatureLayer" ]) .then(([EsriMap, EsriMapView, FeatureLayer]) => { let map: esri.Map = new EsriMap({ basemap: 'hybrid' }); const economicimpactLayer = new FeatureLayer({ url: '//tfsgis.tamu.edu/arcgis/rest/services/EconomicImpactNew/TFEI_new_notsde/MapServer/0', outFields: ["*"], id: "economicimpactLayer" }); let mapView: esri.MapView = new EsriMapView({ container: mapContainer.nativeElement, center: [-99.5, 31.2], zoom: 6.5, map: map }); map.add(economicimpactLayer); mapView.when(() => { return economicimpactLayer.when(function() { let values = []; for (let i = 0; i < economicimpactLayer.fields.length; i++) { console.log(economicimpactLayer.fields[i].alias); values.push(economicimpactLayer.fields[i].alias) } return values }).then(getValues) resolve('true'); }, err => { console.error(err); reject(err); }); function getValues(response) { let array = []; for (let i = 0; i < response.length; i++) { array.push({name: response[i]}); } this.attributesarray = array.slice(); console.log(this.attributesarray) } }) .catch(err => { console.error(err); reject(err); }); }); return promise; } } And the html: <div class="container"> <div class="row"> <div class="column-12"> <h5>Summary Tool (click one of the buttons below to start)</h5> <select name="economicimpactfactorsselect" id="economicimpactfactorsselect" > <option value="" selected> </option> <option *ngFor="let attribute of attributesarray let i = index;" value={{i}}>{{attribute.name}}</option> </select> </div> <div class="column-12"> </div> </div> </div> <br> <div #mapViewNode></div>
... View more
03-26-2020
10:18 AM
|
0
|
1
|
1187
|
POST
|
I am a beginner with the angular framework. I need to populate a drop in my component. The elements will come from a feature layer. The drop down needs be populated in the beginning to work or I guess I could subscribe to a method. I created a service that should return a promise so and on the element I believe I am subscribing to the method. However I am having issues with returning a promise in the service. Can you guys tell me how I should change the service to return the promise I need or if there is a better way to do it? I am using Angular 9, and the esri loader I think it is the latest because I used the command npm install --save esri-loader to install it, although my package.json lists the 2.13.0 version. Thank you for any help! The Component: @Component({ selector: 'app-esri-map', templateUrl: './esri-map.component.html', styleUrls: ['./esri-map.component.css'] }) export class EsriMapComponent implements OnInit { // this is needed to be able to create the MapView at the DOM element in this component @ViewChild('mapViewNode', { static: true }) mapViewEl: ElementRef; // @ViewChild('economicimpactfactorsselect', { static: false }) economicimpactsselect: ElementRef; attributesarray; constructor(private esriMapService: EsriMapService) { } public ngOnInit() { this.esriMapService.loadMap(this.mapViewEl).then(attrarray => this.attributesarray = attrarray) } // ngOnInit } The Service: import {ElementRef, Injectable, ViewChild} from '@angular/core'; import { loadModules } from 'esri-loader'; import esri = __esri; @Injectable() export class EsriMapService { mapView; constructor() { } loadMap(mapContainer: ElementRef) { const promise = new Promise((resolve, reject) => { loadModules([ 'esri/Map', 'esri/views/MapView', "esri/layers/FeatureLayer" ]) .then(([EsriMap, EsriMapView, FeatureLayer]) => { let map: esri.Map = new EsriMap({ basemap: 'hybrid' }); const economicimpactLayer = new FeatureLayer({ url: '//tfsgis.tamu.edu/arcgis/rest/services/EconomicImpactNew/TFEI_new_notsde/MapServer/0', outFields: ["*"], id: "economicimpactLayer" }); let mapView: esri.MapView = new EsriMapView({ container: mapContainer.nativeElement, center: [-99.5, 31.2], zoom: 6.5, map: map }); map.add(economicimpactLayer); mapView.when(() => { return economicimpactLayer.when(function() { let values = []; for (let i = 0; i < economicimpactLayer.fields.length; i++) { console.log(economicimpactLayer.fields[i].alias); values.push(economicimpactLayer.fields[i].alias) } return values }).then(getValues) resolve('true'); }, err => { console.error(err); reject(err); }); function getValues(response) { let array = []; for (let i = 0; i < response.length; i++) { array.push({name: response[i]}); } this.attributesarray = array.slice(); console.log(this.attributesarray) } }) .catch(err => { console.error(err); reject(err); }); }); return promise; } } And the html: <div class="container"> <div class="row"> <div class="column-12"> <h5>Summary Tool (click one of the buttons below to start)</h5> <select name="economicimpactfactorsselect" id="economicimpactfactorsselect" > <option value="" selected> </option> <option *ngFor="let attribute of attributesarray let i = index;" value={{i}}>{{attribute.name}}</option> </select> </div> <div class="column-12"> </div> </div> </div> <br> <div #mapViewNode></div>
... View more
03-26-2020
10:16 AM
|
0
|
0
|
414
|
POST
|
Thank you Kevin. The gp gives the correct result in ArcMap so I am guessing is something in the web app. However, when I debug the web app it shows the selected features varies as the input but the output is always the same. I need to investigate more why this is happening in the web app. I will post the code here later. Thanks again.
... View more
02-01-2016
07:01 AM
|
0
|
0
|
289
|
POST
|
Then that explains why your gp works, if you have one input parameter its index should be 0 and if you also have an output parameter then the index should be 1, because they share index values. But I will try your approach, although I dont think it is going to fix the problem. Thank you
... View more
01-29-2016
11:36 AM
|
1
|
1
|
1031
|
POST
|
No, there is only one output parameter, but I thought the input and output parameters shared indexes, no? So, even thought it is the first output parameter, it should have an index of 2, not of 0, because there are two input parameters. This example shows that the output parameter is indexed as 1 because there is a input parameter first. SetParameterAsText—ArcPy Functions | ArcGIS for Desktop
... View more
01-29-2016
10:24 AM
|
1
|
5
|
1031
|
POST
|
But since I have : Layout_Template = arcpy.GetParameterAsText(0) Selecting_Features = arcpy.GetParameterAsText(1) Shouldn't it be arcpy.SetParameterAsText(2, Scale) like it is now?
... View more
01-29-2016
08:58 AM
|
0
|
7
|
1031
|
POST
|
Hi, I need to know the scale of an mxd in a web application. For that I am running a geoprocessing service. I need to know the scale when there is a definition query and the map zooms in to that feature. I can see in the message that the scale changes, but the output in the web application is always the same scale, although the input feature changes. What am I doing wrong? Thank you for any help. import arcpy import os import uuid # Input Layout template Layout_Template = arcpy.GetParameterAsText(0) if Layout_Template == '#' or not Layout_Template: Layout_Template = "StewardshipTractBoundaryMap" layouttemplatemxd = Layout_Template templatePath = 'D:/ArcGISData/Geoprocessing_Examples/Advanced_HighQualityPrinting3' Selecting_Features = arcpy.GetParameterAsText(1) Input_Polygons = "Stewardship" mxd0 = arcpy.mapping.MapDocument(r"D:\ArcGISData\Geoprocessing_Examples\Advanced_HighQualityPrinting3\\" + layouttemplatemxd + ".mxd") df1 = arcpy.mapping.ListDataFrames(mxd0, "DataFrame1")[0] mxd0.activeView = df1 lyr1 = arcpy.mapping.ListLayers(mxd0, Input_Polygons, df1)[0] lyr1.definitionQuery = "" lyr1.definitionQuery = '"PlanID" = \'%s\'' % Selecting_Features df1.panToExtent(lyr1.getSelectedExtent()) lyr1.getExtent() lyr1extent = lyr1.getExtent() df1.extent = lyr1extent Scale = str(df1.scale) arcpy.RefreshTOC() arcpy.RefreshActiveView() mxd0.save() arcpy.SetParameterAsText(2, Scale) lyr1.definitionQuery = "" arcpy.RefreshTOC() arcpy.RefreshActiveView() arcpy.AddMessage(Scale) mxd0.save() del mxd0, df1, lyr1
... View more
01-29-2016
08:40 AM
|
0
|
12
|
3235
|
POST
|
Hi, I need to know the scale of an mxd in a web application. For that I am running a geoprocessing service. I need to know the scale when there is a definition query and the map zooms in to that feature. I can see in the message that the scale changes, but the output in the web application is always the same scale, although the input feature changes. What am I doing wrong? Thank you for any help. import arcpy import os import uuid # Input Layout template Layout_Template = arcpy.GetParameterAsText(0) if Layout_Template == '#' or not Layout_Template: Layout_Template = "StewardshipTractBoundaryMap" layouttemplatemxd = Layout_Template templatePath = 'D:/ArcGISData/Geoprocessing_Examples/Advanced_HighQualityPrinting3' Selecting_Features = arcpy.GetParameterAsText(1) Input_Polygons = "Stewardship" mxd0 = arcpy.mapping.MapDocument(r"D:\ArcGISData\Geoprocessing_Examples\Advanced_HighQualityPrinting3\\" + layouttemplatemxd + ".mxd") df1 = arcpy.mapping.ListDataFrames(mxd0, "DataFrame1")[0] mxd0.activeView = df1 lyr1 = arcpy.mapping.ListLayers(mxd0, Input_Polygons, df1)[0] lyr1.definitionQuery = "" lyr1.definitionQuery = '"PlanID" = \'%s\'' % Selecting_Features df1.panToExtent(lyr1.getSelectedExtent()) lyr1.getExtent() lyr1extent = lyr1.getExtent() df1.extent = lyr1extent Scale = str(df1.scale) arcpy.RefreshTOC() arcpy.RefreshActiveView() mxd0.save() arcpy.SetParameterAsText(2, Scale) lyr1.definitionQuery = "" arcpy.RefreshTOC() arcpy.RefreshActiveView() arcpy.AddMessage(Scale) mxd0.save() del mxd0, df1, lyr1
... View more
01-29-2016
08:39 AM
|
0
|
0
|
1341
|
POST
|
Hi, I need to know the scale of an mxd in a web application. For that I am running a geoprocessing service. I need to know the scale when there is a definition query and the map zooms in to that feature. I can see in the message that the scale changes, but the output in the web application is always the same scale, although the input feature changes. What am I doing wrong? Thank you for any help. import arcpy import os import uuid # Input Layout template Layout_Template = arcpy.GetParameterAsText(0) if Layout_Template == '#' or not Layout_Template: Layout_Template = "StewardshipTractBoundaryMap" layouttemplatemxd = Layout_Template templatePath = 'D:/ArcGISData/Geoprocessing_Examples/Advanced_HighQualityPrinting3' Selecting_Features = arcpy.GetParameterAsText(1) Input_Polygons = "Stewardship" mxd0 = arcpy.mapping.MapDocument(r"D:\ArcGISData\Geoprocessing_Examples\Advanced_HighQualityPrinting3\\" + layouttemplatemxd + ".mxd") df1 = arcpy.mapping.ListDataFrames(mxd0, "DataFrame1")[0] mxd0.activeView = df1 lyr1 = arcpy.mapping.ListLayers(mxd0, Input_Polygons, df1)[0] lyr1.definitionQuery = "" lyr1.definitionQuery = '"PlanID" = \'%s\'' % Selecting_Features df1.panToExtent(lyr1.getSelectedExtent()) lyr1.getExtent() lyr1extent = lyr1.getExtent() df1.extent = lyr1extent Scale = str(df1.scale) arcpy.RefreshTOC() arcpy.RefreshActiveView() mxd0.save() arcpy.SetParameterAsText(2, Scale) lyr1.definitionQuery = "" arcpy.RefreshTOC() arcpy.RefreshActiveView() arcpy.AddMessage(Scale) mxd0.save() del mxd0, df1, lyr1
... View more
01-29-2016
08:38 AM
|
0
|
0
|
1458
|
POST
|
Hi, I need to know the scale of an mxd in Flex. For that I am running a geoprocessing service. I need to know the scale when there is a definition query and the map zooms in to that feature. I can see in the message that the scale changes, but the output in the web application is always the same scale, although the input feature changes. What am I doing wrong? Thank you for any help. import arcpy import os import uuid # Input Layout template Layout_Template = arcpy.GetParameterAsText(0) if Layout_Template == '#' or not Layout_Template: Layout_Template = "StewardshipTractBoundaryMap" layouttemplatemxd = Layout_Template templatePath = 'D:/ArcGISData/Geoprocessing_Examples/Advanced_HighQualityPrinting3' Selecting_Features = arcpy.GetParameterAsText(1) Input_Polygons = "Stewardship" mxd0 = arcpy.mapping.MapDocument(r"D:\ArcGISData\Geoprocessing_Examples\Advanced_HighQualityPrinting3\\" + layouttemplatemxd + ".mxd") df1 = arcpy.mapping.ListDataFrames(mxd0, "DataFrame1")[0] mxd0.activeView = df1 lyr1 = arcpy.mapping.ListLayers(mxd0, Input_Polygons, df1)[0] lyr1.definitionQuery = "" lyr1.definitionQuery = '"PlanID" = \'%s\'' % Selecting_Features df1.panToExtent(lyr1.getSelectedExtent()) lyr1.getExtent() lyr1extent = lyr1.getExtent() df1.extent = lyr1extent Scale = str(df1.scale) arcpy.RefreshTOC() arcpy.RefreshActiveView() mxd0.save() arcpy.SetParameterAsText(2, Scale) lyr1.definitionQuery = "" arcpy.RefreshTOC() arcpy.RefreshActiveView() arcpy.AddMessage(Scale) mxd0.save() del mxd0, df1, lyr1
... View more
01-29-2016
08:36 AM
|
0
|
0
|
1791
|
POST
|
I am chaging the python code in the Tutorial: Advanced high-quality web map printing/exporting using arcpy.mapping. Everything works great, but when I add a bing map as a basemap in the template, the basemap does not appear in the final pdf. Does anybody know why? Thanks
... View more
04-17-2015
09:22 AM
|
0
|
0
|
2421
|
POST
|
I found that when you convert to Map Document it only converts the active data frame.
... View more
04-17-2015
06:12 AM
|
0
|
0
|
339
|
POST
|
I found that when you convert to Map Document it only converts the active data frame.
... View more
04-17-2015
06:12 AM
|
0
|
0
|
131
|
POST
|
If the ConvertWebMapToMapDocument function renames the active dataframe in the template mxd to "Webmap", what does it rename the other data frame, the inactive one? Thanks
... View more
04-14-2015
06:24 AM
|
0
|
1
|
3242
|
Title | Kudos | Posted |
---|---|---|
1 | 01-29-2016 10:24 AM | |
1 | 01-29-2016 11:36 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|