Skip to content

Commit

Permalink
Added center zoom update
Browse files Browse the repository at this point in the history
  • Loading branch information
ajturner committed Jul 17, 2023
1 parent a42091e commit a02a174
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/components/hub-compass-map/hub-compass-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ export class HubCompassMap {
});
}

@Watch('center')
async updateCenter(newCenter) {
this.mapView.goTo({
center: newCenter,
zoom: this.zoom
});
}
@Watch('zoom')
async updateZoom(newZoom) {
this.mapView.goTo({
center: this.center,
zoom: newZoom
});
}

async addDatasetToMap(datasetId) {

const datasetLayer = await new FeatureLayer({
Expand Down
12 changes: 11 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
>
Add Schools
</calcite-button>
<calcite-button
onclick="moveMap([-75,39], 10)"
>
Move Map
</calcite-button>
</div>

<style>
Expand Down Expand Up @@ -82,7 +87,12 @@
componentEl.datasetIds = ['7c6443b23d364689be9b34324e6c677d'];
componentEl.showLayers = true;
componentEl.showSearch = true;


function moveMap(center, zoom) {
componentEl.center = center;
componentEl.zoom = zoom;
}

function addDatasets(datasetId) {
console.log("addDatasets", componentEl.datasetIds.concat([datasetId]))
componentEl.datasetIds = componentEl.datasetIds.concat([datasetId]);
Expand Down

0 comments on commit a02a174

Please sign in to comment.