- you trigger the event for
'location-canvas'
, what is only a string, you must supply thegoogle.maps.Map
-instance as argument triggering the resize-event onclick may be too early, use the
after
-method of the plugin instead.after: function(){if($(this).text()==='Google Map'){ //map must be the google.maps.Map-instance and available here center=map.getCenter(); google.maps.event.trigger(map,'resize'); map.setCenter(center); }}
Demo: http://jsfiddle.net/doktormolle/xzVpW/
Note: the map
-variable is not available inside the after-method. In my modified fiddle I stored the instance inside $('#location-canvas').data