Skip to content

Commit

Permalink
reame + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
fdq09eca committed Nov 16, 2023
1 parent a4c6441 commit 07e3ba1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
8 changes: 2 additions & 6 deletions demo/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
components: {
Map,
},
methods: {
addMap() {
useMapStore().createMapComponent(this.$el);
Expand Down Expand Up @@ -62,7 +62,7 @@ button {
opacity: 0.5;
}
button:hover{
button:hover {
opacity: 1;
}
Expand All @@ -72,13 +72,9 @@ button:hover{
font-weight: bold;
}
#add-map-btn {
background-color: blue;
color: white;
font-weight: bold;
}
</style>
19 changes: 11 additions & 8 deletions demo/src/stores/MapStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ export const useMapStore = defineStore("mapStore", {
(event) => {
const dragState = event.action;
if (dragState === "update") {
this.syncMaps(mapObj);
this.sync_mapObjects(mapObj);
}
}
);

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

Expand All @@ -78,19 +78,22 @@ export const useMapStore = defineStore("mapStore", {
} else {
mapObj = this.get_mapObject(id);
}

this.mapObjects = this.mapObjects.filter((mo) => mo !== mapObj);

mapObj?.view.container.remove();
mapObj?.view.destroy();
mapObj?.map.destroy();
},

syncMaps(targetMapObj) {
sync_mapObjects(src) {
this.mapObjects
.filter((mo) => mo !== targetMapObj)
.forEach((mo) => {
mo.view.extent = targetMapObj.view.extent;
mo.view.zoom = targetMapObj.view.zoom;
.filter((dst) => dst !== src)
.forEach((dst) => {
dst.view.extent = src.view.extent;
dst.view.zoom = src.view.zoom;
dst.view.scale = src.view.scale;
dst.view.rotation = src.view.rotation;
});
},
},
Expand Down

0 comments on commit 07e3ba1

Please sign in to comment.