|
POST
|
Ok, let me know if this is right. I stuck this function in the main.js file since I have to do the calculation quickly, before the local layer widget loads: function getBatchNumnber() {
var sitesUrl = "https://ocean.floridamarine.org/arcgis/rest/services/Projects_FWC/Florida_Reef_Resiliency_Program/MapServer/0";
var queryTask = new QueryTask(sitesUrl);
var batchQuery = new Query();
var statDef = new StatisticDefinition();
statDef.statisticType = "max";
statDef.onStatisticField = "Batch";
statDef.outStatisticsFieldName = "CurrentBatch";
batchQuery.where = "1=1";
batchQuery.outFields = ["Batch"];
batchQuery.outStatistics = [statDef];
batchQuery.returnGeometry = false;
queryTask.execute(batchQuery).then(function(result) {
currentBatch = result.features[0].attributes.MAX_Batch;
console.log("Max batch value: ", this.currentBatch);
return window.currentBatch;
});
} I got the batch number I need for my definition query, Now I need to pass the def query to the LocalLayer.config for it to be executed in the LocalLayer.js file here: if (layer.type.toUpperCase() === 'DYNAMIC') {
if (layer.imageformat) {
var ip = new ImageParameters();
ip.format = layer.imageformat;
if (layer.hasOwnProperty('imagedpi')) {
ip.dpi = layer.imagedpi;
}
lOptions.imageParameters = ip;
}
lLayer = new ArcGISDynamicMapServiceLayer(layer.url, lOptions);
if (layer.hasOwnProperty('definitionQueries')) {
var definitionQueries = JSON.parse(layer.definitionQueries)
var layerDefinitions = []
for (var prop in definitionQueries) {
layerDefinitions[prop] = definitionQueries[prop];
}
lLayer.setLayerDefinitions(layerDefinitions);
} Is this kind of what you had in mind? I can set the def query to something like SELECT * FROM "FRRP Sites: WHERE "Batch = batchNum" Of course, I know this is probably formatted wrong!
... View more
04-29-2019
10:56 AM
|
0
|
1
|
3103
|
|
POST
|
Thanks Robert. Are you saying that there is no way to render labels client side? It seems there should be some way to redefine the labels on the resulting feature layer and render them in the map? I tried using LabelClass and couldn't get that to work either. If not, is there any workaround? I could use some options 🙂 Two things I can think of are 1. creating a message box for each point (not sure if that's possible) or 2. trying to filter the layer when the map loads(somehow) so the layer gets displayed as drawn from server (but only the points I need). I already thought of doing a definition query, but I have to do a statistical field calculation to extract the correct features, and I don't think I can do that with a def query.
... View more
04-29-2019
08:47 AM
|
0
|
3
|
3103
|
|
POST
|
I have a web app built with WAB 2.10 that display two layers, I polygon and a point layer which are hosted at ArcGIS REST services. Both of the layers have labels that were configured in the ArcGIS map document and then published. Originally I brought in the layers as feature classes and the labels would not render. I then brought them in as a dynamic layer and now I can get the labels to show. I don't really understand why they don't show when I add the layers to the map as feature layers, since this would be my preference, but I can work around this. The problem is that I am running a query on the point layer (since I don't need to see all of the points), but I cannot get the labels to show for the resulting point layer. The is perplexing, because the drawing info for the result layer is cloned from the original REST layer (which shows labels). var layerInfo = lang.clone(currentAttrs.layerInfo);
var featureCollection = {
layerDefinition: layerInfo,
featureSet: null
};
//For now, we should not add the FeatureLayer into map.
//resultLayer = new FeatureLayer(featureCollection);
resultLayer = new FeatureLayer(featureCollection, {
outFields:["*"],
showLabels: true
}); and when I log out the result layers info, all of the labeling info appears to be present in the layer properties. Here is the query result layer not showing any labels: There must be something else I need to be doing to get the labels to show, but I can't figure it out. The only thing I can think of is that either something is missing in the label properties, or it has something to do with the rendering. Do I need to add something to the code snippet below? if(!queryUtils.isTable(currentAttrs.layerInfo)){
if(!currentAttrs.config.useLayerSymbol && currentAttrs.config.resultsSymbol){
var symbol = symbolJsonUtils.fromJson(currentAttrs.config.resultsSymbol);
renderer = new SimpleRenderer(symbol);
resultLayer.setRenderer(renderer);
}
} One other thing I have tried, is to use the LabelClass constructor as described in esri's javascript API reference page here: https://developers.arcgis.com/javascript/3/jsapi/labelclass-amd.html, but no luck. I don't know where to go from here, so if anyone sees anything obvious I am missing please let me know. Thanks!
... View more
04-29-2019
07:57 AM
|
0
|
5
|
3348
|
|
POST
|
Thank you Robert, that will help greatly in the future!! So I can change the mobileLayout, and then tell the util.js file to Look Here!!! That should be a lot easier in most cases than searching through all of the files to try and find the best place to drop some custom code. Probably safer too, as sometimes that can have unintended consequences. For instance to stop the legend from opening in mobile mode, I had to edit the configManager.js file by dropping in: this.appConfig.widgetPool.widgets[0].openAtStart = false; under an existing conditional. It is working, but some of the files in the jimu.js folder give me a little pause when I think about modifying them! Thanks again
... View more
04-16-2019
09:00 AM
|
0
|
0
|
725
|
|
POST
|
I know I have asked a similar question, and have read numerous posts on this subject, but I am still confused about how the mobileLayout section in the main app config is supposed to work. To my understanding, any widget or map configurations in the mobileLayout section should kick in when the app is run in mobile. I have viewed the Config Manager and jimu utilities where this behavior appears to be defined, but when I try and make a change in a configuration in the mobileLayout section, it always appears to be ignored. I usually end up giving up and modifying the javascript in some file to force the desired behavior. In this case I do not want the legend to openAtStart in mobile config, but just setting this to false in the mobileLayout does not work (it still opens). I would also like to set a new map extent in mobile, but no luck there either. It would be really nice if I could get this to work since I run in to this a lot and it would save a lot of time. Here is my entire main config: {
"theme": {
"name": "FWRITheme",
"styles": [
"green",
"default",
"yellow",
"black",
"blue"
],
"version": "2.10",
"sharedTheme": {
"isPortalSupport": true,
"useHeader": false,
"useLogo": false
}
},
"portalUrl": "https://myfwc.maps.arcgis.com",
"appId": "",
"authorizedCrossOriginDomains": [],
"title": "FWC Fish Stocking Locator",
"subtitle": "Fish and Wildlife Conservation Commission",
"keepAppState": false,
"logo": "images/logo.png",
"geometryService": "https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",
"links": [],
"widgetOnScreen": {
"widgets": [
{
"uri": "themes/FWRITheme/widgets/HeaderController/Widget",
"position": {
"left": 0,
"top": 0,
"right": 0,
"height": 40,
"relativeTo": "browser"
},
"version": "2.10",
"id": "themes_FWRITheme_widgets_HeaderController_Widget_20",
"name": "HeaderController"
},
{
"uri": "widgets/Scalebar/Widget",
"position": {
"left": 7,
"bottom": 25,
"relativeTo": "map"
},
"version": "2.10",
"id": "widgets_Scalebar_Widget_21",
"name": "Scalebar"
},
{
"uri": "widgets/Search/Widget",
"position": {
"left": 55,
"top": 5,
"relativeTo": "map"
},
"version": "2.10",
"id": "widgets_Search_Widget_22",
"name": "Search"
},
{
"uri": "widgets/Coordinate/Widget",
"position": {
"left": 7,
"bottom": 5,
"relativeTo": "map"
},
"version": "2.10",
"id": "widgets_Coordinate_Widget_23",
"name": "Coordinate"
},
{
"position": {
"left": 55,
"top": 45,
"relativeTo": "map"
},
"placeholderIndex": 1,
"id": "_27",
"name": "SearchStockedFish",
"label": "Search Stocked Fish",
"version": "2.10",
"closeable": true,
"uri": "widgets/SearchStockedFish/Widget",
"config": "configs/SearchStockedFish/config__27.json",
"openAtStart": true
},
{
"position": {
"left": 105,
"top": 45,
"relativeTo": "map"
},
"placeholderIndex": 1,
"id": "_28",
"name": "WaterbodySearch",
"label": "Search for Waterbodies",
"version": "2.9",
"closeable": true,
"uri": "widgets/WaterbodySearch/Widget",
"config": "configs/WaterbodySearch/config__28.json",
"icon": "configs\\WaterbodySearch\\icon__28.png"
},
{
"position": {
"left": 155,
"top": 45,
"relativeTo": "map"
},
"placeholderIndex": 1,
"id": "_26",
"name": "Identify",
"version": "2.9.0.1",
"uri": "widgets/Identify/Widget",
"closeable": true,
"IsController": false,
"config": "configs/Identify/config__26.json"
},
{
"position": {
"left": 205,
"top": 45,
"relativeTo": "map"
},
"placeholderIndex": 1,
"id": "_24",
"name": "Print",
"version": "2.10",
"closeable": true,
"uri": "widgets/Print/Widget",
"config": "configs/Print/config__24.json"
},
{
"position": {
"left": 255,
"top": 45,
"relativeTo": "map"
},
"placeholderIndex": 1,
"id": "_25",
"version": "2.5",
"closeable": true,
"uri": "widgets/eBookmark/Widget",
"name": "eBookmark",
"IsController": false,
"config": "configs/eBookmark/config__25.json"
},
{
"uri": "widgets/OverviewMap/Widget",
"position": {
"right": 0,
"bottom": 0,
"zIndex": 1,
"relativeTo": "map"
},
"version": "2.10",
"id": "widgets_OverviewMap_Widget_29",
"name": "OverviewMap"
},
{
"uri": "widgets/HomeButton/Widget",
"position": {
"left": 7,
"top": 75,
"relativeTo": "map"
},
"version": "2.10",
"id": "widgets_HomeButton_Widget_30",
"name": "HomeButton"
},
{
"uri": "widgets/MyLocation/Widget",
"position": {
"left": 7,
"top": 150,
"relativeTo": "map"
},
"version": "2.10",
"visible": false,
"id": "widgets_MyLocation_Widget_31",
"name": "MyLocation"
},
{
"uri": "widgets/AttributeTable/Widget",
"visible": false,
"version": "2.10",
"position": {
"relativeTo": "browser"
},
"id": "widgets_AttributeTable_Widget_32",
"name": "AttributeTable"
},
{
"uri": "widgets/Splash/Widget",
"visible": false,
"position": {
"relativeTo": "browser"
},
"version": "2.10",
"id": "widgets_Splash_Widget_33",
"name": "Splash"
},
{
"uri": "widgets/ZoomSlider/Widget",
"position": {
"top": 5,
"left": 7,
"relativeTo": "map"
},
"version": "2.10",
"id": "widgets_ZoomSlider_Widget_34",
"name": "ZoomSlider"
},
{
"uri": "widgets/ExtentNavigate/Widget",
"visible": false,
"position": {
"top": 190,
"left": 7,
"relativeTo": "map"
},
"version": "2.10",
"id": "widgets_ExtentNavigate_Widget_35",
"name": "ExtentNavigate"
},
{
"uri": "widgets/FullScreen/Widget",
"visible": true,
"position": {
"top": 110,
"left": 7,
"relativeTo": "map"
},
"version": "2.10",
"id": "widgets_FullScreen_Widget_36",
"name": "FullScreen"
},
{
"uri": "widgets/FWRISplash/Widget",
"positionRelativeTo": "browser",
"id": "widgets_FWRISplash_Widget_37",
"name": "FWRISplash",
"version": "0.0.1",
"position": {
"relativeTo": "browser"
},
"config": "configs/FWRISplash/config__38.json"
},
{
"uri": "widgets/FWRIViewSettings/Widget",
"positionRelativeTo": "browser",
"id": "widgets_FWRIViewSettings_Widget_38",
"name": "FWRIViewSettings",
"version": "0.0.1",
"position": {
"relativeTo": "browser"
}
},
{
"uri": "widgets/LocalLayer/Widget",
"positionRelativeTo": "browser",
"id": "widgets_LocalLayer_Widget_39",
"name": "LocalLayer",
"version": "2.0",
"position": {
"relativeTo": "browser"
},
"config": "configs/LocalLayer/config_widgets_LocalLayer_Widget_39.json"
}
],
"panel": {
"uri": "jimu/OnScreenWidgetPanel",
"position": {
"relativeTo": "map"
}
}
},
"map": {
"3D": false,
"2D": true,
"position": {
"left": 0,
"top": 40,
"right": 0,
"bottom": 0
},
"itemId": "3dbbb8f6d83c481381decdb150963858",
"mapOptions": {
"extent": { //I want to change this extent in mobile
"xmin": -10223667.439313974,
"ymin": 2732381.698461617,
"xmax": -8364718.911418981,
"ymax": 3745019.449183363,
"spatialReference": {
"wkid": 102100
}
}
},
"id": "map",
"portalUrl": "https://myfwc.maps.arcgis.com",
"mapRefreshInterval": {
"useWebMapRefreshInterval": true
}
},
"widgetPool": {
"panel": {
"uri": "themes/FWRITheme/panels/FoldablePanel/Panel",
"position": {
"top": 5,
"right": 5,
"bottom": 5,
"zIndex": 5,
"relativeTo": "map"
}
},
"widgets": [
{
"uri": "widgets/Legend/Widget",
"visible": true,
"version": "2.10",
"id": "widgets_Legend_Widget_18",
"name": "Legend",
"openAtStart": true, // I do not want this to open at start in mobile
"index": 2
},
{
"uri": "widgets/LayerList/Widget",
"version": "2.10",
"id": "widgets_LayerList_Widget_19",
"name": "LayerList",
"index": 3,
"config": "configs/LayerList/config_widgets_LayerList_Widget_19.json",
"openAtStart": false
},
{
"name": "eDraw",
"label": "Draw and Measure",
"version": "2.8.1",
"visible": false,
"uri": "widgets/eDraw/Widget",
"config": "configs/eDraw/config_widgets_eDraw_Widget_40.json",
"index": 5,
"id": "widgets_eDraw_Widget_40"
},
{
"name": "HelpfulLinks",
"version": "2.10",
"uri": "widgets/HelpfulLinks/Widget",
"config": "configs/HelpfulLinks/config_widgets_Links_Widget_41.json",
"index": 6,
"id": "widgets_HelpfulLinks_Widget_41"
}
],
"groups": []
},
"mobileLayout": {
"widgetOnScreen": {
"widgets": [
{
"uri": "themes/FWRITheme/widgets/HeaderController/Widget",
"position": {
"left": 0,
"top": 0,
"right": 0,
"height": 40,
"relativeTo": "browser"
},
"version": "2.10"
},
{
"uri": "widgets/Scalebar/Widget",
"position": {
"left": 7,
"bottom": 40,
"relativeTo": "map"
},
"version": "2.10"
},
{
"uri": "widgets/Search/Widget",
"position": {
"left": 55,
"top": 5
},
"version": "2.10"
},
{
"uri": "widgets/Coordinate/Widget",
"position": {
"left": 7,
"bottom": 17,
"relativeTo": "map"
},
"version": "2.10"
},
{
"position": {
"left": 55,
"top": 45
}
},
{
"position": {
"left": 105,
"top": 45
}
},
{
"position": {
"left": 155,
"top": 45
}
},
{
"position": {
"left": 205,
"top": 45
}
},
{
"position": {
"left": 255,
"top": 45
}
},
{
"uri": "widgets/OverviewMap/Widget",
"position": {
"right": 0,
"bottom": 0,
"zIndex": 1
},
"version": "2.10"
},
{
"uri": "widgets/HomeButton/Widget",
"inPanel": false,
"position": {
"left": 7,
"top": 75
},
"version": "2.10"
},
{
"uri": "widgets/MyLocation/Widget",
"inPanel": false,
"position": {
"left": 7,
"top": 110
},
"version": "2.10"
},
{
"uri": "widgets/AttributeTable/Widget",
"version": "2.10",
"visible": false,
"position": {
"relativeTo": "browser"
}
},
{
"uri": "widgets/Splash/Widget",
"visible": false,
"position": {
"relativeTo": "browser"
},
"version": "2.10"
},
{
"uri": "widgets/ZoomSlider/Widget",
"visible": true,
"position": {
"top": 5,
"left": 7
},
"version": "2.10"
},
{
"uri": "widgets/ExtentNavigate/Widget",
"visible": false,
"position": {
"top": 190,
"left": 7
},
"version": "2.10"
},
{
"uri": "widgets/FullScreen/Widget",
"visible": false,
"position": {
"top": 150,
"left": 7
},
"version": "2.10"
},
{
"uri": "widgets/FWRISplash/Widget",
"positionRelativeTo": "browser"
},
{
"uri": "widgets/FWRIViewSettings/Widget",
"positionRelativeTo": "browser"
},
{
"uri": "widgets/LocalLayer/Widget",
"positionRelativeTo": "browser"
}
]
},
"map": {
"position": {
"left": 0,
"top": 40,
"right": 0,
"bottom": 0
},
"mapOptions": {
"extent": {
"xmin": -97, // change does not take effect
"ymin": 27,
"xmax": -88,
"ymax": 36,
"spatialReference": {
"wkid": 102100
}
}
}
},
"widgetPool": {
"panel": {
"uri": "themes/FWRITheme/panels/FoldablePanel/Panel",
"position": {
"top": 5,
"right": 5,
"bottom": 5,
"zIndex": 5
}
},
"widgets": [
{
"uri": "widgets/Legend/Widget",
"visible": false,
"version": "2.10",
"id": "widgets_Legend_Widget_18",
"name": "Legend",
"openAtStart": false, // opens anyway
"index": 1
}
]
}
},
"loadingPage": {
"backgroundColor": "#508dca",
"backgroundImage": {
"visible": false
},
"loadingGif": {
"visible": true,
"uri": "configs/loading/images/predefined_loading_1.gif",
"width": 58,
"height": 29
}
},
"wabVersion": "2.10",
"isTemplateApp": true,
"isWebTier": false,
"httpProxy": {
"useProxy": true,
"alwaysUseProxy": false,
"url": "",
"rules": []
},
"dataSource": {
"dataSources": {
"widget~_27~0": {
"id": "widget~_27~0",
"type": "Features",
"label": "Find Stocked Fish",
"dataSchema": {
"geometryType": "esriGeometryPoint",
"fields": [
{
"name": "OBJECTID",
"type": "esriFieldTypeOID",
"alias": "OBJECTID",
"domain": null
},
{
"name": "Shape",
"type": "esriFieldTypeGeometry",
"alias": "Shape",
"domain": null
},
{
"name": "COUNTY",
"type": "esriFieldTypeString",
"alias": "COUNTY",
"length": 254,
"domain": null
},
{
"name": "WATERBODY",
"type": "esriFieldTypeString",
"alias": "WATERBODY",
"length": 254,
"domain": null
},
{
"name": "FISH_STOCK",
"type": "esriFieldTypeDouble",
"alias": "FISH_STOCK",
"domain": null
},
{
"name": "SPECIES",
"type": "esriFieldTypeString",
"alias": "SPECIES",
"length": 254,
"domain": null
},
{
"name": "SIZE",
"type": "esriFieldTypeString",
"alias": "SIZE",
"length": 254,
"domain": null
},
{
"name": "PHASE",
"type": "esriFieldTypeString",
"alias": "PHASE",
"length": 254,
"domain": null
},
{
"name": "LONG",
"type": "esriFieldTypeDouble",
"alias": "LONG",
"domain": null
},
{
"name": "LAT",
"type": "esriFieldTypeDouble",
"alias": "LAT",
"domain": null
},
{
"name": "Year",
"type": "esriFieldTypeString",
"alias": "Year",
"length": 10,
"domain": null
},
{
"name": "created_user",
"type": "esriFieldTypeString",
"alias": "created_user",
"length": 255,
"domain": null
},
{
"name": "created_date",
"type": "esriFieldTypeDate",
"alias": "created_date",
"length": 8,
"domain": null
},
{
"name": "last_edited_user",
"type": "esriFieldTypeString",
"alias": "last_edited_user",
"length": 255,
"domain": null
},
{
"name": "last_edited_date",
"type": "esriFieldTypeDate",
"alias": "last_edited_date",
"length": 8,
"domain": null
}
],
"displayField": "COUNTY",
"objectIdField": {
"name": "OBJECTID",
"type": "esriFieldTypeOID",
"alias": "OBJECTID",
"domain": null
},
"typeIdField": null
}
},
"widget~_27~1": {
"id": "widget~_27~1",
"type": "Features",
"label": "Find a Waterbody",
"dataSchema": {
"geometryType": "esriGeometryPoint",
"fields": [
{
"name": "OBJECTID",
"type": "esriFieldTypeOID",
"alias": "OBJECTID",
"domain": null
},
{
"name": "FEATURE_ID",
"type": "esriFieldTypeDouble",
"alias": "GNIS ID",
"domain": null
},
{
"name": "FEATURE_NA",
"type": "esriFieldTypeString",
"alias": "Name",
"length": 254,
"domain": null
},
{
"name": "COUNTY_NUM",
"type": "esriFieldTypeDouble",
"alias": "County FIPS Code",
"domain": null
},
{
"name": "PRIMARY_LA",
"type": "esriFieldTypeString",
"alias": "Latitude (DMS)",
"length": 254,
"domain": null
},
{
"name": "SOURCE_LAT",
"type": "esriFieldTypeString",
"alias": "Source Latitude (DMS)",
"length": 254,
"domain": null
},
{
"name": "SOURCE_LON",
"type": "esriFieldTypeString",
"alias": "Source Longitude (DMS)",
"length": 254,
"domain": null
},
{
"name": "SOURCE_L_1",
"type": "esriFieldTypeDouble",
"alias": "Source Latitude",
"domain": null
},
{
"name": "SOURCE_L_2",
"type": "esriFieldTypeDouble",
"alias": "Source Longitude",
"domain": null
},
{
"name": "MAP_NAME",
"type": "esriFieldTypeString",
"alias": "USGS Quad Name",
"length": 254,
"domain": null
},
{
"name": "Shape",
"type": "esriFieldTypeGeometry",
"alias": "Shape",
"domain": null
},
{
"name": "FEATURE_CL",
"type": "esriFieldTypeString",
"alias": "FEATURE_CL",
"length": 254,
"domain": null
},
{
"name": "STATE_ALPH",
"type": "esriFieldTypeString",
"alias": "STATE_ALPH",
"length": 254,
"domain": null
},
{
"name": "STATE_NUME",
"type": "esriFieldTypeDouble",
"alias": "STATE_NUME",
"domain": null
},
{
"name": "COUNTY_NAM",
"type": "esriFieldTypeString",
"alias": "COUNTY_NAM",
"length": 254,
"domain": null
},
{
"name": "PRIM_LONG_",
"type": "esriFieldTypeString",
"alias": "PRIM_LONG_",
"length": 254,
"domain": null
},
{
"name": "PRIM_LAT_D",
"type": "esriFieldTypeDouble",
"alias": "PRIM_LAT_D",
"domain": null
},
{
"name": "PRIM_LONG1",
"type": "esriFieldTypeDouble",
"alias": "PRIM_LONG1",
"domain": null
},
{
"name": "ELEV_IN_M",
"type": "esriFieldTypeDouble",
"alias": "ELEV_IN_M",
"domain": null
},
{
"name": "ELEV_IN_FT",
"type": "esriFieldTypeDouble",
"alias": "ELEV_IN_FT",
"domain": null
},
{
"name": "DATE_CREAT",
"type": "esriFieldTypeDate",
"alias": "DATE_CREAT",
"length": 8,
"domain": null
},
{
"name": "DATE_EDITE",
"type": "esriFieldTypeString",
"alias": "DATE_EDITE",
"length": 254,
"domain": null
},
{
"name": "created_user",
"type": "esriFieldTypeString",
"alias": "created_user",
"length": 255,
"domain": null
},
{
"name": "created_date",
"type": "esriFieldTypeDate",
"alias": "created_date",
"length": 8,
"domain": null
},
{
"name": "last_edited_user",
"type": "esriFieldTypeString",
"alias": "last_edited_user",
"length": 255,
"domain": null
},
{
"name": "last_edited_date",
"type": "esriFieldTypeDate",
"alias": "last_edited_date",
"length": 8,
"domain": null
}
],
"displayField": "MAP_NAME",
"objectIdField": {
"name": "OBJECTID",
"type": "esriFieldTypeOID",
"alias": "OBJECTID",
"domain": null
},
"typeIdField": null
}
}
},
"settings": {}
},
"logoLink": "http://"
}
Thanks!!
... View more
04-16-2019
06:55 AM
|
1
|
2
|
814
|
|
POST
|
Thanks for the suggestions, but I never did get a promise to work no matter what I tried. I know I am leaving out something important, but for now promises are Greek to me. I did find a much simpler solution, however. I knew that there had to be an existing variable some place in one of the js files that already contained the features list, and once I found it (finally!), the rest was a piece of cake!! Sometimes I like to make a mountain out of a molehill. In the item-list.js file: var PHGA_array = [];
if (featureSet.features.length > 0) {
this._showFilteredFeaturesOnLoad(featureSet.features, this._selectedLayer.id);
//creates feature list
this._creatFeatureList(featureSet.features);
var wmaArray = featureSet.features;
wmaArray.forEach(function(feature) {
var id = feature.attributes.PHGA_ID;
PHGA_array.push(id);
});
console.log("PHGA Array ", PHGA_array);
}
... View more
04-10-2019
01:06 PM
|
0
|
0
|
1233
|
|
POST
|
Yes, I totally forgot! But I am still confused as to how to get js to wait until the results are ready. Should I be trying to use a promise.then(), or is there a better way? Honestly, I am still trying to wrap my head around promises, and I have never really been able to get one to actually work! They always seem to NOT wait.
... View more
04-09-2019
01:24 PM
|
0
|
2
|
1233
|
|
POST
|
Robert, The _searchedFeatures are part of the _itemListObject. What is weird is that I can log out the _itemListObject and it appears that the _searchedFeatures and the "Wildlife Maganagement Areas" are there almost immediately. But when I try and get to the WMAs directly with the code: var itemList = _itemListObject;
var wmaArray = itemList._searchedFeatures['Wildlife Management Areas'];
console.log("WMAs ", wmaArray); Here is what I am seeing in the console when I log out _itemsListObject: Do I need to access the _searchedFeatures first before trying to access the "Wildlife Management Areas"? I didn't think it would make much difference. I guess I thought I could just try and go straight to the WMAs and wait for the result before executing and next function.
... View more
04-09-2019
01:05 PM
|
0
|
4
|
1233
|
|
POST
|
I thought this would be very straight forward, but it has turned into an extremely challenging task. I am using the nearme widget to capture features from a polygon layer. The resulting feature attributes can then be used as a filter for an attribute query in a web form. I just need to capture the features, loop through that attributes and return an array of id's, one for each feature. Sounds simple enough, except that it can take up to 8 seconds for the results to populate, depending on the size of the buffer used. I am trying to set up a promise function to wait for the results, and then once captured I can loop through the array and return the ids. I can't seem to get this to work, I just undefined. I think the problem is that it is hard to determine exactly when the results have finished populating. This is what I have tried: _getResultsArray: function(itemList) {
console.log("item list object ", itemList); //is defined!!
var wmaArray = null;
var def = new Deferred();
if (itemList) {
wmaArray = itemList._searchedFeatures['Wildlife Management Areas'];
console.log("WMAs ", wmaArray);
def.resolve(wmaArray);
}
console.log("wma array ", def);
return def.promise;
},
//the above function is called in the _CreateBuffer() function
this._getResultsArray(this._itemListObject).then(lang.hitch(this, function(wmaArray){
console.log("WMAs ", wmaArray); ///returns undefined. Is not waiting for result
}));
I have also tried this without getting any result: this.own(on(this._itemListObject, "load", lang.hitch(this, function () {
var wmaArray = itemList._searchedFeatures['Wildlife Management Areas'];
console.log("WMAs ", wmaArray); //nothing gets logged
})));
This only way I can get the results is by setting a timeout, but this is not a good solution. Even if I set it for 8 seconds, I can still get be undefined if there are a lot of returns! Additionally, if there are only a couple of results, that can be a big problem as well. setTimeout(function() {
var wmaArray = itemList._searchedFeatures['Wildlife Management Areas'];
console.log("WMAs ", wmaArray);
}, 8000);
//this returns an array of features, which is just what I need, but I need a better solution!! Can anyone see what is wrong with the first solution? Am I going about the the wrong way? Thanks for any advice.
... View more
04-09-2019
11:49 AM
|
1
|
6
|
1332
|
|
POST
|
I know that when viewing my app in Firefox browser, the query widget loads before the layer, which causes the layer to be undefined. To deal with this I set a timeout in my function (_getSelectedLayerInformation) within a Promise, which works and returns the correct info. The problem is that in the function is called I am not getting back anything. _getSelectedLayerInfomation: function(){
var map = this.map;
var type = 0;//0 means doesn't select any layer
var layerItem = "FRRP_Subregions";
var glayerIds = map.graphicsLayerIds;
var items = this.layerChooserFromMapWithDropbox.getSelectedItems();
if(items.length > 0){
console.log("layer items length ", items.length);
layerItem = "FRRP_Subregions";
}
return new Promise (function(resolve, reject) {
setTimeout(function() {
var layer = map.getLayer("FRRP_Subregions");
console.log("sub-regions ", layer);
if(layer){
console.log("layer ", layer);
//var layerInfo = layerItem.layerInfo;
//layer = layerInfo.layerObject;
if(layer.url){
console.log("layer url ", layer.url);
if(glayerIds.indexOf(layer.id) >= 0){
//layer exist in map
type = 1;
}else{
//layer exist in MapService
type = 2;
}
}else{
//feature collection
type = 3;
}
}
console.log(type, layerItem, layer);
return {
type: type,
layerItem: layerItem,
layer: layer
};
}, 500);
})
}, The above function gets called inside of this function, but returns nothing. I can't figure out how to set up a promise that actually works that will execute the _getSelectedLayerInformation function and then execute the rest of the code. _featureSetChooser: function() {
this.featureSetChooserForSingleLayer = null;
let info = this._getSelectedLayerInfomation();
info.then(console.log("layer info ", info)); //// returns Promise pending???
if(type > 0){
this.featureSetChooserForSingleLayer = new FeatureSetChooserForSingleLayer({
map: this.map,
featureLayer: info.layer,
updateSelection: false
});
this._selectionHandle = on(info.layer, 'selection-complete', lang.hitch(this, function() {
var oldUseSelectedChecked = this.selectionRadio.getStatus() && this.selectionRadio.getValue();
this._updateSelectedFeaturesCount();
if(oldUseSelectedChecked){
this._updateBuffer();
}
}));
this.own(on(this.featureSetChooserForSingleLayer, 'user-clear', lang.hitch(this, this._onUserClear)));
this.own(on(this.featureSetChooserForSingleLayer, 'loading', lang.hitch(this, lang.hitch(this, function(){
this._clearBufferLayer();
this._onLoading();
}))));
this.own(on(this.featureSetChooserForSingleLayer, 'unloading', lang.hitch(this, lang.hitch(this, function(){
this._onUnloading();
this._updateBuffer();
}))));
this.featureSetChooserForSingleLayer.placeAt(this.featureSetChooserDiv);
//uncheck "Use selected features" option when begin drawing
this.own(on(this.featureSetChooserForSingleLayer, 'draw-activate', lang.hitch(this, function(){
this.uncheckSelectedFeaturesRadio();
})));
}
var draw = query(".jimu-single-layer-featureset-chooser", this.domNode)[0];
console.log("drawbox ", draw);
}, In the above function, the log statement on line 4 returns a pending promise. I am still trying how to implement promises, so I think I am leaving something out, but just can't figure out what that is! Thanks ahead of time for any pointers!
... View more
03-29-2019
11:21 AM
|
0
|
0
|
770
|
|
POST
|
Thanks Robert, That will get me going in the right direction. And If I am reading correctly I should be able to use the Feature Action for both the Query popup and the map popup!
... View more
03-11-2019
08:36 AM
|
0
|
1
|
1043
|
|
POST
|
I want to add a couple of links the the bottom of a popup for a result feature. I was able to do this for the popup that shows when clicking on one of the results in the Query widget results table. This is unfortunately a lot harder to do for the popup that shows when the feature is clicked on the map (the results are a point layer). I cannot find where in the application that the actual 'onClick' event occurs. The links must be added AFTER the point on the map is clicked, so adding them to the template is not as option. This is because the links are dependent on the field value for the clicked feature. For the Query widget popup, I added two functions in the utils.js file: addViewLinkToInfoWindow: function() {
var attSect = query('.attachmentsSection', this.domNode)[0];
var attList = query('.attachmentsSection ul', this.domNode)[0];
var titleDiv = query('.attachmentsSection div', this.domNode)[0];
html.removeClass(attSect, 'hidden');
titleDiv.parentNode.removeChild(titleDiv);
var viewurl = "https://fwc-spdev5.fwc.state.fl.us/FRRP/Sites/Details/3020";
var viewTransect = domConstruct.toDom('<li class="viewSite"><strong><a href="' + viewurl + '" target="_blank">View Site Details</a></strong></li>');
domConstruct.place(viewTransect, attList);
//console.log("attribute list ", attList);
},
addTransectLinksToInfoWindow: function() {
var attSect = query('.attachmentsSection', this.domNode)[0];
var attList = query('.attachmentsSection ul', this.domNode)[0];
var titleDiv = query('.attachmentsSection div', this.domNode)[0];
html.removeClass(attSect, 'hidden');
titleDiv.parentNode.removeChild(titleDiv);
var addurl = "https://fwc-spdev5.fwc.state.fl.us/FRRP/Transects/Add/3020";
var viewurl = "https://fwc-spdev5.fwc.state.fl.us/FRRP/Sites/Details/3020";
var addTransect = domConstruct.toDom('<li class="addTransect"><strong><a href="' + addurl + '" target="_blank">Add or Edit Transect</a></strong></li>');
var editTransect = domConstruct.toDom('<li class="viewSite"><strong><a href="' + viewurl + '" target="_blank">View Site Details</a></strong></li>');
domConstruct.place(addTransect, attList);
domConstruct.place(editTransect, attList);
//console.log("attribute list ", attList);
}, And then I called them in the SingleQueryResult.js file in the _onResultsTableClicked (event) if(transectNum === 2) {
queryUtils.addViewLinkToInfoWindow();
this.map.infoWindow.show(centerPoint);
} else {
queryUtils.addTransectLinksToInfoWindow();
this.map.infoWindow.show(centerPoint);
} If anyone knows where I can add this code so that I can add the same links to the popup resulting from a feature click, can you please let me know. Popups(infoWindows) can be confusing! lol Thank you!
... View more
03-11-2019
07:37 AM
|
0
|
3
|
1159
|
|
POST
|
Thanks Robert, I was able to use the statisticsUtils to get the max value, but it takes a long time to resolve. I know I have to use the Deferred() object to resolve the QueryTask before building the where expression (I tried doing this in the _getWhereInfo function in TaskSetting.js), but could never figure out how to get it to work. Just kept returning a promise instead of the value. I ended up getting it to work by cheating and placing the TaskQuery function in the main Widget.js file so it would get called sooner, I then returned a global variable with the value, so I could use it in the where statement. I know it's a hack, but I will have to keep working on the correct way to do this. This is the function I placed in the Widget.js file: _getBatchNumber: function() {
var sitesUrl = "https://ocean.floridamarine.org/arcgis/rest/services/Projects_FWC/Florida_Reef_Resiliency_Program/MapServer/0";
var queryTask = new QueryTask(sitesUrl);
var batchQuery = new Query();
var statDef = new StatisticDefinition();
statDef.statisticType = "max";
statDef.onStatisticField = "Batch";
statDef.outStatisticsFieldName = "CurrentBatch";
batchQuery.where = "1=1";
batchQuery.outFields = ["Batch"];
batchQuery.outStatistics = [statDef];
batchQuery.returnGeometry = false;
queryTask.execute(batchQuery).then(function(result) {
currentBatch = result.features[0].attributes.MAX_Batch;
//console.log("Max batch value: ", this.currentBatch);
return window.currentBatch;
});
}, ...and from the TaskSetting.js file: _getWhereInfo: function(){
var batchNum = window.currentBatch;
var result = {
status: 0,
where: ""
};
if(this.askForValues){
var newExpr = this.filterParams.getFilterExpr();
var validExpr = newExpr && typeof newExpr === 'string';
if(validExpr){
result.status = 1;
result.where = newExpr;
}else{
result.status = -1;
result.where = null;
}
}else{
result.status = 1;
//result.where = this.currentAttrs.config.filter.expr;
var whereExpr = "Batch = " + batchNum;
console.log("where expression: ", whereExpr);
result.where = whereExpr;
}
if(result.status === 1 && !result.where){
result.where = "1=1";
//return result;
}
return result;
}, Thanks!!
... View more
02-28-2019
01:10 PM
|
0
|
0
|
1966
|
|
POST
|
I have a web application with a Query widget that is pointing to a REST service point layer. The layer is NOT in the map, and will only display the results of a query. The users will be able to perform a spatial query on the layer, but first I want to filter the data via an SQL expression or esri QueryTask so that only a subset of the data is available for the spatial query, if this makes any sense. I can't do a definition query in the mxd because the data get updated regularly, so this needs to be dynamic. Basically I want to look at all of the numbers in a particular field, find the largest number (or most recent batch) and use that number to plug in to the SQL Expression in the TaskSetting.js file (or if there is an SQL property that would do the same thing at the time of the query). This way, when the user performs the spatial query, they will only be querying the latest batch numbers and not the entire dataset. I tried using QueryTask, but this returns feature sets, not the value, and I can't seem to figure out if there is a way to set the where statement to filter out all features except the ones with the highest value in the "Batch" field. I can hard code the expression with the correct value (see line 19), but then I have to update the value every time the data is updated on the server! _getWhereInfo: function(){
var result = {
status: 0,
where: ""
};
if(this.askForValues){
var newExpr = this.filterParams.getFilterExpr();
var validExpr = newExpr && typeof newExpr === 'string';
if(validExpr){
result.status = 1;
result.where = newExpr;
}else{
result.status = -1;
result.where = null;
}
}else{
result.status = 1;
//result.where = this.currentAttrs.config.filter.expr;
result.where = "Batch = 20"; //value hard coded
//console.log("where expression ", result.where);
}
if(result.status === 1 && !result.where){
result.where = "1=1";
}
return result;
}, I tried using "Batch = Max(Batch)" and a few variations, but no luck so far! Maybe I am going about this all wrong?
... View more
02-27-2019
11:13 AM
|
0
|
2
|
2147
|
| Title | Kudos | Posted |
|---|---|---|
| 8 | 10-28-2025 10:15 AM | |
| 2 | 10-14-2025 06:36 AM | |
| 1 | 09-16-2022 09:31 AM | |
| 1 | 06-13-2024 05:45 AM | |
| 1 | 06-26-2025 06:28 AM |
| Online Status |
Offline
|
| Date Last Visited |
a month ago
|