So I load my google maps with gmaps.js, which makes it easier to work with. The problem is some of the native functions aren't available, specifically I need addListenerOnce
http://hpneo.github.io/gmaps/
I load my map like this:
searchmap = new GMaps({
div: '#searchmap',
lat: '40.7142691000',
lng: '-74.0059729000',
});
I can add a event listener like this:
searchmap.addListener('idle', function() {
//do something here
});
However I can't add the native addListenerOnce
, so I assumed I could do this (which does not work):
google.maps.event.addListenerOnce(searchmap, 'idle', function(){
//do something
});
So any idea how I can use the addListenerOnce
? (Clearly I am a JS novice... a lot of poking around in the github repo didn't help)
You need to add the listener to the native google.maps.Map object:
http://hpneo.github.io/gmaps/documentation.html#GMaps-map
This should work:
google.maps.event.addListenerOnce(searchmap.map, 'idle', function(){
//do something
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With