POST
|
My approach would be to add a listener to the collection of client side graphics. You could do this like: view.whenLayerView(featureLayer).then(function(layerView){
layerView.featuresView.graphics.on("change", function(changes){
changes.added.forEach(function(graphicAdded){
// add graphic to list. create a new html element, fill it with information
// from graphic, append it to list. give it a unique id based on the graphic.uid
// if you want to render the graphic's symbol, use renderer as shown above here
})
changes.removed.forEach(function(graphicRemoved){
// remove graphic from list. use graphic uid to find element to remove
})
})
}) You can use the symbolPreview approach I mentioned above to get the symbol for a given graphic.
... View more
03-31-2017
12:05 PM
|
0
|
0
|
1980
|
POST
|
What do you mean by list of features? Do you mean that, for each graphic on the map (AKA feature), you want to want to place that feature in a list somewhere off the map? If so, what information do you want to include in that list? Do you want to see the symbol for each feature in the list? If so you can pull in 'esri/symbols/support/symbolPreview' and use it like this: // feature
var graphic;
// reference to list HTML element
var listRef;
var symbol = graphic.symbol ? graphic.symbol : graphic.layer.renderer.getSymbol(graphic);
symbolPreview.renderPreviewHTML(symbol,{
opacity: 1
}).then(svgElement => listRef.appendChild(svgElement)) If you want to continuously add and remove features from the list, you have several options. You could add a listener to the layerView's collection of graphics and add/remove items from the list as they are added and removed to this map. If this seems too complicated the legend widget might be what you want though. It can be rendered off the map in whatever element you pass in.
... View more
03-31-2017
11:25 AM
|
0
|
7
|
1980
|
POST
|
Is this the example you're referring to? ArcGIS API for JavaScript Sandbox I see a fullExtent being set properly once the layer has loaded. My understanding is that fullExtent is not calculated in the client, rather it is passed from the service. I would check your service and make sure it has a fullExtent. If you're building a featureLayer in the client I doubt fullExtent will be calculated automatically. In this case you may have to calculate it yourself by finding the smallest bounding box that contains all features.
... View more
03-31-2017
08:06 AM
|
1
|
0
|
1142
|
POST
|
It's of course possible that someone else has encountered this bug. For the time being, though, I think there is probably an acceptable workaround. For example, if we only have to worry about one layer, or the sublayers of one layer, we could try something like this: function getVisibleLayerIds(map, layer){
if (layer.sublayers){
return layer.sublayers.filter(sublayer => sublayer.visible).map(sublayer => layer.sublayers.indexOf(sublayer));
} else {
return layer.visible ? [map.allLayers.indexOf(layer)] : [-1];
}
} This could be calculated on click and the result could be passed into the layerId property of IdentifyParams.
... View more
03-30-2017
09:36 AM
|
0
|
4
|
715
|
POST
|
I'd consider it a bug since "visible" doesn't appear to be working, and the documentation for "top" appears to be wrong. It's not clear to me what a layer id is in this situation. You should be able to use Collection.flatten to get all layers + all sublayers and then map that to a list of ids. But what does [0,1,2] refer to here? Are those ids just "index of layer?"
... View more
03-30-2017
09:08 AM
|
0
|
6
|
1404
|
POST
|
By default it looks like identify is run on the top layer only, regardless of client layer visibility. You can change this using the identify params. For instance if you wanted to run identify only on visible layers, you could set the "layerOption" property on the params to "visible." IdentifyParameters | API Reference | ArcGIS API for JavaScript 4.3 If you want to get specific about which layers to query, you can pass an array of layerIds in as the "layerIds" property.
... View more
03-30-2017
08:01 AM
|
0
|
13
|
1404
|
POST
|
I looked into this a little more. Popups are working on multipoint geometries, which is curious because hitTest doesn't work on multipoints. I wasn't sure how the view knows that user clicked on a multipoint without hitTest. I asked a coworker and it turns out that the popupManager uses a spatial query to do this calculation as a fallback if hitTest doesn't return anything. Basically, when you click on the map, an extent is created for each layer based on the pixel size of the graphics in that layer and that extent is tested against all the graphics in that layer. My feeling is that this method is likely temporary until hitTest matures. This might affect your use-case a little bit: if you want to do a spatial query to test if the cursor is intersecting a multipoint, you can. But it will involve creating some geometry to represent where the use clicked and testing that geometry against each graphic in all applicable layers. These tests will spatial tests (something like Extent.intersects or geometryEngine.intersects), so they'll likely be slower than hitTest and you could definitely run into speed issues as the number of graphics increase.
... View more
03-30-2017
07:51 AM
|
2
|
0
|
805
|
POST
|
Are you referring to the layers on the main map being drawn incorrectly at some zoom levels? Looks like a bug to me. I'm really surprised to see that this behavior is linked to adding a layer to the overview map, but it does seem to be. I do notice that, although this issue seems to occur on load no matter what, if you comment out the "mapView.goTo," the layers will correct themselves and seem to not break again as I zoom in and out.
... View more
03-28-2017
12:25 PM
|
1
|
1
|
382
|
POST
|
It looks to me like hitTest is not working on Multipoint geometries in 2D. Multipoints aren't supported at all yet in 3D. Here's a jsbin based on your sample that I used to test: JS Bin - Collaborative JavaScript Debugging . That just gets a bunch of features from a point feature service and adds them as a single multipoint graphic. Sure often, hitTest is not returning anything as you mouse over the graphic. Edit: I should also mention that, because multipoints aren't supported yet in 3D, I've found it useful to just use single point geometries and relate them with some shared attribute field->value. This isn't a great long term solution but it's what my team is currently doing. I also changed the jsbin to use a graphics layer. I'm not sure if hitTest works on view.graphics at all.
... View more
03-28-2017
12:04 PM
|
1
|
2
|
805
|
POST
|
Great point, I forgot about the dojo loader because I don't use it. But it makes perfect sense to use the dojo loader for this sort of thing since you're already using it to pull in Esri modules. Introduction to AMD Modules - Dojo Toolkit Tutorial is a good resource.
... View more
03-23-2017
02:36 PM
|
0
|
0
|
1209
|
POST
|
If I understand correctly, you want to split your JS up into multiple files but share the same context. Browser JavaScript doesn't have the ability to import other JS files by default. But there are lot of tools out there for this like browserify, webpack, or systemjs. These tools work by letting you use import or require statements in your javascript files and handling the complex task of registering files as packages or bundling everything into one file. If your project is small and you don't want to go to the trouble of pulling in a complex library for this, you could just use an object on the global object for things you want to share between JS files. You could do this by attaching an object literal to the window, ie window.myNameSpace = {} You'll be able to attach variables you want to share between files to window.myNameSpace, ie window.myNameSpace.map = new Map(...). Keep in mind that the order your JS will run in matters if you take this approach.
... View more
03-23-2017
01:05 PM
|
0
|
0
|
1209
|
POST
|
I'm unsure about the best way to remove a map and/or a view. Map.destroy and MapView/SceneView.destroy aren't documented in the 4.X SDK, which sometimes means they're a little rough around the edges. I would expect that view.destroy();
view = null as well as removing all your other references to the view should be enough. Looking at the state of the view after .destroy is called, most of its properties are set to null and the suspended property is set to true, so even if you didn't set it to null, it's not going to be doing a whole lot after destroy is called. I can confirm that map.destroy() is throwing an error, but it's not clear to me you would necessarily want to destroy the map when the user toggles the view open and closed, especially if they may toggle that map open again. Can I ask what happens if you leave the map alone and just destroy/recreate the view (based on the original map) when the user toggles the map closed and back open? Another thing to test would be not destroying anything and just changing the visibility of the div containing the view.
... View more
03-23-2017
12:43 PM
|
0
|
1
|
2616
|
POST
|
I don't know the answer here but I'm curious how you got multiple results into the popup in 4.2, I don't think I've seen that working in the 4.X API in general. My understanding is that popups rely on hitTest to search for the feature that was clicked on. (Although in 3D, currently, popups seem to rely on a back-end query for on-the-ground graphics). Since hitTest only seems to return one graphic per layer view, it doesn't seem like multiple graphics in a popup should work right now. If you get a chance, could you try to replicate how you got it working in a simple 4.2 sandbox like: JS Bin - Collaborative JavaScript Debugging ?
... View more
03-23-2017
08:32 AM
|
0
|
4
|
1248
|
POST
|
As far as I know there isn't anything in the Esri JavaScript API to help you with this directly. In JavaScript you can write text to a blob and save the blob as a file. There are lot of hacky ways to do this in JavaScript (an alternate approach is this). None of these are particularly elegant (at least that I'm aware of). Check out the JavaScript File and Blob classes or data URI encoding for more information. You could also use something like this, which should simplify things and support more (all?) browsers. Since you're interested in .docx and/or pdf you're probably going to want to look for some other libraries, unless you want to learn the formats for those kinds of files and construct them manually. This looks promising for pdfs. It looks like it allows you to write text and canvas to a pdf. In general the file support in JavaScript is kind of a mess. It's not hard to write something to a text file and "download" it to the user's file system, but anything other than that and I suspect you're going to have to pull in some libraries.
... View more
03-22-2017
01:26 PM
|
0
|
0
|
365
|
POST
|
Try this: JS Bin - Collaborative JavaScript Debugging In this situation, your layers are already baked into the web map that you'll pulling in. You just have to find the layer in question and edit the infoTemplate property.
... View more
03-22-2017
05:54 AM
|
2
|
1
|
435
|
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
|