@@ -82,6 +82,7 @@ L.UtfGrid = (L.Layer || L.Class).extend({
8282 this . _update ( ) ;
8383
8484 var zoom = this . _map . getZoom ( ) ;
85+ map . on ( 'zoomend' , this . _zoomend , this ) ;
8586
8687 if ( zoom > this . options . maxZoom || zoom < this . options . minZoom ) {
8788 return ;
@@ -94,6 +95,7 @@ L.UtfGrid = (L.Layer || L.Class).extend({
9495
9596 onRemove : function ( ) {
9697 var map = this . _map ;
98+ map . off ( 'zoomend' , this . _zoomend , this ) ;
9799 map . off ( 'click' , this . _click , this ) ;
98100 map . off ( 'mousemove' , this . _move , this ) ;
99101 map . off ( 'moveend' , this . _update , this ) ;
@@ -226,6 +228,18 @@ L.UtfGrid = (L.Layer || L.Class).extend({
226228 }
227229 } ,
228230
231+ _zoomend : function ( ) {
232+ var curZoom = this . _map . getZoom ( ) ;
233+ for ( var key in this . _cache ) {
234+ if ( this . _cache . hasOwnProperty ( key ) ) {
235+ var zoom = parseInt ( key . split ( '_' ) [ 0 ] ) ;
236+ if ( zoom !== curZoom ) {
237+ delete this . _cache [ key ] ;
238+ }
239+ }
240+ }
241+ } ,
242+
229243 _loadTileP : function ( zoom , x , y ) {
230244 var head = document . getElementsByTagName ( 'head' ) [ 0 ] ,
231245 key = zoom + '_' + x + '_' + y ,
0 commit comments