|
POST
|
Yes, for comparison, this is what a successful one looks like:
... View more
04-02-2019
12:17 PM
|
0
|
5
|
1634
|
|
POST
|
That gives me the same detail page as above: Not sure if you saw my edit to my last post. The request URL for 2008 data is quite different than other years.
... View more
04-02-2019
12:09 PM
|
0
|
7
|
1634
|
|
POST
|
It gives me this 30 times in the console (I think if you click on them you can make them bigger?): From the network tab: When I double click the red line in the network tab: If the "query string is too long" is referring to the MgmtTractID query I make, then that's really weird because 2008 has the least amount of IDs to query. Other years have upwards of 200. This one only has 29. Edit: Actually, the requested URL here is much longer than the others, so it does have to do with it being quite long. The other successful queries just make a request to the MapServer url:
... View more
04-02-2019
11:57 AM
|
0
|
9
|
3506
|
|
POST
|
Just noticed in my console that I get 404 Not Found errors when I try to query for 2008 data, don't receive that for any of the other years. I use a proxy to access my data, haven't the slightest why it'd only be one year that it can't query. I'll keep working on it, report back if I figure it out. Thanks for your help.
... View more
04-02-2019
11:43 AM
|
0
|
11
|
3506
|
|
POST
|
I understand. It's just odd because it generates the statement and when I try it in Desktop it works. I can't see anything wrong with this: MgmtTractID IN(
'{B1CE758E-4CA2-469E-9933-8746DFACA3EF}',
'{A37D1BE3-005A-4D2C-AE76-6B30E98AF981}',
'{BBA93CA8-08F0-4DF5-9EFE-6F4EDF5664D2}',
'{75CC656A-BDBC-4BFA-A6A0-1B1BA62DE105}',
'{88E58225-D2A1-4E35-8E79-9EE5B17A94A3}',
'{CD2B81CA-1FF3-4930-932C-1E88F1AF1C9D}',
'{5483E110-E6E2-46BE-98E5-3BE2ED0F60BF}',
'{BE01BA5D-C604-494B-BCB6-4160AB5474E1}',
'{0FA279E3-38E1-4BAC-910B-6991066B97D3}',
'{A6D44511-C057-42D8-8096-B7A84D80BE82}',
'{9B8F4664-0E2D-452B-AE2D-34768A0BFC0B}',
'{75E9C08C-3E14-4344-B35A-57CCF41D1497}',
'{7EEED5DC-3C1E-49DA-AE89-445E35D3BA7A}',
'{1A52D3FA-FE09-4996-8F0D-4FA6EB68F121}',
'{CD343F57-A2DF-43D8-8616-872CF8514E16}',
'{F4E855C9-0A45-4B0E-A5D8-4C02178733B7}',
'{4814C6C4-C583-4F8E-81FA-122FBA807EFE}',
'{0ECFC833-928C-4B9C-96F0-F75F31FCD7B9}',
'{305D7D13-8CEF-4253-A7AC-B418852FA37C}',
'{3249A913-299E-43FF-82F2-EA76DF8C7FD0}',
'{22432A46-E938-49DF-B1AA-E52347DA5BAF}',
'{907B11E8-77E1-4C65-B6B4-A41F0DD9B44E}',
'{801E7790-5715-44F8-9F26-97BCA0FCF0AD}',
'{C90E76A7-F195-4B6C-ADF0-50D7BCB8BB9E}',
'{0A00ACB3-5759-40CF-AD90-739406DFD4C5}',
'{35D8BDC1-EF20-4185-86B1-3C6DB6F08412}',
'{95E3803D-8797-47A5-BB68-D69A45711B1C}',
'{7556D941-DF86-464E-B9F6-1194241479EB}',
'{DC3B0C72-4FB7-4042-81F4-297F6F254330}'
)
... View more
04-02-2019
11:28 AM
|
0
|
13
|
3506
|
|
POST
|
I have tried it in Desktop and it works as expected. Thanks for the tip on the "IN" - I did that and 2015 and 2016 data started showing up. Still doesn't show 2008 data though...
... View more
04-02-2019
10:53 AM
|
0
|
15
|
3506
|
|
POST
|
I create a definition expression on a featureLayer through it's relationship with table. The definition expression gets applied to the table first, then the definition expression for the featureLayer is created and applied. The definition expression is pulling records of a certain year in the table, then through it's relationship with the featureLayer I get GUIDs of those that match the pulled records in the table and set the featureLayer's definition expression based on those GUIDs. The problem is that for some years this works and for others it doesn't. I can see in the debugger that the definition expression gets created correctly for the featureLayer, but when I apply it to the featureLayer, nothing displays on the map. If I switch the year to another year, the definition expression gets applied and the appropriate polygons appear for that year. If I switch back to the previous year, again, no polygons are displayed, even though they exist for that year. It's pretty odd behavior and I'm not sure why this would be happening. Records in the table when the definition expression is set to YearTreated = 2015. Records in the related feature layer that match these MgmtTractIDs My code should produce a definition expression like this for application to the featureLayer: var de = "MgmtTractID = '{...}' OR MgmtTractID = '{...}' OR MgmtTractID = '{...}' ..so on and so forth Apply that definition expression to the feature layer and I get nothing displayed on the map. This definition expression works for 2009, 2010, 2011, 2012, 2013, 2014, 2017, 2018, and 2019. It doesn't work for 2008, 2015, or 2016. I have checked and rechecked that the DE is being created correctly with formatting and that the MgmtTractIDs do indeed show up in the related feature layer. Everything looks fine. on(dom.byId("data-year"), "change", function () {
var year = dom.byId("data-year").value;
//Defintion expressions are already set upon first load of the map, don't need to recalculate
//if the year hasn't been changed. A change event is fired on load of the map.
if (year !== currentYear) {
hbMgmtTableFL.setDefinitionExpression('YearTreated = ' + year);
hbMgmtTableFL.refresh();
//The habitat management feature layer needs to be filtered using the related table.
getTractDefExpression();
}
});
function getTractDefExpression() {
var recordIDs = new Query();
recordIDs.where = "1=1";
hbMgmtTableFL.queryIds(query, function (OIDs) {
if (OIDs !== null) {
//Create relationship query
var relatedRecordsQuery = new RelationshipQuery();
relatedRecordsQuery.objectIds = OIDs;
relatedRecordsQuery.outFields = ["MgmtTractID"];
relatedRecordsQuery.relationshipId = 0;
hbMgmtTableFL.queryRelatedFeatures(relatedRecordsQuery, function (fset) {
//Get all MgmtTractIDs for the current year from the table
//The table already has it's definition expression set, so it'll
//only pull the MgmtTractIDs for the year that is set
var MgmtTractIDsArr = [];
for (i = 0; i < OIDs.length; i++) {
var OID = OIDs[i];
var features = fset[OID].features;
var mgmtTractId = features[0].attributes.MgmtTractID;
if (!(MgmtTractIDsArr.includes(mgmtTractId))) {
MgmtTractIDsArr.push(mgmtTractId);
};
}
//Create the definition expression for the feature layer
var whereClause;
for (i = 0; i < MgmtTractIDsArr.length; i++) {
if (i == 0) {
whereClause = "MgmtTractID = '" + MgmtTractIDsArr[i] + "'";
}
else {
whereClause = whereClause + " OR MgmtTractID = '" + MgmtTractIDsArr[i] + "'";
}
}
//Set the polygon feature layer's definition expression based on the GUIDs
debugger;
hbMgmtTractFL.setDefinitionExpression(whereClause);
hbMgmtTractFL.refresh();
});
}
else {
debugger;
hbMgmtTractFL.setDefinitionExpression('MgmtTractID = 0');
hbMgmtTractFL.refresh();
}
});
};
... View more
04-02-2019
09:34 AM
|
0
|
17
|
5492
|
|
POST
|
Not sure if you get the notification of a reply or not since I replied to the other person, sorry! See the above code for what I ended up doing. Though I'm not using Pro.
... View more
04-02-2019
06:54 AM
|
1
|
0
|
6063
|
|
POST
|
When I was trying this, ArcGIS Javascript API wasn't supporting the file upload function yet, which was why it didn't work. I had to switch back to 3.x to proceed with the functionality I needed. I don't know if 4.x has been updated or not yet to include a file upload function, so the below code is 3.x code. Regardless, this is the code I ended up with. The key is that you assign the itemID to a DataFile object and pass the DataFile object as a parameter to the service. Then get your parameter in python and it will recognize it as a file instead of a nonsensical itemID: Python code for getting the file and unzipping it. I did not have to do anything with the itemID in here, after assigning the itemID to a DataFile object in JS, it comes in as a zip file instead of an itemID: #Get the uploaded zip file
uploadedZip = arcpy.GetParameterAsText(0)
#Unzip the file into the scratch folder
try:
zip_ref = zipfile.ZipFile(uploadedZip, 'r')
zip_ref.extractall(scratchFolder)
zip_ref.close()
arcpy.AddMessage("Successfully extracted zip file...")
#Get the path to the unzipped geodatabase file
for file in os.listdir(scratchFolder):
if file.endswith(".gdb") and file != "scratch.gdb":
uploadedGDB = os.path.join(scratchFolder, file)
try:
#Get the feature class out of the user uploaded geodatabase. Make sure it exists and the user did not alter
#the name.
fcName = "{0}_MgmtTracts_Template".format(stateID)
mgmtTractFC = os.path.join(uploadedGDB, fcName) JS passing itemID as parameter: mgmtGP = new Geoprocessor("https://www.stuff.com/myServer/rest/services/HabitatManagement/HabitatManagement/GPServer/HabitatManagement");
function mgmtUpload() {
//I did a bunch of form validation here in if/else statements. Took it out for ease of reading
else {
//upload the zip file and get back the itemID (via uploadSucceeded)
var upload = esri.request({
url: "https://www.stuff.com/myServer/rest/services/HabitatManagement/HabitatManagement/GPServer/uploads/upload",
form: dojo.byId("mgmtUploadForm"),
content: { f: 'json' },
handleAs: 'json',
}).then(mgmtUploadSucceeded, mgmtUploadFailed);
}
}
function mgmtUploadSucceeded(response) {
//After you upload your file, you have to index into your response object
//using "item" and grab the itemID from the itemID property
var itemID = response["item"].itemID;
//Create the DataFile object you will assign your itemID to
var dataFile = new esri.tasks.DataFile();
//The itemID points to the zip file, which is why I assign it the dataFile object
dataFile.itemID = itemID;
//The Input_Zip_File parameter is assigned the dataFile object which is really the itemID
var params = { "Input_Zip_File": dataFile };
console.log('Input parameters: ' + dojo.toJson(params));
mgmtGP.submitJob(params, gpJobComplete, gpJobStatus, function (error) {
console.error('[(jobStatus: ' + gpError.jobStatus + ') (jobId: ' + gpError.jobId + ') ' + '(messages: ' + gpError.messages + ')]');
}).then(function (promiseResult) {
//Re-enable submit mgmt data habitat button
$("#mgmt").button('enable').removeClass('ui-state-disabled');
});
}
... View more
04-02-2019
06:52 AM
|
2
|
0
|
6063
|
|
POST
|
Thank you Robert, that finally got me where I needed to be. You've answered countless questions from me on this community, I do sincerely appreciate your patience! If you wouldn't mind explaining more, how could my popup not be the actual map.infoWindow when I define it before I instantiate my map? Just trying to understand this better. //Replace infoWindow with Popup object
var popup = new Popup({
fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25])),
}, domConstruct.create("div"));
//Instantiate the map
map = new Map("map", {
basemap: "hybrid",
center: [-85.603281, 36.241294],
zoom: 6,
infoWindow: popup
}); The other question I have (sorry, I'm full of questions); is there anyway to avoid running the select-change event twice when you click on features that overlap? If I click where the green dot is, the selection-change event runs through twice, once for each feature, I assume because both features technically get selected, even though it only highlights one. The last feature that runs through the selection-change event is the one that gets highlighted, so the content in the popup shows as I would expect it to. Unfortunately, there isn't a .getSelectedFeatures() method that would return an array of selected features, so I don't think I can get just the one considered "on top" by using indexes. Not a huge deal as everything works fine, just wondering if I can avoid unnecessary processing somehow. This ended up being the final code for the popup select-change event. popup.on("selection-change", function () {
var feature = popup.getSelectedFeature();
if (feature != undefined && feature._graphicsLayer.name == "MgmtTracts") {
var OID = feature.attributes.OBJECTID;
relatedTractAttrb(OID);
}
});
... View more
03-22-2019
11:44 AM
|
0
|
1
|
4402
|
|
POST
|
Edit: we were writing at the same time. Will read your response...... Now I've read it. That was my thought too, on a select-change event I should be able to see what layers are coming through. I can't access the features to determine the layer on a select-change event though, see below in my response. Does anything get returned by "selection-change"? Does not appear that it returns features or graphics. I also can't seem to access popup object properties, which I don't quite understand. For example, if I click on a feature in the map and look at the popup object in the console, I can see it has a features property (just as it is noted in the documentation). If I try to access the features property doing something like so: var features = popup.features;
console.log(features); I just get "undefined." If I try to access the count property where I can see the popup has a count of 3 features, the count comes back as 0. console.log(popup) //The count property displays "3"
var count = popup.count
console.log(count) //The count displays "0" If I try to access the isShowing property of the popup, I get false even though the popup is displaying on the map. var visible = popup.isShowing
console.log(visible); The only way I can do anything on a selection-change event is if I can access those features... there's also a million other issues such as my hbMgmtTractFL not even being recognized as a layer on the map by the popup object unless the InfoTemplate is set. If the infoTemplate is set, then the features in that FL actually highlight, if it isn't only the background feature highlights (which is also a featureLayer with an infoTemplate set). A popup set-features event also is not accessible for determining layers, just tried it.
... View more
03-22-2019
10:09 AM
|
0
|
3
|
4402
|
|
POST
|
That is helpful, thank you. I have other feature layers that use InfoTemplates; they are truly being formatted with stuff in curly brackets so I think those I do need to define, unlike the one seen above. So, to use the select-change event and setFeatures() I need to create a Popup object. BUT, I still need to use a click event to be able to differentiate between layers. The only layer that uses a click event is the layer seen above to bring up the popup since the content has to be calculated every time due to the related feature query. The others are InfoTemplates and nothing needs to be calculated, they are pre-defined before the layer is added to the map. So when I click on features in the layer where they overlap, only one feature is retrieved; whatever the map designates as the one on "top." hbMgmtTractFL.on("click", function(feature {}); I guess my problem is that I don't understand how to use setFeatures(). If I set the features on the popup, I think it would only be setting the single feature that is on top when the overlapping features are clicked. hbMgmtTractFL.on("click", function(feature) {
myPopup.setFeatures(feature.graphic);
var OID = feature.graphic.attributes.OBJECTID;
//call function to calculate content and do call map.infoWindow.setContent()
}); This code currently makes the InfoWindow/Popup flash when I click the overlapping features. It also highlights all the geometry associated with the event point, when I just want it to highlight one feature at a time. I have not yet attempted to implement select-change because I'm not sure where I would call it. //Replace infoWindow with popup
var popup = new Popup({
fillSymbol = selectionSym
}, domConstruct.create("div"));
map = new Map("map", {
basemap: "hybrid",
center: [-85.603281, 36.241294],
zoom: 6,
infoWindow: popup
});
//Add the habitat management tract feature layer
var hbMgmtTractFL = new FeatureLayer("https://xxx/rest/services/HabitatMonitoring/HabitatData/MapServer/3", {
refreshInterval: 10,
mode: FeatureLayer.MODE_ONDEMAND,
visible: false,
outFields: ["*"]
});
hbMgmtTractFL.setMinScale(500000);
hbMgmtTractFL.setSelectionSymbol(selectionSym);
//Format mgmtTract popup content on click of a feature
hbMgmtTractFL.on("click", function (feature) {
//Does setFeatures() go here somewhere?
//popup.setFeatures(feature.graphic) <-- Only one feature though.
var OID = feature.graphic.attributes.OBJECTID;
relatedTractAttrb(OID);
});
function relatedTractAttrb(oids) {
var relate = new RelationshipQuery();
relate.objectIds = [oids];
relate.relationshipId = 0;
relate.outFields = ['*'];
hbMgmtTractFL.queryRelatedFeatures(relate, function (fset) {
//do stuff to create content
map.infoWindow.setTitle("Habitat Management Tract " + oids[0]);
map.infoWindow.setContent(content);
});
} It works for the features with InfoTemplates defined perfectly. It's just the hbMgmtTractFL feature layer that I can't figure out, and I know it has something to do with that fact that the template is set in the click function... Clicking on other feature layers with InfoTemplates (view in My Videos) :
... View more
03-21-2019
09:30 AM
|
0
|
1
|
4402
|
|
POST
|
What is the difference between these three? Do you have to define a popup object before you define a popup template? My understanding is that the popup template is the same as an info template, the only difference is that the popupTemplate lets you use graphs/pictures and do extra formatting. I think when I define a feature layer and it's properties, I can use a popupTemplate for the infoTemplate property, correct? Is myPopupTemplate.setContent() the same method as myInfoTemplate.setContent()? I create all the content for the popup dynamically, so I can't use fieldInfos or anything like that in the PopupTemplate. This is also why I can't use a "click" function on a feature that brings up the InfoTemplate, because if there are overlapping features (on the same feature layer) and a user uses the arrows on the popup, the click function won't fire again, thus the InfoTemplate does not update. This leaves me with a select-change event on a Popup object (if the select-change event does not fire when the arrows are used, then this whole question is moot and there is no solution to using arrows which would be dumb)...but I don't understand how that correlates with PopupTemplate/InfoTemplate/InfoWindow. Popup objects have their own setContent method. Do I not need a PopupTemplate or an InfoTemplate and instead just set the content and title using the Popup object's own methods? This is my current code using an InfoTemplate. Note that the content for the InfoTemplate is fired on click of a feature and arrows on the popup do not act as a click. It would be great if there was a solution to the arrow problem while still using InfoTemplates so then I wouldn't have to mess with popup/popupTemplate. var mgmtTractPopupBox = new InfoTemplate();
//Add the habitat management tract feature layer
var hbMgmtTractFL = new FeatureLayer("https://xxx/rest/services/HabitatMonitoring/HabitatData/MapServer/3", {
refreshInterval: 10,
mode: FeatureLayer.MODE_ONDEMAND,
visible: false,
outFields: ["*"],
infoTemplate: mgmtTractPopupBox
});
hbMgmtTractFL.setMinScale(500000);
hbMgmtTractFL.setSelectionSymbol(selectionSym);
//Format mgmtTract popup content on click of a feature
hbMgmtTractFL.on("click", function (feature) {
var OID = feature.graphic.attributes.OBJECTID;
relatedTractAttrb(OID);
});
function relatedTractAttrb(oids) {
var relate = new RelationshipQuery();
relate.objectIds = [oids];
relate.relationshipId = 0;
relate.outFields = ['*'];
hbMgmtTractFL.queryRelatedFeatures(relate, function (fset) {
var features = fset[oids].features;
var rows = ['<table id="mgmtPopupTable1"><tr><th>Veg Practice</th><th>Herbicide</th><th>Month Treated</th>\
<th>Year Treated</th><th>Implemented By</th><th>Funded By</th><th>Farm Bill Code</th></tr>'];
for (i = 0; i < features.length; i++) {
var feature = features[i]
var vegPractice = vegPName(feature.attributes.VegMgmtPractice);
var herbicide = herbName(feature.attributes.Herbicide);
var monthTreated = monthName(feature.attributes.MonthTreated);
var yearTreated = feature.attributes.YearTreated;
var impBy = impName(feature.attributes.ImplementedBy);
var fundBy = fundName(feature.attributes.FundedBy);
var fbc = feature.attributes.FarmBillCode;
if (fundBy == "CRP" || fundBy == "CRP - CREP") {
fbc = crpName(fbc);
}
else if (fundBy == "EQIP" || fundBy == "EQIP - RCPP") {
fbc = eqipName(fbc);
}
else {
fbc = "Not applicable";
}
var contentRow = '<tr><td>' + vegPractice + '</td><td>' + herbicide + '</td><td>' + monthTreated + '</td><td>' + yearTreated +
'</td><td>' + impBy + '</td><td>' + fundBy + '</td><td>' + fbc + '</td></tr>';
rows.push(contentRow);
}
content = rows.join("");
content = content + '</table>';
mgmtTractPopupBox.setTitle("Habitat Management Tract ${OBJECTID}");
mgmtTractPopupBox.setContent(content);
});
} The documentation on all three of these things is incredibly confusing and I wish ESRI would clean it up
... View more
03-21-2019
06:42 AM
|
1
|
7
|
4895
|
|
POST
|
I have a InfoTemplate that sets content based on the click of a feature. When people switch through features using the arrows on the popup, the function that sets the content does not fire. I imagine the arrows do not count as a click event, how do I handle this? There are three features that overlap each other, two of them are in the same feature class, one of them is a different feature class. Switching with the arrows between the two feature classes show the appropriate popups for each, but the feature layer with the two features selected uses the same information in both popups as the content is set based on a click. If I click either of these features independently where they do not overlap, their content sets correctly. hbMgmtTractFL.on("click", function (feature) {
var OID = feature.graphic.attributes.OBJECTID;
relatedTractAttrb('popupContent', OID);
});
function relatedTractAttrb(purpose, oids) {
//set all the content
} I have looked at the documentation and I don't see a clear event for switching between features with the arrows. I thought it was supposed to act as a click event, but I suppose not?
... View more
03-20-2019
08:23 AM
|
0
|
0
|
754
|
|
POST
|
Figured it out... dumb SQL mistake, using the javascript operator of "or" instead of the SQL operator of "or" in my definition expression. Final code that's FINALLY working. With the records that come out of the initial query task (on hbMgmtTableFL), I should be able to set the popup with those values for each polygon that is visible on the map. I'll have to format the popup on click of a feature with another ".queryRelatedFeatures(...)" call. //After adding the layers to the map get the initial definition expression of the tract feature layer
map.on("layers-add-result", function () {
getDefinitionExpression();
});
function getDefinitionExpression() {
var recordIDs = new Query();
recordIDs.where = "1=1";
hbMgmtTableFL.queryIds(query, function (OIDs) {
//Create relationship query
var relatedRecordsQuery = new RelationshipQuery();
relatedRecordsQuery.objectIds = OIDs;
relatedRecordsQuery.outFields = ["MgmtTractID"];
relatedRecordsQuery.relationshipId = 0;
hbMgmtTableFL.queryRelatedFeatures(relatedRecordsQuery, function (fset) {
//Get all MgmtTractIDs for the current year
var MgmtTractIDsArr = [];
for (i = 0; i < OIDs.length; i++) {
var OID = OIDs[i];
var feature = fset[OID].features;
var mgmtTractId = feature[0].attributes.MgmtTractID;
if (!(MgmtTractIDsArr.includes(mgmtTractId))) {
MgmtTractIDsArr.push(mgmtTractId);
};
}
//Create the definition expression
var whereClause;
for (i = 0; i < MgmtTractIDsArr.length; i++) {
if (i == 0) {
whereClause = "MgmtTractID = '" + MgmtTractIDsArr[i] + "'";
}
else {
whereClause = whereClause + " OR MgmtTractID = '" + MgmtTractIDsArr[i] + "'";
}
}
//Set the polygon feature layer's definition expression based on the GUIDs
hbMgmtTractFL.setDefinitionExpression(whereClause);
hbMgmtTractFL.refresh();
});
});
};
... View more
03-01-2019
10:23 AM
|
0
|
0
|
5749
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-18-2020 10:31 AM | |
| 2 | 09-16-2025 02:17 PM | |
| 3 | 09-12-2025 09:26 AM | |
| 1 | 08-16-2023 05:11 PM | |
| 1 | 02-27-2024 06:48 AM |
| Online Status |
Offline
|
| Date Last Visited |
09-16-2025
02:16 PM
|