Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This seems like it should be a relatively simple thing to do, but for whatever reason I can't figure it out.

I'm trying to add functionality to select a group of parcels as laid out in this example, and display queried information for those parcels in a popup info window. I've got it displaying the queried data in an infowindow correctly, and it highlights the correct parcel for the info being displayed, but I'm having issues highlighting every selected parcel. In the above example it sets the selection symbol with setSelectionSymbol(), but for whatever reason this isn't working for me, and I'm not exactly sure what I'm doing wrong.

I've included the parts of my code that are relevant to my problem, including parts that deal with toggling the parcel layer on and off in a legend.

Thank you for any help! If i can help clarify anything at all let me know!

function init() {

    //initialize popup window
     var popup = new esri.dijit.Popup({
    fillSymbol: new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]))
    }, dojo.create("div"));

    //add geometry service from server
    esri.config.defaults.geometryService = new esri.tasks.GeometryService("http://2501s-jjohnson:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer");

    //initalize map = new esri.Map("map", {
      basemap : "satellite",
      center : [-111.924531, 40.611871],
      zoom : 13,
      infoWindow: popup

    //query parcel and show info in popup window
     function executeIdentifyTask(evt) {
      var query = new esri.tasks.Query();
      query.geometry = pointToExtent(,evt.mapPoint,10);
      var deferred = featureParcel.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);[deferred]);;


    //trigger feature layer parcel query if parcels are turned on 
     function clickConnect(connect){
            //perform the identify task on click 
            clickHandler = dojo.connect(, "onClick", executeIdentifyTask);
            //disconnect the click handler 

          clickHandler = null;

    //add parcel layer
     var parcels = new esri.layers.ArcGISDynamicMapServiceLayer("http://2501s-jjohnson:6080/arcgis/rest/services/Parcels_UT/MapServer", {
      id : 'parcels',
      visible : false
      layer : parcels,
      title : 'Parcels'

    //add parcel feature layer query info for popup window
    var content = "<b>Address</b>: ${ADDR}" + "<br /><b>Owner Name</b>: ${OWNER}" + "<br /><b>Parcel ID</b>: ${APN}" + "<br /><b>City</b>: ${CITY}" + "<br /><b>Acres</b>: ${TOTAL_ACRES}"+ " <br /><a href='${COUNTY_LINK}' target='_blank'>County Assessor Site</a>"   
    var popUpTemplate = new esri.InfoTemplate("Parcel", content);   

    //add parcel feature layer
    featureParcel = new esri.layers.FeatureLayer("http://2501s-jjohnson:6080/arcgis/rest/services/Parcels_UT/MapServer/0",{
      mode: esri.layers.FeatureLayer.MODE_SELECTION,
      outFields: ["*"],

    //set selection Symbol
    var selectionSymbol = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,255,0,0.5]));
    selectionSymbol.setOutline(new esri.symbol.SimpleLineSymbol("solid", new dojo.Color([255,0,0]), 2));

    //create legend
    dojo.connect(, 'onLayersAddResult', function(results) {
      var legend = new esri.dijit.Legend({
        map :,
        layerInfos : legendLayers
      }, "retail");
    //add all layers to map[parcels]);
    //add layer arrays into  legend object
    legendLayers["parcel"] = parcelLayer;

    dojo.connect(, 'onLayersAddResult', function(results) {
        //for each layer array in legend object
        for (var k in legendLayers){
      //add legend check boxes for each layer
      //to toggle layer visibility
      dojo.forEach(legendLayers[k], function(layer) {
        var layerName = layer.title;
        var checkBox = new dijit.form.CheckBox({
          name : "checkBox" +,
          value :,
          checked : layer.layer.visible,
          onChange : function(evt) {
            var clayer =;
            this.checked = clayer.visible;

           //toggle the feature layer parcel query
           //parcelClick indicates whether the parcel layer is on
            if (this.value ==="parcels" && this.checked === true){
                parcelClick = true;
            } else if (this.value ==="parcels"){
                parcelClick = false;

        //add the check box and label to the table of contnents, dojo.byId(k), "after");
        var checkLabel = dojo.create('label', {
          'for' :,
          innerHTML : layerName
        }, checkBox.domNode, "after");"<br />", checkLabel, "after");

    dojo.connect(, "onLoad", initSelectToolbar);

        function initSelectToolbar(map) {
  selectionToolbar = new esri.toolbars.Draw(map);
  var selectQuery = new esri.tasks.Query();

  dojo.connect(selectionToolbar, "onDrawEnd", function(geometry) {
    selectQuery.geometry = geometry;
    var deferred = featureParcel.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW);[deferred]);;


  function pointToExtent(map, point, toleranceInPixel) {
   var pixelWidth = map.extent.getWidth() / map.width;
   var toleraceInMapCoords = toleranceInPixel * pixelWidth;
   return new esri.geometry.Extent( point.x - toleraceInMapCoords,
                point.y - toleraceInMapCoords,
                point.x + toleraceInMapCoords,
                point.y + toleraceInMapCoords,
                map.spatialReference );                           

share|improve this question
Just a thought: the example does further work with the layer in a onSelectionComplete handler, whereas you may not? It could be a map.refresh might be needed to show the selection symbols. – Ron Beloin Mar 11 '13 at 23:58
can you upload your Html code also for this above example – user48443 Mar 4 at 13:17
Please move this to be a comment on the original question, rather than an answer. – Sara Barnes Mar 4 at 13:24
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. – John Barça Mar 4 at 15:07

1 Answer 1

You are doing two things going on here. You have a click handler, that, when there is a click on the map, it creates a new selection using the point geometry from the click. That handler is toggled on and off by your clickConnect function.

But you also have a draw handler, that on draw end creates a new selection using the geometry from the drawing toolbar. That handler is not toggled on and off by your clickConnect function. It executes whether or not the parcel layer is on.

Try logging to console when either one of these selection queries is triggered. Since both of them create a new selection, I suspect that you are having a conflict between the two selections executing. (And likely the onDrawEnd selection is tripping off even when the parcel layer is turned off.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.