POST
|
Perfect! I was under the impression that it need to be added to the map in order to perform the query, etc. Thank you again!
... View more
01-15-2020
09:11 AM
|
0
|
2
|
1078
|
POST
|
Hi Robert Scheitlin, GISP - Thank you so much for the help! I can't believe I couldn't figure this out. Out of curiosity, is there a way to hide the feature layer so that the graphic is the only feature you see on the map? Some of the features are layered on top of one another so I don't want it to look like a mess.
... View more
01-15-2020
09:06 AM
|
0
|
4
|
1078
|
POST
|
I have some code that queries a feature layer by passing an ID in the URL, zooms to that feature and only displays that feature on a map. ( Modified from Select Parcel by URL Parameters ). I would like to update this from the current working copy I have in the 3.31 version of the API to the latest 4.14 API. I have been able to get most of the functionality working in 4.14 except being able to only display the feature from the query result on the map. Below is what I have currently working where it zooms to the feature based on the ID in the URL and then the bottom section is the code block from 3.31 that I am having trouble revising. 4.14/ <html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>Treatment Tracker</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.14/esri/themes/light/main.css">
<style>
html, body, #viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<!-- START ESRI MAP SCRIPT -->
<script src="https://js.arcgis.com/4.14/"></script>
<script>
var OID;
require([
"esri/Map",
"esri/views/MapView",
"esri/geometry/SpatialReference",
"esri/layers/MapImageLayer",
"esri/layers/FeatureLayer",
"esri/views/layers/FeatureLayerView",
"esri/layers/support/ImageParameters",
"esri/layers/support/LabelClass",
"esri/layers/GraphicsLayer",
"esri/Graphic",
"esri/geometry/geometryEngine",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleMarkerSymbol",
"esri/renderers/SimpleRenderer",
"esri/tasks/support/Query",
"esri/tasks/QueryTask",
"esri/tasks/support/FeatureSet",
"esri/core/urlUtils",
"esri/widgets/Expand",
"esri/PopupTemplate",
"dojo/domReady!"
], function(
Map,
MapView,
SpatialReference,
MapImageLayer,
FeatureLayer,
FeatureLayerView,
ImageParameters,
LabelClass,
GraphicsLayer,
Graphic,
geometryEngine,
SimpleFillSymbol,
SimpleLineSymbol,
SimpleMarkerSymbol,
SimpleRenderer,
Query,
QueryTask,
FeatureSet,
urlUtils,
Expand,
PopupTemplate
){
// START OF ESRI WEBMAP CREATION
//create labels for wetlands layer
const wetlandlabelclass = new LabelClass({
labelExpressionInfo: { expression: "$feature.WETLAND_TYPE" },
symbol: {
type: "text", // autocasts as new TextSymbol()
color: "black",
haloSize: 1,
haloColor: "white"
}
});
// create the map
var map = new Map({
basemap: "topo-vector"
});
// create the mapview
var view = new MapView({
container: "viewDiv",
map: map,
//center: [-86.424759,43.932883],
zoom: 14
});
//add National Wetlands Inventory Feature Layer
var wetlands = new FeatureLayer({
url: "[...]/hydro/MapServer/18",
labelingInfo: [wetlandlabelclass]
});
map.add(wetlands);
//add Treatments Feature Layer (for some reason it cannot be added as a MapImageLayer which is the 4.x version of ArcGISDynamicMapServiceLayer)
var aqtreatments = new FeatureLayer({
url: "[...]/MapServer/2"
});
map.add(aqtreatments);
// Create graphics layer and symbol to use for displaying the results of query
var resultsLayer = new GraphicsLayer();
map.add(resultsLayer);
//build query task
var queryTask = new QueryTask({
url: "[...]/MapServer/2"
});
//build query filter
var query = new Query();
query.returnGeometry = true;
query.outSpatialReference = view.spatialReference; //added for testing
query.outFields = ["*"];
//pass the url parameters.
var urlObject = urlUtils.urlToObject(window.location.href);
if (urlObject.query)
{
if (urlObject.query.id)
{ OID = urlObject.query.id; }
//set query based on the parameters
var treatmentid = "OBJECTID = '" + OID + "'";
query.where = treatmentid;
}
// execute query
queryTask.execute(query).then(zoomparcel);
//Zoom to the extent of the graphics
function zoomparcel(result){
var AOI = result.features;
view.goTo(AOI);
}
//END
});
</script>
</head>
<!-- START OF PAGE LAYOUT -->
<body>
<div id="viewDiv"></div>
</body>
<!-- END OF PAGE LAYOUT -->
</html>
3.31/ //Execute task and call showResults on completion
queryTask.execute(query, showResults);
}
function showResults(featureSet)
{
//remove all graphics on the maps graphics layer
map.graphics.clear();
map.infoWindow.hide();
//QueryTask returns a featureSet. Loop through features in the featureSet and add them to the map.
var resultFeatures = featureSet.features;
for (var i=0, il=resultFeatures.length; i<il; i++)
{
//Get the current feature from the featureSet. Feature is a graphic
var graphic = resultFeatures[i];
//need to create var symbol
//graphic.setSymbol(symbol);
//Set the infoTemplate. - Don't need?
//graphic.setInfoTemplate(infoTemplate);
//Add graphic to the map graphics layer.
map.graphics.add(graphic);
}
//Zoom to the extent of the graphics - replaced by view.goTo()
var myFeatureExtent = esri.graphicsExtent(resultFeatures);
map.setExtent(myFeatureExtent.getExtent().expand(3));
... View more
01-15-2020
07:52 AM
|
0
|
6
|
1336
|
POST
|
I have been reading more on attribute rules and took a look at them in Pro - this is exactly what I need but this doesn't seem to be available in ArcGIS Online? Is that true or is there a work around to add attribute rules to a hosted feature layer? #attributerules #agol #arcgisonline #hostedfeaturelayer
... View more
12-30-2019
07:39 AM
|
1
|
2
|
1916
|
POST
|
Hi Hamed Farzin, I had stumbled upon this link earlier but it looks like this has to be manually done every time new data is added to the feature layer - unless I am missing something? I was hoping to have these calculations done automatically so I don't have to check the data every day and perform the calculation. Similar to how you can set up calculations on fields in Survey123
... View more
12-16-2019
05:11 AM
|
1
|
0
|
1916
|
POST
|
Is there a way to set up automatic calculations (concatenate) on a specific field? I have 3 hidden fields that I would like to equal the values from other required fields that the users will be entering data into. Example: locationID field equals SiteID + area_designation + areaID I was hoping to not have to manually calculate the data every time a feature is added to the layer.
... View more
11-26-2019
08:03 AM
|
2
|
5
|
2210
|
POST
|
I've recently encountered an issue with the Web AppBuilder for ArcGIS Filter widget not saving when I change "Display features in the layer that match all of the following expressions" to "Display features in the layer that match any of the following expressions". I can change this option and navigate through the different layers to add additional expressions but when I click OK, exit and open the widget back up, that drop down reverts back to "all of the following" for every layer. I seem to be able to change (and save) the drop down that is located under the "+New filter" though.
... View more
08-22-2019
01:00 PM
|
0
|
3
|
643
|
POST
|
Hi Than Aung, thank you for your reply! We had started to go a different direction to see if using the REST API could accomplish something similar to what we have been looking for but we have not made much progress - so we are headed back down the API for JavaScript route. I will have to dig a little deeper into the time out information, we decided to implement a simple print button that opens the generic Windows print screen to save to PDF for the time being so some sections of the code need to be uncommented to test. I seem to still be a bit lost on passing the variables - in my php code they are $array[#] with the # representing the different columns. I could potentially capture them from the actual feature layer using something similar to graphic.attributes.<attribute name> For the template I had published there doesn't seem to be much information on what exactly needs to be in the text box or are they kept empty? I usually only see the window that shows the spot to type in the element name. Thank you for the information about the deferred and promise dojo object - I will have to take another look at this.
... View more
08-22-2019
12:51 PM
|
0
|
0
|
419
|
POST
|
Thank you Robert - I will look into the logs to see if I can figure out what is going on. I certainly appreciate your time helping me with this matter.
... View more
08-12-2019
10:49 AM
|
0
|
0
|
419
|
POST
|
Robert Scheitlin, GISP It still keeps timing out whenever I incorporate the customTextElements. As soon as I comment that section out - the print works. Also - the "blah" is embedded into the code so it would print out blah in every box, correct? How would you print out certain attributes associated with the object being printed?
... View more
08-12-2019
08:42 AM
|
0
|
2
|
419
|
POST
|
Robert Scheitlin, GISP Similar to what I see as well but I am still a bit confused as to how those elements "pick up" the attribute information. Also it seems like whenever I add the customTextElements to my code, the print service times out. The year seems to work just fine with <dyn type="date" format="yyyy"> in the properties but as soon as I add something like this to the other text boxes, they don't show up in the Execute Task information. Though I could be typing in something incorrect. {
"results": [{
"paramName": "Output_JSON",
"dataType": "GPString",
"value": [{
"layoutOptions": {
"hasAuthorText": false,
"hasCopyrightText": false,
"hasTitleText": false,
"hasLegend": true,
"customTextElements": [
{"Weather": ""},
{"EPA": ""},
{"Chemical": ""},
{"tmDate": ""},
{"Target": ""},
{"Site": ""},
{"Year": ""}
]
},
"pageSize": [
11.0,
8.5
],
"layoutTemplate": "TREATMENTS",
"activeDataFrameSize": [
8.7866,
7.3068
]
}]
}],
"messages": []
}
... View more
08-12-2019
07:29 AM
|
0
|
4
|
419
|
POST
|
Robert Scheitlin, GISP Sorry to confuse you, that is certainly not my intention. More than likely that is exactly what I am doing - I have been at this for 3, almost 4 weeks so I have been reading a lot of material and probably confusing myself. So what I have is a custom print service that I published. Below is a screen shot with a few elements removed. It has a some text boxes (where it says empty) that I would like to have only certain attribute information appear on the printout. I do not have data driven pages enabled because there are no layers in this template (just wanted to create something nice for the printout). I currently have the attribute information working as a PHP array where it captures the information I need from the ID in the URL and prints it into an html div but I have not been able to figure out how to get that same information and place it on this layout.
... View more
08-12-2019
06:51 AM
|
0
|
6
|
979
|
POST
|
Robert Scheitlin, GISP Ah okay - I was under the assumption that this text was hard coded so that is why I was a bit confused. I've seen examples using the customTextElements but I don't believe I have seen any with variables being called. Can you use something like $array[0] if you have everything defined or does it have to be formatted a certain way?
... View more
08-12-2019
06:17 AM
|
0
|
8
|
979
|
POST
|
Robert Scheitlin, GISP I'm still a bit of a novice with this so forgive me. How are you passing the variables to the text boxes on your layout?
... View more
08-12-2019
05:45 AM
|
0
|
10
|
979
|
POST
|
Robert Scheitlin, GISP - do you have to 'hard code' the text for the customTextElements or can you pass variables or certain attributes from the feature being printed?
... View more
08-12-2019
05:35 AM
|
0
|
12
|
979
|
Title | Kudos | Posted |
---|---|---|
1 | 07-29-2020 10:51 AM | |
1 | 12-30-2019 07:39 AM | |
1 | 08-05-2019 10:59 AM | |
1 | 02-20-2019 07:23 AM | |
1 | 12-16-2019 05:11 AM |
Online Status |
Offline
|
Date Last Visited |
11-25-2020
09:12 AM
|