Skip to content

Commit

Permalink
Adding layers to the map once it has been created now works
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamoss committed Apr 25, 2018
1 parent 1e049d0 commit 7cf2e54
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions dist/layers/vector-tile.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/layers/vector-tile.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-openlayers",
"version": "0.2.4",
"version": "0.2.5",
"description": "OpenLayer React Components",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -16,6 +16,9 @@
"build:app": "cross-env NODE_ENV=production webpack --config app/webpack.config",
"types": "dts-generator --name react-openlayers --project . --out dist/index.d.ts",
"copy:static": "cp src/map.css dist/map.css && cp src/custom/popup.css dist/custom/popup.css",
"packy": "npm pack && mv react-openlayers-0.2.1.tgz /Users/keithmoss/Downloads/react-openlayers-0.2.1.tgz",
"wml:add": "wml add ./ /Users/keithmoss/Documents/Work/GitHub/ealgis-yarn/frontend/node_modules/react-openlayers",
"wml:start": "wml start",
"upgrade": "npm-check-updates -a/--upgradeAll && npm i"
},
"repository": {
Expand Down
5 changes: 5 additions & 0 deletions src/layers/vector-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ class VectorTile extends React.Component<any, any> {
if (this.props.zIndex) {
this.layer.setZIndex(this.props.zIndex)
}

this.props.mapComp.layers.push(this.layer)
// If the map has already been mounted then we need to manually add the layer to the OL Map
if ("map" in this.props.mapComp) {
this.props.mapComp.map.addLayer(this.layer)
}

let olEvents = Util.getEvents(this.events, this.props)
for (let eventName in olEvents) {
Expand Down

0 comments on commit 7cf2e54

Please sign in to comment.