|
POST
|
Ack, of course! Sometimes you just need someone to point out the obvious! I am storing several renderers in a config file and the user will choose one at run time. The fromJSON method is nice because it instantiates a renderer without my knowing the type at design time. This is what finally worked from me: var featureLayer = new FeatureLayer("https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_Counties/FeatureServer/0");
var rendererConfig = {"type": "simple","label": "","description": "","symbol": {"color": [0,112,255,64],"outline": {"color": [0,0,0,255],"width": 1,"type": "esriSLS","style": "esriSLSSolid","marker": null},"type": "esriSFS","style": "esriSFSSolid"}};
var blueRenderer = jsonUtils.fromJson(rendererConfig);
featureLayer.setRenderer(blueRenderer);
map.addLayer(featureLayer); Many thanks to you both for the quick replies! Jill
... View more
08-03-2017
06:36 PM
|
0
|
0
|
1572
|
|
POST
|
Hi! Does anybody have a working example of how to use the fromjson method on the esri/renderers/jsonUtils module? Using the following code I expect a blue symbology to be applied but the blueRenderer object always ends up 'undefined'. var featureLayer = new FeatureLayer("https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_Counties/FeatureServer/0");
var rendererConfig = '{"color"[0,112,255,64],"outline": {"color": [0,0,0,255],"width": 1,"type": "esriSLS","style": "esriSLSSolid","marker": null},"type": "esriSFS","style": "esriSFSSolid"}';
var blueRenderer = jsonUtils.fromJson(rendererConfig);
featureLayer.setRenderer(blueRenderer);
map.addLayer(featureLayer); Full code here - https://codepen.io/js_gsi/pen/prNvXJ. Maybe my JSON is not well formed? I pulled it from this playground. Thank you! Jill
... View more
08-03-2017
02:57 PM
|
0
|
3
|
2218
|
|
POST
|
Hi Jose, Yes, exactly. The parameter of the before-apply-edits event includes an array of the features that are being modified (added, updated or deleted). You can manipulate these features here before the feature service is updated. In this example, I add the username and timestamp to the new record before it's pushed to the server. _onBeforeApplyEdits: function (evt) {
if (evt.adds != null) {
var currentDate = new Date();
var dateTime = currentDate.getTime() - (currentDate.getTimezoneOffset() * 60000);
this._newFeature = evt.adds[0];
this._newFeature.attributes["createUserField"] = this._currentUsername;
this._newFeature.attributes["createDateField"] = dateTime;
this._newFeature.attributes["updateUserField"] = this._currentUsername;
this._newFeature.attributes["updateDateField"] = dateTime;
}
} Hope that helps! Jill
... View more
04-21-2017
02:29 PM
|
1
|
1
|
1357
|
|
POST
|
Thanks for your reply, Undral. Here's a quick and dirty workaround that I came up with, in case anyone else needs this functionality. I'd be interested in hearing if someone has a more elegant solution. After creating the feature table, I create the menu that allows the user to choose the direction of sorting. By specifying the targetNodeId and selector properties it will appear as the context menu when the user right clicks a column header. var sortMenu = new Menu({
id: "sortMenu",
targetNodeIds: [tableDiv.id],
selector: ".dgrid-sortable"
});
sortMenu.addChild(new MenuItem({
id: "sortAscending",
label: "Sort Ascending",
iconClass: "iconSortAscending",
onClick: lang.hitch(this, "_onSortAscendingClick")
}));
sortMenu.addChild(new MenuItem({
id: "sortDescending",
label: "Sort Descending",
iconClass: "iconSortDescending",
onClick: lang.hitch(this, "_onSortDescendingClick")
}));
sortMenu.startup(); The only way I could see to capture the name of the field to be sorted was to grab it from the contextmenu event of the column header. dojo.forEach(this._resultsAttributeTable.columns, lang.hitch(this, function(column) {
on(column.headerNode, 'contextmenu', lang.hitch(this, function(e) {
if (e.currentTarget.hasOwnProperty("field")) {
this._fieldSort = e.currentTarget.field;
}
}));
})); Finally, do the sorting when the menu item is clicked. _onSortAscendingClick: function(e) {
if (this._fieldSort) {
this._resultsAttributeTable.grid.set('sort', this._fieldSort);
this._fieldSort = null;
}
},
_onSortDescendingClick: function(e) {
if (this._fieldSort) {
this._resultsAttributeTable.grid.set('sort', [ { attribute: this._fieldSort, descending: true } ]);
this._fieldSort = null;
}
} Thanks! Jill
... View more
07-11-2016
12:05 PM
|
0
|
1
|
1179
|
|
POST
|
Hi, I have an existing app that has a FeatureTable populated by a FeatureLayer that has been created client side from the results of a query. I recently migrated the app from 3.16 to 3.17 and was pleased to see that a few issues have been resolved but a new one popped up which is that I can no longer sort the table. When I click on the column header I don't get the popup menu that allows the user to choose ascending or descending. I also don't get any console errors. To show what I mean, I combined these two samples, Feature collection | ArcGIS API for JavaScript 3.17 and Using FeatureTable | ArcGIS API for JavaScript 3.17. That code is listed below. Any ideas are appreciated! Thanks! Jill <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Using FeatureTable</title>
<link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.17/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.17/esri/css/esri.css">
<script src="//js.arcgis.com/3.17/"></script>
<style>
html, body, #map{
width:100%;
height:100%;
margin:0;
padding:0;
}
</style>
<script>
var map;
require([
"esri/layers/FeatureLayer",
"esri/dijit/FeatureTable",
"esri/geometry/webMercatorUtils",
"esri/map",
"dojo/dom-construct",
"dojo/dom",
"dojo/parser",
"dojo/ready",
"dojo/on",
"dojo/_base/lang",
"dijit/registry",
"dijit/form/Button",
"dijit/layout/ContentPane",
"dijit/layout/BorderContainer",
"dijit/form/TextBox",
"esri/request",
"dojo/_base/array",
"esri/geometry/Point",
"esri/graphic"
], function (
FeatureLayer, FeatureTable, webMercatorUtils, Map,
domConstruct, dom, parser, ready, on,lang,
registry, Button, ContentPane, BorderContainer, TextBox, esriRequest, array, Point, Graphic
) {
parser.parse();
ready(function(){
var myFeatureLayer;
var map = new Map("map",{
basemap: "dark-gray"
});
map.on("load", loadTable);
function loadTable(){
//create a feature collection for the flickr photos
var featureCollection = {
"layerDefinition": null,
"featureSet": {
"features": [],
"geometryType": "esriGeometryPoint"
}
};
featureCollection.layerDefinition = {
"geometryType": "esriGeometryPoint",
"objectIdField": "ObjectID",
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"type": "esriPMS",
"url": "images/flickr.png",
"contentType": "image/png",
"width": 15,
"height": 15
}
}
},
"fields": [{
"name": "ObjectID",
"alias": "ObjectID",
"type": "esriFieldTypeOID"
}, {
"name": "description",
"alias": "Description",
"type": "esriFieldTypeString"
}, {
"name": "title",
"alias": "Title",
"type": "esriFieldTypeString"
}]
};
//create a feature layer based on the feature collection
myFeatureLayer = new FeatureLayer(featureCollection, {
id: 'flickrLayer'
});
//set map extent
on(myFeatureLayer, "load", function(evt){
var extent = myFeatureLayer.fullExtent;
if (webMercatorUtils.canProject(extent, map)) {
map.setExtent( webMercatorUtils.project(extent, map) );
}
});
map.addLayer(myFeatureLayer);
myFeatureTable = new FeatureTable({
"featureLayer" : myFeatureLayer,
"map" : map
}, 'myTableNode');
myFeatureTable.startup();
requestPhotos();
}
function requestPhotos() {
//get geotagged photos from flickr
//tags=flower&tagmode=all
var requestHandle = esriRequest({
url: "https://api.flickr.com/services/feeds/geo?&format=json",
callbackParamName: "jsoncallback"
});
requestHandle.then(requestSucceeded, requestFailed);
}
function requestSucceeded(response, io) {
//loop through the items and add to the feature layer
var features = [];
array.forEach(response.items, function(item) {
var attr = {};
attr["description"] = item.description;
attr["title"] = item.title ? item.title : "Flickr Photo";
var geometry = new Point(item);
var graphic = new Graphic(geometry);
graphic.setAttributes(attr);
features.push(graphic);
});
myFeatureLayer.applyEdits(features, null, null);
}
function requestFailed(error) {
console.log('failed');
}
});
});
</script>
</head>
<body class="claro esri">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'" style="width:100%; height:100%;">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center', splitter:true" style="height:50%">
<div id="map"></div>
</div>
<div id="bot" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom', splitter:true" style="height:50%">
<div id="myTableNode"></div>
</div>
</div>
</body>
</html>
... View more
07-06-2016
12:40 PM
|
0
|
3
|
3572
|
|
POST
|
Hi Jonathan. There will be a 3.17 release? In addition to 4.0? Thanks for the reply! Jill
... View more
05-17-2016
12:39 PM
|
0
|
2
|
1041
|
|
POST
|
Hi Cory, Did you every find an answer to this? I'm having the same issue at 3.16. Jill
... View more
05-13-2016
02:41 PM
|
0
|
0
|
738
|
|
POST
|
Hi, I've created a custom featureLayer from a featureClass that's been created from some query results. I add it to the map and then used it to spin up a featureTable. The featureTable looks fine but I can't seem to get table records to sync with the map graphics. When I select a feature from the table, the header says that one feature has been selected but the map doesn't pan, like in the samples and I get the following console error: TypeError: Object doesn't support property or method 'emit' TypeError: Object doesn't support property or method 'emit' at Anonymous function (http://js.arcgis.com/3.16/esri/dijit/FeatureTable.js:74:136) If I choose "Center on Selection" from the Options menu I get an additional console error: Error: FeatureLayer::_query - query contains one or more unsupported parameters Can anyone point me to where I'm setting things up incorrectly? var resultsLayerDefinition = {
"geometryType": queryResults[0].geometryType,
"fields": queryResults[0].fields
};
//Workaround. FeatureTable will not work with results directly.
//https://community.esri.com/thread/165943
var copyFeatures = dojo.map(allFeatures, function (feature) {
return new Graphic(feature.toJson());
});
var resultsFeatureClass = {
layerDefinition: resultsLayerDefinition,
featureSet: {
"features": copyFeatures,
"geometryType": queryResults[0].geometryType
}
};
this._resultsFeatureLayer = new FeatureLayer(resultsFeatureClass);
var renderer = new SimpleRenderer(this._pointSymbol);
this._resultsFeatureLayer.setRenderer(renderer);
this.map.addLayer(this._resultsFeatureLayer);
this._resultsAttributeTable = new FeatureTable({
"featureLayer" : this._resultsFeatureLayer,
"map" : this.map,
"syncSelection": true,
"zoomToSelection": true
}, 'attributeTable');
this._resultsAttributeTable.startup(); I'm using JSAPI 3.16. Thanks! Jill ETA: It seems that others have reported this issue: JSAPI Feature layer created from feature collection and the feature table.
... View more
05-13-2016
11:50 AM
|
0
|
4
|
5739
|
|
POST
|
Thank you for the replies! Ken, you are right. There are some group layers in there and when I remove them I don't get the extra results. I don't see this referenced anywhere in the help. Thanks again! Jill
... View more
05-13-2016
08:52 AM
|
0
|
0
|
724
|
|
POST
|
Hi, I'm having an issue where the identify task seems to be returning records for layers that I have not specified. Sometimes it will return records for the same layer twice. My request looks like this: //[server_name]/arcgis/rest/services/[service_name]/MapServer/identify?geometry={"x":-9857097.368979331,"y":5159521.918742495,"spatialReference":{"wkid":102100}}&geometryType=esriGeometryPoint&sr=102100&layers=visible:5,139,22,135,133,24,25,28,141,73,115&layerDefs=&time=&layerTimeOptions=&tolerance=5&mapExtent={"xmin":-9912437.77745782,"ymin":5112742.457431949,"xmax":-9766901.675602788,"ymax":5190861.1003394285,"spatialReference":{"wkid":102100}}&imageDisplay=952,511,96&returnGeometry=true So, I'm requesting layers 5,139,22,135,133,24,25,28,141,73,115 only. But my results look like this (attributes and geometry removed for brevity): { "results": [{ "layerId": 139, "layerName": "2016 TIP Points" }, { "layerId": 6, "layerName": " 2013 TIP Points" }, { "layerId": 139, "layerName": "2016 TIP Points" }, { "layerId": 73, "layerName": "Road Jurisdiction" }, { "layerId": 73, "layerName": "Road Jurisdiction" }, { "layerId": 115, "layerName": "County" }] } So, why am I getting results for layer 6 and layer 139 and 73 twice (there is only one feature there)? If I identify at a different location I get a different set of extra layers being queried. Any ideas? Am I not using the Layers parameter correctly? Thanks! Jill
... View more
05-11-2016
02:23 PM
|
0
|
3
|
3686
|
|
POST
|
Hi! Thank you so much for all of the replies. I really appreciate it. Robert, you are correct. The Map object's toScreen and toMap methods do give me the expected results. Thanks for the suggestion! However, Bill, your comments made me reevaluate my strategy. You are right that tweaking the symbology gave me what I was looking for. Thanks! Jill
... View more
04-25-2016
01:17 PM
|
0
|
0
|
1986
|
|
POST
|
Hi All, Ultimately what I'm trying to do is convert a map point to a screen point so that I can offset it by a distance in screen units and then convert it back to map point so I can place it on the map. I'm trying to do this using the toMapGeometry and toScreenGeometry methods in the screenUtils module but they don't work as I expect them to. Taking the offset out of the equation for a minute, what's confusing is that if I take a map point and convert it to a screen point and then convert it back to a map point again the X and Y are not the same as the original point. Shouldn't they be the same? Am I using these methods incorrectly? Here's my code (for whatever reason syntax highlighting is not working for me today...): var screenGeo = screenUtils.toScreenGeometry(this.map.extent, this.map.width, this.map.height, evt.geometry); var mapPointGeo = screenUtils.toMapGeometry(this.map.extent, this.map.width, this.map.height, screenGeo); //Ouput: ?evt.geometry type: "point" x: -88.18114353491255 y: 41.7207439952267 ?screenGeo type: "point" x: 64564 y: 33899 ?mapPointGeo type: "point" x: -83.94943230599165 y: 98.94651940930635 I was expecting evt.geometry and mapPointGeo to be the same. There are two other methods that are depreciated: toMapPoint and toScreenPoint. These do work as expected (once I do some geographic/web merc conversion). Any ideas? Thanks! Jill
... View more
04-20-2016
02:28 PM
|
0
|
4
|
5707
|
|
POST
|
You are right on, Robert. This worked. Strange that I have installed v2 on other workstations in C:\Program Files without problems. Thanks for the reply, I really appreciate it! Jill
... View more
04-06-2016
08:27 AM
|
0
|
0
|
2157
|
|
POST
|
Hi, I've downloaded and extracted the latest version of WAB but when I run startup.bat I get the following error: fs.js:653 return binding.mkdir(pathModule._makeLong(path), ^ Error: EPERM, operation not permitted 'C:\Program Files\WebAppBuilderForArcGIS\server\logs' at Object.fs.mkdirSync (fs.js:653:18) at Object.<anonymous> (C:\Program Files\WebAppBuilderForArcGIS\server\server.js:73:6) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3 Press any key to continue . . . I thought maybe it was a permissions problem so I ran startup.bat as an administrator and now I simply get the error: "server" directory does not exist Press any key to continue . . . The server directory definitely exists. It contains 17 files and 3 directories. I've deleted everything and downloaded a fresh copy but still get the same error. Node.js is installed from a previous version of WAB. Ideas? Thanks! Jill
... View more
04-04-2016
01:22 PM
|
0
|
5
|
6146
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-21-2023 11:03 AM | |
| 1 | 08-22-2024 12:12 PM | |
| 1 | 06-17-2022 08:38 AM | |
| 2 | 05-23-2023 07:45 AM | |
| 1 | 01-29-2025 11:07 AM |
| Online Status |
Offline
|
| Date Last Visited |
08-22-2025
12:28 PM
|