-
Notifications
You must be signed in to change notification settings - Fork 0
/
arcgis-js-sdk-geojson.html
116 lines (101 loc) · 3.89 KB
/
arcgis-js-sdk-geojson.html
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://js.arcgis.com/4.26/esri/themes/light/main.css"/>
<script src="https://js.arcgis.com/4.26/"></script>
<title>Load 45MB RAW GeoJSON with ArcGIS Maps SDK for JavaScript & Esri basemap</title>
<style>#viewDiv,body,html{padding:0;margin:0;height:100%;width:100%}.esri-popup__button--dock,.esri-popup__button.esri-popup__action{display:none}.esri-view-width-xlarge .esri-popup__main-container{width:250px}.esri-feature {letter-spacing: 0em;line-height: 1.55rem;font-feature-settings: "liga"1, "calt"0;background: #fff;padding: 1em;}.esri-feature__content-element{padding: 0}.esri-feature__content-element p{margin:0}.esri-feature.esri-widget{width:400px; display:none}</style>
</head>
<body>
<div id="viewDiv"></div>
<script>
require([
"esri/core/promiseUtils",
"esri/WebMap",
"esri/views/MapView",
"esri/layers/GraphicsLayer",
"esri/widgets/Feature",
"esri/config"
], (
promiseUtils,
WebMap,
MapView,
GraphicsLayer,
Feature,
esriConfig
) => {
esriConfig.apiKey= "<YOUR-API-KEY>";
const webmap = new WebMap({
portalItem: { id: "d1ce356f049d47bea501a80f1485d490" },
basemap: "arcgis-navigation"
});
const view = new MapView({
map: webmap,
container: "viewDiv",
center: [2.069802, 46.9244927],
zoom: 5
});
const graphic = {
popupTemplate: {
content: "Mouse over features to show details..."
}
};
// Provide graphic to a new instance of a Feature widget
const feature = new Feature({
graphic: graphic,
map: view.map,
spatialReference: view.spatialReference
});
feature.when(() =>{
feature.container.addEventListener('mouseover', (event) => {
feature.container.style.display = "none";
})
})
view.ui.add(feature, "manual");
view.when(function() {
const fLayer = webmap.allLayers.getItemAt(1);
fLayer.popupEnabled = false
fLayer.outFields = ["medianIncome2015", "nom"];
view.whenLayerView(fLayer).then((layerView) => {
let highlight;
let objectId;
const debouncedUpdate = promiseUtils.debounce((event) => {
view.hitTest(event).then((event) => {
// Make sure graphic has a popupTemplate
const results = event.results.filter((result) => {
return result.graphic.layer.popupTemplate;
});
const result = results[0];
const newObjectId =
result && result.graphic.attributes[fLayer.objectIdField];
if (!newObjectId) {
highlight && highlight.remove();
objectId = feature.graphic = null;
feature.container.style.display = "none"
} else if (objectId !== newObjectId) {
feature.container.style.display = "block"
highlight && highlight.remove();
objectId = newObjectId;
feature.graphic = result.graphic;
highlight = layerView.highlight(result.graphic);
}
});
});
view.on("pointer-move", (event) => {
feature.container.style.top = (event.y + 10) + "px";
feature.container.style.left = (event.x - 200 + 10) + "px";
debouncedUpdate(event).catch((err) => {
if (!promiseUtils.isAbortError(err)) {
throw err;
}
});
});
});
});
})
</script>
</body>
</html>