AnsweredAssumed Answered

select by layer

Question asked by jay.kapalczynski on Mar 9, 2018
Latest reply on Mar 13, 2018 by jay.kapalczynski

I am trying the below.  The example works fine....

ArcGIS API for JavaScript Sandbox 


I put in my Map Service and it does not work????  I stripped the return results and calculation to the html out of the example link above...but the below code works with the ESRI map service but not mine.


The only difference I see is that my Map Service is a polygon...does that matter.  Why is my Polygon map service not showing the results in the buffer....


Any thoughts?



<!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Select with feature layer</title>
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="">
      html, body, #mapDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        background-color: #fff;
        box-shadow: 0 0 5px #888;
        font-size: 1.1em;
        max-width: 15em;
        padding: 0.5em;
        position: absolute;
        right: 20px;
        top: 20px;
        z-index: 40;
    <script src=""></script>
      var map;
        "esri/map", "esri/layers/FeatureLayer",
        "esri/tasks/query", "esri/geometry/Circle",
        "esri/graphic", "esri/symbols/SimpleMarkerSymbol",
        "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "esri/renderers/SimpleRenderer",
        "esri/config", "esri/Color", "dojo/dom", "dojo/domReady!"
      ], function(
        Map, FeatureLayer,
        Query, Circle,
        Graphic, SimpleMarkerSymbol,
        SimpleLineSymbol, SimpleFillSymbol, SimpleRenderer,
        esriConfig, Color, dom
      ) {
        // Use a proxy page if a URL generated by this page is greater than 2000 characters
        // This should not be needed as nearly all query & select functions are performed on the client
        // = "/proxy/";
        map = new Map("mapDiv", {
          basemap: "streets",
          center: [-95.249, 38.954],
          zoom: 14,
          slider: false
        // Add the census block points in on demand mode. An outfield is specified since it is used when calculating   the total population falling within the one mile radius.
        var featureLayer = new FeatureLayer("",{     
             outFields: ["*"]

        // Selection symbol used to draw the selected census block points within the buffer polygon
        var symbol = new SimpleMarkerSymbol(
          new SimpleLineSymbol(
            new Color([247, 34, 101, 0.9]),
          new Color([207, 34, 171, 0.5])
        // Make unselected features invisible
        var nullSymbol = new SimpleMarkerSymbol().setSize(0);
        featureLayer.setRenderer(new SimpleRenderer(nullSymbol));
        var circleSymb = new SimpleFillSymbol(
          new SimpleLineSymbol(
            new Color([105, 105, 105]),
          ), new Color([255, 255, 0, 0.25])
        var circle;

        // When the map is clicked create a buffer around the click point of the specified distance
        map.on("click", function(evt){
          circle = new Circle({
            center: evt.mapPoint,
            geodesic: true,
            radius: 1,
            radiusUnit: "esriMiles"
          var graphic = new Graphic(circle, circleSymb);

          var query = new Query();
          query.geometry = circle.getExtent();
          // Use a fast bounding box query. It will only go to the server if bounding box is outside of the visible map.
          featureLayer.queryFeatures(query, selectInBuffer);

        function selectInBuffer(response){
          var feature;
          var features = response.features;
          var inBuffer = [];
          // Filter out features that are not actually in buffer, since we got all points in the buffer's bounding box
          for (var i = 0; i < features.length; i++) {
            feature = features[i];
          var query = new Query();
          query.objectIds = inBuffer;
          // Use an objectIds selection query (should not need to go to the server)
          featureLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW, function(results){

    <span id="messages">Click on the map to select census block points within 1 mile.</span>
    <div id="mapDiv"></div>