-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from EOX-A/map/feature/styles
Style Parsing
- Loading branch information
Showing
8 changed files
with
273 additions
and
126 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,78 @@ | ||
import { VectorTile } from "ol/layer"; | ||
import "../main"; | ||
import vectorTileLayerStyleJson from "./vectorTilesLayer.json"; | ||
import { VectorTile } from "ol/layer"; | ||
|
||
describe("VectorTile Layer", () => { | ||
it("loads a Vector Layer", () => { | ||
it("loads a Vector Layer, applies flat style", () => { | ||
// @ts-ignore | ||
vectorTileLayerStyleJson[0].style = { | ||
// @ts-ignore | ||
"fill-color": "yellow", | ||
"stroke-color": "black", | ||
"stroke-width": 4, | ||
}; | ||
cy.mount( | ||
`<eox-map layers='${JSON.stringify(vectorTileLayerStyleJson)}'></eox-map>` | ||
).as("eox-map"); | ||
return new Cypress.Promise((resolve) => { | ||
cy.get("eox-map").should(($el) => { | ||
const eoxMap = <EOxMap>$el[0]; | ||
const layer = eoxMap.getLayerById("countries") as VectorTile; | ||
setTimeout(() => { | ||
// to do: not able to wait for rendercomplete directly, as `applyStyle` is async | ||
const features = layer | ||
.getSource() | ||
.getFeaturesInExtent(eoxMap.map.getView().calculateExtent()); | ||
expect(features.length).to.be.greaterThan(10); | ||
resolve(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
it("loads a Vector Layer, applies mapbox style", () => { | ||
vectorTileLayerStyleJson[0].style = { | ||
version: 8, | ||
name: "countries", | ||
sources: {}, | ||
layers: [ | ||
{ | ||
id: "countries_fill", | ||
type: "fill", | ||
source: "countries", | ||
"source-layer": "ne_10m_admin_0_countries", | ||
paint: { | ||
"fill-color": "green", | ||
"fill-opacity": 1, | ||
}, | ||
}, | ||
{ | ||
id: "countries_outline", | ||
type: "line", | ||
source: "countries", | ||
"source-layer": "ne_10m_admin_0_countries", | ||
paint: { | ||
"line-color": "#cdcdcd", | ||
"line-width": 2.5, | ||
}, | ||
}, | ||
], | ||
}; | ||
cy.mount( | ||
`<eox-map layers='${JSON.stringify(vectorTileLayerStyleJson)}'></eox-map>` | ||
).as("eox-map"); | ||
cy.get("eox-map").and(($el) => { | ||
const eoxMap = <EOxMap>$el[0]; | ||
const layer = eoxMap.getLayerById("countries") as VectorTile; | ||
const features = layer | ||
.getSource() | ||
.getFeaturesInExtent(eoxMap.map.getView().calculateExtent()); | ||
expect(features.length).to.be.greaterThan(10); | ||
return new Cypress.Promise((resolve) => { | ||
cy.get("eox-map").should(($el) => { | ||
const eoxMap = <EOxMap>$el[0]; | ||
const layer = eoxMap.getLayerById("countries") as VectorTile; | ||
setTimeout(() => { | ||
// to do: not able to wait for rendercomplete directly, as `applyStyle` is async | ||
const features = layer | ||
.getSource() | ||
.getFeaturesInExtent(eoxMap.map.getView().calculateExtent()); | ||
expect(features.length).to.be.greaterThan(10); | ||
resolve(); | ||
}, 1000); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.