<?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: Very slow FeatureLayer in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/very-slow-featurelayer/m-p/1140556#M44137</link>
    <description>&lt;P&gt;Did you ever figure out why it was so slow?&lt;/P&gt;</description>
    <pubDate>Thu, 03 Feb 2022 21:11:56 GMT</pubDate>
    <dc:creator>ChrisMahon3</dc:creator>
    <dc:date>2022-02-03T21:11:56Z</dc:date>
    <item>
      <title>Very slow FeatureLayer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/very-slow-featurelayer/m-p/87145#M4184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using ArcGis JS 4.11 and my maps are made here on ArcGis Online:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;A WebMap&lt;/LI&gt;&lt;LI&gt;FeatureLayers (hosted)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a working sample where I use my WebMap and featurelayers, but it is soooo slow when I call the featurelayer. I use a query to get the featurelayer. It can be tested like this:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;navigate with search to for example: Veluwestraat 64 2800 Mechelen&lt;/LI&gt;&lt;LI&gt;When you then click another address (for example 68 or so) a api call is made to get the capakey. With this capakey I then load in the featurelayer with a query. This click option only works in "Mechelen" because the FeatureLayer is a layer with the borders of the parcels.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code works,&amp;nbsp;but it is just so slow. Is this normal or can I do something to make it faster?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;BR /&gt;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt; &amp;lt;meta charset="utf-8" /&amp;gt;&lt;BR /&gt; &amp;lt;meta name="viewport"&lt;BR /&gt; content="initial-scale=1,maximum-scale=1,user-scalable=no" /&amp;gt;&lt;BR /&gt; &amp;lt;title&amp;gt;Search widget with custom source - 4.11&amp;lt;/title&amp;gt;&lt;BR /&gt; &amp;lt;style&amp;gt;&lt;/P&gt;&lt;P&gt;html,&lt;BR /&gt; body,&lt;BR /&gt; #viewDiv {&lt;BR /&gt; padding: 0;&lt;BR /&gt; margin: 0;&lt;BR /&gt; height: 100%;&lt;BR /&gt; width: 100%;&lt;BR /&gt; }&lt;BR /&gt; &amp;lt;/style&amp;gt;&lt;BR /&gt; &amp;lt;link rel="stylesheet"&lt;BR /&gt; href="https://js.arcgis.com/4.11/esri/themes/light/main.css" /&amp;gt;&lt;BR /&gt; &amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;BR /&gt; &amp;lt;script src="https://js.arcgis.com/4.11/"&amp;gt;&amp;lt;/script&amp;gt;&lt;BR /&gt; &amp;lt;script&amp;gt;&lt;BR /&gt; require([&lt;BR /&gt; "esri/Graphic",&lt;BR /&gt; "esri/request",&lt;BR /&gt; "esri/views/MapView",&lt;BR /&gt; "esri/widgets/Search",&lt;BR /&gt; "esri/widgets/Search/SearchSource",&lt;BR /&gt; "esri/geometry/geometryEngine",&lt;BR /&gt; "esri/geometry/Point",&lt;BR /&gt; "esri/layers/WMSLayer",&lt;BR /&gt; "esri/WebMap",&lt;BR /&gt; "esri/layers/FeatureLayer"&lt;BR /&gt; ], function (&lt;BR /&gt; Graphic,&lt;BR /&gt; esriRequest,&lt;BR /&gt; MapView,&lt;BR /&gt; Search,&lt;BR /&gt; SearchSource,&lt;BR /&gt; geometryEngine,&lt;BR /&gt; Point,&lt;BR /&gt; WMSLayer,&lt;BR /&gt; WebMap,&lt;BR /&gt; FeatureLayer&lt;BR /&gt; ) {&lt;BR /&gt; var url = "http://loc.geopunt.be/v2/location?",&lt;/P&gt;&lt;P&gt;layer = new WMSLayer({&lt;BR /&gt; url: 'https://geoservices.informatievlaanderen.be/raadpleegdiensten/GRB-basiskaart/wms'&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;//*** ADD ***//&lt;BR /&gt; var map = new WebMap({&lt;BR /&gt; portalItem: {&lt;BR /&gt; id: "8047aff130794b7fbc991fd1ac12ecf7"&lt;BR /&gt; }&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;var featureLayer;&lt;BR /&gt; var view = new MapView({&lt;BR /&gt; map: map,&lt;BR /&gt; center: [4.3, 51], //lon, lat&lt;BR /&gt; container: "viewDiv",&lt;BR /&gt; scale: 288896&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;view.popup.viewModel.autoOpenEnabled = false;&lt;/P&gt;&lt;P&gt;var customSearchSource = new SearchSource({&lt;BR /&gt; name: "Vlaanderen zoekopdracht",&lt;BR /&gt; placeholder: "Geef je straatnaam in",&lt;BR /&gt; displayField: "name",&lt;BR /&gt; // Provide a getSuggestions method&lt;BR /&gt; // to provide suggestions to the Search widget&lt;BR /&gt; getSuggestions: function (params) {&lt;BR /&gt; // You can request data from a&lt;BR /&gt; // third-party source to find some&lt;BR /&gt; // suggestions with provided suggestTerm&lt;BR /&gt; // the user types in the Search widget&lt;BR /&gt; return esriRequest(url, {&lt;BR /&gt; query: {&lt;BR /&gt; q: params.suggestTerm&lt;BR /&gt; },&lt;BR /&gt; responseType: "json"&lt;BR /&gt; }).then(function (results) {&lt;BR /&gt; // Return Suggestion results to display&lt;BR /&gt; // in the Search widget&lt;BR /&gt; return results.data.LocationResult.map(function (item) {&lt;BR /&gt; return {&lt;BR /&gt; key: "name",&lt;BR /&gt; text: item.FormattedAddress,&lt;BR /&gt; sourceIndex: params.sourceIndex&lt;BR /&gt; };&lt;BR /&gt; });&lt;BR /&gt; });&lt;BR /&gt; },&lt;BR /&gt; // Provide a getResults method to find&lt;BR /&gt; // results from the suggestions&lt;BR /&gt; getResults: function (params) {&lt;BR /&gt; // If the Search widget passes the current location,&lt;BR /&gt; // you can use this in your own custom source&lt;BR /&gt; var operation = "q=" + params.suggestResult.text.replace(/ /g, "+");&lt;BR /&gt; var query = {};&lt;BR /&gt; // You can perform a different query if a location&lt;BR /&gt; // is provided&lt;BR /&gt; if (params.location) {&lt;BR /&gt; query.lat = params.location.latitude;&lt;BR /&gt; query.lon = params.location.longitude;&lt;BR /&gt; } else {&lt;BR /&gt; query.q = params.suggestResult.text.replace(/ /g, "+");&lt;BR /&gt; }&lt;BR /&gt; return esriRequest(url + operation, {&lt;BR /&gt; query: query,&lt;BR /&gt; responseType: "json"&lt;BR /&gt; }).then(function (results) {&lt;BR /&gt; // Parse the results of your custom search&lt;BR /&gt; var searchResults = results.data.LocationResult.map(function (feature) {&lt;BR /&gt; // Create a Graphic the Search widget can display&lt;BR /&gt; var graphic = new Graphic({&lt;BR /&gt; geometry: new Point({&lt;BR /&gt; x: feature.Location.Lon_WGS84,&lt;BR /&gt; y: feature.Location.Lat_WGS84&lt;BR /&gt; }),&lt;BR /&gt; attributes: feature&lt;BR /&gt; });&lt;BR /&gt; // Optionally, you can provide an extent for&lt;BR /&gt; // a point result, so the view can zoom to it&lt;BR /&gt; var buffer = geometryEngine.geodesicBuffer(&lt;BR /&gt; graphic.geometry,&lt;BR /&gt; 50,&lt;BR /&gt; "meters"&lt;BR /&gt; );&lt;BR /&gt; // Return a Search Result&lt;BR /&gt; var searchResult = {&lt;BR /&gt; extent: buffer.extent,&lt;BR /&gt; feature: graphic,&lt;BR /&gt; name: feature.FormattedAddress&lt;BR /&gt; };&lt;BR /&gt; return searchResult;&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;// Return an array of Search Results&lt;BR /&gt; return searchResults;&lt;BR /&gt; });&lt;BR /&gt; }&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;// Create Search widget using custom SearchSource&lt;BR /&gt; var searchWidget = new Search({&lt;BR /&gt; view: view,&lt;BR /&gt; sources: [customSearchSource],&lt;BR /&gt; includeDefaultSources: false&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;searchWidget.on("select-result", function (event) {&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;view.on("click", function (event) {&lt;BR /&gt; map.remove(featureLayer);&lt;BR /&gt; esriRequest(url, {&lt;BR /&gt; query: "latlon=" + event.mapPoint.latitude + "," +&lt;BR /&gt; event.mapPoint.longitude,&lt;BR /&gt; responseType: "json"&lt;BR /&gt; }).then(function (results) {&lt;/P&gt;&lt;P&gt;var frslt = results.data.LocationResult[0];&lt;/P&gt;&lt;P&gt;$.ajax({&lt;BR /&gt; type: "GET",&lt;BR /&gt; dataType: "json",&lt;BR /&gt; cache: false,&lt;BR /&gt; url: "http://geoservices.beta.informatievlaanderen.be/capakey/api/v2/parcel?x=" + frslt.Location.X_Lambert72 + "&amp;amp;y=" + frslt.Location.Y_Lambert72 + "&amp;amp;data=cadmap",&lt;BR /&gt; success: function (data) {&lt;BR /&gt; console.log(data);&lt;BR /&gt; featureLayer = new FeatureLayer({&lt;BR /&gt; url: "https://services7.arcgis.com/c7P8EHq0LFjkXc7L/arcgis/rest/services/Percelen_Mechelen/FeatureServer",&lt;BR /&gt; outFields: ["*"], // Return all fields so it can be queried client-side&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;var sql;&lt;BR /&gt; var queryCaPaKey = data.capakey;&lt;BR /&gt; sql = "CAPAKEY = '" + queryCaPaKey + "'";&lt;BR /&gt; featureLayer.definitionExpression = sql&lt;/P&gt;&lt;P&gt;map.add(featureLayer);&lt;BR /&gt; },&lt;BR /&gt; error: function (err) {&lt;BR /&gt; console.log(err);&lt;BR /&gt; }&lt;BR /&gt; });&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;// Add the search widget to the top left corner of the view&lt;BR /&gt; view.ui.add(searchWidget, {&lt;BR /&gt; position: "top-right"&lt;BR /&gt; });&lt;BR /&gt; });&lt;BR /&gt; &amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt; &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is appreciated&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Serge&lt;/P&gt;&lt;DIV data-extension-version="1.0.4"&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Oct 2019 18:46:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/very-slow-featurelayer/m-p/87145#M4184</guid>
      <dc:creator>SergeDe_Backer</dc:creator>
      <dc:date>2019-10-08T18:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Very slow FeatureLayer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/very-slow-featurelayer/m-p/1140556#M44137</link>
      <description>&lt;P&gt;Did you ever figure out why it was so slow?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 21:11:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/very-slow-featurelayer/m-p/1140556#M44137</guid>
      <dc:creator>ChrisMahon3</dc:creator>
      <dc:date>2022-02-03T21:11:56Z</dc:date>
    </item>
  </channel>
</rss>

