Esri / react-arcgis

A few components to help you get started using the ArcGIS API for JavaScript and esri-loader with React
Apache License 2.0
319 stars 79 forks source link

Sketch Layer with SceneView #125

Closed tomrussell closed 5 years ago

tomrussell commented 5 years ago

I'm having trouble working with Sketch layers when using a SceneView container, when the SketchViewModel is initialised in my useEffect hook I get an error saying that it expects the property of view to be of type MapView

I can work with a 2D view layer instead, which is initialising/ functioning correctly, but I've seen in the JS API documentation that Sketch should be compatible (with some limitations) to a Scene layer as well. Does anyone have any idea what could be wrong here?

  useEffect(() => {
    loadModules(['esri/widgets/Sketch/SketchViewModel']).then(([SketchViewModel]) => {
      if (!sketch && graphicsLayer) {
        setSketch(new SketchViewModel({ view, layer: graphicsLayer }));
      }
    });
  }, [graphicsLayer]);
tomwayson commented 5 years ago

Have you tried what you are trying to do outside of React, like in a JS Bin w/ just the ArcGIS API for JavaScript?

tomrussell commented 5 years ago

Yes I have, changing the MapView in this code sample to a SceneView is working how I’d expect

https://developers.arcgis.com/javascript/latest/sample-code/sketch-geometries/index.html

tomwayson commented 5 years ago

Is the version of the ArcGIS API are you using the same as in the JS Bin from the above sample?

Another thing to try would be to create a CodeSandbox w/ React and just esri-loader that does what you are trying to do.

Please provide the versions of all relevant libraries used and links to any JS Bins or CodeSandboxes you create.

tomrussell commented 5 years ago

Think I've found a likely cause for the issue here, I'm loading the Map/ Scene containers with @esri/react-arcgis@4.0.0 which is internally using esri-loader@2.6.0. All other modules in my app are loaded using my own import of esri-loader@2.10.1, which I can see will request 4.12.0 modules from ArcGIS API

I haven't checked through the release notes for the API but perhaps SceneView support for Sketch was added in recent versions - does this sound about right to you?

Is this what you're trying to address with #114 ? Can you suggest a workaround until this is implemented?

tomwayson commented 5 years ago

I don't think you'll have to wait long @tomrussell, once #134 #135 is approved, I'll merge and cut a v5 release for you to try. Your input is welcome on that PR.

rpatelcode commented 5 years ago

Yes I have, changing the MapView in this code sample to a SceneView is working how I’d expect

https://developers.arcgis.com/javascript/latest/sample-code/sketch-geometries/index.html

Can you please share this Sketch react component code I need it.

tomwayson commented 5 years ago

@tomrussell your issue should be fixed as of v.5.0.0

tomrussell commented 5 years ago

Looks great @tomwayson - works a treat, thanks for the effort on putting this together

@rpatelcode this should give you some guidance on where to start - https://codesandbox.io/s/damp-wood-bnzk6

The components I've written were made following the example on the readme - if you're comfortable working with the hooks API you can get pretty far with this method

rpatelcode commented 5 years ago

Here is the component I tried to make it works https://codesandbox.io/s/sketch-map-srsr6 still struggling how to include screenshot like this https://developers.arcgis.com/javascript/latest/sample-code/sceneview-screenshot/index.html

tomwayson commented 5 years ago

@rpatelcode are you experiencing a bug w/ react-arcgis?

rpatelcode commented 5 years ago

NO, it's not a bug, probably don't know how to make it works

tomwayson commented 5 years ago

then I suggest you go open a question on GeoNet