1

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?

Kevin192291
  • 1,925
  • 4
  • 26
  • 43

1 Answers1

0

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();

R10t--
  • 803
  • 7
  • 16