<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Replace auto-generated OBJECTID with my own ID field when creating a GeoJSON layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115711#M75237</link>
    <description>&lt;P&gt;I've figured out a workaround. I need to add the property outFields: ["*"] to GeoJSONLayer to include my id as an attribute.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Nov 2021 16:56:37 GMT</pubDate>
    <dc:creator>ironmaskito</dc:creator>
    <dc:date>2021-11-10T16:56:37Z</dc:date>
    <item>
      <title>Replace auto-generated OBJECTID with my own ID field when creating a GeoJSON layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115491#M75219</link>
      <description>&lt;P&gt;I am creating a GeoJSONLayer client-side using an example payload containing geojson data. ArcGIS auto-generates a `&lt;STRONG&gt;OBJECTID&lt;/STRONG&gt;` attribute, and I'm hoping I can replace this value with an `&lt;STRONG&gt;id&lt;/STRONG&gt;` feature property in my payload. My goal is to query for the feature using the id provided in my geojson data. I think GeoJSONLayer's &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html#objectIdField" target="_self"&gt;objectIdField&amp;nbsp;&lt;/A&gt;&lt;SPAN&gt;will do the trick, but I can't figure out how to implement it based off of the accompanying direction:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;The name of an&amp;nbsp;&lt;/SPAN&gt;oid&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html#fields" target="_blank" rel="noopener"&gt;field&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;containing a unique value or identifier for each feature in the layer.&amp;nbsp;&lt;/SPAN&gt;id&lt;SPAN&gt;&amp;nbsp;property of the feature object in the GeoJSON will be used as ObjectID. If&amp;nbsp;&lt;/SPAN&gt;id&lt;SPAN&gt;&amp;nbsp;property is not present and&amp;nbsp;&lt;/SPAN&gt;objectIDField&lt;SPAN&gt;&amp;nbsp;is not specified,&amp;nbsp;&lt;/SPAN&gt;ObjectID&lt;SPAN&gt;&amp;nbsp;field will be generated for each feature.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I've included a snippet of Geojson data I want to display below with the `&lt;STRONG&gt;id&lt;/STRONG&gt;` property (0x1023) providing the new value for `ObjectID`.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;{
  "overlayId": "2d882141-0d9e-59d4-20bb-58e6d0460699.1",
  "featureId": "example.geojson.1",
  "format": "geojson",
  "feature": {
    "type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "geometry": {
          "type": "Point",
          "coordinates": [
            -15.9423828125,
            -15.297068292853805
          ]
        },
        "properties": {
          "sys_style": "default"
        },
        "name": "Point",
        "id": "0x1023",
        "description": "Feature Point Example"
      }
	]
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I create a GeoJSONLayer from the above data, ArcGIS simple autogenerates the ObjectID like usual (first feature has ObjectID = 1, and so on). I also tried setting GeoJSONLayer's `objectIdField` to `id`, but that didn't work either. I'm a bit stuck, as I couldn't find any examples online trying to accomplish what I am. Would appreciate any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    this.layer = new GeoJSONLayer({
      url: createUrl(geojson),
      renderer: this.getRenderer(), 
      elevationInfo: {
        mode: 'on-the-ground'
      },
      objectIdField: "id", // use the id in geojson data instead of the auto-generated OBJECTID as an attribute
    });
  }

  private createUrl(geojson: GeoJSON.GeoJSON): string {
    const blob: Blob = new Blob([JSON.stringify(geojson)], {
      type: 'application/json'
    });
    return URL.createObjectURL(blob);
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 01:03:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115491#M75219</guid>
      <dc:creator>ironmaskito</dc:creator>
      <dc:date>2021-11-10T01:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: Replace auto-generated OBJECTID with my own ID field when creating a GeoJSON layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115512#M75221</link>
      <description>&lt;P&gt;When working with ESRI's API and maps,&amp;nbsp;&lt;SPAN&gt;ObjectID is required as part of the ability to process the layer object. If you'd like to have a customized structure why use the API and not built one manually through a function that adds the details into a GeoJSON format?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 03:06:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115512#M75221</guid>
      <dc:creator>shaylavi</dc:creator>
      <dc:date>2021-11-10T03:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Replace auto-generated OBJECTID with my own ID field when creating a GeoJSON layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115676#M75234</link>
      <description>&lt;P&gt;The use case above is for testing purposes. I just want to know if what I'm trying to accomplish is possible with objectIdField property.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 16:07:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115676#M75234</guid>
      <dc:creator>ironmaskito</dc:creator>
      <dc:date>2021-11-10T16:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Replace auto-generated OBJECTID with my own ID field when creating a GeoJSON layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115697#M75235</link>
      <description>&lt;P&gt;I would also be open to adding my id field as an additional attribute to the geojson feature. I can't figure out how to add my own custom attributes, so I'm stuck with the auto-generated OBJECTID. I know ideally I would be setting/getting this information from a database, but for now I'm forced to store data on my local machine.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 16:39:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115697#M75235</guid>
      <dc:creator>ironmaskito</dc:creator>
      <dc:date>2021-11-10T16:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Replace auto-generated OBJECTID with my own ID field when creating a GeoJSON layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115702#M75236</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Until versions up to 4.21,&amp;nbsp;The GeoJSONLayer expects the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;id&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;property of the feature object in the GeoJSON to be of type number. Other data types are not honored. It is stated in known limitations section of the&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html" target="_self"&gt;GeoJSONLayer&lt;/A&gt;&lt;SPAN&gt; document.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;However, starting at version 4.22, GeoJSONLayer &amp;nbsp;supports string and number feature ids for the ObjectID field. You can test this using our &lt;A href="https://github.com/Esri/feedback-js-api-next/blob/master/CHANGELOG.md" target="_self"&gt;next build&lt;/A&gt;&amp;nbsp;which shows what's coming at 4.22.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/U_B_U/pen/JjyBXVM?editors=0010" target="_self"&gt;This simple test app&lt;/A&gt; shows that this can now be done at the JS API version 4.22. The version 4.22 will be released end of December.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 16:43:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115702#M75236</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-11-10T16:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Replace auto-generated OBJECTID with my own ID field when creating a GeoJSON layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115711#M75237</link>
      <description>&lt;P&gt;I've figured out a workaround. I need to add the property outFields: ["*"] to GeoJSONLayer to include my id as an attribute.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 16:56:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/replace-auto-generated-objectid-with-my-own-id/m-p/1115711#M75237</guid>
      <dc:creator>ironmaskito</dc:creator>
      <dc:date>2021-11-10T16:56:37Z</dc:date>
    </item>
  </channel>
</rss>

