POST
|
As of v4.10 of the API the renderNow() method of the feature widget no longer seems to function correctly. Previously in v4.9 the following code snippet would result in the full html being output to the html variable: var div = document.createElement('div'); _graphic.attributes = feature.attributes; var featureWidget = new Feature({ graphic: _graphic, container: div}); featureWidget.renderNow(); var html = div.outerHTML; Using v4.10 - 4.12 results in only placeholder divs being output to the html variable, no actual data. Example output from v4.9: <div class="esri-feature"><div class="esri-feature__size-container"><div class="esri-feature__main-container"><div><font size="2">ID: 2062683<br>GIS Area (SqM2): 23.08</font></div></div></div></div> Example output from v4.12: <div class="esri-feature esri-widget"><div class="esri-feature__size-container"><h4 class="esri-feature__title"></h4><div class="esri-feature__main-container"></div></div></div> If I use a $timeout (as in AngularJS app) and re-check div.outerHTML, it does provided the expected result after a brief pause so I imagine there's now some promise at play under the hood of renderNow().
... View more
07-15-2019
05:05 PM
|
0
|
0
|
301
|
POST
|
My updated code to transform old dateFormat into newer equivalent that works: function onLayerChanged(layer, esri) { var fieldInfos; if (layer.popupInfo) { fieldInfos = _.map(layer.popupInfo.fieldInfos, function (fieldInfo) { if (fieldInfo.format && fieldInfo.format.dateFormat) { // Transform old dateFormat values to new equivalent e.g. "dayShortMonthYear" becomes "day-short-month-year" fieldInfo.format.dateFormat = getDateFormat(fieldInfo.format.dateFormat); } return fieldInfo; }); } _graphic = new esri.Graphic({ popupTemplate: { content: layer.popupInfo ? layer.popupInfo.description : '', fieldInfos: fieldInfos } }); } function getDateFormat(dateFormat) { // Swap any older style dateFormats for newer version switch (dateFormat) { case 'shortDate': return 'short-date'; break; case 'shortDateLE': return 'short-date-le'; break; case 'longMonthDayYear': return 'long-month-day-year'; break; case 'dayShortMonthYear': return 'day-short-month-year'; break; case 'longDate': return 'long-date'; break; case 'shortDateLongTime': return 'short-date-long-time'; break; case 'shortDateLELongTime': return 'short-date-le-long-time'; break; case 'shortDateShortTime': return 'short-date-short-time'; break; case 'shortDateLEShortTime': return 'short-date-le-short-time'; break; case 'shortDateShortTime24': return 'short-date-short-time-24'; break; case 'shortDateLEShortTime24': return 'short-date-le-short-time-24'; break; case 'shortDateShortTime24': return 'short-date-short-time-24'; break; case 'shortDateLEShortTime24': return 'short-date-le-short-time-24'; break; case 'longMonthYear': return 'long-month-year'; break; case 'shortMonthYear': return 'short-month-year'; break; case 'year': return 'year'; break; default: return dateFormat; } }
... View more
08-08-2018
06:28 PM
|
0
|
0
|
931
|
POST
|
I've just noticed that the possible values defined for dateFormat in PopupTemplate | API Reference | ArcGIS API for JavaScript 4.8 is different to the dataFormat detail provided in the layer.popupInfo.fieldInfos returned by ArGIS fr the layer. So I guess this will be the reason for non-applied formatting. Is there a helper method anywhere to convert between the two formats "dayShortMonthYear" > "day-short-month-year". I guess I could write some code to manually swap uppercase chars with a - and lowercase equivalent.
... View more
08-08-2018
06:10 PM
|
0
|
1
|
931
|
POST
|
Thanks for steering me in the right direction John, it's very much appreciated! It's mostly working for me now, but dates are being a problem as the popupInfo.fieldInfos "dateFormat" defined is not being applied. Dates are always being formated as an America date & time rather than the "dayShortMonthYear" defined for the field. All other formats seem to get applied without issue though e.g. number of decimal places for numeric values. Here's the relevant code being used under the AngularJS framework: function onLayerChanged(layer, esri) { _graphic = new esri.Graphic({ // esri/Graphic popupTemplate: { content: layer.popupInfo ? layer.popupInfo.description : '', fieldInfos: layer.popupInfo ? layer.popupInfo.fieldInfos : null } }); } function onFeaturesChanged(features, esri) { _this.parsedFeatures.length = 0; _this.parsedFeatures = _.map(features, function (feature) { var div = document.createElement('div'); _graphic.attributes = feature.attributes; var featureWidget = new esri.Feature({ // esri/widgets/Feature graphic: _graphic, container: div }); featureWidget.renderNow(); return { id: feature.uid, html: div.outerHTML }; }); } This is the popupInfo.description being used from the layer: "<b>Title No:</b> {TitleNo}<br /><b>Owner names:</b> {Owners}<b><br />Type:</b> {Type}<br /><b>Land District:</b> {LandDistrict}<br /><b>Issue Date:</b> {IssueDate}<br /><b>Guarantee Status:</b> {GuaranteeStatus}<br /><b>Estate Description:</b> {EstateDescription}<br /><b>Area:</b> {AREA_HA} ha" Here are the relevant popupInfo.fieldInfos from the layer: Original output html when we were taking the popupInfo.description and populating the attributes manually, without any formatting (html template does not include blue title area): And more advanced html output using esri/widgets/Feature and code above (html template does not include blue title area): As you can see, the Area numeric value is being formatted as defined in popupInfo.fieldInfos, but the Issue Date is not respecting the "dayShortMonthYear" format defined. Any ideas what I might be doing wrong? Perhaps none of the defined formats are being applied and it's all default formatting?
... View more
08-08-2018
05:02 PM
|
0
|
2
|
931
|
POST
|
In 4.8 is it possible to use a PopupTemplate, PopupViewModel or similar and manually add the popupInfo from a layer, along with a desired feature and generate the raw html for use outside of the map? We have a application where were using the layer.popupInfo.description and manually populating the attributes to generate our html, but we'd like to go one step further and also apply the rich formatting that is available under layer.popupInfo.fieldInfos[].format. Or perhaps there is an exposed method somewhere in the JS API that will allow us to apply the fieldInfos to an attribute value one at a time manually?
... View more
08-02-2018
08:41 PM
|
0
|
4
|
1198
|
POST
|
We're authenticating against ArcGIS Portal from an ASP.NET MVC web application using Owin.Security.Providers.ArcGISPortal. For the page that shows the webmap we'd like to re-use the server-side obtained access token, rather than requiring the user to login a 2nd time with the same credentials using the ArcGIS API for JavaScript 3.22. Is there anyway to achieve this? Following the linked example found through the documentation for esri.IdentityManager.registerToken(), I've tried the following method to share the access token: var credentialsJSON = { serverInfos: [{ server: "https://[HOST]", tokenServiceUrl: "https://[HOST]/arcgis/tokens/", adminTokenServiceUrl: "https://[HOST]/arcgis/admin/generateToken", shortLivedTokenValidity: 1800, currentVersion: 10.5, hasServer: true }], oAuthInfos: [], credentials: [{ userId: user.userId, server: "https://[HOST]/arcgis", token: user.userAccessToken, expires: user.userAccessTokenExpiry, validity: 1800, isAdmin: false, ssl: false, creationTime: user.userAccessTokenIssued, scope: "server" }] }; esriId.initialize(credentialsJSON); But I'm still not getting access to the webmap. I see a html login modal over the empty map div with the title "Please sign in to access the item on https://[HOST]/arcgis (b11824af61df463586dad40d1df7abbd)". In the console log I see the following message logged: dojo.io.script error Error: You do not have permissions to access this resource or perform this operation. at Object.g.load (init.js:984) at init.js:87 at c (init.js:103) at d (init.js:103) at a.Deferred.resolve.callback (init.js:105) at c (init.js:104) at d (init.js:103) at a.Deferred.resolve.callback (init.js:105) at init.js:999 at n (init.js:107) and for the network request to https://[HOST]/arcgis/sharing/rest/content/items/b11824af61df463586dad40d1df7abbd?f=json&callback=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback I see the following response: dojo.io.script.jsonp_dojoIoScript1._jsonpCallback({"error":{"code":403,"messageCode":"GWM_0003","message":"You do not have permissions to access this resource or perform this operation.","details":[]}});
... View more
12-12-2017
03:07 PM
|
0
|
0
|
742
|
POST
|
I have an ASP.NET MVC web application that is authenticating users server-side against ArcGIS Portal successfully using Owin.Security.Providers.ArcGISPortal. I would like to use the granted authorization client-side in the browser without requiring the user to login a second time via ArcGIS's JavaScript API v3.21. Does anyone have any pointers regarding how to obtain a relevant token and pass this through client-side to access portal secured web maps, etc.? There is a context.AccessToken that I can obtain via ArcGISPortalAuthenticationHandler and make available as a claim, but when I try to use this manually via a url like so https://myportal.domain.com/arcgis/sharing/rest/content/items/1c3fbebbd4994f94b7e4d91449c2954c/data?f=json&token={access_token} I get an "Invalid token" response back. Any ideas? If you know of a working example for ArcGIS Online then this could also help me as ArcGIS Online and ArcGIS Portal seem to be identical in their mechanics.
... View more
09-28-2017
02:15 PM
|
0
|
0
|
1417
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|