|
POST
|
Hi, yes you can do that. Simply move the arcgisRest.UserSession.completeOAuth2() call into the main page. The key is to detect if you're in the state where the access_token has been passed by the URL. One way to do it would be something like this: // Define a global session variable.
let session = null;
// ADDED: ---------------------------------
const clientIdFromURL = new URLSearchParams(window.location.search).get('clientID');
const parsedHash = new URLSearchParams(
window.location.hash.substr(1) // skip the first char (#)
);
var accessTokenFromURL = parsedHash.get('access_token');
// only call completeOAuth2 if we have the clientID and access token:
if(clientIdFromURL && accessTokenFromURL) {
session = arcgisRest.UserSession.completeOAuth2({
clientId: clientIdFromURL,
});
localStorage.setItem('__ARCGIS_REST_USER_SESSION__', session.serialize());
}
// END ADDED SECTION: ---------------------------------
// Check to see if there is a serialized session in local storage.
const serializedSession = localStorage.getItem('__ARCGIS_REST_USER_SESSION__'); If you do this, the thing to think about would be: since you're not doing the "redirect via authenticate.html" thing, the access_token is right in the URL bar: which is not ideal, security-wise. So I would recommend using some JavaScript to remove that.
... View more
03-26-2021
07:36 AM
|
0
|
0
|
3108
|
|
POST
|
Hi, have you tried setting the "popup" property to false in the example (here)? I think that should work fine - let us know if it's not working and we can try to fix. Your redirect URI will be the page that has CompleteOauth2 function call in it - in the sample, that is called here.
... View more
03-25-2021
03:50 PM
|
0
|
2
|
3118
|
|
POST
|
Hi, there are a few ways you can do this: you could use some code to push the data to a Feature Service (in ArcGIS Online or ArcGIS Enterprise) via the REST API (addFeatures endpoint). Alternatively, you could have a process the regularly runs and pulls the data from your third party service into a Feature Service. A third option might be Koop.
... View more
03-04-2021
01:09 PM
|
0
|
0
|
943
|
|
POST
|
Can you please double-check the codepen URL you posted? It currently goes to a blank page.
... View more
01-07-2021
07:55 AM
|
0
|
0
|
1946
|
|
POST
|
One option is to use the Search widget within the Expand Widget. Demo: https://codepen.io/gavinr/pen/NWRGaGw?editors=0010
... View more
12-02-2020
06:06 AM
|
1
|
1
|
1396
|
|
POST
|
Yes that code looks like it should work. Make sure you check if your "distance" variable is actually defined within your function. You can use console.log to see if the value is defined. As a quick attempt, you could also move the line var distance = document.getElementById("buffer").value; within your function "myFunction"
... View more
11-23-2020
06:46 AM
|
0
|
1
|
1752
|
|
POST
|
Hi Henry Pelesh, It looks like you've added a line: const layer = new GraphicsLayer(); that is correct, it creates a GraphicsLayer, but you have not added that layer to the map. After that line you should add: jmv.view.map.add(layer); After you add that line, the drawn shape will stay visible on the map after you draw it.
... View more
09-25-2020
09:13 AM
|
2
|
3
|
5599
|
|
POST
|
Henry, could you please post your widget code that is not working so we can load it up to replicate your issue? Thanks!
... View more
09-08-2020
10:49 AM
|
0
|
6
|
5599
|
|
BLOG
|
Typically the Feature Form widget is used within a side panel, like in this sample.
But what if you want a slightly different workflow where the user draws their boundary and then is prompted with a popup to fill out. We can combine the Sketch widget and the Feature Form widget within a Modal for that effect:
Demo here
... View more
08-24-2020
12:02 PM
|
2
|
0
|
1180
|
|
POST
|
Here's a version using the ArcGIS API for JavaScript version 4.16. It uses the CIMSymbol which is in beta and has some caveats (read those before using): https://codepen.io/gavinr/pen/BaKpbYd See also: Arrows along a line | ArcGIS API for JavaScript 4.16
... View more
08-24-2020
11:14 AM
|
0
|
1
|
5508
|
|
POST
|
This was addressed in the recent esri-leaflet release. We hope this solves your issue. L.esri.FeatureLayer where clause is not always persisting · Issue #1196 · Esri/esri-leaflet · GitHub
... View more
08-06-2020
11:25 AM
|
0
|
1
|
2421
|
|
POST
|
Hi! What program are you using to unzip in that screenshot?
... View more
07-14-2020
09:01 AM
|
0
|
2
|
706
|
|
POST
|
The latest version of the ArcGIS API for JavaScript version 3 (v3.32) has a method called "nearestVertex" - would that work for you? esri/geometry/geometryEngine | API Reference | ArcGIS API for JavaScript 3.32 (you may have to check that this exists at your version, or update to v3.32)
... View more
07-07-2020
06:00 AM
|
0
|
0
|
1412
|
|
BLOG
|
In part 1 of the series, we used TSDX to create a TypeScript+React Component, installed it into the Experience Builder client folder, and included the Component in a custom widget. The widget did not actually do anything though. In this post, we'll go through how to using ArcGIS API for JavaScript within the component, how to interact with the Map object, and how to pass in configuration settings from Experience Builder. Create a Map in the TSDX Example Page Right now, the Example App (what shows when you run npm start in the example folder) is totally empty except for your widget. In an Experience Builder app, your widget will most likely be interacting with other widgets like the Map widget. To mirror this situation in the Example App, we need to include the ArcGIS API for JavaScript directly and create a map object on the page. Lets start in the example directory of your TSDX project. Within there, the structure of components will be: /example index.tsx - already existing main file. We'll update this to contain the Map and Wrapper (below). /components Map.js - a React component responsible for creating and displaying the ArcGIS API for JavaScript Map object. Pass in a function ( viewReady ) to be called when the map is ready and can pass a reference to the View back up to index.tsx . Wrapper.js - The equivalent to our custom Experience Builder widget, in that it "wraps" our custom component. index.tsx passes a reference to the mapView that it gets from Map.js . Map.js To include the ArcGIS API for JavaScript map on the page, we will use the esri-loader and esri-loader-hooks packages. To install these dependencies, browse to the example directory in your terminal then run: npm install --save esri-loader esri-loader-hooks The entire contents of Map.js can be found here. At a high level, we're creating a DOM Node Reference, passing it to useMap (from the esri-loader-hooks library) to create the map, and using useWatch (also from the esri-loader-hooks library). Within the onUpdateChange function, the line const [FeatureLayer] = await loadModules(... is loading the FeatureLayer module from the ArcGIS API for JavaScript so we can use it to create a layer and add to the map. Finally, at the end of the useWatch function, we call viewReady(view) as a "callback" to the parent component to give it a reference to the MapView ( view variable) that we created here in this component. index.tsx In index.tsx , we're importing the two components Map and Wrapper and including them in the JSX. The mapView is passed from the Map component to the Wrapper component via React state (see the setMapView call in the function that is passed as a prop to the Map component). Also in index.tsx, we've created a CSS file and are importing it - basically making the map the full size of the page and hovering the widget over the top of it. Wrapper.js Wrapper.js is the equivalent of the custom Experience Builder wrapper widget that we will build. It is a light-weight "wrapper" and includes our component directly. The first prop that we pass into our component is the mapView - that comes directly from the parent component, index.tsx . We will use the Experience Builder infrastructure to load any ArcGIS API for JavaScript modules we need to use, so this widget should mirror that. To do this, we use the loadModules module from esri-loader and load whatever we want and pass it into our component as the second prop, modules . Our widget is going to operate on a Feature Layer, so the third prop is the string ID of the Feature Layer we're working with. In this example app we know it because we created the Feature Layer ourselves in Map.js , but in Experience Builder that will be configured in the Builder interface and will be passed into our component from the config. package.json One last step is to include the browserslist property in your package.json file. This fixes an error that happens because the app is trying to support older browsers. All the changes for this step are summarized here. Update the Component Since we'll be using the ArcGIS API for JavaScript, first we setup our component to use the type definitions. First run: npm install --saveDev @types/arcgis-js-api Then add this as the first line to src/index.tsx : /// <reference types="@types/arcgis-js-api" /> This tells the TypeScript compiler to use these types, and now you can use the variable __esri to refer to any types in the ArcGIS API for JavaScript. Next, build out the new functionality for your widget. This is where your widget will deviate from our example. In our example, we're creating a Sketch widget and doing a query against the Feature Layer to find the number of intersecting features after each drawing. Full code is here. Update the Experience Builder Widget In part 1, we created a basic wrapper around the component, which did not take any props as input. In this part 2, the component will now take three props: the MapView, the modules, and the Feature Layer ID. We added these to the Example App above, and similarly they must be added to the Experience Builder widget. Unlike the Example app above where we had to install and import esri-loader (to get access to the ArcGIS API for JavaScript) and create a map, in Experience Builder we already have those - you can simply drag the Map object into the Experience. We do have to configure the custom widget to know which map widget it should operate on, so that's what we'll do first. Start up Experience Builder and setup your custom widget per the instructions in part 1. Then, in your Experience, add a Map widget. You probably want to choose a web map that contains the layer you're using in the Example App, but not totally necessary. Next, create a Settings panel to allow the Experience Author to choose the Map and LayerID. To do this, create src/settings/settings.tsx and other required files, and use the JimuMapViewSelector and the JimuLayerViewSelector . Full code is here. Next, update the widget code ( src/runtime/widget.tsx ) to pass in the props to the component. I'll go through each of the three props below. 1. MapView When the user chooses a Map in the Settings panel that we created above, the config useMapWidgetIds gets set. To use this to get the MapView in the widget, use the JimuMapViewComponent to put the jimuMapView into state it can be used. {this.props.hasOwnProperty("useMapWidgetIds") &&
this.props.useMapWidgetIds &&
this.props.useMapWidgetIds.length === 1 && (
<JimuMapViewComponent
useMapWidgetIds={this.props.useMapWidgetIds}
onActiveViewChange={(jmv: JimuMapView) => {
if (jmv && jmv.view) {
this.setState({
jimuMapView: jmv,
});
}
}}
/>
)} After that is set, we can update the component, passing in this state: <MyWidget
mapView={this.state.jimuMapView ? this.state.jimuMapView.view : false} 2. featureLayerId Similar to above, the Feature Layer ID gets set in the Settings. This one is simpler than JimuMapView though since it's just a string, all that is needed is to update the JSX: <MyWidget
mapView={this.state.jimuMapView ? this.state.jimuMapView.view : false}
featureLayerId={this.props.config.layerId} 3. modules To instruct Experience Builder to load the ArcGIS API for JavaScript for us, update the widget's manifest.json file to include a dependency property: "dependency": ["jimu-arcgis"] This allows the inclusion of modules directly in our widget like this: const Sketch = require("esri/widgets/Sketch"); ... and then just pass these imports as an array in the JSX, so our final component in our widget JSX will look like: <MyWidget
mapView={this.state.jimuMapView ? this.state.jimuMapView.view : false}
featureLayerId={this.props.config.layerId}
modules={[Sketch]}
></MyWidget> (full code) Completed Component and Widget When complete, you can include your widget with an Experience to get something like this, all while still able to use your component in a React app like this. The full, completed code for this tutorial can be found here (component) and here (Experience Builder widget wrapper). Thanks for reading, and use the comments for questions, discussion, and links to the widgets you've built.
... View more
07-01-2020
07:20 AM
|
2
|
1
|
2932
|
|
POST
|
Henry and Ricky, we are tracking this issue here: L.esri.FeatureLayer where clause is not always persisting · Issue #1196 · Esri/esri-leaflet · GitHub
... View more
06-23-2020
10:01 AM
|
0
|
0
|
2421
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-26-2019 11:05 AM | |
| 1 | 03-06-2024 07:59 AM | |
| 1 | 12-29-2022 01:20 PM | |
| 1 | 06-21-2022 06:17 AM | |
| 1 | 07-08-2022 06:45 AM |
| Online Status |
Offline
|
| Date Last Visited |
08-06-2025
05:59 AM
|