|
POST
|
Stan, That was it. I tired it yesterday but without the var you suggested. I needed to change the widget configs file and not the config file inside the widget folder. The scope confuses me though I have to define the variable outside the function I though would need it. var crimeDate = this.config.crimes;
this.config.layers.layer.forEach(function (layer) {
//lots of functions
}; Thank you Robert Scheitlin, GISP and Stan McShinsky
... View more
06-02-2015
08:45 AM
|
1
|
0
|
785
|
|
POST
|
Robert, I am calling this.config.crimes; in the startup function. I have changed the scope of the variable (using Stan suggestions above) trying to make it work. I am sure you are tired of seeing this code: //setup click event for buttons
query("select").forEach(function (node) {
on(node, "click", function (e) {
var target = e.target || e.srcElement;
//----Number of Features---------------
lLayer.on("update-end", function (evt) {
dom.byId("featcount").innerHTML = " " + evt.target.graphics.length;
});
//-------------------
var crimeDate = this.config.crimes;
switch (target.value) {
case "106":
defExp2 = crimeDate;
break;
}
... View more
06-02-2015
08:25 AM
|
0
|
0
|
785
|
|
POST
|
Robert, Here is my json I am assuming that if i wanted to do the layer in my json my code would be this.config.layers.layer { "crimes": "Month='January'",
"layers": {
"layer": [
{
"type": "Feature",
"url": "http://gis.ashland.or.us/arcgis/rest/services/sandbox/crimeloc/MapServer/2",
"name": "crimeloc_filter",
"opacity": 0.59,
"visible": true,
"showLabels": true,
"popup": {
"title": "Crime",
"fieldInfos": [
{
"fieldName": "crime",
"label": "crime",
"visible": true
},
{
"fieldName": "date",
"label": "date",
"visible": true
},
{
"fieldName": "time",
"label": "time",
"visible": true
},
{
"fieldName": "Address",
"label": "Address",
"visible": true
},
{
"fieldName": "Description",
"label": "Description",
"visible": true
},
{
"fieldName": "IncidntNum",
"label": "IncidntNum",
"visible": true
},
{
"fieldName": "Descript",
"label": "Descript",
"visible": true
},
{
"fieldName": "DayOfWeek",
"label": "DayOfWeek",
"visible": true
},
{
"fieldName": "Date_1",
"label": "Date_1",
"visible": true
},
{
"fieldName": "Time_1",
"label": "Time_1",
"visible": true
},
{
"fieldName": "PdDistrict",
"label": "PdDistrict",
"visible": true
},
{
"fieldName": "Resolution",
"label": "Resolution",
"visible": true
},
{
"fieldName": "Location",
"label": "Location",
"visible": true
},
{
"fieldName": "Month",
"label": "Month",
"visible": true
}
],
"showAttachments": true,
"tr": null
},
"autorefresh": 0,
"mode": "ondemand"
}
]
}
}
... View more
06-02-2015
07:50 AM
|
1
|
0
|
3705
|
|
POST
|
Robert, I talked to my boss and he says since I can configure the app for anyone who works at my department that I should not spend all my time writing the settings for my widget. So my "filter" widget will take a lot of time to finish. I am going to try to learn and write the settings in 30-60 min a day. Thank you for a direction to start.
... View more
06-02-2015
07:44 AM
|
1
|
0
|
2233
|
|
POST
|
Robert, json "crimes": "Month='January'" widget this.config.crimes
... View more
06-02-2015
07:36 AM
|
1
|
2
|
3705
|
|
POST
|
Robert, Thank you! I have tried that. I just keep getting an error of crimes not defined (assuming crimes is in my config.json).
... View more
06-02-2015
07:11 AM
|
0
|
10
|
3705
|
|
POST
|
I know this is stupid but I cannot figure out how to get my js to pull some of my config.json into it. Does it have to be a function? After viewing sample code, I see that it can be done with a function. LocalLayer widget: this.config.layers.layer.forEach(function (layer) { Is there any documentation/ videos/ examples on how this can be done. I am looking for a way to amend the config json and have the script reflect that. Such as js var Exp = "fromjson"; json "fromjson": "crime = 'Larceny/Theft' ", Thanks!
... View more
06-01-2015
04:10 PM
|
0
|
12
|
7697
|
|
POST
|
I don't think so, I don't want the user to match up the html and js in the config file. I am thinking of a more automated way.
... View more
06-01-2015
02:05 PM
|
0
|
2
|
2233
|
|
POST
|
Okay I got it! I moved: var target = e.target || e.srcElement;
lLayer.on("update-end", function (evt) {
console.info(evt);
dom.byId("featcount").innerHTML = " " + evt.target.graphics.length; inside : on(node, "click", function (e) { Thank you Robert and Chris for your help!
... View more
06-01-2015
12:35 PM
|
0
|
0
|
1179
|
|
POST
|
The reason I am defining it to itself is because I was testing out options to define graphics. My code: lLayer.on("update-end", function (evt) {
console.info(evt);
dom.byId("featcount").innerHTML = " " + evt.target.graphics.length;
}); I get this error lLayer is the same as layer def as I use here: lLayer.setDefinitionExpression(defArr.join(" AND "));
... View more
06-01-2015
12:28 PM
|
0
|
2
|
1179
|
|
POST
|
I tried that (that is what Robert has above) My error is: TypeError: Cannot read property 'on' of undefined I removed yourFeatureLayer and that error goes away. and i get this error: Cannot read property 'graphics' of undefined
... View more
06-01-2015
12:22 PM
|
0
|
4
|
1179
|
|
POST
|
Chris, var graphics = graphics;
on("update-end", function (evt) {
//console.info(evt);
dom.byId("featcount").innerHTML = " " + graphics.length;
});
//setup click event for buttons
query("select").forEach(function (node) {
on(node, "click", function (e) {
var target = e.target || e.srcElement;
switch (target.value) {
case "0":
defExp = "crime ='Larceny/Theft'";
break;
case "1":
defExp = "crime ='Vehicle Theft'";
break;
case "2":
defExp = "crime ='Assult'";
break;
case "6":
defExp = "crime ='Other'";
break;
case "7":
defExp = "crime ='DUII'";
break;
case "8":
defExp = "crime ='Fraud'";
break;
case "9":
defExp = "crime ='Burglary'";
break;
case "Clear":
defExp = "";
break;
case "3":
defExp2 = "Month='August'";
break;
case "4":
defExp2 = "Month='July'";
break;
case "5":g
defExp2 = "Month='December'";
break;
case "Clear2":
defExp2 = "";
break;
case "10":
defExp3 = "Time_1 >= '18:00' AND Time_1 <= '06:00'";
break;
case "11":
defExp3 = "Time_1 >= '07:00' AND Time_1 <= '09:00' OR Time_1 >= '17:00' AND Time_1 <= '19:00'";
break;
case "12":
defExp3 = "Time_1 >= '06:00' AND Time_1 <= '20:00'";
break;
case "13":
defExp3 = "Time_1 >= '21:00' AND Time_1 <= '02:00'";
break;
case "Clear3":
defExp3 = "";
break;
}
var defArr = [];
if (defExp !== "") {
defArr.push(defExp);
}
if (defExp2 !== "") {
defArr.push(defExp2);
}
if (defExp3 !== "") {
defArr.push(defExp3);
}
lLayer.setDefinitionExpression(defArr.join(" AND "));
});
});
... View more
06-01-2015
12:05 PM
|
0
|
6
|
3955
|
|
POST
|
Robert, I almost have this working. I am using this code in a WAB widget. I cannot get .evt.target.graphics.length to work. I cannot find a way to define evt target and length Can you provide any insight on this. Thank you
... View more
06-01-2015
11:37 AM
|
0
|
8
|
3955
|
|
POST
|
Robert, Yes it is a feature layer with setDefinitionExpression. Thank you
... View more
05-29-2015
09:47 AM
|
0
|
10
|
3955
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-28-2025 01:53 PM | |
| 1 | 08-24-2022 09:40 AM | |
| 1 | 07-19-2018 04:41 PM | |
| 1 | 04-05-2024 03:12 PM | |
| 1 | 07-04-2024 11:42 AM |