POST
|
Hi Robert, I found a question similar to mine (Executing a series of queries inside a loop) that helped me resolve the problem. For anyone looking at this post in the future, below is basically what worked for me. _requestSucceeded: function(response, io){
var indexLength = response.length;
if(indexLength !== 0){
this.ResultLayer = new GraphicsLayer();
this.map.addLayer(this.ResultLayer);
var queries = [];
for(var i = 0; i < indexLength; i++){
var def = new Deferred();
var accountNum = response[i].AccountNum;
var address = response[i].Address;
this.list.add({
accountNum: accountNum,
address: address
});
var queryString = "AccountNum = " + response[i].AccountNum;
var query = new Query();
var queryTask = new QueryTask("arcgis/rest/services/Dynamic/AccountNumber/MapServer/0");
query.where = queryString;
query.returnGeometry = true;
query.outFields = ["OBJECTID"];
queries.push(queryTask.execute(query, lang.hitch(this, this._onSuccessfulAccNumQuery, symbolColor, include, def, i, indexLength), lang.hitch(this, function(error){
def.resolve({state: 'failure', value: error});
})).then(this.list._addResult(i, indexLength)));
}
all(queries).then(lang.hitch(this, function (){
var resultExtent = [];
for(var i = 0, len = indexLength; i < len; i++){
if(this.list.items[i].graphic){
resultExtent.push(this.list.items[i].graphic);
}
}
var gExt = graphicsUtils.graphicsExtent(resultExtent);
this.map.setExtent(gExt.expand(1.5), true);
}));
} else{
new Message({
titleLabel: "Ratio Query",
message: "No Results were found."
});
}
},
_onSuccessfulAccNumQuery: function(symbolColor, include, def, i, indexLength, results){
var features = results.features;
for(var j = 0, len = features.length; j < len; j++){
var line = Color.fromRgb("rgb(" + symbolColor + ")");
var color = Color.fromRgb("rgb(" + symbolColor + ",0.25)");
var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, line, 2), color);
var graphic = features[j];
graphic.setSymbol(symbol);
graphic.setAttributes({...});
var infoTemplate = new InfoTemplate();
infoTemplate.setTitle("${TITLE}");
infoTemplate.setContent("CONTENT");
graphic.setInfoTemplate(infoTemplate);
this.list.items[i].graphic = graphic;
var graphicItem = this.ResultLayer.add(graphic);
if(include){
graphicItem.show();
} else{
graphicItem.hide();
}
}
def.resolve({state: 'success', value: results});
} Thank you. William
... View more
03-22-2017
08:03 AM
|
0
|
0
|
740
|
POST
|
Hello, I have a query in a loop. I have added .then to the end of the queryTask (see below) to add a graphic for each result upon resolution, but I want to set the extent based on all the results. How do I do this? queryTask.execute(query, lang.hitch(this, this._onQueryResult, symbolColor, include, def, i), lang.hitch(this, function(error){
def.resolve({state: 'failure', value: error});
})).then(this.list._addResults(i)); Any help is greatly appreciated. William
... View more
03-17-2017
08:10 AM
|
0
|
2
|
1515
|
POST
|
Hi 2CDSD 2C, I've attached a theme with the changes I mentioned above. Just add this to your *WAB\client\stemapp\themes folder. Start Web AppBuilder and select eFoldableTheme from the theme panel. This worked for me. William
... View more
03-16-2017
05:52 AM
|
0
|
0
|
1077
|
POST
|
Hi Robert, I had commented out line 7 a while back and had left it that way. Thank you. William
... View more
03-15-2017
09:49 AM
|
0
|
0
|
1388
|
POST
|
Hi Robert, I'm having trouble getting an event to fire when I click my result list. My Widget.HTML for the list is below. <div data-dojo-type="widgets/RatioQuery/List" data-dojo-attach-point="list" data-dojo-attach-event="click:_selectResultItem" class="query-list">
<!--some other divs displaying search criteria, and, when run, dynamically generated result divs-->
</div> My Widget.JS for the click event is below. _selectResultItem: function (){
console.log("CLICKED!");
}, My List.JS for the click event is below. _onClick: function(evt){
console.log("EVT");
console.info(evt);
}, Any idea why nothing is happening/logged? Is this because the div with the data-dojo-attach-event can't be clicked directly, because it's covered by other divs? Thank you. William
... View more
03-15-2017
08:30 AM
|
0
|
2
|
1388
|
POST
|
2CDSD 2C, If you want the scale to be in all new applications that you create from now on, refer to this folder path: *WAB\client\stemapp\themes\FoldableTheme\widgets\HeaderController\
*WAB = the location of your WAB installation If you want the scale to be in a specific application that you created, refer to this folder path: *WAB\server\apps\#\themes\FoldableTheme\widgets\HeaderController\
# = the number given to the application by WAB In Widget.JS, add the following code to the startup function (lines 5-20 below). startup: function() {
this.inherited(arguments);
//start of addition for scale
var MyMap = this.map;
var MyScaleWindow = this.scaleInfo.innerHTML;
var MyScaleTest = this.scaleInfo;
var scale = esri.geometry.getScale(MyMap);
var myNumber = dojoNumber.format(scale, {
places: 0
});
htmlSet.set(MyScaleTest, "Scale: 1:" + myNumber);
this.map.on("extent-change", getmyscale);
function getmyscale() {
var scale = esri.geometry.getScale(MyMap);
var myNumber = dojoNumber.format(scale, {
places: 0
});
htmlSet.set(MyScaleTest, "Scale: 1:" + myNumber);
};
//end of addition for scale
this.resize();
// this.timeoutHandle = setTimeout(lang.hitch(this, this.resize), 100);
}, In Widget.HTML, add line 11 below. <div>
<!-- solve the bug of style delay loading -->
<div class="header-section jimu-float-leading" data-dojo-attach-point="headerNode">
<img class="logo jimu-float-leading jimu-leading-margin1" data-dojo-attach-point="logoNode" data-dojo-attach-event="onload:_onLogoLoad">
<div class="titles jimu-float-leading jimu-leading-margin1" data-dojo-attach-point="titlesNode">
<div class="jimu-title jimu-float-leading" data-dojo-attach-point="titleNode"></div>
<div class="jimu-subtitle jimu-float-leading jimu-leading-margin5" data-dojo-attach-point="subtitleNode"></div>
</div>
<!--start of addition for scale-->
<div data-dojo-attach-point="scaleInfo" class="coordinate-scale jimu-float-leading" id="addedForScale"></div>
<!--end of addition for scale-->
<div class="links jimu-float-leading jimu-leading-margin25" data-dojo-attach-point="linksNode">
<div class="dynamic-section jimu-float-leading" data-dojo-attach-point="dynamicLinksNode"></div>
<div class="signin-section jimu-float-leading" data-dojo-attach-point="signInSectionNode">
<a href="#" class="jimu-link" data-dojo-attach-event="onclick:_onSigninClick"
data-dojo-attach-point="signinLinkNode">${nls.signin}</a>
<a href="" target="_blank" class="jimu-link" data-dojo-attach-event="onclick:_onUserNameClick" data-dojo-attach-point="userNameLinkNode"></a>
<a href="#" class="jimu-link" data-dojo-attach-event="onclick:_onSignoutClick" data-dojo-attach-point="signoutLinkNode">${nls.signout}</a>
</div>
</div>
</div>
<div class="container-section jimu-float-leading" data-dojo-attach-point="containerNode"></div>
</div> To style the scale, go to the css\style.css file and add something like this at the end. /*added for scale*/
#addedForScale {
display: inline;
line-height: 40px;
width: 130px;
overflow: hidden;
font-size: 14px;
color: #fff;
background-color: rgb(90,102,117);/*for ie8*/
background-color: rgba(90,102,117,0.5);
}
@media screen and (max-width:500px){
#addedForScale{
display: none;
}
} NOTE: This is for adding the scale to the Foldable Theme. Hope this helps. William P.S. A name is a whole lot easier to type than 2CDSD C2. Just saying...
... View more
03-14-2017
02:30 PM
|
2
|
2
|
1077
|
POST
|
Hi Robert, I've created a graphics layer, added the REST results to graphics and added the graphics to the graphic layer. Would I use another QueryTask for the onClick event of the widget's list items to find the graphic by ObjectID? William
... View more
03-14-2017
10:59 AM
|
0
|
4
|
1388
|
POST
|
Hello, I'm working on a widget that takes user input, such as school district, sale date range, sale price range, etc., and uses esriRequest to pass those values to a non-ArcGIS rest service. The rest service puts the request in SQL format, queries a non-ArcGIS database and returns information, such as account number, address, sale date, sale price, buyer, seller, square footage, etc., on the parcels that match the user's parameters. A queryTask is performed to add a featureSet of the graphic to each result. Then a list of results are displayed in the widget and graphics are added to the Graphics Layer. Now I need the results in the list to link to the corresponding graphic so when it's click, the map zooms to the result on the map and displays its infoTemplate. How do I go about doing this? Should I add the graphics to a new layer? If so, would it be a FeatureLayer and how would I create it? I saw that FeatureLayers can be created from a featureCollection, but how do I create the layerDefinition and featureSet that are needed to create the featureCollection? Any help is greatly appreciated. Thank you. William
... View more
03-09-2017
12:44 PM
|
0
|
6
|
2097
|
POST
|
Hi Robert, In your code above, should def (line 16) be passed to onQueryResult also? William
... View more
03-07-2017
11:28 AM
|
0
|
1
|
1145
|
POST
|
Hi Robert, How do I force the code to wait for the deferred to resolve? On the QueryTask's API page, under Event Details, I see complete (onComplete) that looks promising, but I can't find an example of it used in code. William
... View more
03-07-2017
09:19 AM
|
0
|
3
|
1145
|
POST
|
Hi Robert, I used your code and it worked, sort of. It seems the color value of the last parcel is applied to all the parcels. William
... View more
03-07-2017
07:57 AM
|
0
|
5
|
1145
|
POST
|
Hi Robert, I added the following line var color = new Color.fromArray(symbolColor); and changed var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([symbolColor]), 2), new Color([symbolColor,0.25])); to var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, color, 2), color); The graphics still look black, but now it looks like all the console.info lines are showing a: 1, b: 5, g:5 , r: 2 for the color values. I think it has something to do with the deferred, because all the console.log(symbolColor) from line 9 display in the console and then all the console.info(symbol) from line 22. Also, there is the reference error about graphic not being defined when line 33 is uncommented. William
... View more
03-06-2017
02:02 PM
|
0
|
7
|
1145
|
POST
|
Hi Robert, The value of console.log(symbolColor) varies by accountNum, but some examples are in the screenshot below. William
... View more
03-06-2017
01:01 PM
|
0
|
9
|
1145
|
POST
|
Hi Robert, I'm trying to get the graphic for each parcel returned from the rest service set to a variable, pass that variable as part of an object and add the graphic to the map, however I seem to be missing something, most likely related to dojo/Deferred. The code below seems to work, but if I uncomment line 33, I get "Reference Error: graphic is not defined". If I comment out line 20 and uncomment line 21, all the parcels are black, and the symbolColor, while correct in the console.log(line 9), has NaN for the RGB values in the console.info(line 22). _requestSucceeded: function(response){
for(var i = 0, len = response.length; i < len; i++){
var accountNum = response[i].AccountNum;
var include = response[i].Include;
var symbolColor = response[i].SymbolColor;
var def = new Deferred();
console.log(symbolColor);
//Get information on the shape of each parcel from the AccountNum
var queryString = "AccountNum = " + response[i].AccountNum;
var query = new Query();
var queryTask = new QueryTask("arcgis/rest/services/Dynamic/AccountNumber/MapServer/0");
query.where = queryString;
query.returnGeometry = true;
queryTask.execute(query, lang.hitch(this, function(results){
var features = results.features;
for(var i = 0, len = features.length; i < len; i++){
var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,0,0]), 2), new Color([255,255,0,0.25]));
//var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([symbolColor]), 2), new Color([symbolColor,0.25]));
console.info(symbol);
var graphic = features[i];
graphic.setSymbol(symbol);
this.map.graphics.add(graphic);
}
def.resolve({state: 'success', value: results});
}), lang.hitch(this, function(error){
def.resolve({state: 'failure', value: error});
}));
this.list.add({
//graphic: graphic,
accountNum: accountNum,
include: include,
symbolColor: symbolColor
});
}
} William
... View more
03-06-2017
12:10 PM
|
0
|
11
|
1915
|
POST
|
Hi Robert, From my widget, I use esriRequest to pass user specified input (say a school district, a sale date range and a sale price range) to the my rest service. The rest service puts the request in SQL format, queries the database and returns information on the parcels that match, such as account number, address, sale date, sale price, seller, buyer, square footage, etc. I'm not sure how to query an ArcGIS rest service directly from my rest service to get the geometry or spatial references to link the database data to the map. William
... View more
03-03-2017
12:08 PM
|
0
|
13
|
1915
|
Title | Kudos | Posted |
---|---|---|
1 | 12-28-2016 08:09 AM | |
1 | 11-28-2016 08:34 AM | |
1 | 11-28-2016 08:39 AM | |
1 | 12-07-2016 06:14 AM | |
1 | 12-08-2016 08:44 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|