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

Cannot get $mapObject #48

Closed
pwnz22 opened this issue Feb 22, 2017 · 12 comments
Closed

Cannot get $mapObject #48

pwnz22 opened this issue Feb 22, 2017 · 12 comments

Comments

@pwnz22
Copy link

pwnz22 commented Feb 22, 2017

this.$refs.gmap.mapCreated.then((gmapObject) => {
    console.log(gmapObject)
})

I want to get the $mapObject and running the above code in mounted() { } but i wont work. Also i want to getCenter() or getBounds()
this.$refs.gmap.$mapObject.getCenter() - I have tried for 2 hourse, i cant get the center or even bounds in mehtods. Events like bounds_changed and center_changed working. But i need mapObject to get or set center. Pls help!

@xkjyeah
Copy link
Owner

xkjyeah commented Feb 22, 2017 via email

@xkjyeah
Copy link
Owner

xkjyeah commented Feb 22, 2017 via email

@pwnz22
Copy link
Author

pwnz22 commented Feb 22, 2017

now i have this. I need to set it to gmap-map?)

@xkjyeah
Copy link
Owner

xkjyeah commented Feb 22, 2017 via email

@pwnz22
Copy link
Author

pwnz22 commented Feb 22, 2017

Now im getting something there in console.log.
But can i getBounds() in this closure?
I mean console.log(gmapObject.getBounds()) or console.log(gmapObject.getCenter()). I'm doing this but there an strange object. There is no values for lat and lng

@xkjyeah
Copy link
Owner

xkjyeah commented Feb 22, 2017 via email

@pwnz22
Copy link
Author

pwnz22 commented Feb 22, 2017

Thanks for the fast response)

I'm also using this event.
And the last question is it good practice to watch the bounds
when i'm listenin to the event @bounds_changed="bounds = $event"
and then run method there like:

watch: {
            'bounds': function (bounds) {
                this.boundsChanged(bounds)
            }
        }

@xkjyeah
Copy link
Owner

xkjyeah commented Feb 22, 2017 via email

@pwnz22
Copy link
Author

pwnz22 commented Feb 22, 2017

Because i'm doing ajax request and need also use lodash.debounce to not make 100 requests at once when user dragging the map)

I deleted the watch and did something like this : @bounds_changed="boundsChanged($event)"

@xkjyeah
Copy link
Owner

xkjyeah commented Feb 22, 2017 via email

@xkjyeah
Copy link
Owner

xkjyeah commented Feb 22, 2017 via email

@pwnz22
Copy link
Author

pwnz22 commented Feb 22, 2017

I also deed that. Thanks a lot :)
I will close the issue.

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