@@ -277,31 +277,29 @@ define([
277277 } ) ;
278278
279279 var self = this ;
280- $ . each ( geojsonLayer . _layers , function ( idx , layer ) {
281- var feature = layer . feature ;
282- layer . feature . map_mouse_over = false ;
283- hoverTract . watchForValue ( feature . id ,
284- function ( ) {
285- layer . setStyle ( self . _styleFunction ( feature , true ) ) ;
286- } ,
287- function ( ) {
288- layer . setStyle ( self . _styleFunction ( feature ) ) ;
289- } ) ;
290- layer . on ( "mouseover" , function ( e ) {
291- hoverTract . select ( feature . id ,
292- feature ,
293- self . getPropertyData ( ) ,
294- colorbrewer [ self . _colorBrewerName ] ) ;
295- feature . map_mouse_over = true ;
296- console . log ( feature ) ;
297- } ) ;
298- layer . on ( "mouseout" , function ( e ) {
299- feature . map_mouse_over = false ;
300- // TODO: Move this somewhere else
301- hoverTract . select ( null ) ;
302- } ) ;
303-
304-
280+ $ . each ( geojsonLayer . _layers , function ( idx , layer ) {
281+ var feature = layer . feature ;
282+ feature . highlighted = false ;
283+ hoverTract . watchForValue ( feature . id ,
284+ function ( ) {
285+ feature . highlighted = true ;
286+ layer . setStyle ( self . _styleFunction ( feature ) ) ;
287+ } , function ( ) {
288+ feature . highlighted = false ;
289+ layer . setStyle ( self . _styleFunction ( feature ) ) ;
290+ } ) ;
291+ layer . on ( "mouseover click" , function ( e ) {
292+ if ( ! hoverTract . contains ( feature . id ) ) {
293+ hoverTract . clear ( ) ;
294+ hoverTract . select ( feature . id ,
295+ feature ,
296+ self . getPropertyData ( ) ,
297+ colorbrewer [ self . _colorBrewerName ] ) ;
298+ }
299+ } ) ;
300+ layer . on ( "mouseout" , function ( e ) {
301+ hoverTract . deselect ( feature . id ) ;
302+ } ) ;
305303 } ) ;
306304
307305 if ( this . _layers_id [ add [ i ] ] ) {
@@ -318,7 +316,7 @@ define([
318316
319317 } ,
320318
321- _styleFunction : function ( feature , highlight ) {
319+ _styleFunction : function ( feature ) {
322320
323321 if ( this . _itemStyle ) {
324322 return this . _itemStyle ( feature ) ;
@@ -331,8 +329,8 @@ define([
331329 var val = parseFloat ( feature . properties [ this . _currentProperty ] ) ;
332330
333331 if ( val ) {
334- if ( ( typeof ( highlight ) !== "undefined" ) || feature . map_mouse_over == true ) {
335- return { "fillColor" : this . _getColor ( prop . serie , val ) , "color" : "#404040" , "weight" : 4 , "opacity" : 1.0 , "fillOpacity" : 0.6 } ;
332+ if ( feature . highlighted ) {
333+ return { "fillColor" : this . _getColor ( prop . serie , val ) , "color" : "#404040" , "weight" : 4 , "opacity" : 1.0 , "fillOpacity" : 0.6 } ;
336334 } else {
337335 return { "fillColor" : this . _getColor ( prop . serie , val ) , "weight" : 0 , "opacity" : 0.0 , "fillOpacity" : 0.6 } ;
338336 }
0 commit comments