@@ -99,15 +99,21 @@ var gmap = gmap || {};
9999 // }
100100 // }
101101 }
102+
102103 this . controller = params . controller ;
103104 this . _selected = false ;
104105 this . _highlighted = false ;
105- if ( params . highlightCallback ) {
106+
106107 this . highlightCallback = params . highlightCallback ;
107- }
108- if ( params . selectCallback ) {
109108 this . selectCallback = params . selectCallback ;
110- }
109+
110+ var empty_function = function ( ) { return { } ; }
111+
112+ this . _responsive_unselected_poly_options = params . responsive_unselected_opts == null ? empty_function : params . responsive_unselected_opts ;
113+ this . _responsive_highlighted_poly_options = params . responsive_highlighted_opts == null ? empty_function : params . responsive_highlighted_opts ;
114+ this . _responsive_selected_poly_options = params . responsive_selected_opts == null ? empty_function : params . responsive_selected_opts ;
115+
116+
111117 if ( params . color ) {
112118 this . unselected_poly_options = gmap . _ . extend ( { } , this . _unselected_poly_options , { "fillColor" : params . color } ) ;
113119 } else {
@@ -128,7 +134,7 @@ var gmap = gmap || {};
128134 }
129135 }
130136 for ( var i = 0 , len = params . multipolygon . length ; i < len ; i ++ ) {
131- this . polygons . push ( new google . maps . Polygon ( gmap . _ . extend ( { } , this . unselected_poly_options , {
137+ this . polygons . push ( new google . maps . Polygon ( gmap . _ . extend ( { } , this . unselected_poly_options , this . _responsive_unselected_poly_options ( ) , {
132138 paths : params . multipolygon [ i ] ,
133139 map : params . map
134140 } ) ) ) ;
@@ -171,14 +177,20 @@ var gmap = gmap || {};
171177 }
172178 return multipoly ;
173179 } ,
180+
174181 // Redraw the polygons associated with the feature
182+ // Highlighted and selected states inherit from unselected state
183+ // NOTE: Remember to set your z-index for your highlights/selects above
184+ // your unselected polygons!
175185 redraw : function ( ) {
176- var opts = gmap . _ . extend ( { } , this . unselected_poly_options ) ;
186+ var opts = gmap . _ . extend ( { } , this . unselected_poly_options , this . _responsive_unselected_poly_options ( ) ) ;
177187
178188 if ( this . _highlighted ) {
179- opts = gmap . _ . extend ( opts , this . _highlighted_poly_options ) ;
180- } else if ( this . _selected ) {
181- opts = gmap . _ . extend ( opts , this . _selected_poly_options ) ;
189+ opts = gmap . _ . extend ( opts , this . _highlighted_poly_options , this . _responsive_highlighted_poly_options ( ) ) ;
190+ }
191+
192+ if ( this . _selected ) {
193+ opts = gmap . _ . extend ( opts , this . _selected_poly_options , this . _responsive_selected_poly_options ( ) ) ;
182194 }
183195
184196 for ( i = 0 , len = this . polygons . length ; i < len ; i ++ ) {
@@ -195,8 +207,8 @@ var gmap = gmap || {};
195207 this . controller . selected . setSelected ( false ) ;
196208 }
197209 this . _selected = true ;
198- this . redraw ( ) ;
199210 this . controller . selected = this ;
211+ this . redraw ( ) ;
200212 if ( this . selectCallback ) {
201213 this . selectCallback ( ) ;
202214 }
@@ -370,12 +382,16 @@ var gmap = gmap || {};
370382 if ( params . getColor ) {
371383 opts . color = params . getColor ( data [ i ] . properties ) ;
372384 }
373- if ( params . highlightCallback ) {
374- opts . highlightCallback = params . highlightCallback ;
375- }
376- if ( params . selectCallback ) {
377- opts . selectCallback = params . selectCallback ;
378- }
385+
386+ // Responsive polygon options
387+ opts . responsive_unselected_opts = params . responsive_unselected_opts ;
388+ opts . responsive_highlighted_opts = params . responsive_highlighted_opts ;
389+ opts . responsive_selected_opts = params . responsive_selected_opts ;
390+
391+ // Callbacks
392+ opts . highlightCallback = params . highlightCallback ;
393+ opts . selectCallback = params . selectCallback ;
394+
379395 self [ data [ i ] . id ] = new gmap . Feature ( opts ) ;
380396 }
381397
0 commit comments