POST
|
Robert, The reason is I'm not sure about the syntax, could it be something like this? on(dom.byId("layerList"),'toggle', function(evt){
layerCuenVisible = evt.layerList.layerIndex(0).visible;
layerCuenVisible = evt.layerList.layerIndex(1).visible;
});
... View more
05-14-2018
03:51 PM
|
0
|
1
|
941
|
POST
|
Hi Robert, Hi Ken, Thank you very much for your comments which have been very helpful. I've changed the code and it woks better, but the problem is that it doesn't recognise any poligon. I gess the way Itried to acces the property "visible" of the layerList is not correct. Here the new code. //Global variables
var layerAcuiVisible, layerCuenVisible;
app.map.on("layers-add-result", function (evt) {
var layerListDom = new LayerList({
map: app.map,
layers: [{
layer: f1,
showSubLayers: false,
showLegend: true,
showOpacitySlider: true,
visibility: false,
id: "Acuíferos"
},{
layer: f2,
showSubLayers: false,
showLegend: true,
showOpacitySlider: true,
visibility: false,
id: "Cuencas"
}],
showLegend: true,
},"layerList");
layerListDom.startup();
});
app.map.on("click", function (evt) {
var query = new Query();
query.geometry = evt.mapPoint;
if (layerAcuiVisible) {
var deferred = f1.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (selection) { });
}
if (layerCuenVisible) {
var deferred = f2.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (selection) { });
}
app.map.infoWindow.setFeatures([deferred]);
app.map.infoWindow.show(evt.mapPoint);
});
//It verifies which one of the layers is visible
on(dom.byId("layerList"),'toggle', function(evt){
layerAcuiVisible = evt.dom.byId("layerList").layers.id("Acuíferos").visible;
layerCuenVisible = evt.dom.byId("layerList").layers.id("Cuencas").visible;
});
... View more
05-14-2018
02:13 PM
|
0
|
3
|
941
|
POST
|
Hi Robert, Thank you very much, for your answer. I alredy have changed the programm and the change looks like this: app.map.on("click", function (evt) {
var query = new Query();
query.geometry = evt.mapPoint;
on(layerListDom,'toggle', function(evt){
if (layerIndex[1].visible === true) {
var deferred = f1.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (selection) { });
}
if (layerIndex[2].visible === true) {
var deferred = f2.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (selection) { });
}
});
app.map.infoWindow.setFeatures([deferred]);
app.map.infoWindow.show(evt.mapPoint);
}); However it doesn't seem to work, where is the mistake? Once again, thank you very much!
... View more
05-14-2018
11:31 AM
|
0
|
6
|
941
|
POST
|
I programmed an application in ArcGIS JavaScript version 3.23. The aplication uses a LayerList. It is required to know if one of the layers is visible (active) or not in order to be able to perform another action. Which is te ay to access de visibility property of any of the layers? or How sholuld I know if one of the layers was activated by te user and it is visible?. The idea is that when any of the layers Aquifers or Basins is selected and that the user clicks on some element, Aquifer or Basin, select this element in a unique way. Next I show the parts of the program that I use app.map = new Map("map", {
map: map,
basemap: "topo",
center: [-102.199176, 23.068129],
minZoom: 4,
autoResize: true,
zoom: 5,
fadeOnZoom: true,
infoWindow: popup,
navigationMode: "css-transforms"
});
app.map.on("layers-add-result", function (evt) {
var layerListDom = new LayerList({
map: app.map,
layers: [{
layer: f1,
showSubLayers: false,
showLegend: true,
showOpacitySlider: true,
visibility: false,
id: "Aquifers"
},{
layer: f2,
showSubLayers: false,
showLegend: true,
showOpacitySlider: true,
visibility: false,
id: "Basins"
},
},"layerList");
layerListDom.startup();
app.map.on("click", function (evt) {
var query = new Query();
query.geometry = evt.mapPoint;
var layer_visible = app.map.getLayer(app.map.layerIds[0]);
var layer_visible1 = app.map.getLayer(app.map.layerIds[1]);
if (layer_visible.visibility === true) {
var deferred = f1.selectFeatures(query, FeatureLayer.SELECTION_NEW, function
(selection) { });
}
if (layer_visible1.visibility === true) {
var deferred = f2.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (selection) { });
}
app.map.infoWindow.setFeatures([deferred]);
app.map.infoWindow.show(evt.mapPoint);
});
... View more
05-11-2018
12:34 PM
|
0
|
8
|
1174
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|