I was wondering if someone could help me with this: I'd want to take measures without popup windows on clicking, only these popups should appear out of measuring.
This is my identify task:
map.on("load", mapReady);
var parcelsURL = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/";
map.addLayer(new ArcGISDynamicMapServiceLayer(parcelsURL,
{ visible: false }));
function mapReady () {
map.on("click", executeIdentifyTask);
//create identify tasks and setup parameters
identifyTask = new IdentifyTask(parcelsURL);
identifyParams = new IdentifyParameters();
identifyParams.tolerance = 3;
identifyParams.returnGeometry = true;
identifyParams.layerIds = [2];
identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
identifyParams.width = map.width;
identifyParams.height = map.height;
}
function executeIdentifyTask (event) {
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 === 'States') {
var taxParcelTemplate = new InfoTemplate("Estado: ${STATE_NAME}",
"Población: ${POP2000} personas<br/> Dens. Pob.: ${POP00_SQMI} pers./milla cuadr.<br/> Área: ${area} millas cuadradas ");
feature.setInfoTemplate(taxParcelTemplate);
}
else if (layerName === 'Building Footprints') {
console.log(feature.attributes.STATE_NAME);
var buildingFootprintTemplate = new InfoTemplate("",
"Estado: ${STATE_NAME}");
feature.setInfoTemplate(buildingFootprintTemplate);
}
return feature;
});
});
And my measure task:
function initt() {
//This sample requires a proxy page to handle communications with the ArcGIS Server services. You will need to
//replace the url below with the location of a proxy on your machine. See the 'Using the proxy page' help topic
//for details on setting up a proxy page.
esri.config.defaults.io.proxyUrl = "/proxy/";
esri.config.defaults.io.alwaysUseProxy = false;
//This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications
esri.config.defaults.geometryService = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
dojo.connect(map, 'onLoad', function(map) {
});
}
function initToolbar(mymap) {
//define a new line symbol and point symbol to use for measure tools
var pms = new esri.symbol.PictureMarkerSymbol("images/flag.png",24,24);
pms.setOffset(9,11);
var sls = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DOT,
new dojo.Color([255,0,0,0.55]), 4);
var measurement = new esri.dijit.Measurement({
map: mymap,
lineSymbol:sls,
pointSymbol:pms,
}, dojo.byId('measurementDiv'));
measurement.startup();
measurement.setTool("area",true);
}
dojo.ready(initt);
and the button action:
on(dojo.byId("medidas"),"click",fmedidas);
function fmedidas(){
initToolbar(map);
}
Many thanks.
Hi Eduardo,
Here is an example that demonstrates this. When a measurement tool is selected, the map's click event to identify the features is disconnected When the measurement is finished, the event is re-connected.
This is the code I use to halt the identify task if a measurement tool is active. Hope it helps
Luci
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) { identifyParams.geometry = event.mapPoint; identifyParams.mapExtent = map.extent; ...
Many thanks, problem solved!!.