Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gmaps.js using native Google Maps API v3 functions

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)

like image 475
cantaffordavan Avatar asked Mar 22 '23 18:03

cantaffordavan


1 Answers

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
});
like image 136
geocodezip Avatar answered Apr 01 '23 07:04

geocodezip