|
POST
|
I realize this is a pretty vague question, but I'm having trouble wrapping my brain around it. Say I have a feature layer loaded up, it's made up of polygons. If I click on the one of the polygons, the blue selection outline shows up to indicate which one I have clicked on, and I assume some sort of object is being returned to me. What is it and how do I access it? By default each map has a GraphicsLayer so I *think* the object being returned is a graphic. I'd like to learn how to access the geometry of it so I can start doing simple calculations like acreage on whatever polygon the user has clicked. It appears map.graphics will return an array of the graphics that make up the GL in your map (of which I only have the default, I have not added any of my own). If I were to click on a polygon, would you have to use the method .getSelectedFeatures() or something to get the single graphic of interest? Or would you do something like map.graphics[0]? When I have tried console.log(map.graphics[0]); I get "undefined" in the console. Though if I do console.log(map.graphics) I can see there is 1 graphic in the array with an index of 0. I'm just not sure where to go from here. If I can get the graphic then I can use the geometry property to start working with it.
... View more
05-02-2018
09:40 AM
|
0
|
5
|
3919
|
|
POST
|
I instantiate my map with the basemap set to "hybrid". The hybrid basemap automatically has a reference layer added to display labels for various places. Now, if I switch the basemap via a basemap gallery to something like "imagery" where there should be no reference labels, the reference labels still persist. If I switch it to other basemaps, again, the references persist whether they're supposed to or not. How can I remove the reference layer for basemaps that aren't supposed to have it? If I instantiate my map with "satellite" first, all the basemaps work as expected when switching between them (things that are supposed to have labels, have labels. Things that aren't supposed to have labels don't). I see there is a property that would allow me to remove the reference layer when switching maps, but since the reference layer is automatically added, I don't know what the 'id' of it is. Code (the reference layer persists when switching basemaps): //Instantiate the map
map = new Map("map", {
basemap: "hybrid",
center: [-85.603281, 36.241294],
zoom: 6
});
//Create basemap gallery
var basemapGallery = new BasemapGallery({
showArcGISBasemaps: true,
map: map
}, "gallery");
basemapGallery.startup(); Code (the basemaps work as expected, reference layer does not persist if it's not supposed to): //Instantiate the map
map = new Map("map", {
basemap: "satellite",
center: [-85.603281, 36.241294],
zoom: 6
});
//Create basemap gallery
var basemapGallery = new BasemapGallery({
showArcGISBasemaps: true,
map: map
}, "gallery");
basemapGallery.startup();
... View more
05-02-2018
07:33 AM
|
0
|
5
|
2794
|
|
POST
|
Still not sure what exactly went wrong, but it must have been a corrupt install somehow. I used Control Panel > Uninstall Program > ArcGIS 10.6 > Uninstall/Change > Repair and it must have found the missing library because it works now.
... View more
04-25-2018
08:21 AM
|
2
|
0
|
1829
|
|
POST
|
I'm encountering a really weird error and I'm not sure what to do about it. I can't recall if I ran my script in 10.6 yet, so this could be a 10.6 problem as I recently upgraded from 10.5.1. I have a custom script tool in an ArcToolbox. I can run this python script in PyCharm IDE and it works great. When I try to run it from ArcMap, it tries to import the numpy module but fails as it can't seem to find it. While I don't use numpy in my script tool, I understand that the arcpy __init__.py script is where it is being imported. When I look in PyCharm, the Python interpreter shows numpy version 1.9.3 as part of the modules available, so I know it's there (and it's obviously there since the script works fine in PyCharm). Error: Python exe:
... View more
04-25-2018
08:00 AM
|
0
|
1
|
2309
|
|
POST
|
I think I figured out a way to do this, even if it's a bit clunky it'll do what I need it to. First, you parse the JSON response in javascript using JSON.parse(). This will return an object with properties of messages, jobId, and jobStatus. The messages object may be an array, so you can loop through the array of messages and look for type "esriJobMessageTypeError". These are your error messages. If a message matches that type you can access the "description" which is the actual error message. My code looks a little something like this now: function gpJobComplete(result) {
console.log(result.jobStatus + '(' + result.jobId + ')');
var jsonResults = dojo.toJson(result);
var jsonParsed = JSON.parse(jsonResults);
for (var i = 0; i < jsonParsed.messages.length; i++) {
var message = jsonParsed.messages[i];
if (message.type == "esriJobMessageTypeError") {
console.log("My error message: " + message.description);
};
}
... View more
04-24-2018
12:12 PM
|
1
|
0
|
1438
|
|
POST
|
I have a geoprocessing service with a bunch of custom errors built in. If an error occurs, I would like to get the error message and return it to the user, but the results of a geoprocessing service are these huge JSON responses. Is there a way to easily parse these? For instance, this is the ESRI job failure response, all I want is the line in red below to return the user: esriJobFailed(j62e4482338eb4149a0f8e9a6e574cd90):{"messages":[{"type":"esriJobMessageTypeInformative","description":"Submitted."},{"type":"esriJobMessageTypeInformative","description":"Executing..."},{"type":"esriJobMessageTypeInformative","description":"Executing (HabitatClassification): HabitatClassification C:\\arcgisserver\\directories\\arcgissystem\\arcgisuploads\\services\\MollyGPTesting\\HabitatClassification.GPServer\\ie6130b0b-b340-47e6-8b46-dcf2926abbe2\\VA_Habitat.gdb.zip AL"},{"type":"esriJobMessageTypeInformative","description":"Start Time: Tue Apr 24 14:44:29 2018"},{"type":"esriJobMessageTypeInformative","description":"Executing (HabitatClassification): HabitatClassification C:\\arcgisserver\\directories\\arcgissystem\\arcgisuploads\\services\\MollyGPTesting\\HabitatClassification.GPServer\\ie6130b0b-b340-47e6-8b46-dcf2926abbe2\\VA_Habitat.gdb.zip AL"},{"type":"esriJobMessageTypeInformative","description":"Start Time: Tue Apr 24 14:44:29 2018"},{"type":"esriJobMessageTypeInformative","description":"Running script HabitatClassification..."},{"type":"esriJobMessageTypeInformative","description":"Executing script \"HabitatClassification\"..."},{"type":"esriJobMessageTypeInformative","description":"Start Time 04/24/2018 14:44.29..."},{"type":"esriJobMessageTypeInformative","description":"c:\\arcgisserver\\directories\\arcgisjobs\\mollygptesting\\habitatclassification_gpserver\\j62e4482338eb4149a0f8e9a6e574cd90\\scratch\\scratch.gdb"},{"type":"esriJobMessageTypeInformative","description":"c:\\arcgisserver\\directories\\arcgisjobs\\mollygptesting\\habitatclassification_gpserver\\j62e4482338eb4149a0f8e9a6e574cd90\\scratch"},{"type":"esriJobMessageTypeInformative","description":"Successfully extracted zip file..."},{"type":"esriJobMessageTypeInformative","description":"c:\\arcgisserver\\directories\\arcgisjobs\\mollygptesting\\habitatclassification_gpserver\\j62e4482338eb4149a0f8e9a6e574cd90\\scratch\\VA_Habitat.gdb"},{"type":"esriJobMessageTypeError","description":"You have renamed a field from the original template. Please return it to its original state."},
... View more
04-24-2018
11:47 AM
|
0
|
1
|
1609
|
|
POST
|
Are you using 4.6 or 3.23? Sounds like 3.23 based on the setOpacity() method you're trying to use. Got any code to share? I don't have a slider, but I've got some radio buttons set up that allow the user to change opacity in 3.23. I would like to use a slider but haven't gotten around to it yet. The JS: on(query('input[name="setOpacity"]'), "click", function(evt){
var opacity = evt.target.id;
switch(opacity){
case "100-percent":
patchesFL.setOpacity(1);
break;
case "25-percent":
patchesFL.setOpacity(.25);
break;
case "50-percent":
patchesFL.setOpacity(.50);
break;
case "75-percent":
patchesFL.setOpacity(.75);
}
}); The HTML: <div id="opacity">
<h5>Opacity</h5>
<input type="radio" id="100-percent" name="setOpacity" value="100" checked>0%
<input type="radio" id="75-percent" name="setOpacity" value="25">25%
<input type="radio" id="50-percent" name="setOpacity" value="50">50%
<input type="radio" id="25-percent" name="setOpacity" value="75">75%
</div>
... View more
04-12-2018
05:37 AM
|
1
|
1
|
4226
|
|
POST
|
Upon rebuilding my application piece by piece, I determined the problem was that I had not yet styled something. I am in the process of transferring this web application from toying around with it in sandbox to putting it in an actual development software (Visual Studio) - there is a geoprocessing service that I had included in my JS code, but hadn't added the HTML buttons or anything yet to run that service in the development software so when I went back to sandbox and my HTML there included buttons to run the GP service, the popups worked, but when I went to VS and the HTML didn't include those buttons, the popups broke. I'm still a little unclear as to why this affected the popups, but it's fixed so alls well that ends well, I guess.
... View more
04-12-2018
05:15 AM
|
0
|
0
|
1081
|
|
POST
|
I had this working but suddenly it's not working and I cannot figure out why because all I've changed is my HTML and some styling (in the body) which should have nothing to do with the popup contents. The variables (function names) are global as the documentation says they should be. There is literally no reason this should not work, yet it doesn't. The require statement and global variables: var map, qhStatus, coarseClassify, fineClassify, cropType, pcType, pubOrPriv;
require([
"esri/map",
"esri/request",
"esri/arcgis/utils",
"esri/layers/FeatureLayer",
"esri/tasks/Geoprocessor",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/graphic",
"esri/renderers/UniqueValueRenderer",
"esri/renderers/SimpleRenderer",
"esri/Color",
"esri/InfoTemplate",
"esri/tasks/query",
"esri/tasks/QueryTask",
"esri/dijit/Legend",
"esri/dijit/PopupTemplate",
"dojo/query",
"dojo/dom",
"dojo/dom-construct",
"dojo/on",
"dojox/widget/Standby",
"dojo/parser",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dojo/domReady!"
],
function(
Map,
esriRequest,
arcgisUtils,
FeatureLayer,
Geoprocessor,
SimpleLineSymbol,
SimpleFillSymbol,
Graphic,
UniqueValueRenderer,
SimpleRenderer,
Color,
InfoTemplate,
Query,
QueryTask,
Legend,
PopupTemplate,
query,
dom,
domConstruct,
on,
Standby,
parser
) { The popup content for one of my popups (though none of them are working as they should). Note that the Number_Format function is called successfully and formats correctly but my custom function "pubOrPriv" is not called, thus the popups don't reflect the correct information. //Format the popup content for the CIP areas feature layer
var cipPopupContent = "<ul><li>State: ${StateID}</li>" +
"<li>Area: ${Area_ac:NumberFormat(places: 2)} acres</li>" +
"<li>Land Type: ${PublicLand:pubOrPriv}</li></ul>"
var cipPopupBox = new InfoTemplate("${Name} ${Route} Area", cipPopupContent); Example custom function that is supposed to be called when a cipPopupBox should appear: //Format the land type attribute for the cipPopupBox
pubOrPriv = function(value, key, data){
var land = "";
var pub = value;
var priv = data.PrivateLand;
if (pub == 1 && priv == 0){
land = "Public"
}
else if (pub == 0 && priv == 1){
land = "Private"
}
else{
land = "Public and private"
}
return land;
}; The popup functions work as expected when the HTML is like so: <div id="map"></div>
<div id="info">
<div id="legend"></div>
</div>
<div id="HabClassifyGPService">
State: <select id="stateAbbrev" name="stateIDList" form="uploadForm">
<option value="AL">Alabama</option>
<option value="AR">Arkansas</option>
<option value="DE">Delaware</option>
<option value="GA">Georgia</option>
<option value="FL">Florida</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Lousiana</option>
<option value="MD">Maryland</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="NE">Nebraska</option>
<option value="NJ">New Jersey</option>
<option value="NC">North Carolina</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="PA">Pennsylvania</option>
<option value="SC">South Carolina</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="VA">Virginia</option>
<option value="WV">West Virginia</option>
</select>
<form id="uploadForm" method="post" enctype="multipart/form-data">
<label class="custom-file-upload">
<input type="file" name="file" id="dataUpload"/>
<span id="fileUploadLabel">File Upload</span>
</label>
<input type="button" value="Upload" id="upload"/>
</form>
</div>
<div id="viewableLayers">
Select year: <select id="data-year"></select><br><br>
<legend>Toggle renderers:</legend>
<label><input type="radio" id="qhStatusLyr" name="chosenLayer" value="qhStatus" checked>Quail Habitat Status</label>
<label><input type="radio" id="coarseHabLyr" name="chosenLayer" value="coarse">Coarse-level Habitat Types</label>
<label><input type="radio" id="fineHabLyr" name="chosenLayer" value="fine">Fine-level Habitat Types</label><br>
<legend>Set Transparency:</legend>
<input type="radio" id="100-percent" name="setOpacity" value="100" checked>0%
<input type="radio" id="75-percent" name="setOpacity" value="25">25%
<input type="radio" id="50-percent" name="setOpacity" value="50">50%
<input type="radio" id="25-percent" name="setOpacity" value="75">75%<br><br>
<legend>Toggle layers:</legend>
<label><input type="checkbox" id="protectCoverLyr" name="pcLayer" value="pc">Protective Cover</label>
<label><input type="checkbox" id="faLyr" name="faLayer" value="fa" checked>Focal & Reference Areas</label>
</div> The popups do not work when the HTML is like so (I haven't added the HabitatClassifyGP stuff yet to this version): <div id="map"></div>
<div id="info">
Select data year to display: <br />
<select id="data-year"></select>
<div id="legendDiv">
<div id="legend"></div>
</div>
<div id="layersDiv">
<h5>Layers</h5>
<div id="toggleLayers">
<label><input type="checkbox" id="protectCoverLyr" name="pcLayer" value="pc">Protective Cover</label>
<label><input type="checkbox" id="faLyr" name="faLayer" value="fa" checked>Focal & Reference Areas</label>
</div>
</div>
<div id="rendererDiv">
<h5>Renderers</h5>
<label><input type="radio" id="qhStatusLyr" name="chosenLayer" value="qhStatus" checked>Quail Habitat Status</label>
<label><input type="radio" id="coarseHabLyr" name="chosenLayer" value="coarse">Coarse-level Habitat Types</label>
<label><input type="radio" id="fineHabLyr" name="chosenLayer" value="fine">Fine-level Habitat Types</label><br />
<h5>Opacity</h5>
<input type="radio" id="100-percent" name="setOpacity" value="100" checked>0%
<input type="radio" id="75-percent" name="setOpacity" value="25">25%
<input type="radio" id="50-percent" name="setOpacity" value="50">50%
<input type="radio" id="25-percent" name="setOpacity" value="75">75%
</div>
</div> How do I get it to call my functions??
... View more
04-11-2018
01:07 PM
|
0
|
1
|
1308
|
|
POST
|
Unfortunately I do not have that setting. I'm not clear why I would want to disable Javascript anyway? I think you meant "enable" in your last direction.
... View more
04-10-2018
08:43 AM
|
0
|
0
|
2117
|
|
POST
|
The Javascript API 3.23 site says that it supports Microsoft Edge, but I cannot get any of my data to load in an edge browser. It only loads the basemap. In Chrome, my feature layers show up, in Edge, they do not. Anybody else encounter this problem? I get a couple error messages: SCRIPT5: Access denied. SEC7117: Network request to https://xxx/rest/services/HbMonitoringTest/HabitatData/MapServer/2?f=json&callback=dojo_request_script_callbacks.dojo_request_script3 did not succeed. This Internet Explorer instance does not have the following capabilities: privateNetworkClientServer I'm not using any proxies or doing anything weird, it's a pretty simple set up: var cipCentroidsFL = new FeatureLayer("https://xxx/rest/services/HbMonitoringTest/HabitatData/MapServer/0", {
refreshInterval: 1440,
});
cipCentroidsFL.setMaxScale(1000000);
cipCentroidsFL.setMinScale(20000000);
var cipAreasFL = new FeatureLayer("https://xxx/rest/services/HbMonitoringTest/HabitatData/MapServer/3", {
refreshInterval: 1440,
infoTemplate: cipPopupBox,
outFields: ["*"]
});
cipAreasFL.setMinScale(999999);
var patchesFL = new FeatureLayer("https://xxx/rest/services/HbMonitoringTest/HabitatData/MapServer/1", {
refreshInterval: 10,
definitionExpression: 'EXTRACT(YEAR FROM "ObsvDate") = '+ currentYear,
infoTemplate: patchesPopupBox,
outFields: ["*"]
});
patchesFL.setMinScale(500000);
var protectCoverFL = new FeatureLayer("https://xxx/rest/services/HbMonitoringTest/HabitatData/MapServer/2", {
refreshInterval: 10,
definitionExpression: 'EXTRACT(YEAR FROM "ObsvDate") = ' + currentYear,
visible: false,
infoTemplate: pcPopupBox,
outFields: ["*"]
});
protectCoverFL.setMinScale(500000);
patchesFL.setRenderer(qhRenderer);
protectCoverFL.setRenderer(pcRenderer);
cipAreasFL.setRenderer(cipRenderer);
map.addLayers([cipAreasFL, cipCentroidsFL, patchesFL, protectCoverFL]);
... View more
04-10-2018
07:27 AM
|
0
|
2
|
3680
|
|
POST
|
Ah, that would explain why DatePart worked well for my SDE geodatabase in ArcMap (it's an SQL Server database), although I would say the documentation is not particularly correct as I was able to get DatePart to work on my database without the "special" SQL Server syntax they have listed. Still does not explain why the use case switches when trying to perform this query in the Javascript API though. EXTRACT(YEAR FROM...) works on the database while DatePart does not inside the Javascript API.
... View more
04-09-2018
07:16 AM
|
0
|
0
|
1718
|
|
POST
|
For some reason this query works on FGDB but not SDE geodatabases. Is that by design? When I use select by attributes and type this query: EXTRACT(YEAR FROM MyDateField) = 2015 This will work on a file geodatabase. When I try the same query with an SDE geodatabase, I get the error: "There was an error executing the query. Invalid SQL syntax [[Microsoft][ODBC Driver 13 for SQL Server][SQL Server] Incorrect syntax near the keyword 'FROM'.][mydata.dbo.database]." I have tried rewriting the query in these ways but all come back with the same error: EXTRACT(YEAR FROM "MyDateField") = 2015 EXTRACT(YEAR FROM MyDateField) = '2015' EXTRACT(YEAR FROM [MyDateField]) = 2015 The last thing I tried was the DatePart function. This appears to work on SDE geodatabases: DatePart("yyyy", MyDateField) = 2015 I am confused as to why this one works but not the EXTRACT one, especially because DatePart looks like it's meant for personal geodatabases: How To: Search for specific parts of a date stored in a Date-Time field Additionally, when building a query to use as a filter in Javascript API, the EXTRACT(YEAR FROM "MyDateField") = 2015 works on the SDE data and the DatePart does not. You'd think that one of these types of queries would work in all cases...frustrating.
... View more
04-09-2018
05:19 AM
|
0
|
2
|
1878
|
|
POST
|
The answer was that the GUID data type was causing an issue. I still needed to use this in my dissolve, so what I did was copy the GUID field to a new field of data type string, went through with the dissolve, and then copied the string field back to a GUID field.
... View more
04-06-2018
09:47 AM
|
1
|
1
|
2356
|
|
POST
|
Yup, that was the problem. I got around it by copying the GUID field to a field of string data type, doing the dissolve, and copying the string data back to a GUID field and carrying on with the script. I understand GUIDs are supposed to be unique so there shouldn't be a need to dissolve them, but that's not so in my case. It annoys me that it works fine in ArcMap and then when published to Server it breaks, making debugging a painfully slow process.
... View more
04-05-2018
10:53 AM
|
0
|
0
|
1234
|
| 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
|