POST
|
Hi Pierre, It was a bad idea for me to have mentioned that approach (for exactly this reason, among others). A better approach would be creating your own function for querying graphics and feeding the results into the popup. You can see an example of how to do this here (scroll down a bit for two examples). In this case, you could write a function to query for all graphics in your layer using an extent centered on where you click: here's an example based on your sample. The downside of this approach is that you need to pick a number of pixels to search in, which isn't ideal, but it works (I set it to 10 in that example, but realistically it should be adjusted based on your symbol size). Alternatively, I checked your sample against the upcoming release of the API and it seems to work perfectly there.
... View more
09-06-2018
08:25 AM
|
1
|
0
|
949
|
POST
|
According to the feature layer docs, it's possible for the url property to point to the service root and for the layerId property to specify the index of the service, or for the url to include the index. So you could use the layerId property to distinguish between your two layers here. You could access these layers in a few ways. If you know that this app will always have a webmap with two layers, you could do: // webmap.layers is a esri/core/collection of layers excluding the basemap layers
var layer1 = webmap.layers.getItemAt(0);
var layer2 = webmap.layers.getItemAt(1); But if the webmap changes, your app could break. Alternatively, you could use the url and layerId to find the layers you want: var featureServerURL = "https://giswebnew.dotd.la.gov/arcgis/rest/services/DevTemp_Data/FreeValWorkzone_Pilot/FeatureServer"
var layer1 = webmap.layers.find(function(layer) {
return layer.url === featureServerURL && layer.layerId === 0;
});
var layer2 = webmap.layers.find(function(layer) {
return layer.url === featureServerURL && layer.layerId === 1;
});
// but maybe it would be better to write a function and cover both cases
function findLayer(url, layerId, map) {
return map.layers.find(function(layer) {
return (layer.url === url && layer.layerId === layerId) ||
(layer.url === url + "/" + layerId);
});
}
var layer1 = findLayer(featureServerURL, 0, webmap);
var layer2 = findLayer(featureServerURL, 1, webmap); The docs also specify that, in the case where the url points to the service root and no layerId is given, the layer will pull in the first layer in the service. This may not be relevant for your case, but just something to keep in mind.
... View more
03-14-2018
06:43 AM
|
1
|
1
|
1872
|
POST
|
Hi, Looks to me like the issue here is the version of the API you're using. 4.4 doesn't support autocasting renderers and symbols (that is, creating a renderer without using the constructor) - that functionality was added in 4.5. So, if you're using 4.4, you'll need to pull in UniqueValueRenderer and SimpeLineSymbol and use them as classes. I made a few changes and here's the result: JS Bin - Collaborative JavaScript Debugging One thing I changed was how you determine the layer to search. I just hardcoded your layer's URL. Another change I made is using a ClassBreaksRenderer instead of a UniqueValueRenderer. Since you're interested in highlighting all features in a range, that seems like the right choice. A final thing to note is that you may not actually have to do a query here since the min and max segment ids are available pre-query. You could just construct the renderer with that information. Here's another version that does the same thing without the query: JS Bin - Collaborative JavaScript Debugging
... View more
02-26-2018
02:01 PM
|
0
|
5
|
1872
|
POST
|
Try setting the "resultSymbol" property on the Feature Layer Source. This sample has two Feature Layer Sources, I've set the first one so it will use a blue Simple Fill Symbol: JS Bin - Collaborative JavaScript Debugging (To trigger a search, just click the Search and select "Use current location").
... View more
01-30-2018
11:47 AM
|
1
|
1
|
1890
|
POST
|
Hi Scott, I'm not sure if this will be ready in 4.7. I should point out that Feature Layers in a Map View can be highlighted if webGL is used to render them. This capability is marked as beta, you can read more about it here (including how to enable it): FeatureLayer | API Reference | ArcGIS API for JavaScript 4.6 If this isn't an option, I think your best bet would be to watch the "selectedFeature" property on the popup: JS Bin - Collaborative JavaScript Debugging Using that approach, you'll have to decide how to highlight each geometry type. In that sample, a new polygon is added that outlines the feature returned from identify that is currently shown in the popup. For point geometries, you'd probably want to highlight things a little differently. Here's another SDK sample that shows how you might approach highlighting a point: ArcGIS API for JavaScript Sandbox (click on a feature to highlight). As far as the difference between selecting a feature and clicking on it, if you watch the "selectedFeature" property, you're just assuming whatever feature the popup is currently displaying is selected. You can manually add features to the popup (and therefore select them) as in the identify sample, using popup.open: Popup | API Reference | ArcGIS API for JavaScript 4.6. Or, depending on the layer and what kind of search you want to perform on click, you could take advantage of the built-in popup functionality, like this: JS Bin - Collaborative JavaScript Debugging.
... View more
01-30-2018
06:26 AM
|
1
|
3
|
1890
|
POST
|
Okay, I think I understand your point. You're interested in a zoom event, but you'd like to intercept the event at a point before the zoom has actually occurred. You're commenting that the only way to do this is to watch for "double-click," "mouse-wheel," "+", and "-," and add a callback to each of these events separately, and this is inconvenient. That's a really good point, I can see how it would be helpful to allow a user to listen for a "zoom" event, inspect the event object, see what user input had triggered it, and decide on what to do from there. Unfortunately I don't think there's a built-in way to do this.
... View more
12-12-2017
01:17 PM
|
1
|
2
|
1693
|
POST
|
You can watch any property that is an accessor property. Most classes in the 4.XX JS API inherit from accessor (Accessor | API Reference | ArcGIS API for JavaScript 4.5 ), which allows properties to be watched. Drag is different as it is a mouse event that can registered on a view. https://codepen.io/solowt/pen/opNaXo?editors=1000 esri/core/watchUtils is useful for more complex stuff than just watching for a property change. Really? An event as significant as zoom, drag are all inferred by watching the stationary flag? I'm not sure what you mean by this. If I wanted to watch zoom for changes I would use view.watch("zoom", callback);
... View more
12-12-2017
11:41 AM
|
0
|
5
|
1693
|
POST
|
The Feature Layer won't attempt to load unless you add it to the map or manually load it. So try returning new FeatureLayer({ ... }).load(), or add the Feature Layer to your map before returning it. I should note, I'm not sure if a sublayer in a MapImageLayer can be a FeatureLayer.
... View more
12-12-2017
10:58 AM
|
1
|
1
|
3117
|
POST
|
Nice job figuring this out from the minified code! I don't see an easier way to do this without bringing in more of the undocumented API, but I do think it's something that could be exposed to the user without too much trouble in the future. My feeling is that your change isn't going to break anything for now, and as long as you test it with each update, you'll probably be fine. Fair warning though, I'm not particularly knowledgeable about this part of the API, and it's not clear to me why the JS API doesn't just use the browser's request queue. Yann Cabon might have some better advice
... View more
12-12-2017
10:40 AM
|
1
|
0
|
1171
|
POST
|
My feeling is that the sketch tool is mainly aimed at 2D. Drawing in 3D is a more complicated task. You can set things up to "draw" on 3D objects: https://codepen.io/solowt/pen/MrWOvV?editors=1000 (hold control + drag to draw). The key here is that each drag event has an x, y in pixels that is transformed into a point with x, y, and z in world coordinates, so we're just adding a new x, y, z vertex to the polyline for every drag event. The x, y, z coordinates will respect terrain and 3D Objects, allowing us to draw with respect to whatever the x, y in pixels is intersecting, whether it's terrain or a 3D Object. To change how graphics are placed in a Scene View, you can adjust a layer's elevationInfo. You can check out the API documentation for the elevationInfo property on various layers to see how this works. { mode: "relative-to-scene" } may give you something closer to what you're looking for. I would say that for drawing in 3D, if you have to deal with 3D Objects, your best bet for now is to write your own draw tools, similar to the sample I posted, and tailor it to your use case. Keep in mind that "drawing in 3D" is hard to define and you're going to run into lots of weirdness, especially when it comes to drawing Polygons, but also with Polylines. I drew from this perspective, and it looks like what I want: But after rotating the camera, I see I've really drawn this geometry:
... View more
12-12-2017
08:53 AM
|
2
|
1
|
1569
|
POST
|
As per Networking · React Native, it looks like React Native implements the fetch API and also allows you to make HTTP requests from JS via XMLHTTPRequests. So Geoprocessing tools and other networking related things in the JS API may work, though there may be friction in places where the JS API relies on the browser API (browser cookies for example). I should point out that you don't technically need the JS API to make requests to geoprocessing tools. All you need to do is send HTTP requests to the proper URL with the proper parameters and wait for the response. The JS API just provides a wrapper around that process. It may be less of a headache to pull in a simple promise-based HTTP library (like GitHub - axios/axios: Promise based HTTP client for the browser and node.js) and write your own wrapper around the geoprocessing API. You can find more information about the Geoprocessing API here: ArcGIS REST API.
... View more
12-12-2017
06:34 AM
|
1
|
1
|
1781
|
POST
|
I've never used React Native so I can't say anything definitive. My understanding is that you can write JavaScript while using React Native, so some parts of the Esri JS API will probably work, similar to how you can get parts of the API to work in Node. Other parts may not work, as React Native does not target a browser and parts of the JS API rely on the browser API. That last part is a problem when it comes to displaying a map and view. I don't see how React Native could translate the whole JS API view rendering process into something that would make sense to Android/iOS. So my guess is that this isn't really possible to use the JS API to render a view in react native. You might have better luck with the ArcGIS Runtime SDKs for Android and iOS. Here's a repo that looks like it has a proof of concept: GitHub - glazou/react-native-arcgis-sdk-demo: Proof of concept - Use ArcGIS Runtime SDK for Android and iOS in React Nat…
... View more
12-11-2017
01:32 PM
|
1
|
3
|
1781
|
POST
|
Here's a sample that does this: JS Bin - Collaborative JavaScript Debugging Every time the zoom changes, a new renderer is set in order to keep each cone the same approximate height/width in pixels.
... View more
12-08-2017
06:01 AM
|
0
|
0
|
787
|
POST
|
My sample uses a renderer to assign a symbol to each graphic. I can change it so that the symbols are set manually on each graphic and it still works: https://codepen.io/solowt/pen/LOadjd?editors=1000#0
... View more
12-08-2017
05:57 AM
|
0
|
0
|
1146
|
POST
|
There's a few ways you could do this. I notice you're using hitTest to see if the user clicked a line segment. This is fine, but you might run into issues where the user clicks close enough to a segment to open a popup but too far to trigger the hitTest. To avoid this, you could do something like this: view.popup.watch("selectedFeature", function(event) {
if (event && event.attributes && event.attributes.CIRCUIT_ID) {
var segId = event.attributes.CIRCUIT_ID;
featureLayer.renderer = generateRenderer(segId);
history.pushState("", document.title, window.location.pathname + window.location.search);
window.location.hash += segId;
}
});
function generateRenderer(id) {
return {
type: "unique-value",
field: "CIRCUIT_ID",
defaultSymbol: featureLayer.renderer.symbol || featureLayer.renderer.defaultSymbol,
uniqueValueInfos: [{
value: id,
symbol: {
type: "simple-line",
color: "orange",
width: 5,
cap: "round"
}
}]
}
}
... View more
12-07-2017
01:21 PM
|
1
|
8
|
1872
|
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
|