You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -90,13 +91,13 @@ class Recenter extends Widget {
90
91
}
91
92
```
92
93
93
-
Here, we are extending the [Widget][https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html) base class.The [@subclass](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#subclass) decorator is for constructing subclasses off of a given base class. The [Custom Widget guide topic](https://developers.arcgis.com/javascript/latest/custom-widget/#subclass) has more information on using @subclass.
94
+
Here, we are extending the [Widget](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html) base class.The [@subclass](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#subclass) decorator is for constructing subclasses off of a given base class. The [Custom Widget guide topic](https://developers.arcgis.com/javascript/latest/custom-widget/#subclass) has more information on using @subclass.
94
95
95
96
The constructor logic is binding the `_onViewChange()` method to `this` widget instance.
96
97
97
98
#### AddpostInitialize logic
98
99
99
-
The [postInitialize](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#postInitialize) method is called after the widget is created but before the UI is rendered. In this particular case, we will initialize [watchUtils](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#init) to watch for changes to the `View's` [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#center), [interacting](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#interacting), and [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#scale) properties in which it then calls the method, `_onViewChange`.
100
+
The [postInitialize](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#postInitialize) method is called after the widget is created but before the UI is rendered. In this particular case, we will initialize [watchUtils](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#init) to watch for changes to the `View's` [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#center), [interacting](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#interacting), and [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#scale) properties in which it then calls the method, `_onViewChange`.
100
101
101
102
Addthefollowingcodetohandlethis,
102
103
@@ -205,7 +206,7 @@ export = Recenter;
205
206
206
207
### 2.CompilingtheTSXfile
207
208
208
-
Nowthatthewidget's code is implemented, use the TypeScript compiler to compile the _.tsx_ file to its underlying JavaScript implementation.
209
+
Nowthatthewidget's code is implemented, use the TypeScript compiler to compile the _.tsx_ file to its underlying JavaScript implementation.
209
210
210
211
Inthecommandprompt, browsetothelocationofthissampledirectoryandtype`npm run build`. Thiscompilesanyspecified _.tsx_ fileswithinthe _tsconfig.json_'s files to their equivalent _.js_ files. You should now have a new _Recenter.js_ file generated in the same directory as its _.tsx_ file.
211
212
@@ -215,7 +216,7 @@ Now that you generated the underlying _.js_ file for the widget, it can be added
215
216
216
217
#### AddCSS
217
218
218
-
Thewidgetreferencesthe`.recenter-tool' class. Add a style element that references this class as seen below.
219
+
Thewidgetreferencesthe`.recenter-tool' class. Add a style element that references this class as seen below.
219
220
220
221
```css
221
222
.recenter-tool {
@@ -228,7 +229,7 @@ The widget references the `.recenter-tool' class. Add a style element that refe
228
229
z-index: 999;
229
230
}
230
231
231
-
.recenter-tool>p {
232
+
.recenter-tool > p {
232
233
margin: 0;
233
234
}
234
235
```
@@ -265,10 +266,9 @@ require([
265
266
"esri/views/MapView",
266
267
"app/Recenter", // References the custom widget's module
267
268
"esri/layers/VectorTileLayer"
268
-
],
269
-
(Map, MapView, Recenter, VectorTileLayer) => {
269
+
], (Map, MapView, Recenter, VectorTileLayer) => {
270
270
let map, view;
271
-
})
271
+
});
272
272
```
273
273
274
274
Last, initialize the `Recenter` widget then add it to the `view.ui` to place the widget at the `top-right` of the map.
0 commit comments