-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d0584e
commit e4a42b3
Showing
11 changed files
with
122 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Vector as VectorLayer } from "ol/layer"; | ||
import { Vector as VectorSource } from "ol/source"; | ||
import { Stroke, Fill, Style } from "ol/style"; | ||
import { GeoJSON } from "ol/format"; | ||
|
||
export default { | ||
name: "boundary", | ||
|
||
state: { | ||
layer: null, | ||
}, | ||
|
||
getBoundaryLayer: (state) => state.boundary.layer, | ||
|
||
createBoundaryLayer: | ||
() => | ||
({ store, set }) => { | ||
console.log("should create the boundary layer"); | ||
const map = store.getMap(); | ||
const existingLayer = store.getBoundaryLayer(); | ||
if (existingLayer) return; | ||
|
||
const layer = new VectorLayer({ | ||
source: new VectorSource(), | ||
style: new Style({ | ||
stroke: new Stroke({ | ||
color: "rgba(148, 12, 201)", | ||
lineDash: [4], | ||
width: 3, | ||
}), | ||
fill: new Fill({ | ||
color: "rgba(148, 12, 201, 0.05)", | ||
}), | ||
}), | ||
}); | ||
|
||
map.addLayer(layer); | ||
set({ layer }); | ||
}, | ||
|
||
setBoundary: | ||
() => | ||
({ store }) => { | ||
console.log("should add the boundary"); | ||
const map = store.getMap(); | ||
const layer = store.getBoundaryLayer(); | ||
const src = layer.getSource(); | ||
const games = store.getGamesByJoinCode(); | ||
const joinedGame = store.getJoinedGame(); | ||
const game = games[joinedGame]; | ||
const boundary = new GeoJSON().readFeatures(JSON.parse(game.geometry)); | ||
src.addFeatures(boundary); | ||
console.log(src.getExtent()); | ||
map | ||
.getView() | ||
.fit(src.getExtent(), { | ||
duration: 1000, | ||
callback: () => console.log("done"), | ||
}); | ||
}, | ||
|
||
init: ({ store }) => { | ||
store.on("map-created", store.createBoundaryLayer); | ||
store.on("game-joined", store.setBoundary); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.