Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referencing the Map Object #14

Closed
mediavariance opened this issue Oct 3, 2017 · 2 comments
Closed

Referencing the Map Object #14

mediavariance opened this issue Oct 3, 2017 · 2 comments

Comments

@mediavariance
Copy link

What's the proper way to reference the map object from the parent component?

https://jsfiddle.net/mediavariance/0z7qtmeL/3/

My Method does not work:
updateLocation: function() { this.$refs.map.getView().setCenter( [ -118.2436849, 34.0522342 ]); }

@ghettovoice
Copy link
Owner

You should add ref attribute to vl-map tag with value map, then you can get map component instance by ref: this.$refs.map. To access OpenLayers map instance : this.$refs.map.$map, view instance this.$refs.map.$view.
But the recommended way of view state updating is change binded data properties. In your example just set the new value of center data property in method updateLocation: this.center = [...,...]

@mediavariance
Copy link
Author

That's exactly what I needed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants