简体   繁体   中英

arcGIS javascript no lat long after doing Feature Layer query

I have done a query on my feature layer and got a result. the only problem is that the resulting object doesn't contain a LAT and LNG attribute. Here is the problem:

centerAndZoomOnAsset(assetId: string) {
let query = this.pipeFL.createQuery();
query.where = `AssetId = '${assetId}'`;
query.outFields = ['*'];
this.pipeFL.queryFeatures(query).then((result: esri.FeatureSet) => {
  debugger;
  const foundFeatureGraphic: esri.Graphic = result.features[0];
  if (foundFeatureGraphic) {
    const center = foundFeatureGraphic.geometry.extent.center.clone();

At this point I have a value for center, and it has it's x,y coords, however, I do not have: center.latitude or center.longitude... I don't see why it will not have it. When I do a hit test on a click, it contains both lat and lng, but when i query from outside of the hit test, it doesn't contain my lat and lng. Any ideas as to why this is happening?

You need to set the returnGeometry parameter to true in order to get spatial data from the query. See the API here

Try using this:

centerAndZoomOnAsset(assetId: string) {
let query = this.pipeFL.createQuery();
query.where = `AssetId = '${assetId}'`;
query.returnGeometry = true;
query.outFields = ['*'];
this.pipeFL.queryFeatures(query).then((result: esri.FeatureSet) => {
  debugger;
  const foundFeatureGraphic: esri.Graphic = result.features[0];
  if (foundFeatureGraphic) {
    const center = foundFeatureGraphic.geometry.extent.center.clone();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM