|
POST
|
Yes, this can be achieved in 4.x, primarily through the use of a RequestInterceptor. Basically, you'll use the interceptor to capture a print request, get the web map JSON from the request, and then cancel the request before it gets sent. This has several pieces. First, you should define a URL to a print service. Note that in our workflow, a request will never actually get sent to it, but it's best to specify a valid one: var printServiceURL = "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"; Next, somewhere near where your application starts (e.g. where the View is created), you would set up your interceptor: require(["esri/config"], function(esriConfig) {
esriConfig.request.interceptors.unshift({
urls: printServiceURL + "/execute",
before: function(params) {
var error = new Error("cancel");
error._webMapAsJSON = JSON.parse(params.requestOptions.query.Web_Map_as_JSON);
return error;
}
});
}); Elsewhere, you can create a function that accepts a reference to your view, and returns a Promise with the web map JSON: function getWebMapAsJSON(view) {
return new Promise(function(resolve, reject) {
require(["esri/rest/print", "esri/rest/support/PrintParameters", "esri/rest/support/PrintTemplate"], function(print, PrintParameters, PrintTemplate) {
var printTemplate = new PrintTemplate({
//whatever parameters desired
});
var printParameters = new PrintParameters({
//add other parameters as necessary
template: printTemplate,
view: view
});
print.execute(printServiceURL, printParameters).then(function(){}, function(e) {
resolve(e._webMapAsJSON);
});
});
});
} And then elsewhere you can call this function to get the JSON and do whatever you want with it: getWebMapAsJSON(view).then(function(webMapAsJSON) {
console.info(webMapAsJSON);
});
... View more
02-05-2025
10:13 AM
|
0
|
2
|
484
|
|
POST
|
I see what you're talking about. I use SketchViewModel in our applications to support user-drawn geometries, and it doesn't exhibit this behavior. Perhaps your workflows are such that you could use it as an alternative to the Draw module.
... View more
02-03-2025
10:15 AM
|
1
|
0
|
471
|
|
POST
|
You are very generous, especially with such excellent photography. I am already well-rewarded though, so no need to feel like you owe me anything. Have a great weekend!
... View more
01-17-2025
05:24 PM
|
0
|
0
|
627
|
|
POST
|
Ok, I see the problem. In the "manageDynamicSymbology" function, you'll want to change this: if (featureSet.features.length === 0)
featureLayer.renderer = originalRenderer;
else { to this: if (featureSet.features.length === 0) {
if (featureLayer.renderer != originalRenderer)
featureLayer.renderer = originalRenderer;
else
ignoreRendererSet = false;
} else {
... View more
01-17-2025
02:14 PM
|
0
|
2
|
636
|
|
POST
|
I took a closer look at your post from Monday, and think I see the problem. Here is what you posted reproduced for convenience: function zoomRoomUse (ids)
{
require ([
"esri/rest/query",
"esri/rest/support/Query",
"esri/layers/FeatureLayer",
"esri/views/layers/LayerView"
],
function (query, Query, FeatureLayer, LayerView)
{
roomsUseLayer.definitionExpression = roomsUseLayer.objectIdField + " IN(" + ids.join (",") + ")";
// console.log (roomsUseLayer.definitionExpression)
view.whenLayerView (roomsUseLayer).then (function (layerView)
{
var query = roomsUseLayer.createQuery ();
query.objectIds = [ids];
query.where = roomsUseLayer.definitionExpression;
roomsUseLayer.queryFeatures (query).then (function (results)
{
const features = results.features;
var geometry = features[0].geometry.extent.clone ();
for (var k = 0; k < features.length; k++) {
geometry = geometry.union (features[k].geometry.extent.clone ());
view.goTo (geometry).then (function ()
{
roomsUseLayer.visible = true;
manageDynamicSymbology (roomsUseLayer, view);
}).catch (function (error)
{
if (error.name != "view:goto-interrupted") {
console.error (error);
} else {
console.log ("Drawing");
}
});
}
});
});
});
} I think the main problem is that you're calling "manageDynamicSymbology" inside of a loop on line 27. The function manageDynamicSymbology should only ever be called one time, preferably when the layer is created. It never needs to be called again afterwards. For example: var layer = new FeatureLayer({
url: "https://my/url/MapServer/0",
id: "myLayerID"
});
manageDynamicSymbology(layer, view);
view.map.add(layer); Another problem is that you're also calling view.goTo inside the loop, but you want the loop to finish before calling that function. This way, you would only zoom one time to the full extent of the graphics. Here is the updated code: function zoomRoomUse(ids)
{
require ([
"esri/rest/query",
"esri/rest/support/Query",
"esri/layers/FeatureLayer",
"esri/views/layers/LayerView"
],
function (query, Query, FeatureLayer, LayerView)
{
roomsUseLayer.definitionExpression = roomsUseLayer.objectIdField + " IN(" + ids.join (",") + ")";
// console.log (roomsUseLayer.definitionExpression)
view.whenLayerView (roomsUseLayer).then (function (layerView)
{
var query = roomsUseLayer.createQuery ();
query.objectIds = [ids];
query.where = roomsUseLayer.definitionExpression;
roomsUseLayer.queryFeatures (query).then (function (results)
{
const features = results.features;
var geometry = features[0].geometry.extent.clone();
for (var k = 1; k < features.length; k++) {
geometry = geometry.union (features[k].geometry.extent.clone());
}
view.goTo (geometry).then (function ()
{
roomsUseLayer.visible = true;
}).catch (function (error)
{
if (error.name != "view:goto-interrupted") {
console.error (error);
} else {
console.log ("Drawing");
}
});
});
});
});
}
... View more
01-15-2025
11:16 AM
|
0
|
4
|
653
|
|
POST
|
There is a possibility of an infinite loop occurring since setting the renderer will result in the "updating" property being set, and when the "updating" property is set to false, the process starts over again. However, that's what the "ignoreRendererSet" variable exists to prevent, and I don't see any immediate problem with it not doing its job. I would recommend using the browser's developer tools to add some breakpoints and step through the code to help determine where the infinite loop is occurring.
... View more
01-13-2025
06:06 PM
|
0
|
0
|
1333
|
|
POST
|
Yes, you can accomplish this by assigning a value to the suggestionTemplate property. You'll also want to set the outFields property to ensure that values for any fields you use in the template are being returned.
... View more
01-13-2025
02:43 PM
|
0
|
0
|
592
|
|
POST
|
It appears this will happen in cases where (1) a value exists, but no symbol has been defined for it, and (2) there is no default symbol defined. In this case, the feature wouldn't be rendered at all. To avoid the error, you could change the statement on line 34 from: if (defaultSymbol === null) { to if ((defaultSymbol === null) && (originalRenderer.defaultSymbol)) {
... View more
01-13-2025
02:34 PM
|
0
|
2
|
1366
|
|
POST
|
The "Find" sample is working fine, so looks like is still supported. Note that in version 4.20, these modules moved from esri/tasks to esri/rest (more info here). Perhaps you might need to update some references somewhere.
... View more
01-06-2025
02:50 PM
|
0
|
0
|
287
|
|
POST
|
I would recommend watching the updating property on the View. For example: view.watch("updating", function(newValue, oldValue, propertyName, target) {
activityIndicator.style.display = ((newValue) ? "inline" : "none");
});
... View more
01-06-2025
02:44 PM
|
0
|
0
|
314
|
|
POST
|
An alternate way would be to override the delete function: sketchViewModel.delete = function() { }; The above would cause nothing to happen when the delete function is called. If you needed to remove any graphics created by that module, you'd have to use some alternate means, like: sketchViewModel.layer.removeAll();
... View more
12-18-2024
09:22 AM
|
1
|
1
|
540
|
|
POST
|
Follow the instructions in this message, but change "api" in the URLs to "sdk".
... View more
12-12-2024
05:55 PM
|
0
|
0
|
1589
|
|
POST
|
To edit features, you would use: featureLayer.applyEdits({updateFeatures:graphicsArr}) To delete features, you would use: featureLayer.applyEdits({deleteFeatures:graphicsArr})
... View more
12-12-2024
10:56 AM
|
2
|
2
|
1302
|
|
POST
|
Snapping support for these modules was added in v4.30, so wasn't available in 4.26.
... View more
12-12-2024
09:20 AM
|
0
|
0
|
300
|
|
POST
|
This may be a bug in the SDK. One might expect the algorithm to calculate the azimuth first, and then calculate the reverse azimuth off of that value by simply adding or subtracting 180 (depending on whether the calculated azimuth is less than 180 or not, respectively), but that's definitely not the case here, because the SDK is calculating them independently of each other (for the most part). Since it appears the azimuth value is correct, you can just fix the reverseAzimuth value manually after the fact: const bearing = geodesicUtils.geodesicDistance(point1Wgs84, point2Wgs84, "kilometers");
//fix the reverseAzimuth value
bearing.reverseAzimuth = ((bearing.azimuth >= 180) ? bearing.azimuth - 180 : bearing.azimuth + 180);
... View more
12-09-2024
03:54 PM
|
1
|
2
|
636
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Tuesday | |
| 1 | Tuesday | |
| 1 | 2 weeks ago | |
| 3 | 2 weeks ago | |
| 1 | 10-02-2025 01:14 PM |