I would like to deactivate the identify when doing measurement.
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").
Solved! Go to Solution.
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;
}}
Richard,
you could use this code to turn off identify while you are measuring:
Hope this helps!
Tim
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?
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
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);
});
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
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);
});
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.?
Did you try what Steven suggested?
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;
}}