Repository navigation
Expand file tree
/
Copy pathApp.jsx
More file actions
58 lines (47 loc) · 1.36 KB
/
Copy pathApp.jsx
File metadata and controls
58 lines (47 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React, { useRef, useEffect } from "react";
import Bookmarks from '@arcgis/core/widgets/Bookmarks';
import Expand from '@arcgis/core/widgets/Expand';
import MapView from "@arcgis/core/views/MapView";
import WebMap from "@arcgis/core/WebMap";
import "./App.css";
function App() {
const mapDiv = useRef(null);
useEffect(() => {
if (mapDiv.current) {
/**
* Initialize application
*/
const webmap = new WebMap({
portalItem: {
id: "aa1d3f80270146208328cf66d022e09c"
}
});
const view = new MapView({
container: mapDiv.current,
map: webmap
});
const bookmarks = new Bookmarks({
view,
// allows bookmarks to be added, edited, or deleted
editingEnabled: true
});
const bkExpand = new Expand({
view,
content: bookmarks,
expanded: true
});
// Add the widget to the top-right corner of the view
view.ui.add(bkExpand, "top-right");
// bonus - how many bookmarks in the webmap?
webmap.when(() => {
if (webmap.bookmarks && webmap.bookmarks.length) {
console.log("Bookmarks: ", webmap.bookmarks.length);
} else {
console.log("No bookmarks in this webmap.");
}
});
}
}, []);
return <div className="mapDiv" ref={mapDiv}></div>;
}
export default App;