AnsweredAssumed Answered

Combination of Spatial query with Esri Serach Widget

Question asked by G.Denis on Mar 18, 2018

Hello,

 

I try to write a code to combine "esri search widget" with spatial query task "esri.tasks.Query.SPATIAL_REL_WITHIN" .

For example I have two polygons, when the users serach for the adress the marker of the search widget should give a pop up window whether it is in the polygone one, two or in none of them.

 

I hope somebody can help me.


        
  require([
        "esri/map",
        "esri/dijit/Search",
        "esri/layers/FeatureLayer",
        "esri/tasks/QueryTask",
         "esri/tasks/query",
        "esri/InfoTemplate",
        "dojo/dom-construct",
        "dojo/domReady!"
    ], function(
            Map,
            Search,
            FeatureLayer,
            QueryTask,
            Query,
            InfoTemplate,
            domConstruct
            ) {
        
        
        var map = new Map("map", {
            basemap: "osm",
            center: [-85.75, 38.25],
            zoom: 12
        });

 

        var search = new Search({
            showInfoWindowOnSelect: false,
            map: map
        }, "search");
      
        on(dom.byId("execute"), "click", execute);   
       
        function execute() {    
            queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Louisville/LOJIC_LandRecords_Louisville/MapServer/0");    
            //build query filter    
            query = new Query();    
            query.where = "*";    
            query.returnGeometry = false;    
            query.outFields = ["*"];    
            query.spatialRelationship = Query.SPATIAL_REL_CONTAINS;    
            queryTask.execute(query);    
        }   

    });               

Attachments

Outcomes