map2 = {
const container = html`<div id="viewDiv" />
<style>
#viewDiv {
height: 600px;
width: ${width}px;
}
</style>
`;
yield container;
const map = new ArcGIS.Map({
basemap: "arcgis-topographic",
ground: "world-elevation"
});
const mapView = new ArcGIS.MapView({
map,
center: [-122.27, 37.8],
padding: {
top: 16,
right: 16,
left: 16,
bottom: 16
},
zoom: 13,
container,
navigation: {
mouseWheelZoomEnabled: false,
browserTouchPanEnabled: false
}
});
const geojsonRenderer = new ArcGIS.SimpleRenderer({
symbol: new ArcGIS.SimpleLineSymbol({
width: 0,
color: "#fb12ff"
})
});
const geojsonLayer = new ArcGIS.GeoJSONLayer({
url: dataUrl,
renderer: geojsonRenderer
});
map.add(geojsonLayer);
geojsonLayer
.when(() => {
return geojsonLayer.queryExtent();
})
.then((response) => {
mapView.goTo(response.extent);
});
const polyline = new ArcGIS.Polyline({
paths: coordinates
});
const polylineSymbol = {
type: "simple-line",
color: [226, 119, 40],
width: 2.5
};
const polylineGraphic = new ArcGIS.Graphic({
geometry: polyline,
symbol: polylineSymbol
});
mapView.graphics.add(polylineGraphic);
const elevationProfile = new ArcGIS.ElevationProfileViewModel({
view: mapView,
input: polylineGraphic,
unit: "imperial",
profiles: [
{
type: "input",
color: "#f57e42",
title: "Line elevation"
}
]
});
const handlerStats = ArcGIS.reactiveUtils.watch(
() => elevationProfile.profiles.items?.[0]?.statistics,
(statistics) => {
mutable elevationViewModelStatistics = statistics;
}
);
const handlerSamples = ArcGIS.reactiveUtils.watch(
() => elevationProfile.profiles.items?.[0]?.samples,
(samples) => {
mutable elevationSampleData = samples;
}
);
const handlerEffectiveUnits = ArcGIS.reactiveUtils.watch(
() => elevationProfile.effectiveUnits,
(value) => {
mutable elevationEffectiveUnits = value;
}
);
invalidation.then(() => {
mapView.destroy();
polylineGraphic.destroy();
elevationProfile.destroy();
handlerStats.remove();
handlerSamples.remove();
});
}