-
Notifications
You must be signed in to change notification settings - Fork 474
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
Comments
Why don't you try console.log(this.$refs.gmap.$mapObject)?
Did you set <gmap-map ref="gmap-map">?
…On 22 Feb 2017 19:13, "Valijon" ***@***.***> wrote:
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!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#48>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACiTR4eaHuqFXkFRDS9IjXu-XaJbFVEIks5rfBhYgaJpZM4MIgnc>
.
|
Oh, do try this.$refs.gmap.$mapCreated
…On 22 Feb 2017 19:20, "Daniel Sim" ***@***.***> wrote:
Why don't you try console.log(this.$refs.gmap.$mapObject)?
Did you set <gmap-map ref="gmap-map">?
On 22 Feb 2017 19:13, "Valijon" ***@***.***> wrote:
> 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!
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#48>, or mute the
> thread
> <https://github.com/notifications/unsubscribe-auth/ACiTR4eaHuqFXkFRDS9IjXu-XaJbFVEIks5rfBhYgaJpZM4MIgnc>
> .
>
|
now i have this. I need to set it to gmap-map?) |
Oops sorry autocorrect problems.
I meant:
<gmap-map ref="gmap">
…On 22 Feb 2017 19:23, "Valijon" ***@***.***> wrote:
now i have this. I need to set it to gmap-map?)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#48 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACiTRyjjY31wQYc6Nqd0YuismgPOe3bYks5rfBq8gaJpZM4MIgnc>
.
|
Now im getting something there in console.log. |
If you need to setCenter you should just have:
<Gmap-map :center="{...}">
You can call getBounds, but maybe it won't return a thing if Google Maps
has not fully initialized it. Your best bet is to wait for the
bounds_changed event to fire.:
@bounds_changed="doSomethingWith($event")"
$event will be set to the value of getBounds()
…On 22 Feb 2017 19:28, "Valijon" ***@***.***> wrote:
Now im getting something there in console.log.
But can i getBounds() in this closure?
I mean console.log(gmapObject.getBounds())
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#48 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACiTR-wGFeykeP-kDB22C9oMaiKAQCuDks5rfBvXgaJpZM4MIgnc>
.
|
Thanks for the fast response) I'm also using this event.
|
Why would you do that???? Why not just @bounds_changed="boundsChanged"?
On 22 Feb 2017 19:40, "Valijon" <notifications@github.com> wrote:
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)
}
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#48 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACiTRwcO-wHKMSC1pZy_BaXHE_dTkHSkks5rfB6kgaJpZM4MIgnc>
.
|
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 : |
methods: {
boundsChanged: _.debounce(()=>{...}, ....)
}
…On 22 Feb 2017 19:44, "Valijon" ***@***.***> wrote:
Because i'm doing ajax request and need also use lodash.debounce to not
make 100 requests at once when user dragging the map)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#48 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACiTR6VFhQi8a39mdTycG4oZeDFJxQXKks5rfB-xgaJpZM4MIgnc>
.
|
Oops my bad. You can't use arrow functions with debounce. Use a standard
function(){}
…On 22 Feb 2017 19:56, "Daniel Sim" ***@***.***> wrote:
methods: {
boundsChanged: _.debounce(()=>{...}, ....)
}
On 22 Feb 2017 19:44, "Valijon" ***@***.***> wrote:
> Because i'm doing ajax request and need also use lodash.debounce to not
> make 100 requests at once when user dragging the map)
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#48 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ACiTR6VFhQi8a39mdTycG4oZeDFJxQXKks5rfB-xgaJpZM4MIgnc>
> .
>
|
I also deed that. Thanks a lot :) |
I want to get the $mapObject and running the above code in
mounted() { }
but i wont work. Also i want togetCenter()
orgetBounds()
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!The text was updated successfully, but these errors were encountered: