Select to view content in your preferred language

Identify still showing

3186
10
Jump to solution
09-17-2014 08:07 AM
RichardMoussopo
Frequent Contributor

I would like to deactivate the identify when doing measurement.

identify.PNG

here is my function identify code:

function initFunctionality() {

        //map.on("click", doIdentify);

        dojo.connect(map, "onClick", doIdentify);

        identifyTask = new IdentifyTask(".../MapServer");

        identifyParams = new IdentifyParameters();

        identifyParams.tolerance = 3;

        identifyParams.returnGeometry = true;

        identifyParams.layerIds = [21, 54, 36];

        identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;

        identifyParams.width = map.width;

        identifyParams.height = map.height;

        map.infoWindow.resize(650, 200);

        map.infoWindow.setContent(registry.byId("tabs").domNode);

        map.infoWindow.setTitle("Utilities Identify Results");

        symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,

          new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,

            new Color([255, 0, 0]), 2),

          new Color([255, 255, 0, 0.25]));

    }

and I am calling this function on the following event:

//dojo.connect(map, "onLoad", initFunctionality);

    //map.on("load", initFunctionality);

    map.on("layers-add-result", initFunctionality);

This makes the identify window showing up each time I click on the map. I would like to only call the identify only when I click on the identify button on the toolbar to activate the identify function. But when I try to call the initFunctionality() from a button click event, the identify won't work. for some reason, it is only working when called from map.on("load") or map.on("layers-add-result").

0 Kudos
1 Solution

Accepted Solutions
StevenGraf1
Frequent Contributor

Here is how I solved this:

function executeIdentifyTask (event) {

  var measureMode =  dojo.query(".esriButton .dijitButtonNode").some(function(node, index, arr){

          if(node.childNodes[0].checked){

            //at least one of the measure tools is active so disable identify

            return true;

          

          }

      });

  

    if(!measureMode){

    identifyTask = new IdentifyTask(parcelsURL);

          identifyParams = new IdentifyParameters();

          identifyParams.tolerance = 5;

  identifyParams.returnGeometry = true;

          identifyParams.layerIds = visibleLayerIds;

          identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_TOP;

          identifyParams.width = map.width;

          identifyParams.height = map.height;

  identifyParams.layerIds = layer.visibleLayers;

          identifyParams.geometry = event.mapPoint;

          identifyParams.mapExtent = map.extent;

          var deferred = identifyTask

            .execute(identifyParams)

            .addCallback(function (response) {

              // response is an array of identify result objects

              // Let's return an array of features.

              return arrayUtils.map(response, function (result) {

                var feature = result.feature;

                var layerName = result.layerName;

                feature.attributes.layerName = layerName;

                if (layerName === 'Building Interior Space - Basement') {

                  var interiorSpaceBasement = new InfoTemplate("Interior Space",

                    "Building Name: ${Building Name} <br/> Floor Number: ${Floor Number} <br/> Space Name: ${Short Name of Space} <br/> Full Space Name: ${Full Name of Space} <br/> Space Type: ${Space Type} <br/> Staff Name: ${STAFFNM} <br/> Phone: ${PHONE} <br/> Access Type: ${Access Type} <br/>");

                  feature.setInfoTemplate(interiorSpaceBasement);

                }

                return feature;

              });

            });

          // InfoWindow expects an array of features from each deferred

          // object that you pass. If the response from the task execution

          // above is not an array of features, then you need to add a callback

          // like the one above to post-process the response and return an

          // array of features.

          map.infoWindow.setFeatures([deferred]);

          map.infoWindow.show(event.mapPoint);

  identifyParams.layerIds = visibleLayerIds;

        }}

View solution in original post

10 Replies
TimWitt2
MVP Alum

Richard,

you could use this code to turn off identify while you are measuring:

  1.   map.on("mouse-over", windowPop); 
  2.  
  3.   function windowPop(){ 
  4.   if (measurement.area.checked || measurement.distance.checked || measurement.location.checked){ 
  5.   map.setInfoWindowOnClick(false); 
  6.   } else
  7.   map.setInfoWindowOnClick(true); 
  8.   } 
  9.   } 
  10.  
  11.   measurement.on("measure-end", function (){ 
  12.   map.setInfoWindowOnClick(true); 
  13.   }); 

Hope this helps!

Tim

0 Kudos
RichardMoussopo
Frequent Contributor

Thank you Tim for replying,

but it does not seem to work. I am wondering if it could be the mouse-over method. is there a measure-start method?

0 Kudos
TimWitt2
MVP Alum

Richard,

All the mouse-over method does is check if the meassurement tool is active when you hover over the map. If any of the tools are active then it turns off the infowindow ( map.setInfoWindowOnClick(false); .. Once you are done measuring it turns it back on.

Maybe your issue is that your measurement widget is not called measurement? Can you post all of your code?

Tim

0 Kudos
RichardMoussopo
Frequent Contributor

here is my code:

  var measurement = new Measurement({

        map: map

    }, dom.byId("measurementDiv"));

    measurement.startup();

    function windowPop() {

        if (measurement.area.checked || measurement.distance.checked || measurement.location.checked) {

            map.setInfoWindowOnClick(false);

        } else {

            map.setInfoWindowOnClick(true);

        }

    }

    measurement.on("measure-end", function () {

        map.setInfoWindowOnClick(true);

    });

0 Kudos
TimWitt2
MVP Alum

You need to add this:

map.on("mouse-over", windowPop);

Make sure you use version 3.10, because map.setInfoWindowOnClick was added with the latest update.

Tim

0 Kudos
RichardMoussopo
Frequent Contributor

Added, and the identify is still showing up when measuring and yes, I am using 3.10 version:

var measurement = new Measurement({

        map: map

    }, dom.byId("measurementDiv"));

    measurement.startup();

    map.on("mouse-over", windowPop);

     function windowPop() {

        if (measurement.area.checked || measurement.distance.checked || measurement.location.checked) {

            map.setInfoWindowOnClick(false);

        } else {

            map.setInfoWindowOnClick(true);

        }

    }

    measurement.on("measure-end", function () {

        map.setInfoWindowOnClick(true);

    });

0 Kudos
RichardMoussopo
Frequent Contributor

I also tried to just call the method map.setInfoWindowOnClick(false);

and it didn't do anything. I do not think my app is recognizing the setInfoWindowOnClick method.

I am wondering if there is a requirement for that method to work.?

0 Kudos
TimWitt2
MVP Alum

Did you try what Steven suggested?

0 Kudos
StevenGraf1
Frequent Contributor

Here is how I solved this:

function executeIdentifyTask (event) {

  var measureMode =  dojo.query(".esriButton .dijitButtonNode").some(function(node, index, arr){

          if(node.childNodes[0].checked){

            //at least one of the measure tools is active so disable identify

            return true;

          

          }

      });

  

    if(!measureMode){

    identifyTask = new IdentifyTask(parcelsURL);

          identifyParams = new IdentifyParameters();

          identifyParams.tolerance = 5;

  identifyParams.returnGeometry = true;

          identifyParams.layerIds = visibleLayerIds;

          identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_TOP;

          identifyParams.width = map.width;

          identifyParams.height = map.height;

  identifyParams.layerIds = layer.visibleLayers;

          identifyParams.geometry = event.mapPoint;

          identifyParams.mapExtent = map.extent;

          var deferred = identifyTask

            .execute(identifyParams)

            .addCallback(function (response) {

              // response is an array of identify result objects

              // Let's return an array of features.

              return arrayUtils.map(response, function (result) {

                var feature = result.feature;

                var layerName = result.layerName;

                feature.attributes.layerName = layerName;

                if (layerName === 'Building Interior Space - Basement') {

                  var interiorSpaceBasement = new InfoTemplate("Interior Space",

                    "Building Name: ${Building Name} <br/> Floor Number: ${Floor Number} <br/> Space Name: ${Short Name of Space} <br/> Full Space Name: ${Full Name of Space} <br/> Space Type: ${Space Type} <br/> Staff Name: ${STAFFNM} <br/> Phone: ${PHONE} <br/> Access Type: ${Access Type} <br/>");

                  feature.setInfoTemplate(interiorSpaceBasement);

                }

                return feature;

              });

            });

          // InfoWindow expects an array of features from each deferred

          // object that you pass. If the response from the task execution

          // above is not an array of features, then you need to add a callback

          // like the one above to post-process the response and return an

          // array of features.

          map.infoWindow.setFeatures([deferred]);

          map.infoWindow.show(event.mapPoint);

  identifyParams.layerIds = visibleLayerIds;

        }}