|
POST
|
You could also require these modules when your application starts up, i.e. in the same call to require that includes your MapView: require(["esri/Map", "esri/views/MapView", "esri/widgets/Sketch", "esri/widgets/Sketch/SketchViewModel"], function(Map, MapView, Sketch, SketchViewModel) {
var map = new Map({
//etc
});
//etc
}); That way, when your existing code executes, those modules will already be available on the client.
... View more
08-17-2023
03:42 PM
|
0
|
0
|
1807
|
|
POST
|
As the documentation states: "The GeoJSON data must comply with the RFC 7946 specification which states that the coordinates are in SpatialReference.WGS84."
... View more
08-17-2023
10:13 AM
|
0
|
0
|
763
|
|
POST
|
The solutions provided are specific to the samples, because that's how your original request was framed. If you copy and paste the code into the samples, you'll see the solutions do work, and do add an opacity slider into the layer list along with the legend. I can't tell why it doesn't work in your application, because I can't access it or its source code. Perhaps since the code I've provided is specific to the samples, maybe you included the condition that restricts the modifications to a layer with the title "Census Tracts" (line 24 in both snippets).
... View more
08-16-2023
07:03 PM
|
0
|
1
|
1842
|
|
POST
|
If by "legend items" you mean "action items", then perhaps this is what you're looking for: require(["esri/WebMap", "esri/views/MapView", "esri/widgets/LayerList", "esri/widgets/Slider"], (
WebMap,
MapView,
LayerList,
Slider
) => {
const map = new WebMap({
portalItem: {
id: "d5dda743788a4b0688fe48f43ae7beb9"
}
});
// Add the map to a MapView
const view = new MapView({
container: "viewDiv",
map: map
});
async function defineActions(event) {
const item = event.item;
await item.layer.when();
if (item.title === "Census Tracts") {
const slider = new Slider({
min: 0,
max: 1,
precision: 2,
values: [1],
visibleElements: {
labels: true,
rangeLabels: true
}
});
item.panel = {
content: ["legend",slider],
open: true,
className: "esri-icon-sliders-horizontal",
title: "Layer Info"
};
slider.on("thumb-drag", (event) => {
const { value } = event;
item.layer.opacity = value;
});
item.actionsSections = [
[
{
title: "Go to full extent",
className: "esri-icon-zoom-out-fixed",
id: "full-extent"
},
{
title: "Layer information",
className: "esri-icon-description",
id: "information"
}
],
[
{
title: "Increase opacity",
className: "esri-icon-up",
id: "increase-opacity"
},
{
title: "Decrease opacity",
className: "esri-icon-down",
id: "decrease-opacity"
}
]
];
}
}
// Add a legend instance to the panel of a
// ListItem in a LayerList instance
const layerList = new LayerList({
view: view,
listItemCreatedFunction: defineActions
});
layerList.on("trigger-action", (event) => {
// The layer visible in the view at the time of the trigger.
const visibleLayer = event.item.layer;
// Capture the action id.
const id = event.action.id;
if (id === "full-extent") {
// if the full-extent action is triggered then navigate
// to the full extent of the visible layer
view.goTo(visibleLayer.fullExtent).catch((error) => {
if (error.name != "AbortError") {
console.error(error);
}
});
} else if (id === "information") {
// if the information action is triggered, then
// open the item details page of the service layer
window.open(visibleLayer.url);
} else if (id === "increase-opacity") {
// if the increase-opacity action is triggered, then
// increase the opacity of the GroupLayer by 0.25
if (visibleLayer.opacity < 1) {
visibleLayer.opacity += 0.25;
}
} else if (id === "decrease-opacity") {
// if the decrease-opacity action is triggered, then
// decrease the opacity of the GroupLayer by 0.25
if (visibleLayer.opacity > 0) {
visibleLayer.opacity -= 0.25;
}
}
});
view.ui.add(layerList, "top-right");
});
... View more
08-14-2023
11:04 AM
|
0
|
3
|
1858
|
|
POST
|
I see what you mean. I don't see a clear answer in the documentation, so I suppose the best approach is through experimentation. If you query an area where you know features exist, but aren't drawn, do you get them in the results? If not, do you get them from a non-spatial query to the layerview? If they come back in a non-spatial query, perhaps you could filter them yourself using geometryEngine.intersects. However, I think there's a larger consideration here. Your workflow is to query these features, and then add them to the view's graphics layer. If some features are too small to be drawn, we might wonder if adding them to the view's graphics really matters, since they won't be visible anyways. If the thought is that they'll be there if the user zooms in, the problem there would be that those geometries would be highly inaccurate, because the FeatureLayerView only has quantized geometries (i.e. generalized geometries that look the same at the present scale), and not the actual geometries stored in the database. If you want the true geometry, you'll have to query the server.
... View more
08-11-2023
10:17 AM
|
0
|
1
|
1820
|
|
POST
|
It's amazing how many realizations occur at that time of day/night!
... View more
08-11-2023
09:53 AM
|
0
|
0
|
1241
|
|
POST
|
If a FeatureLayer has a definitionExpression set, then features that don't match will not exist on the client. Therefore the associated FeatureLayerView can't return those features on a query because it just plain doesn't have them. In that case, your query will need to go to the server instead, like the following: if (layer.type === 'feature') {
layer.queryFeatures(query).then((results: IQueryFeaturesResponse) => {
this.blah = [];
results.features.forEach((result) => {
this.blah.push(result.attributes.objectId);
const graphic = new Graphic(<GraphicProperties>result.geometry);
this._view.graphics.add(graphic);
})
}).catch((queryError) => {
console.log('Query Error');
console.log(queryError);
})
}
... View more
08-10-2023
04:30 PM
|
1
|
3
|
1842
|
|
POST
|
You might also add this to see if it produces an error message: locateBtn.on("locate-error", function(evt) {
alert(evt.error.message);
});
... View more
08-10-2023
04:17 PM
|
0
|
0
|
1255
|
|
POST
|
A good place to start would probably be the browser's developer tools (F12 or Ctrl-Shift-I)...do you see any error messages that get produced for this workflow?
... View more
08-10-2023
12:51 PM
|
0
|
2
|
1258
|
|
POST
|
The documentation says this: "The Locate widget is not supported on insecure origins. To use it, switch your application to a secure origin, such as HTTPS. Note that localhost is considered 'potentially secure' and can be used for easy testing in browsers that supports Window.isSecureContext." This explains it working on localhost, but does your site use https?
... View more
08-10-2023
12:18 PM
|
0
|
0
|
3720
|
|
POST
|
Glad to help, but don't underestimate yourself. You did your homework and asked for help afterwards, which is already more than a lot of people will do. Plus when you did, you gave a good problem description with all the necessary information and source code, which is also more than many do. You made it pretty easy for me actually...
... View more
08-10-2023
12:05 PM
|
1
|
2
|
3724
|
|
POST
|
My bad...it should actually be more like this: //TOGGLE LOCATE BUTTON
var locateBtn = new Locate({
view: view
});
//added code
locateBtn.on("locate", function(evt) {
$("#rLatitude").val(evt.position.coords.latitude.toString());
$("#rLongitude").val(evt.position.coords.longitude.toString());
});
... View more
08-10-2023
10:47 AM
|
1
|
4
|
3730
|
|
POST
|
It doesn't look like it; conditional logic based upon the declaredClass property is spread amongst at least 4 supporting modules (none of which is the Legend module itself).
... View more
08-10-2023
10:14 AM
|
1
|
0
|
2181
|
|
POST
|
The Legend determines internally what layers it supports and doesn't via the layer's declaredClass property. If it isn't a recognized type (e.g. "myproj.classes.layers.CustomFeatureLayer"), then the layer won't be supported. If you don't have any custom logic driven by the declaredClass property, and none of your added properties or methods contain anything terribly conflicting with the default implementation, you can just reset it (preferably with your constructor); this.declaredClass = "esri.layers.FeatureLayer";
... View more
08-09-2023
04:21 PM
|
1
|
3
|
2193
|
|
POST
|
This should do it: //TOGGLE LOCATE BUTTON
var locateBtn = new Locate({
view: view
});
//added code
locateBtn.on("locate", function(position) {
$("#rLatitude").val(position.coords.latitude.toString());
$("#rLongitude").val(position.coords.longitude.toString());
}); See also the documentation for the locate event of the Locate widget.
... View more
08-09-2023
01:34 PM
|
1
|
6
|
3777
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-19-2024 10:37 AM | |
| 1 | 03-31-2026 02:34 PM | |
| 1 | 12-09-2025 09:35 AM | |
| 2 | 12-09-2025 09:06 AM | |
| 1 | 11-26-2025 12:29 PM |