Hi,
In ArcGIS Experience, I try to develop an app with Query. My data has WKID = 2154 and I need to have his geometry with 4326 WKID.
I try many and many things :
getApiModule = () => {//Va cherche l'API Js pour dessinerreturn new Promise(resolve => {loadArcGISJSAPIModules(['esri/Graphic', 'esri/rest/support/Query', 'esri/geometry/Polygon', 'esri/geometry/SpatialReference']).then(modules => {[this.graphicApi, this.queryApi, this.polygonApi, this.spatialReferenceApi] = modules;resolve('ok');});});}recupRequete = () => {//Si besoin de cherche l'API de requêteif (!this.queryApi) {this.getApiModule().then(() => { this.recupRequete() })} else {//Construit la requêteconst q = new this.queryApi({where: '1=1',outFields: ['*'],returnGeometry: true,outSpatialReference: { 'wkid': 4326 }});console.log(q);//Stocke la requête dans le statethis.query = q.toJSON();}}
In Experience Builder, it seems that it is the dataSourceComponent which bring the request :
In render part :
<DataSourceComponentuseDataSource={this.props.useDataSources[0]}widgetId={this.props.id}query={this.query}queryCount={true}onDataSourceCreated={this.onDataSourceCreated}>{this.recupDonnees}</DataSourceComponent>
onDataSourceCreated = (ds: DataSource) => {//Récupère la datasource lors de sa créationthis.queryDs = ds;}recupDonnees = (ds: DataSource, info: IMDataSourceInfo) => {//Partie temporaire du stockage des options de la liste déroulantelet tmp = [];//Si la datasource est chargéeif (info.status === DataSourceStatus.Loaded) {//Parcours les résultats de la requêtethis.queryDs.getRecords().map((r: any) => {//Construit le label e foncton des champs choisislet label = '';if (this.props.useDataSources[0].fields?.length == 0 || !this.props.useDataSources[0].fields) {label += r.getData()['objectid'];} else {for (let j = 0; j < this.props.useDataSources[0].fields.length; j++) {if (j != 0) {label += '-';}label += r.getData()[this.props.useDataSources[0].fields[0]];}}//Ajoute la donnée dans le contenu de la liste déroulantetmp.push({ label: label, value: r.getData()['objectid'] + label, info: r });})}//définie par défaut les coordonnées du premier enregistrementthis.destinationChange(tmp[0]);//Remplace le contenu de la liste déroulantethis.setState({ destinations: tmp });return null;}
recupDonnees = (ds: any, info: IMDataSourceInfo) => {if (info.status === DataSourceStatus.Loaded) {if (ds.dataSourceJson?.query?.where?.sql) {//get the filter apply on ds in ExBthis.query2.where += ' AND ' + ds.dataSourceJson.query.where.sql}//apply the querythis.queryTaskApi.executeQueryJSON(ds.url, this.query2).then(function (results) {console.log("query results: ", results);//STATE_ABBR should be "ID"console.log("STATE_ABBR: ", results.features);});}}