Getting error while implementing Turf with Arcgis

868
3
04-21-2021 11:58 AM
SahilBansal
New Contributor II

Hi,

While implementing the Turf with the Arcgis, below error is coming:

Argument of type '{ type: string; properties: { stroke: string; }; features: { type: string; properties: { color: string; }; geometry: { type: string; coordinates: number[][]; }; }[]; }' is not assignable to parameter of type 'Position[]'.

 

PFB the code snippet:

 const getPoint = () => {
      var line = turf.lineString({
        type: 'FeatureCollection',
        features: [
          {
            type: 'Feature',
            properties: {
              color: 'orange'
            },
            geometry: {
              type: 'Polygon',
              coordinates: [
        [-77.03166938.878605],
        [-77.02960938.881946],
        [-77.02033938.884084],
        [-77.02566138.885821],
        [-77.02188438.889563],
        [-77.01982438.892368],
        ]
      }
    }
  ]
      });
      const pt = turf.point([this.latthis.lon]);
      console.log('Inside turf'this.lat);

      const snapped = turf.nearestPointOnLine(linept, {units: 'miles'});
    };
0 Kudos
3 Replies
ReneRubalcava
Frequent Contributor

Turf isn't an Esri product. You can get support on the github page for turf https://github.com/Turfjs/turf/

0 Kudos
SahilBansal
New Contributor II

Hi,

I checked this link as well. I just wanna used the properties to show the nearby points on the map for a given route. So that is why i am using TUrf.

Is there any way to do that in Arcgis using Turf.

 

0 Kudos
ReneRubalcava
Frequent Contributor

You'll need to covert the GeoJSON result to an ArcGIS geometry.

https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html

Point takes a latitude and longitude you can use. I have no samples for this.

0 Kudos