|
POST
|
Hmm, interesting. I would try this and see what happens: var clonedFeature = editFeature.clone();
delete clonedFeature.geometry;
var edit = {
updateFeatures: [clonedFeature]
}; The first error suggests to me that you can't edit the geometry on the graphic in question. Whether this is a limitation of applyEdits or a setting on your feature service, I'm not sure. That sample will clone the graphic in question and delete the geometry property.
... View more
09-11-2017
09:46 AM
|
1
|
0
|
2556
|
|
POST
|
I think the next thing to check would be the actual request that's being sent, which you can look at in dev tools. Try opening up your browser's dev tools, switch to the networking tab, and click the feature to send the applyEdits request. A new request should pop up in dev tools, take a look at that, and then take a look at the response when the server gets around to responding. This should give you some hints about what's going wrong. You can copy the request/response information here if you like and we can help you go over it.
... View more
09-11-2017
09:12 AM
|
0
|
0
|
2556
|
|
POST
|
Your code looks fine to me. Try adding "outFields: ["*"]" to the FeatureLayer constructor: var flayer = new FeatureLayer({
url: <url>,
outFields: ["*"]
}); The documentation for applyEdits mentions: Values of non nullable fields must be provided when updating features. Also, make sure YearBuilt expects a string. It may expect a number. I'm unsure how the service will handle a string when it expects a number, it may be able to coerce it, or it may just not work.
... View more
09-11-2017
08:46 AM
|
1
|
2
|
2556
|
|
POST
|
In general this is the kind of thing the JS API should handle. That is, you should be able to add a feature service or layer(s) within a feature service, and the JS API should gracefully handle cases where the service doesn't respond. You might get an error in your console, but everything should continue without a hitch. That aside, if you want to check a service to see if it's responding you can fire a GET off to the service page, like Robert mentioned above.
... View more
09-09-2017
10:50 AM
|
1
|
0
|
3177
|
|
POST
|
Can you check to see if the event is firing at all? (Maybe by adding a console to log in there).
... View more
09-08-2017
11:22 AM
|
0
|
4
|
2877
|
|
POST
|
The measure dijit has 'measure-start' and 'measure-end' events. I would try listening for those events and disabling/enabling infotemplates. Something like: var measurement = new Measurement({
map: map,
defaultAreaUnit: Units.SQUARE_MILES,
defaultLengthUnit: Units.KILOMETERS
}, dom.byId('measurement'));
measurement.on('measure-start', event => {
// disable info templates
});
measurement.on('measure-end', event => {
// enable info templates
});
... View more
09-08-2017
10:30 AM
|
1
|
6
|
2877
|
|
POST
|
Elevation data is expected to be encoded using lerc, which is an open source method for encoding (and compressing?) image data: GitHub - Esri/lerc: Limited Error Raster Compression My feeling based on your description and the error message you're getting is that the image service you've set up isn't serving up lerc encoded data and therefore the JS API isn't equipped to handle it. Also, my understanding is that the JS API expects image services suitable for backing elevation layers to be cached, as elevation data is assumed to have various levels of detail. I'm not sure whether an image server license is required for publishing elevation layers, but here's a list of steps to get an elevation layer published: Publish an elevation image service—Documentation | ArcGIS Enterprise Another troubleshooting option would be to compare your image service's page with the world elevation page: WorldElevation3D/Terrain3D (ImageServer). You can see that service page has a TileInfo field that specifies the LODs, and that the format is LERC.
... View more
09-07-2017
12:18 PM
|
0
|
1
|
1428
|
|
POST
|
To follow up, this is caused by a layer view not being entirely set up when hitTest is called. I don't know of a simple way to get around this error. It's an edge case that probably hasn't been noticed because there's only a small ms window when it will occur. You could check the layerView for each layer and make sure each layerView has a controller before proceeding with the hitTest. That's not really ideal, but it would look like this: view.on('click', e => {
e.stopPropagation();
const lyrsReady = view.layerViews.toArray().every(lv => lv.controller);
if (lyrsReady){
view.hitTest(e).then(r => console.log(r));
}
}); The other thing to note is that hitTest is used as part of the popup logic, so it's entirely possible that you'll run into this error even when you're not manually using hitTest, in which case this won't help.
... View more
09-07-2017
07:46 AM
|
1
|
0
|
1859
|
|
POST
|
I'm actually not sure if either of these will fix the issue, looking into this further. May have to do with clicking on the map when the view has loaded, but the layerView for the layer in question is still loading.
... View more
09-06-2017
01:54 PM
|
1
|
0
|
1859
|
|
POST
|
I can replicate this. Seems like a bug to me. You should be able to fix by wrapping your hitTest in a promise that resolves when the view loads, ie: view.on('click', e => {
view.then(v => {
v.hitTest({x: e.x, y: e.y}).then(results => console.log(results));
});
});
// another option would be to only add the click event when the view has loaded
view.then(v => {
view.on('click', e => {
v.hitTest({x: e.x, y: e.y}).then(results => console.log(results));
});
}); Either way, I believe the intended behavior is for the view to warn the user that it's not ready when this happens.
... View more
09-06-2017
09:29 AM
|
1
|
2
|
1859
|
|
POST
|
There's no way to do this in JavaScript that I know of. JS doesn't have direct access to the machine's networking capabilities. This looks like an open source python solution to your problem, but there's no way to run it in the browser. GitHub - schollz/howmanypeoplearearound: Count the number of people around you by monitoring wifi signals I imagine there are a lot of solutions for this problem, and some of them will involve buying hardware.
... View more
09-05-2017
06:34 AM
|
0
|
0
|
874
|
|
POST
|
What do you mean by size of the scene? If you want the distance between the left edge of the sceneview and the right edge, then I would just find the distance between those two points. You'll have to decide whether you want a planar or geodesic measurement. Here's a code sample for this: // pull in esri/geometry/geometryEngine and esri/geometry/Polyline
// args: sceneView: SceneView, planar: boolean
function getSceneWidth(sceneView, planar){
let leftBound = {x: 0, y: sceneView.height/2}; // left edge of scene in pixels
let rightBound = {x: sceneView.width, y: sceneView.height/2} // right edge of scene in pixels
// iterate along scene until we have a valid point
// this is necessary if the scene is zoomed out and the
// left/right edges are in space
while(!sceneView.toMap(leftBound)){
leftBound = { x: leftBound.x + 1, y: leftBound.y };
}
while (!sceneView.toMap(rightBound)){
rightBound = { x: rightBound.x - 1, y: rightBound.y };
}
let p1 = sceneView.toMap(leftBound);
let p2 = sceneView.toMap(rightBound);
// planar measurement
if (planar) {
// find in meters, divice by 1000 to get to km
return p1.distance(p2) / 1000;
} else {
// geodesic measurement
let polyline = new Polyline({
paths: [ [p1.longitude, p1.latitude], [p2.longitude, p2.latitude] ],
spatialReference: { wkid: 4326 }
});
return geometryEngine.geodesicLength(polyline, 'kilometers');
}
} Another option is to take the ratio between some distance in meters (or whichever linear unit) and that same distance in pixels and use that to convert. The issue with this method in a sceneview is that that ratio will vary based on where on the globe you're measuring, even at the same zoom.
... View more
09-05-2017
06:26 AM
|
2
|
0
|
1030
|
|
POST
|
Here's an updated sample that fixes the winding issues and uses the elevationLayer.queryElevation method rather than a client-side query: rather JS Bin - Collaborative JavaScript Debugging
... View more
09-01-2017
11:31 AM
|
0
|
2
|
2786
|
|
POST
|
I believe you could this via the REST API. To edit a layer within a feature service: ArcGIS REST API The thing to note here is that these kinds of calls allow you to redefine everything about a feature service/layer within a feature service, so it's easy to mess something up. I'm not sure what domain JSON looks like exactly, but you should be able to get JSON for a feature layer, edit the domains on it, and post it using the above call. edit- I should say that I don't believe there's a JS API wrapper around that REST call, but you can use esri/Request to make the request.
... View more
09-01-2017
09:53 AM
|
0
|
0
|
958
|
|
POST
|
I didn't mean to imply that it was broken, which would mean that there's a bug to be fixed. That isn't the case as far as I know. My understanding is that some work needs to be done to deliver this functionality. I agree that this should work. But there are workarounds. For feature layers, I suggest you use a definition expression to show/hide certain features. For graphics layers you can probably get away with cloning and flipping the visibility property of the clone. Something like this: // for graphics layer
// clone graphic and toggle visibility, remove old graphic and add clone
function toggleVisibility(graphic){
if (graphic.layer && graphic.layer.declaredClass === 'esri.layers.GraphicsLayer'){
const clone = graphic.clone();
clone.visibility = !graphic.visibility;
graphic.layer.remove(graphic);
graphic.layer.add(clone);
}
}
// for feature layer
// keep track of hidden graphics
let hiddenGraphics = []
// takes objectIdField and array of graphics and returns a definition expression
// to hide all those graphics
function getDefExpression(oidField, graphicsArray){
return graphicsArray.reduce((accum, curr) => {
if (accum.length === 0){
return `${oidField} != ${curr.attributes[oidField]}`;
} else {
return `${accum} AND ${oidField} != ${curr.attributes[oidField]}`;
}
},"");
}
// takes a graphic and uses the above function and array to toggle its visbility
// via definition expression
function toggleVisibility(graphic){
const layer = graphic.layer;
const oidField = layer.objectIdField;
if (layer && layer.declaredClass === 'esri.layers.FeatureLayer'){
let idx = hiddenGraphics.indexOf(graphic);
if (idx >= 0){
hiddenGraphics.splice(idx, 1);
} else {
hiddenGraphics.push(graphic);
}
layer.definitionExpression = getDefExpression(oidField, hiddenGraphics);
}
} Here's a sample for feature layers. Click on graphics to hide them: JS Bin - Collaborative JavaScript Debugging
... View more
09-01-2017
09:02 AM
|
0
|
0
|
4058
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-03-2017 08:23 AM | |
| 1 | 11-02-2017 08:36 AM | |
| 1 | 11-02-2017 09:23 AM | |
| 1 | 09-20-2017 02:07 PM | |
| 1 | 10-06-2017 05:54 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:24 AM
|