|
POST
|
It may help to set the outFields parameter on your query to ["*"]; So: var query = featureLayer.createQuery();
query.where = featureLayer.objectIdField + " = " + objectId;
query.outFields = ["*"]; This will ensure that the returned feature has all attribute fields. However, it looks to me like you're trying to fill in the form based on the attributes already in the client. In this code: view.on("click", function(evt) {
unselectFeature();
view.hitTest(evt.screenPoint).then(function(response) {
if (response.results.length > 0 && response.results[0].graphic) {
var feature = response.results[0].graphic;
selectFeature(feature.attributes[featureLayer.objectIdField]);
inputDescription.value = feature.attributes["equipament"];
inputUserInfo.value = feature.attributes["num_i_s"];
form1.value = feature.attributes["lado"];
form2.value = feature.attributes["sustent"];
form3.value = feature.attributes["braco"];
form4.value = feature.attributes["botoneira"];
form5.value = feature.attributes["av_acustic"];
attributeEditing.style.display = "block";
updateInstructionDiv.style.display = "none";
}
});
});
The query is being sent in selectFeature(...) but then you immediately set the fields in the form. This means you're going to be using the attributes that exist in the client before the query returns. This isn't really a problem, assuming the client has the attributes. What's the output if you add a console.log(feature.attributes) right after the selectFeature(...) line? If the attributes are missing at this point, try changing your feature layer constructor: var flayer = new FeatureLayer({
url: <url>,
outFields: ["*"]
}); And see if that helps. If this doesn't help, you could try to set the form fields after the query has returned by moving that logic to the callback in selectFeatures.
... View more
06-02-2017
07:54 AM
|
2
|
1
|
1797
|
|
POST
|
Yeah, you're right. I'm not sure if this is currently supported/easily achievable. Ideally there would be a way to specify that a layer is 'on-the-ground' with an offset to get this effect. But 'on-the-ground' layers ignore the offset. There is a mesh symbol that is probably suitable for this kind of thing: MeshSymbol3D | API Reference | ArcGIS API for JavaScript 4.3 The trouble is, I don't know how to specify a geometry in order to describe a surface (rather than a polygon). It wouldn't be too hard to build your own "mesh geometry" in the browser using view.basemapTerrain.getElevation at some resolution inside your polygon, but I don't see any documentation about how you'd use this data to create geometry in the JS API. Scene layers often use a mesh symbol and can have a geometry type of "mesh." So they're able to draw this kind of thing in a scene. It looks like they use this format to hold the geometry data. You might be able to use arcgis pro to create the geometry you're after and serve it up to the JS API somehow. Another option would be to use externalRenderers to create the geometry you want and render it as part of the scene. I've played around with this using Three.js and it should be doable, though it would take some work. I might reply to this thread later if I get a chance to make a sample for this.
... View more
06-01-2017
10:53 AM
|
0
|
2
|
1949
|
|
POST
|
I suspect you can do this by setting the elevationInfo of the layer in question to relative-to-ground. So: layer.elevationInfo = { mode: 'relative-to-ground' }; I'm not sure if that will work. If it doesn't, another option would be to set the elevationInfo mode to 'absolute' and manually calculate the position of each vertex in the polygon. You can do this with view.basemapTerrain.getElevation(<point>) + offset from terrain (meters). You'd want to do that for each vertex in the polygon to get a new z value for each one.
... View more
06-01-2017
07:44 AM
|
0
|
4
|
1949
|
|
POST
|
Like I said above, I'm unsure if this is doable on an image service. My understanding is that you don't actually have the geometries in the client with the image service, just an image. If you have a feature service or a graphics layer with polygon geometries, here's how I would approach this: 1. Add an on-mouse-move event to the map. 2. When the event fires, loop through every polygon geometry in the layer (first you can filter by the map's current extent to rule out polygons not currently visible). 3. For each polygon check to see if some condition is met. If it is, break from the loop and "snap" to that polygon. Some considerations: 1. You can check for intersection with the extent like this: <Polygon Graphic>.geometry.extent.intersects(<point geometry>) -> true|false. 2. You can use the geometryEngine to check if a polygon intersects a point. You might try this, but the extent check is much faster, which you may want to consider depending on how much polygons you have. Also the extent check may be better If you want a fuzzy search, which it sounds like you might. 3. You might look at geometryEngine.buffer/geodesicBuffer. You could buffer each polygon at some distance and check for the mouse point's intersection with the buffer (or the extent of the buffer). This should give a better fuzzy search. 4. Another option is the geometryEngine's nearestVertex/nearestVertices methods. You could define some distance and check for a vertex in each polygon within that distance, and snap to that polygon if a vertex is found within that distance. This is probably the best solution, but I'm unsure how well it will perform. 5. Something you'll have to consider is what you want to do if the mouse meets your condition for multiple polygons. 6. You may want to add a debounce on the search. Mouse move events trigger a lot, and you probably don't want to do a search for every event. Underscore.js has a debounce function that you can copy if needed: underscore.js 7. "Snapping" the cursor is not allowed in the browser. There is no way to move the cursor programmatically. I imagine this is for security reasons. I would recommend that you replace "snapping" with some kind of highlight to show which polygon the mouse is near.
... View more
05-31-2017
07:55 AM
|
0
|
1
|
1964
|
|
POST
|
You can use text symbols as a workaround, but I agree this is a pretty significant shortcoming.
... View more
05-30-2017
01:36 PM
|
1
|
0
|
584
|
|
POST
|
.on('changes'... will only work on items being added, removed, or moved. If you're just concerned with visibility, you need to watch the visible property on each layer. Here's an example of how you might do this: JS Bin - Collaborative JavaScript Debugging There's a few things to note here: I'm watching for changes on the map.layers collection, because a layer might be added or removed from the map, in which case I want to start watching its visible property (if added) or remove an old watcher (if removed). I'm using a Map to keep track of watchers. This is just a convenient way to associate a layer to a watcher. You don't have to do this if you don't care about cleaning up old watchers. I'm using the esri/core/watchUtils watch method in order to check for changes on the visible property on each layer. You can test this by clicking on the eye icons in the layer list and looking at the console, it should print the layer name and its visibility when it changes. If you want to include basemaps, just change map.layers to map.allLayers everywhere you see it in the sample.
... View more
05-30-2017
11:07 AM
|
1
|
1
|
4478
|
|
POST
|
Hey Jack, I was thinking about this and I realized that there must be a way to transform between ECEF and long/lat/z in the JS API. Sure enough, the esri/views/3d/externalRenderers module exposes this functionality. Normally this module is for creating your own scene and placing it in the same rendering pipeline as the main scene, but you should also be able to use it for coordinate conversions to (and from) ECEF. This functionality is implemented in webGL, which means inputs and outputs are a bit weird: externalRenderers | API Reference | ArcGIS API for JavaScript 4.3 Coordinates are input as an array like this: [longitude1, latitude1, z1, longitude2, latitude2, z2, ...] for as many points as you like. The results will be output in an array with [x1, y1, z1, x2, y2, z2, ...] in meters. You can pass in an empty array and the results be placed in that. You specify the starting index (in your input array) and how many points you want to transform in the function params. Here's an example of how you could find the distance between two points with the same long/lat but a different z: JS Bin - Collaborative JavaScript Debugging This should work for any two points with long/lat/z (must be wgs84 or web mercator), but keep in mind it's the straight line distance, which isn't always what you want. There's also going to be some error here, but, in general, I think this should be pretty good. Also, ECEF is in meters, so the output distance will all be in meters.
... View more
05-30-2017
08:23 AM
|
2
|
0
|
648
|
|
POST
|
Can you clarify what you mean by snapping? Should the mouse "snap" to the edge of a polygon when the user mouses near the polygon? Or should the popup open when the mouse is near a polygon? You may be able to snap to polygons based on their extent and the mouse position. It's fairly cheap to test if a point is located inside an extent, and every polygon has an extent, which is the smallest bounding box around that polygon. I'm not sure the best way to approach this with an image service though. My understanding is that an image service will just serve up an image, which won't differentiate between different polygon geometries. If this is accurate, it seems probable that you'd have to do this kind of a query on the back-end, where the polygon geometries actually exist.
... View more
05-30-2017
07:52 AM
|
0
|
3
|
1964
|
|
POST
|
I was trying to inject some levity into the discussion, apologies if I didn't succeed. It's worth noting that, while a lot of the functionality you mention is missing a plug-and-play solution, the building blocks to accomplish most (maybe all) of those things are exposed in the API. I've had to tackle most of those issues myself, building on top of the API. The building blocks are really what's exciting to me: the potential is there to build some really cool things, in 2D and 3D.
... View more
05-25-2017
12:46 PM
|
0
|
0
|
3713
|
|
POST
|
I'm by no means an expert in this area but here's a brief rundown of my understanding. To start with, I would say that all of these measurements are approximations. None of them take variations in elevation into account (obviously). My understanding is that, for very sensitive measurements, other methods are used. That said, you can get pretty good approximations of the great-circle distance between two points on the earth's surface using the geometry engine. If you have two points with a longitude, latitude, and altitude, the geometry engine won't help (it appears to ignore the altitude), but you have some other options. One of them is to take the average of the altitudes of the two points and find the great-circle distance between the two new points. In practice this gives reasonably good results. The farther the distance between the two points, the greater the error. I would say this is acceptable for most normal use cases. Another is to convert from a long, lat, z coordinate system into a 3 dimensional cartesian coordinate system (ECEF is a commonly used one). Once you have two points in ECEF, you can use the distance formula to calculate the straight-line distance between the two points: let d = Math.sqrt(Math.pow(x1-x2, 2) + Math.pow(y1-y2, 2) + Math.pow(z1-z2, 2)) Here's a stackoverflow question and answer that provides some code that may be helpful if you want to implement either of these options: geometry - Taking altitude into account when calculating geodesic distance - Stack Overflow
... View more
05-25-2017
06:11 AM
|
1
|
2
|
2857
|
|
POST
|
This seems hard to do...mainly because the basemap gallery does not actually change the basemap of the map in question. I have no idea why this is or what the issue is. Anyway, here's a somewhat hacky solution: JS Bin - Collaborative JavaScript Debugging I added a "fake" basemap to the end of the list with a white image (referenced by URL) and a title of "Clear basemap." Clicking on that basemap will toggle the visibility of the basemap on and off. I'm not too familiar with the 3.20 API, so if someone else knows of the correct way to determine the basemap layers on a given map, please feel free to chime in. The way I'm finding them in that example is brittle and probably won't work on a lot of maps.
... View more
05-24-2017
10:15 AM
|
1
|
1
|
4824
|
|
POST
|
You can get the IDs by looking at basemapGallery.basemaps. This will be an array of objects, each of which will have a property called id that points to that basemap's id in the gallery. I think the challenge here will be making a good user experience for removing basemaps from the list. No obvious way to do this occurs to me. Here's an ugly example where control + click will remove a basemap from the list: JS Bin - Collaborative JavaScript Debugging It seems that the event listeners need to be reset after each removal, probably because the entire list gets removed and re-added whenever it changes.
... View more
05-24-2017
08:43 AM
|
1
|
3
|
4824
|
|
POST
|
Do you want to hide the basemap(s)? If so this will hide all basemap layers: // ES6
map.basemapLayerIds.forEach(id => {
map.getLayer(id).hide()
});
//ES5
map.basemapLayerIds.forEach(function(id){
map.getLayer(id).hide()
});
// use .show() to show the layer
To actually remove the layer you can do this: map.basemapLayerIds.forEach(id => {
map.removeLayer(map.getLayer(id));
});
I'm not sure the best way to go about adding this functionality to the basemap widget. I agree that it would be nice if the gallery included this option, but aside from some DOM manipulation, I think your best bet would be locating this functionality somewhere else. Oh, I may have misunderstood. If the goal is to clear the basemap, you can do this with: basemapGallery.remove(<id-of-layer>);
// ids are basemap_0 -> basemap_N It looks like basemaps are displayed in reverse order: so basemap_0 will be the ID of the bottom-right basemap in the widget.
... View more
05-24-2017
07:28 AM
|
2
|
7
|
4824
|
|
POST
|
Nice, that looks cool. Please let us know how it turns out.
... View more
05-23-2017
08:53 AM
|
2
|
0
|
4641
|
|
POST
|
Yep, that looks right to me. The image will always be there if you use a Picture Marker symbol. If you want to have the image only show up when you click it, you could change the symbol when the point is clicked, or you could place the image inside the pop-up when the point is clicked.
... View more
05-23-2017
08:31 AM
|
1
|
2
|
4641
|
| 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
|