Search code examples
javascriptjquerygoogle-maps-api-3google-maps-markersjquery-ui-map

how to attach an event listener using jQuery map v3?


i am trying to load more markers when the map is dragged and i'm not sure how to get the current bounds.

var map = $('#map');
map.gmap().bind('init', function(evt, map) {
    $(map).dragend(function(){
        console.log('a');
    });
});

i need to somehow get the current bounds inside the dragend callback and load more markers..

notice that i am using jQuery UI Map v3 and not Google Maps Api v3 witch is a bit different in the way it calls different methods

anyone has any ideas, i can't find this in the wiki?

thanks


Solution

    • variant #1 (using the addEventListener-method of the plugin)
          $(function() { 
            $('#map_canvas')
              .gmap()
                .bind('init', function(evt, map) {
                    $(map)
                      .addEventListener('dragend',function(){
                                          console.log('a');
                                        });
                      });
          });
    • variant #2(using the addEventListener-method of the google-Maps-API)
      $(function() { 
        $('#map_canvas')
          .gmap()
            .bind('init', function(evt, map) {
                google.maps.event.addListener(map,'dragend',function(){
                                      console.log('b');
                                    });
                  });
      });