POST
|
Hi all, I am running a queryTask and queryFeatures on a State and a sub-State feature layers respectively. The function is supposed to select features from the sub-State featureLayer which are above (or below) the State average (the input from the State feature Layer). I am being able to run the query on the sub-State layer, but I am not able to retrieve the State value. I'll appreciate it if someone can look into it. Here is the relevant code: function queryParam(){
var stateAvg;
myURL = "subStateURL";
queryTask = new esri.tasks.QueryTask(myURL);
query = new esri.tasks.Query();
query.returnGeometry = true;
query.outFields = ["*"];
query.where = "1=1";
distFeatureLayer.setDefinitionExpression(someString);
distFeatureLayer.queryFeatures(query, function(featureSet) {
stateAvg=returnStateAverage(stateGeography, stateIndicator);
for ( i = 0; i < featureSet.features.length; i++) {
var indValue = featureSet.features.attributes[indicator];//'indicator' same as 'stateIndicator'
if (userSelectedCriteria == "Above") {//user selects the criteria using a combobox
if (indValue > stateAvg) {
selDist.push(featureSet.features.attributes.Dist_name);
selStAbbr.push(featureSet.features.attributes.St_abbr);
}
} else if (userSelectedCriteria == "Below") {
if (indValue < stateAvg) {
selDist.push(featureSet.features.attributes.Dist_name);
selStAbbr.push(featureSet.features.attributes.St_abbr);
}
}
}
strDist = "(Dist_name = '" + selDist[0] + "' AND St_abbr = '" + selStAbbr[0] + "')";
if (selDist.length > 1) {
for ( i = 1; i < selDist.length; i++) {
strDist += "OR (Dist_name = '" + selDist + "' AND St_abbr = '" + selStAbbr + "')";
}
}
distFeatureLayer.setDefinitionExpression(strDist);
distFeatureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);
distFeatureLayer.setRenderer(renderer);
distFeatureLayer.refresh();
hide("loaderExecute");
});
}
function returnStateAverage(geography, indicator){
var stateVal;
var myURL = "stateURL";
queryTask = new esri.tasks.QueryTask(myURL);
query = new esri.tasks.Query();
query.returnGeometry = false;
query.outFields = ["*"];
query.where = "State_name='" + geography + "'";
queryTask.execute(query, function(fSet) {
var features = fSet.features;
dojo.forEach(features, function(feature) {
stateVal = feature.attributes[indicator];
return stateVal;
});
});
}
... View more
04-04-2013
12:33 PM
|
0
|
5
|
1025
|
POST
|
Samir, It does not appear to be anything with the JSAPI... This seems to work fine: http://jsfiddle.net/shadc/WD6ta/ . All I did is point to another SampleWorldCities service?? Your service or proxy is suspect... ("http://localhost:6080/arcgis/rest/services/SampleWorldCities/MapServer/0") Are you running everything from localhost? -Shad Hi Shad, Thanks for looking into it. I ran the code on JSFiddle (your link) and the behavior is the same. It runs fine the first time, but if you run it again, the combobox does not get populated. Did you encounter the same behavior? Thanks Samir
... View more
04-04-2013
11:48 AM
|
0
|
0
|
1725
|
POST
|
Can you post your code? Are you using both http and https requests? Hi Shad, Thanks for offering to help. Please find the html file with a very basic application. I am using http requests only. Thanks Samir
... View more
04-04-2013
05:56 AM
|
0
|
0
|
1725
|
POST
|
Hi all, I have been working on this web application for sometime and I have a big presentation coming up next Wednesday. Unfortunately, starting last week, something has gone wrong with the application and I cannot fix it. The issue is that when my application loads, the console log shows "Error {code: 400, message: "Unable to complete operation.", details: Array[0], log: undefined, _ssl: undefined}. Suspecting something wrong with my code, I have checked my code umpteenth number of times. I also recreated my services and checked through REST as well. Eventually I created a basic bare bones application and tried it with ESRI's SampleWorldCities service, and I still get the same message. I suspect there is something going on with serverapi.arcgisonline.com. if not, then can someone help me resolve this issue. I have spent two days trying to resolve this and cannot progress on completing my application. I'll really appreciate any help. PLEASE HELP! Thanks Samir
... View more
04-03-2013
12:17 PM
|
0
|
7
|
2705
|
POST
|
i've always found it helpful to debug proxies directly in the browser. if the global mustMatch tag in the proxy.config is set to "false" you should be able to navigate to a page like this directly.. http://[webserver]/proxy/proxy.ashx?http://www.esri.com Hi John, I had some issues with my application which was working fine till last week. In order to find the problem, I was searching this forum and found your post. The issue is that my combobox, which should get populated dynamically when the application loads, is failing in the first attempt. However, refreshing the page helps populate it, but again fails in the next refresh and so on.....I have looked at my code and there doesn't seem to be anything different from last week. As part of solution hunting, I decided to look into proxy page setting. I am using proxy.jsp. When I use the url as suggested by you above, the console log says "500 Internal server error". What could be the issue? I am using Server 10.1 Javascript API 3.2. Thanks for your help in advance Samir
... View more
04-02-2013
08:34 AM
|
0
|
0
|
519
|
POST
|
I have the same issue with my application. It was running fine all this while but this error message start appearing since last week. I have checked my code but cannot find any reason for this to happen. Interestingly, in my case the error message appears at the initial load. My dynamic combobox is not populated and some of my functions such as zoom etc. do not work. Refreshing the app takes care of these issues, but another refresh gives the same error message. So every alternate refresh gives the error message. Also, when this error message appears, my functions run only when I click the relevant button twice. This is quite a general overview as it'll be hard to share my entire code to figure out where the problem lies. If too many people are facing this issue, then maybe ESRI should look into it from there end. Thanks Samir
... View more
04-02-2013
05:12 AM
|
0
|
0
|
1423
|
POST
|
This should be pretty easy. Use a function to actually populate the content of your infoWindow. First, create your infoTemplate: var theTemplate = new esri.InfoTemplate();
theTemplate.setContent(setPopupContent); Next, set up your dojo.connect for clicks on the features in your layer: //Listener event for feature selection and the popup info widow
dojo.connect(theFeatureLayer,"onClick",function(evt){
//Listener event for feature selection and the popup info widow
var query = new esri.tasks.Query();
query.geometry = pointToExtent(map,evt.mapPoint,15);
var deferred = theFeatureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);
map.infoWindow.setFeatures([evt.graphic]);
map.infoWindow.show(evt.mapPoint);
}); Lastly, create the function which will populate your template with the content you want: function setPopupContent(graphic) {
attr = graphic.attributes;
curState = attr.STATE;
content = 'Create your content here';
//If The state clicked is ABC, append the special notation
if (curState == "ABC") {
content = content + "<br/><br/>(estimates based on State average)";
}
return content;
} Steve Thanks Steve, My scenario is a bit different. In my app, the user might select multiple geographies (states) at one time, but the infoWindow content should display differently only for the selected (developer-specified) geography. I tried this code earlier, but this would set the result content for all geographies if the selected geography is part of the subset: for ( j = 0; j < newGeog.length; j++) {
if (newGeog == "A" || newGeog == "B" || newGeog == "C") {
resultContent = "<tr>" + indc + ": <td>${" + indv + ":formatNumber} (State average)</td></tr>";
} else {
resultContent = "<tr>" + indc + ": <td>${" + indv + ":formatNumber}</td></tr>";
}
}
... View more
03-20-2013
07:50 AM
|
0
|
0
|
202
|
POST
|
Hello, In my application, I would like to set infoTemplate so that it can display additional information in the infoWindow (not in the title) based on which feature is clicked e.g. if features in the State 'ABC' are clicked, the info window should show additional text such as "(estimates based on State average)", but should not show this additional text when click on any other feature. How do I accomplish this? Thanks Samir
... View more
03-19-2013
06:57 AM
|
0
|
2
|
544
|
POST
|
Hi, I am using ArcGIS Server 10.1 JavaScript API 3.2. I have a Java code on a remote server which can take JSON array from my application and convert it to an Excel spreadsheet. My application is hosted on Amazon Cloud. Each time I make a call to the remote server using xmlHttp request, it rejects it with the error 404 (not found). I understand it could be a cross domain issue, and we tried putting a header in our Java code such as 'header(�??Access-Control-Allow-Origin: http://myWebAppAddress�?�)' but it did not work. We also tried placing the code in my local server and tried it with local insttall of my app and it failed again. However, if I create a string for the URL for the remote server and place it in the adress bar of my browser, the Java code executes and downloads the excel file on my machine. Javascript console message provides me the request URL as "http://localhost:8080/myApFolderOnTomcat/"http://remoteIP:8080/codeFolderName/exportData.do?jsonText={....}". Is it normal for the request header to have my local host address as well? I'll really appreciate it if someone can help me resolve this. Thanks Samir
... View more
03-08-2013
06:12 AM
|
0
|
1
|
577
|
POST
|
Samir I think what they mean "dynamic layers" as a property of the service. NOTE: this is a property of the ArcGIS REST Services Directory for your MapService Supports Dynamic Layers: true I am not too sure if this is the correct way for you to follow. I just tried implementing what you are trying to do and had no success. However, in my case, the queries ran correctly with no errors but the featureSet was not "ordered by" the field that I indicated. Sometimes it would actually change my result set based on OBJECTID ASC or DESC order (which I had indicted in the orderByFields param) but it NEVER sorted by the field that I indicated. I am not sure if I was implementing it correctly ... but my results were inconclusive. I tried it with both a featureLayer.selectFeatures and an MapService URL via a QueryTask.execute. No luck. Sorry, I wish I could be more of help but I am also stuck here with no way to order my results other than what was suggested by Steve (array.sort). Below is a "watered-down" version of the two different sets of code that I used for testing:
//TEST 1: Use existing featureLayer to perform query
var selectQuery = new esri.tasks.Query();
selectQuery.geometry = geometry;
selectQuery.orderByFields = ["MEASURE ASC"];
pointFeatureLayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW);
//TEST 2: Use QueryTask to query MapServer Layer
var queryTaskOperation = new esri.tasks.QueryTask("http://myserver:6080/arcgis/rest/services/FeatureServices/TestEditngService/MapServer/0");
query.outFields = ["OBJECTID", "REACHCODE", "REACHRESOLUTION", "MEASURE", "EVENTTYPE"];
var query= new esri.tasks.Query();
query.geometry = geometry;
query.orderByFields = ["MEASURE DESC"];
query.returnGeometry = true;
queryTaskOperation.execute(query, function (featureSet) {
alert("total features = " + featureSet.features.length);
//NOTE: I step through the code and can see what the returned featureSet.features array looks like here!
}, function (e) {
alert("Error during query task");
});
Hello, Steve's code actually worked for me. I made minor modifications and the code is below: myFeatureLayer.queryFeatures(query, function(featureSet) {
featureSet.features.sort(function(a, b) {
return a.attributes[myField] - b.attributes[myField]; //ascending order
});
}); Thanks Samir
... View more
03-08-2013
05:39 AM
|
0
|
0
|
871
|
POST
|
Hi, I am trying to add a toggle button to the title of the titlePane. In the attached images, I have placed a form with a toggle button on top of titlePane. This looks good when the pane is closed, but this button loses it's position when the form opens. Is it possible to programmatically place a checkbox or a toggle button on top of the title pane? I am using ArcGIS Server 10.1, Javascript API 3.2 Thanks Samir I found a solution to this issue using dojo's 'placeAt' function. The code is in this post at stackoverflow.com I hope it'll be helpful to others. Thanks Samir
... View more
02-27-2013
09:06 AM
|
0
|
0
|
217
|
POST
|
Hello, I adapted the following sample to put the attribute inspector in the right pane of the page: http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/widget_attributeinspectorpane (When I watched users try to use the attribute inspector in the info window, I noticed they had to pan the map and make adjustments in order to see all of the fields they needed to edit.) Anyway, I'm working with floor plans so before I can enable editing, the user queries a building and the first floor is loaded. The selected floor is used in a definition expression on the feature layer used for editing. The layerInfos and attribute inspector are set up in the initSelectToolbar function. attInspector = new esri.dijit.AttributeInspector({ layerInfos: layerInfos }, "attributesDiv"); <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="title:'Enter/Edit Room'"> <div id="attributesDiv"></div> </div> I get this error in firebug "Tried to register widget with id==attributesDiv but that id is already registered". I've tried using different variations from to put the attribute inspector in a new div inside attributesDiv but they haven't worked. I'm thinking I may not have have the right require statement. Any help would be greatly appreciated. Take care, Kelly Hi Kelly, I have encountered this issue with some other variables I used in my application. I figured that I encountered this problem with my global variables. I suspect your variable 'attInspector' might be a global variable. Also, you might need to 'destroy' this variable after use each time. I hope this is helpful, Samir
... View more
02-27-2013
07:02 AM
|
0
|
0
|
241
|
POST
|
Hi, I am trying to use PrintTask to print map from my web application. It works fine but I have some issues with the legend layer task. I am using ArcGIS Server 10.1 API with Javascript 3.2. The API reference suggests that legendLayer.layerId includes the id of the operational layer in the legend. I wish to have the syblayer ids displayed in the legend but not the layer id. If I do not include layer id in my legendLayer task, the sublayer does not print as well. Additionally, I would like to have some control over the heading of this legend as well as the class intervals. Right now it is showing the abbreviated name and values to the sixth decimal point for the indicator. I would like to replace the heading with the descriptive name of the indicator which should change dynamically when a different indicator is selected. Likewise I would like to round off the class interval values to the second decimal point. Here is the code, and the output map is attached: var legendLayer = new esri.tasks.LegendLayer();
legendLayer.layerId = "stateFeatureLayer";
legendLayer.subLayerIds = [0, 1];
var layoutOptions = {
titleText : "Test Map",
scalebarUnit : "Miles",
legendLayers : [legendLayer]
};
... View more
02-27-2013
05:35 AM
|
0
|
0
|
955
|
POST
|
Have you tried to use jQuery's bind method to raise the map control's resize event? IE8 is very picky in parsing JavaScript code. Try using IE9. If it works in IE9 then you are sure it is not your code but this buggy, useless browser.
... View more
02-26-2013
11:40 AM
|
0
|
0
|
290
|
POST
|
What is it you're trying to match? Do you want a JSON representation of the result featureSet? If so, you can do this: var featureJSON = dojo.toJson(featureSet.toJson()); alert(featureJSON); In your code, the items array is going to contain a list of plain string values...when this gets converted to a string, it will not look much like the original featureSet object data. Thanks Jeff and Mike, Since I needed the output string to be formatted in JSON, Graphic.toJson() or featureSet.toJson() did not apply to my situation for now, but it be of help later. So thanks for your inputs. What worked for me was to convert each item to Json before I combined all those together: Here is the revised code: var queryA = new esri.tasks.Query(); queryA.where = myGeogString; //myGeogString declared earlier and has a multiple query string ("State_name"='xyz' OR "State_name"='abc' .....) queryA.returnGeometry = false; queryA.outFields = ["*"]; var results; queryTask.execute(queryA, function(featureSet) { var attr = [], items = []; for ( i = 0, il = featureSet.features.length; i < il; i++) { var features = featureSet.features; var fattributes = features.attributes; results = []; for (att in fattributes) { for ( k = valueB.length; k > -1; k--) { //length of array of indicators for each feature in myGeogString if (att == valOutB ) { var myInd = dojo.toJson(valueB ); var myAttr = dojo.toJson(fattributes[att]); results.push(myInd + ":" + myAttr); } } } var loc = dojo.toJson(featureSet.features.attributes.State_name); items.push('{"location":'+loc + "," + results+"}"); } var locStr = dojo.toJson("locations"); var itemsJson = "{"+locStr+":["+items+"]}"; alert(itemsJson); });
... View more
02-26-2013
11:36 AM
|
0
|
0
|
495
|
Title | Kudos | Posted |
---|---|---|
1 | 01-30-2013 09:05 AM | |
1 | 04-16-2013 07:00 AM |
Online Status |
Offline
|
Date Last Visited |
07-01-2022
12:12 AM
|