Skip to content

Commit 1a74b2f

Browse files
authored
Update to 4.24 and don't use tslib from the CDN (#434)
1 parent d10f4ee commit 1a74b2f

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

4.x/typescript/Recenter/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ The proceeding steps will begin with implementing the widget in the .tsx file.
1717
## Usage
1818

1919
### Implement Recenter TSX file
20+
2021
#### Add dependency paths and import statements
2122

2223
```ts
23-
import {subclass, property} from "esri/core/accessorSupport/decorators";
24+
import { subclass, property } from "esri/core/accessorSupport/decorators";
2425

2526
import Widget = require("esri/widgets/Widget");
2627
import { init } from "esri/core/watchUtils";
@@ -39,7 +40,7 @@ First we're going to create a `Coordinates` type alias. `Coordinates` is an [esr
3940
type Coordinates = Point | number[] | any;
4041
```
4142

42-
Next, we will create a few [Typescript interfaces](https://www.typescriptlang.org/docs/handbook/interfaces.html) to aid in reusing object types.
43+
Next, we will create a few [TypeScript interfaces](https://www.typescriptlang.org/docs/handbook/interfaces.html) to aid in reusing object types.
4344

4445
```ts
4546
interface Center {
@@ -57,8 +58,8 @@ interface Style {
5758
}
5859

5960
interface RecenterParams extends __esri.WidgetProperties {
60-
view: MapView,
61-
initialCenter: number[]
61+
view: MapView;
62+
initialCenter: number[];
6263
}
6364
```
6465

@@ -90,13 +91,13 @@ class Recenter extends Widget {
9091
}
9192
```
9293
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.
9495
9596
The constructor logic is binding the `_onViewChange()` method to `this` widget instance.
9697

9798
#### Add postInitialize logic
9899

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`.
100101

101102
Add the following code to handle this,
102103

@@ -205,7 +206,7 @@ export = Recenter;
205206

206207
### 2. Compiling the TSX file
207208

208-
Now that the widget's code is implemented, use the TypeScript compiler to compile the _.tsx_ file to its underlying JavaScript implementation.
209+
Now that the widget's code is implemented, use the TypeScript compiler to compile the _.tsx_ file to its underlying JavaScript implementation.
209210

210211
In the command prompt, browse to the location of this sample directory and type `npm run build`. This compiles any specified _.tsx_ files within the _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.
211212

@@ -215,7 +216,7 @@ Now that you generated the underlying _.js_ file for the widget, it can be added
215216

216217
#### Add CSS
217218

218-
The widget references the `.recenter-tool' class. Add a style element that references this class as seen below.
219+
The widget references the `.recenter-tool' class. Add a style element that references this class as seen below.
219220
220221
```css
221222
.recenter-tool {
@@ -228,7 +229,7 @@ The widget references the `.recenter-tool' class. Add a style element that refe
228229
z-index: 999;
229230
}
230231

231-
.recenter-tool>p {
232+
.recenter-tool > p {
232233
margin: 0;
233234
}
234235
```
@@ -265,10 +266,9 @@ require([
265266
"esri/views/MapView",
266267
"app/Recenter", // References the custom widget's module
267268
"esri/layers/VectorTileLayer"
268-
],
269-
(Map, MapView, Recenter, VectorTileLayer) => {
269+
], (Map, MapView, Recenter, VectorTileLayer) => {
270270
let map, view;
271-
})
271+
});
272272
```
273273
274274
Last, initialize the `Recenter` widget then add it to the `view.ui` to place the widget at the `top-right` of the map.

4.x/typescript/Recenter/index.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
66

77
<title>Custom Recenter Widget</title>
8-
<link rel="stylesheet" href="https://js.arcgis.com/4.23/esri/themes/light/main.css" />
8+
<link rel="stylesheet" href="https://js.arcgis.com/4.24/esri/themes/light/main.css" />
99

1010
<style>
1111
html,
@@ -27,7 +27,7 @@
2727
z-index: 999;
2828
}
2929

30-
.recenter-tool>p {
30+
.recenter-tool > p {
3131
margin: 0;
3232
}
3333
</style>
@@ -42,9 +42,9 @@
4242
]
4343
};
4444
</script>
45-
<script src="https://js.arcgis.com/4.23/"></script>
45+
<script src="https://js.arcgis.com/4.24/"></script>
4646
<script>
47-
require(["esri/Map", "esri/Basemap", "esri/views/MapView", "app/Recenter", "esri/layers/VectorTileLayer"],(
47+
require(["esri/Map", "esri/Basemap", "esri/views/MapView", "app/Recenter", "esri/layers/VectorTileLayer"], (
4848
Map,
4949
Basemap,
5050
MapView,
@@ -53,14 +53,13 @@
5353
) => {
5454
let map, view;
5555
const tileLayer = new VectorTileLayer({
56-
url:
57-
"https://www.arcgis.com/sharing/rest/content/items/92c551c9f07b4147846aae273e822714/resources/styles/root.json"
56+
url: "https://www.arcgis.com/sharing/rest/content/items/92c551c9f07b4147846aae273e822714/resources/styles/root.json"
5857
});
5958

60-
const basemap = new Basemap ({baseLayers: [ tileLayer ]});
59+
const basemap = new Basemap({ baseLayers: [tileLayer] });
6160

6261
map = new Map({
63-
basemap: basemap
62+
basemap
6463
});
6564

6665
view = new MapView({
@@ -82,4 +81,4 @@
8281
<body>
8382
<div id="viewDiv" class="esri-widget"></div>
8483
</body>
85-
</html>
84+
</html>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "recenter",
3+
"private": true,
34
"version": "3.0.0",
45
"scripts": {
56
"dev": "tsc -w",
67
"build": "tsc"
78
},
89
"dependencies": {
9-
"@types/arcgis-js-api": "^4.23.0",
10-
"tslib": "^2.3.1",
11-
"typescript": "^4.6.2"
10+
"@types/arcgis-js-api": "^4.24.0",
11+
"typescript": "^4.7.4"
1212
}
1313
}

4.x/typescript/Recenter/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"compilerOptions": {
33
"esModuleInterop": true,
44
"experimentalDecorators": true,
5-
"importHelpers": true,
65
"jsx": "react",
76
"jsxFactory": "tsx",
87
"lib": ["DOM","ES2020"],

0 commit comments

Comments
 (0)