POST
|
I have got it working by reverting back to using JQuery: function setPopupContent(target) { var locationId = target.graphic.attributes.ObjectID; var url = urlGetLocationExtendedPointsData + '/' + locationId; return $.get(url).then(function(data) { var source = $("#map-popup-content-template").html(); var template = Handlebars.compile(source); var context = { RiskQualityChartTitle: data.SiteName } var html = template(context); return html; }); } For some reason the esriRequest was not working. Thanks for your help anyway.
... View more
12-06-2017
08:53 AM
|
1
|
0
|
555
|
POST
|
Is there any difference between the promise returned from return queryBlocksTask.execute(query).then(function(result) and return esriRequest(url, options).then(function (response) ?
... View more
12-06-2017
08:07 AM
|
0
|
2
|
555
|
POST
|
Yes, it works fine when it is just a simple function that returns some HTML. I am having this problem because I want to do an async request. In this scenario, there does not seem to be a way to get the API to actually execute the promise that I am returning.
... View more
12-06-2017
07:52 AM
|
0
|
4
|
555
|
POST
|
I have just tried this - and there is no difference. Thanks anyway. Any other suggestions?
... View more
12-06-2017
07:46 AM
|
0
|
6
|
1232
|
POST
|
I have just tried setting the block to be as below: function setPopupContent(target) { var locationId = target.graphic.attributes.ObjectID; var url = urlGetLocationExtendedPointsData + '/' + locationId; var options = { query: { f: 'json' }, responseType: 'json' }; return esriRequest(url, options).then(function (response) { // THIS CODE IS NEVER EXECUTED! var source = $("#map-popup-content-template").html(); var template = Handlebars.compile(source); var context = { RiskQualityChartTitle: "Chart title" } var html = template(context); return html; }); } The block starting 'THIS CODE IS NEVER EXECUTED' is still never executed, with no message appearing in the console.
... View more
12-06-2017
06:33 AM
|
0
|
8
|
1232
|
POST
|
Thanks for your responses. I have tried the exact block of code above with 'otherwise' and neither the 'then' nor the 'otherwise' are ever called. No request is actually made (according to the Chrome Network tab). It seems that the code that calls my function (buried in the API) never calls the promise I am returning (as far as I can see).
... View more
12-06-2017
06:06 AM
|
0
|
1
|
1232
|
POST
|
Further up in the code (not uploaded to you) I am loading the esriRequest as follows: require([ "esri/Map", ... "esri/request", "dojo/Deferred" ], function (Map, ... esriRequest, Deferred) { The esriRequest and Deferred objects are in-scope to the functions I have uploaded to you. The code before the esriRequest is executing ok (each time that the user clicks a map point / graphic).
... View more
12-06-2017
05:35 AM
|
0
|
13
|
1232
|
POST
|
Summary: My PopupTemplate JavaScript promise for the contents is never being executed. My Requirements: I am attempting to code a feature that will allow the user to click on a graphic in a Feature Layer and see a popup. We have integrated the map into our ASP.Net MVC web application using the JavaScript 4.5 API. I have coded the popup in JavaScript as a Popup Template. When the user clicks on a graphic (that will represent a map pin-point), I need the code to do an (asynchronous) AJAX HTTP GET to an endpoint in order to retrieve a JSON object. The object will contain some data that will be displayed in the popup. I have assigned the 'content' property of my PopupTemplate to my JavaScript function that returns a promise. My Problem: It appears that the promise is never being executed, as breakpoints in my code within the promise are never hit. I have tried several ways to code the promise with no success. I am using esriRequest to actually do the AJAX GET, and returning the promise from this as the function assignment. Please see my attached code. I think the JavaScript API is just executing my function and ignoring the promise that I am returning.
... View more
12-06-2017
03:15 AM
|
0
|
16
|
2486
|
POST
|
I am attempting to implement the Proxy for App Login detailed in the following: ArcGIS Security and Authentication | ArcGIS for Developers However, I am getting the error below when the proxy code is attempting to convert the token 'from a Portal token into a Server token': {"error":{"code":400,"message":"Unable to generate token","details":["Unable to generate token for this server"]}} The code is doing a GET to the following URI: https://www.arcgis.com/sharing/generateToken?token=<token>&serverURL=https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer?f=json&f=json Is there any reason why a token would not be able to be generated for https://services.arcgisonline.com?
... View more
11-08-2017
08:09 AM
|
0
|
1
|
1556
|
Title | Kudos | Posted |
---|---|---|
1 | 12-06-2017 08:53 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|