ÿþ/ * 
 *   P a n o M a p T y p e C o n t r o l   C l a s s   
 *     C o p y r i g h t   ( c )   2 0 0 7 ,   G o o g l e   
 *     A u t h o r :   P a m e l a   F o x ,   o t h e r s 
 *   
 *   L i c e n s e d   u n d e r   t h e   A p a c h e   L i c e n s e ,   V e r s i o n   2 . 0   ( t h e   " L i c e n s e " ) ; 
 *   y o u   m a y   n o t   u s e   t h i s   f i l e   e x c e p t   i n   c o m p l i a n c e   w i t h   t h e   L i c e n s e . 
 *   Y o u   m a y   o b t a i n   a   c o p y   o f   t h e   L i c e n s e   a t 
 *   
 *               h t t p : / / w w w . a p a c h e . o r g / l i c e n s e s / L I C E N S E - 2 . 0 
 * 
 *   U n l e s s   r e q u i r e d   b y   a p p l i c a b l e   l a w   o r   a g r e e d   t o   i n   w r i t i n g ,   s o f t w a r e 
 *   d i s t r i b u t e d   u n d e r   t h e   L i c e n s e   i s   d i s t r i b u t e d   o n   a n   " A S   I S "   B A S I S , 
 *   W I T H O U T   W A R R A N T I E S   O R   C O N D I T I O N S   O F   A N Y   K I N D ,   e i t h e r   e x p r e s s   o r   i m p l i e d . 
 *   S e e   t h e   L i c e n s e   f o r   t h e   s p e c i f i c   l a n g u a g e   g o v e r n i n g   p e r m i s s i o n s   a n d 
 *   l i m i t a t i o n s   u n d e r   t h e   L i c e n s e . 
 * 
 *   T h i s   c l a s s   l e t s   y o u   a d d   a   c o n t r o l   t o   t h e   m a p   w h i c h   m i m i c s   G M a p T y p e C o n t r o l 
 *     a n d   a l l o w s   f o r   t h e   a d d i t i o n   o f   a   t r a f f i c   b u t t o n / t r a f f i c   k e y . 
 * / 
 
 / * 
   *   C o n s t r u c t o r   f o r   P a n o M a p T y p e C o n t r o l 
   * / 
 f u n c t i o n   P a n o M a p T y p e C o n t r o l ( o p t _ o p t s )   { 
     t h i s . o p t i o n s   =   o p t _ o p t s   | |   { } ; 
 } 
 
 
 P a n o M a p T y p e C o n t r o l . p r o t o t y p e   =   n e w   G C o n t r o l ( ) ; 
 
 / * * 
   *   I s   c a l l e d   b y   G M a p 2 ' s   a d d O v e r l a y   m e t h o d .   C r e a t e s   t h e   b u t t o n   
   *     a n d   a p p e n d s   t o   t h e   m a p   d i v . 
   *   @ p a r a m   { G M a p 2 }   m a p   T h e   m a p   t h a t   h a s   h a d   t h i s   P a n o M a p T y p e C o n t r o l   a d d e d   t o   i t . 
   *   @ r e t u r n   { D O M   O b j e c t }   D i v   t h a t   h o l d s   t h e   c o n t r o l 
   * /   
 P a n o M a p T y p e C o n t r o l . p r o t o t y p e . i n i t i a l i z e   =   f u n c t i o n ( m a p )   { 
     v a r   c o n t a i n e r   =   d o c u m e n t . c r e a t e E l e m e n t ( " d i v " ) ; 
     v a r   m e   =   t h i s ; 
 
     v a r   p a n o D i v   =   m e . c r e a t e B u t t o n _ ( " Z d j c i a   n a   m a p i e " ) ; 
     p a n o D i v . t i t l e = ' Z o b a c z   z d j c i a   w   o k o l i c y ' ; 
     p a n o D i v . s t y l e . m a r g i n R i g h t   =   " 5 p x " ; 
     G E v e n t . a d d D o m L i s t e n e r ( p a n o D i v ,   " c l i c k " ,   f u n c t i o n ( )   { 
         i f   ( m e . p a n o L a y e r )   { 
             i f   ( m e . p a n o L a y e r . g e t E n a b l e d ( ) )   { 
                 m e . p a n o L a y e r . d i s a b l e ( ) ; 
             }   e l s e   { 
                 m e . p a n o L a y e r . e n a b l e ( ) ; 
             } 
         }   e l s e   { 
             m e . p a n o L a y e r   =   n e w   P a n o r a m i o L a y e r ( m a p ) ; 
             m e . p a n o L a y e r . e n a b l e ( ) ; 
         } 
         m e . t o g g l e B u t t o n _ ( p a n o D i v . f i r s t C h i l d ,   m e . p a n o L a y e r . g e t E n a b l e d ( ) ) ; 
     } ) ; 
     m e . t o g g l e B u t t o n _ ( p a n o D i v . f i r s t C h i l d ,   f a l s e ) ; 
 
     / *     v a r   m a p D i v   =   m e . c r e a t e B u t t o n _ ( " M a p " ) ; 
     v a r   s a t D i v   =   m e . c r e a t e B u t t o n _ ( " S a t e l l i t e " ) ; 
     v a r   h y b D i v   =   m e . c r e a t e B u t t o n _ ( " H y b r i d " ) ; 
   
 m e . a s s i g n B u t t o n E v e n t _ ( m a p D i v ,   m a p ,   G _ N O R M A L _ M A P ,   [ s a t D i v ,   h y b D i v ] ) ; 
     m e . a s s i g n B u t t o n E v e n t _ ( s a t D i v ,   m a p ,   G _ S A T E L L I T E _ M A P ,   [ m a p D i v ,   h y b D i v ] ) ; 
     m e . a s s i g n B u t t o n E v e n t _ ( h y b D i v ,   m a p ,   G _ H Y B R I D _ M A P ,   [ s a t D i v ,   m a p D i v ] ) ;   
     
     G E v e n t . a d d L i s t e n e r ( m a p ,   " m a p t y p e c h a n g e d " ,   f u n c t i o n ( )   { 
         i f   ( m a p . g e t C u r r e n t M a p T y p e ( )   = =   G _ N O R M A L _ M A P )   { 
             G E v e n t . t r i g g e r ( m a p D i v ,   " c l i c k " ) ;   
         }   e l s e   i f   ( m a p . g e t C u r r e n t M a p T y p e ( )   = =   G _ S A T E L L I T E _ M A P )   { 
             G E v e n t . t r i g g e r ( s a t D i v ,   " c l i c k " ) ; 
         }   e l s e   i f   ( m a p . g e t C u r r e n t M a p T y p e ( )   = =   G _ H Y B R I D _ M A P )   { 
             G E v e n t . t r i g g e r ( h y b D i v ,   " c l i c k " ) ; 
         } 
     } ) ; 
 * / 
     c o n t a i n e r . a p p e n d C h i l d ( p a n o D i v ) ; 
   / *   c o n t a i n e r . a p p e n d C h i l d ( m a p D i v ) ; 
     c o n t a i n e r . a p p e n d C h i l d ( s a t D i v ) ; 
     c o n t a i n e r . a p p e n d C h i l d ( h y b D i v ) ; * / 
 
     m a p . g e t C o n t a i n e r ( ) . a p p e n d C h i l d ( c o n t a i n e r ) ; 
 
     G E v e n t . t r i g g e r ( m a p ,   " m a p t y p e c h a n g e d " ) ; 
     r e t u r n   c o n t a i n e r ; 
 } 
 
 / * 
   *   C r e a t e s   s i m p l e   b u t t o n s   w i t h   t e x t   n o d e s .   
   *   @ p a r a m   { S t r i n g }   t e x t   T e x t   t o   d i s p l a y   i n   b u t t o n 
   *   @ r e t u r n   { D O M   O b j e c t }   T h e   d i v   f o r   t h e   b u t t o n . 
   * / 
 P a n o M a p T y p e C o n t r o l . p r o t o t y p e . c r e a t e B u t t o n _   =   f u n c t i o n ( t e x t )   { 
     v a r   b u t t o n D i v   =   d o c u m e n t . c r e a t e E l e m e n t ( " d i v " ) ; 
     t h i s . s e t B u t t o n S t y l e _ ( b u t t o n D i v ) ; 
     b u t t o n D i v . s t y l e . c s s F l o a t   =   " l e f t " ; 
     b u t t o n D i v . s t y l e . s t y l e F l o a t   =   " l e f t " ; 
     v a r   t e x t D i v   =   d o c u m e n t . c r e a t e E l e m e n t ( " d i v " ) ; 
     t e x t D i v . a p p e n d C h i l d ( d o c u m e n t . c r e a t e T e x t N o d e ( t e x t ) ) ; 
     t e x t D i v . s t y l e . w i d t h   =   " 6 e m " ; 
     b u t t o n D i v . a p p e n d C h i l d ( t e x t D i v ) ; 
     r e t u r n   b u t t o n D i v ; 
 } 
 
 / * 
   *   A s s i g n s   e v e n t s   t o   M a p T y p e   b u t t o n s   t o   c h a n g e   m a p t y p e 
   *     a n d   t o g g l e   b u t t o n   s t y l e s   c o r r e c t l y   f o r   a l l   b u t t o n s 
   *     w h e n   b u t t o n   i s   c l i c k e d . 
   *     @ p a r a m   { D O M   O b j e c t }   d i v   B u t t o n ' s   d i v   t o   a s s i g n   c l i c k   t o 
   *     @ p a r a m   { G M a p 2 }   M a p   o b j e c t   t o   c h a n g e   m a p t y p e   o f . 
   *     @ p a r a m   { O b j e c t }   m a p T y p e   G M a p T y p e   t o   c h a n g e   m a p   t o   w h e n   c l i c k e d 
   *     @ p a r a m   { A r r a y }   o t h e r D i v s   A r r a y   o f   o t h e r   b u t t o n   d i v s   t o   t o g g l e   o f f 
   * /     
 P a n o M a p T y p e C o n t r o l . p r o t o t y p e . a s s i g n B u t t o n E v e n t _   =   f u n c t i o n ( d i v ,   m a p ,   m a p T y p e ,   o t h e r D i v s )   { 
     v a r   m e   =   t h i s ; 
 
     G E v e n t . a d d D o m L i s t e n e r ( d i v ,   " c l i c k " ,   f u n c t i o n ( )   { 
         f o r   ( v a r   i   =   0 ;   i   <   o t h e r D i v s . l e n g t h ;   i + + )   { 
             m e . t o g g l e B u t t o n _ ( o t h e r D i v s [ i ] . f i r s t C h i l d ,   f a l s e ) ; 
         } 
         m e . t o g g l e B u t t o n _ ( d i v . f i r s t C h i l d ,   t r u e ) ; 
         m a p . s e t M a p T y p e ( m a p T y p e ) ; 
     } ) ; 
 } 
 
 / * 
   *   C h a n g e s   s t y l e   o f   b u t t o n   t o   a p p e a r   o n / o f f   d e p e n d i n g   o n   b o o l e a n   p a s s e d   i n . 
   *   @ p a r a m   { D O M   O b j e c t }   d i v     B u t t o n   d i v   t o   c h a n g e   s t y l e   o f 
   *   @ p a r a m   { B o o l e a n }   b o o l C h e c k   U s e d   t o   d e c i d e   t o   u s e   o n   s t y l e   o r   o f f   s t y l e 
   * / 
 P a n o M a p T y p e C o n t r o l . p r o t o t y p e . t o g g l e B u t t o n _   =   f u n c t i o n ( d i v ,   b o o l C h e c k )   { 
       d i v . s t y l e . f o n t W e i g h t   =   b o o l C h e c k   ?   " b o l d "   :   " " ; 
       d i v . s t y l e . b o r d e r   =   " 1 p x   s o l i d   w h i t e " ; 
       v a r   s h a d o w s   =   b o o l C h e c k   ?   [ " T o p " ,   " L e f t " ]   :   [ " B o t t o m " ,   " R i g h t " ] ; 
       f o r   ( v a r   j   =   0 ;   j   <   s h a d o w s . l e n g t h ;   j + + )   { 
           d i v . s t y l e [ " b o r d e r "   +   s h a d o w s [ j ] ]   =   " 1 p x   s o l i d   # b 0 b 0 b 0 " ; 
     }   
 } 
 
 / * 
   *   R e q u i r e d   b y   G M a p s   A P I   f o r   c o n t r o l s .   
   *   @ r e t u r n   { G C o n t r o l P o s i t i o n }   D e f a u l t   l o c a t i o n   f o r   c o n t r o l 
   * / 
 P a n o M a p T y p e C o n t r o l . p r o t o t y p e . g e t D e f a u l t P o s i t i o n   =   f u n c t i o n ( )   { 
     r e t u r n   n e w   G C o n t r o l P o s i t i o n ( G _ A N C H O R _ T O P _ R I G H T ,   n e w   G S i z e ( 0 ,   4 0 ) ) ; 
 } 
 
 / * 
   *   S e t s   t h e   p r o p e r   C S S   f o r   t h e   g i v e n   b u t t o n   e l e m e n t . 
   *   @ p a r a m   { D O M   O b j e c t }   b u t t o n   B u t t o n   d i v   t o   s e t   s t y l e   f o r 
   * / 
 P a n o M a p T y p e C o n t r o l . p r o t o t y p e . s e t B u t t o n S t y l e _   =   f u n c t i o n ( b u t t o n )   { 
     b u t t o n . s t y l e . c o l o r   =   " # 0 0 0 0 0 0 " ; 
     b u t t o n . s t y l e . b a c k g r o u n d C o l o r   =   " w h i t e " ; 
     b u t t o n . s t y l e . f o n t   =   " s m a l l   A r i a l " ; 
     b u t t o n . s t y l e . b o r d e r   =   " 1 p x   s o l i d   b l a c k " ; 
     b u t t o n . s t y l e . p a d d i n g   =   " 0 p x " ; 
     b u t t o n . s t y l e . m a r g i n =   " 0 p x " ; 
     b u t t o n . s t y l e . t e x t A l i g n   =   " c e n t e r " ; 
     b u t t o n . s t y l e . f o n t S i z e   =   " 1 2 p x " ;   
     b u t t o n . s t y l e . c u r s o r   =   " p o i n t e r " ; 
 } 
 
