Skip to content

Commit

Permalink
setup at mapStore
Browse files Browse the repository at this point in the history
  • Loading branch information
fdq09eca committed Nov 15, 2023
1 parent 59962a1 commit fa327f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
19 changes: 1 addition & 18 deletions demo/src/components/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useMapStore } from "../stores/MapStore";
import Logo from "./Logo.vue";
import LonLatBox from "./LonLatBox.vue";
import ScaleBox from "./ScaleBox.vue";
import * as reactiveUtils from "@arcgis/core/core/reactiveUtils.js";
export default {
components: {
Expand Down Expand Up @@ -43,23 +43,6 @@ export default {
beforeMount() {
this.mapObject = this.mapStore.init_mapObject();
reactiveUtils.on(
() => this.view,
"drag",
(event) => {
const dragState = event.action;
if (dragState === "update") {
useMapStore().syncMaps(this.mapObject);
}
}
);
reactiveUtils.watch(
() => this.view?.zoom,
(zoom) => {
useMapStore().syncMaps(this.mapObject);
}
);
},
mounted() {
Expand Down
19 changes: 19 additions & 0 deletions demo/src/stores/MapStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineStore } from "pinia";
import Map from "@arcgis/core/Map.js";
import MapView from "@arcgis/core/views/MapView.js";
import { v4 as uuid } from "uuid";
import * as reactiveUtils from "@arcgis/core/core/reactiveUtils.js";

export const useMapStore = defineStore("mapStore", {
state() {
Expand Down Expand Up @@ -39,6 +40,24 @@ export const useMapStore = defineStore("mapStore", {

const mapObj = { id: id, map: map, view: view };

reactiveUtils.on(
() => view,
"drag",
(event) => {
const dragState = event.action;
if (dragState === "update") {
this.syncMaps(mapObj);
}
}
);

reactiveUtils.watch(
() => view.zoom,
(zoom) => {
this.syncMaps(mapObj);
}
);

this.mapObjects.push(mapObj);
return mapObj;
},
Expand Down

0 comments on commit fa327f7

Please sign in to comment.