|
POST
|
I'm not sure you're allowed to do this as it presents a security concern. There may be a way around it if you keep poking around though. One way to get similar behavior is to add an action to your popupTemplate. Something like this: JS Bin - Collaborative JavaScript Debugging In that example, clicking on the action in the popup fires a function that looks at the feature in the open popup, takes its "Online" field from its attributes, and opens a new tab.
... View more
08-17-2017
12:27 PM
|
1
|
0
|
1389
|
|
POST
|
You can do it like this in 4.4: view.inputManager.mode = 'pro'; Doesn't look like the inputManager is documented yet. In 'pro' mode, the right mouse button is zoom in/out if you drag the mouse while it's held down.
... View more
08-17-2017
11:21 AM
|
2
|
1
|
1233
|
|
POST
|
You may be able to create a dynamic map image sublayer from a raster: Sublayer | API Reference | ArcGIS API for JavaScript 4.4 Here's a sample that does something similar: ArcGIS API for JavaScript Sandbox Specifically, you're probably interested in a dynamic data layer, which is the source for a single dynamic sublayer: Sublayer | API Reference | ArcGIS API for JavaScript 4.4
... View more
08-17-2017
09:40 AM
|
0
|
0
|
1586
|
|
POST
|
Good to know you've got it working. Ideally the server wouldn't return 200 and an error. I'm not sure what that's about, but maybe it's unavoidable. Would be interested to know why the order of the sublayers matter.
... View more
08-17-2017
09:03 AM
|
0
|
1
|
2577
|
|
POST
|
In the 4.XX API, layers are promises. let fLayer = new FeatureLayer({url: ...});
map.layers.add(flayer);
fLayer.then(fl => console.log('layer is loaded'));
... View more
08-17-2017
08:29 AM
|
0
|
1
|
2327
|
|
POST
|
Thanks for the detailed write-up. I don't know a whole lot about this subject (dynamic sublayers) so I don't know how much help I'll be but I'll give it a shot. One big issue here is that errors are not thrown correctly when the image request fails. For example, in the sample you posted, this request is made: rest call. The server returns an error, but this error seems to go unhandled in the client, and as a result nothing happens. I suspect this is what is happening when you try to get sublayers 12 and 13. Try copying the request URL (filter network tab for export) from the network tab of dev tools into the browser and see if you get back an error when you specify sublayers 12 and 13. In the case of the sample you posted, what goes wrong here is one sublayer (with id 4) is a dynamic layer with a different source, ie is isn't part of the Map Service. You have to specify that this sublayer is a dynamic layer and specify its source explicitly, like in the original code sample. Another thing I noticed while looking at this is that the server doesn't handle export calls (which, by the way, is the call that gets an image from a Map Server) with both dynamicLayers and layers. If you have one dynamic layer, then all sublayers will be specified as dynamic layers in the export request. This is why the parameters change from layers to dynamic layers. For the layers that are part of the Map Service, that Map Service is their source in the dynamicLayers list, and this is specified by their id. For other layers, not included in the Map Service, a separate source needs to be specified. Not being able to handle layers and dynamicLayer is either a design choice or a limitation. But if you specify both dynamicLayers and layers on an export request, layers are ignored. Going a little further here, looking at this example: layers:show:43,44,51,50,36,37,38,1,2,3,53,54,6,8,9,10,55,13,14,15,16,17,22,58,59,25,30,31,32,33 There is no sublayer with id 12 in this list. What I think is happening here is this: When you manually specify to include sublayers 12 and 13, the Map Server is queried for its information, including a list of sublayer ids. The JS code then looks at this information and see that there is no sublayer with id 12. It then sends an export request to the Map Server using dynamicLayers as it assumes that sublayer 12 must be a dynamic layer with a different source. But a different source is not specified. Ideally an error would be thrown here in cases where an alternate source is not specified, but maybe there are some odd edges cases where you would want to send the request. Anyway, the request is made and fails, and that failure is not handled correctly, so there's no user feedback. Long story short, I would try specifying sublayers with id 43 and 44, or any ids that are included in that list. I assume all of your sublayers are sourced from the same Map Service, so you shouldn't need to worry about dynamicLayers at all. As far as your first question, regarding visibility, I'm not sure why this isn't handled correctly. But I think you should be able to manually specify visibility for each sublayer.
... View more
08-17-2017
08:23 AM
|
0
|
3
|
2577
|
|
POST
|
In order to disable popups, you could disabled them on each layer individually. But probably the easiest way to do is to add your own click event like: // this will stop click events from propagating further
let eventCatcher = view.on('click', e => e.stopPropagation());
// this will resume click events
eventCatcher.remove();
... View more
08-16-2017
06:13 AM
|
1
|
1
|
1243
|
|
POST
|
OAuth works fine for AGOL users or Portal users. I agree that that would be a nice convenience method. You could write it yourself though, something like: function checkUserPermissions(token, featureLayerURL){
return esriRequest(featureLayerURL,{
query: {
token: token,
f: 'json'
}
})
.then(r => true)
.otherwise(err => false);
}
... View more
08-15-2017
10:54 AM
|
1
|
0
|
1387
|
|
POST
|
Token are not generated per resource, just per user. So a mapper is generating a token the same way an editor is, their token will just not be accepted when they try to access a resource they don't have permission to view. I'm not sure the best way for you to handle this, but you may want to have users login using OAuth (that's 3.XX). Once the user has logged in, you'll have PortalUser object, which has information about that user's role and privileges. You could check this object and show a warning. Another option is just to add a catch to the code that adds the layers in question. When a tries to view a layer, a request is made to the server for the layer information. If the user doesn't have permission, an error is thrown from within the asynchronous request code. You can tap into this error by adding a .catch(err => <show error dialogue>) to the asynchronous code that is loading the layer(s). It's hard for me to say more without knowing how layers are being added/other specific details about your application.
... View more
08-15-2017
06:59 AM
|
2
|
2
|
1387
|
|
POST
|
I would second this, although I don't think the .getExtent function made it into 4.XX. Also, .expand modifies the extent in place so it's probably best to clone it first.
... View more
08-15-2017
05:53 AM
|
1
|
5
|
5849
|
|
POST
|
Awesome. Good to know elevation layers are supported as long as the spatial references match and the service is cached.
... View more
08-15-2017
05:49 AM
|
1
|
0
|
2522
|
|
POST
|
Is there any special documentation of how to publish a cached elevation service in a projected coordinate system and not global? You might check out this: Publish an elevation image service—Documentation (10.3 and 10.3.1) | ArcGIS for Server Doesn't go into a lot of detail unfortunately. I can`t add ground: "world-elevation" as default there because it will never support the local coordinate system, so I need a custom ground base layer in my appropriate system. That's what the error that gets thrown when you try to add 'world-elevation' suggests to me. You can create a local scene and add 'world-elevation' as the ground and it will work fine: JS Bin - Collaborative JavaScript Debugging as long as the SRs match. I can't guarantee hosting an elevation service in the same SpatialReference as your local scene will solve the problem, but it seems like it should.
... View more
08-14-2017
06:00 AM
|
1
|
0
|
2522
|
|
POST
|
I've used flexbox a lot with the JS API, but I've avoided placing the map div inside a flexbox. I've always isolated the map div from the rest of the page that heavily use flexbox. I may get a chance to try to make a sample that places a map inside a flexbox. Can you provide some details about how your map div is positioned? Is it a item/child within a flexbox?
... View more
08-11-2017
10:30 AM
|
0
|
0
|
931
|
|
POST
|
Robert's answer covers this well, but I would add that the thing to do might be to write your own move function: function move(graphic, geometry){
newGraphic = graphic.clone();
newGraphic.geometry = geometry;
graphic.layer.remove(graphic);
graphic.layer.add(newGraphic);
} This may cut down on boilerplate if moving a graphic is something you're doing a lot. That example work for a graphics layer. For other kinds of layers, it may be more complicated and you should handle each layer type and the view's graphics layer (view.graphics) differently.
... View more
08-11-2017
05:55 AM
|
1
|
0
|
2922
|
|
POST
|
What probably want to do here is: User clicks map: do a hitTest, if a graphic is a found, take that graphic's geometry and continue Using the geometry obtained in step 1, create a circle geometry with the center as the geometry from step 1 and a radius of whatever you like (note, circles can be geodesic if you're using wgs84 or web mercator, default unit for setting radius is meters) Take the extent of the circle you just created (circles, like polygons automatically compute their extent when created. Access this via circle.extent). Test the extent of the circle against all the graphics on each featureLayer you want to search. This can be done manually or with featureLayerView.queryFeatures or with featureLayer.queryFeatures Take the array of graphics that results from step 4 and filter them against the original circle. Use geometryEngine.intersects(circle, graphic.geometry) for each graphic that passed the previous test. The result is an array of graphics that fit inside the circle for each feature layer you tested. You can now compute distance using the geometry Engine, or Point.distance(point) and display the results however you like. It's preferable (in my opinion) to do the extent search first because it's cheap compared to the circle search, and the majority of graphics will likely be eliminated. The geometryEngine.intersects method is more expensive when using a circle or polygon, so this should only be tested against graphics you know are inside the circle's extent. Edit - this is the client-side method. You can also pass in the circle to featureLayer.queryFeatures to do this on the server. If you do this, you'll want to send one featureLayer.queryFeatures request for each featureLayer. You'll wrap these requests in Promise.all(), wait for all of them to return, and then display your results with polylines or however you like. If you use the server, you don't need to worry about the intersects method being expensive so forget the circle.extent stuff for that.
... View more
08-10-2017
12:42 PM
|
1
|
1
|
2334
|
| 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
|