0

I am trying now to use autocomplete widget, i fond code written for API version 3.1, i use 4.1; I changed connection links and other things that might need to change. now i have response of attributes, but i do autocomplete does not work. help please.

Code:

Sample Code html, body, #viewDiv { padding: 0; margin: 0; height: 100%; width: 100%; }

</style>
<script src="https://js.arcgis.com/4.10/"></script>
<script>


  require(["esri/Map","esri/views/MapView", "esri/tasks/QueryTask","esri/tasks/support/Query","dojo/domReady!"], 

  function (Map, MapView, QueryTask, Query) {



    var map = new Map({
basemap: "topo-vector"
        })

var view = new MapView({ container: "viewDiv", map: map, extent: { // Extent Chemi rukistvis() xmin: 5278000, ymin: 5147000, xmax: 4377000, ymax: 5247784, spatialReference: 102100 } });

    $(function () {
        var array = []
        queryTask = new QueryTask("http://localhost:6080/arcgis/rest/services/Melioracia_Geo_201801251705/MapServer/3");
        query = new Query();
        query.returnGeometry = false;
        query.outFields = ["სარწყავი_სისტემა"];
        query.where = "OBJECTID > 0";
        queryTask.execute(query, showResults);


        function showResults(results) {
            // Collect the results
            var resultItems = [];
            var resultCount = results.features.length;
            for (var i = 0; i < resultCount; i++) {
                var featureAttributes = results.features[i].attributes;
                for (var attr in featureAttributes) {
                    // Convert the attribute to a string. Null Values create an extra comma which stops the widget from functioning.
                    tags = String(featureAttributes[attr]);
                    // push the attributes tothe blank array
                    resultItems.push(tags);
                    }
                }

            // Sort the array
            sorted = resultItems.sort()

            // Remove Duplicates
            var uniqueNames = [];
            $.each(sorted, function (i, el) {
                if ($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
            });

            // Set the varrible array
            array = uniqueNames

            // This is your AutoComplete Widget
            var availableTags = array;

            // Reference the div id which you want the autocomplete list to appear (in this case tag)
            $("#tags").autocomplete({
                // set the source as the availble tags above
                source: availableTags
            });

        } 

    });

  });
</script>

Tags:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.