@@ -14,7 +14,7 @@ google.maps.Label = function(opt_options) {
1414
1515 var span = this . span_ = document . createElement ( 'span' ) ;
1616 span . style . cssText = 'position: relative; left: -50%;' +
17- 'white-space: nowrap; color: #000;' ;
17+ 'white-space: nowrap; color: #000;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-khtml-user-select:none; ' ;
1818
1919 span . style . cssText += ! this . get ( 'textOnly' ) ?
2020 'border: 1px solid ' + this . get ( 'strokeColor' ) + '; border-radius: 5px; ' +
@@ -25,7 +25,7 @@ google.maps.Label = function(opt_options) {
2525
2626 var div = this . div_ = document . createElement ( 'div' ) ;
2727 div . appendChild ( span ) ;
28- div . style . cssText = 'position: absolute; display: none' ;
28+ div . style . cssText = 'position: absolute; display: none;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-khtml-user-select:none; ' ;
2929} ;
3030
3131google . maps . Label . prototype = new google . maps . OverlayView ( ) ;
@@ -82,3 +82,90 @@ google.maps.Label.prototype.draw = function() {
8282 div . style . zIndex = this . get ( 'zIndex' ) ;
8383 this . span_ . innerHTML = this . get ( 'text' ) . toString ( ) ;
8484} ;
85+
86+
87+ // custom dropdown menu control
88+
89+ google . maps . DropDownControl = function ( options ) {
90+ var ctx = this ;
91+ this . options = options ;
92+
93+ // generate the controls
94+ this . div_ = document . createElement ( 'div' ) ;
95+ this . div_ . className = "gmnoprint" ;
96+ this . div_ . draggable = false ;
97+ this . div_ . style . cssText = "margin: 5px; margin-top: 0;z-index: 0; position: absolute; cursor: pointer; text-align: left; width: 100px; right: 0px; top: 0px;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-khtml-user-select:none" ;
98+
99+ this . div_head = document . createElement ( 'div' ) ;
100+ this . div_head . style . cssText = "direction: ltr; overflow: hidden; text-align: left; position: relative; color: rgb(0, 0, 0); font-family: Roboto,Arial,sans-serif; -moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-khtml-user-select: none; font-size: 11px; background-color: rgb(255, 255, 255); padding: 1px 6px; border-radius: 2px; background-clip: padding-box; border: 1px solid rgba(0, 0, 0, 0.15); box-shadow: 0px 1px 4px -1px rgba(0, 0, 0, 0.3); font-weight: 500;" ;
101+ this . div_head . title = options . title ;
102+
103+ google . maps . event . addDomListener ( this . div_head , 'mouseover' , function ( ) {
104+ ctx . div_head . style . backgroundColor = "rgb(235,235,235)" ;
105+ } ) ;
106+ google . maps . event . addDomListener ( this . div_head , 'mouseout' , function ( ) {
107+ ctx . div_head . style . backgroundColor = "rgb(255,255,255)" ;
108+ } ) ;
109+
110+ this . header = document . createElement ( 'span' ) ;
111+ this . header . innerHTML = ( options . headerPrefix || "" ) + options . list [ options . listDefault || 0 ] ;
112+ var arrow = document . createElement ( 'img' ) ;
113+ arrow . src = "http://maps.gstatic.com/mapfiles/arrow-down.png" ;
114+ arrow . style . cssText = "-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-khtml-user-select: none; border: 0px none; padding: 0px; margin: -2px 0px 0px; position: absolute; right: 6px; top: 50%; width: 7px; height: 4px;" ;
115+
116+ this . div_head . appendChild ( this . header ) ;
117+ this . div_head . appendChild ( arrow ) ;
118+ this . div_ . appendChild ( this . div_head ) ;
119+
120+ // generate list of dropdown entries
121+ this . div_list = document . createElement ( 'div' ) ;
122+ this . div_list . style . cssText = "background-color: white; z-index: -1; padding-top: 2px; background-clip: padding-box; border-width: 0px 1px 1px; border-style: none solid solid; border-color: use-text-color rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15); border-top-colors: none; border-right-colors: none; border-bottom-colors: none; border-left-colors: none; border-image: none; box-shadow: 0px 1px 4px -1px rgba(0, 0, 0, 0.3); position: relative; text-align: left; display: none;" ;
123+
124+ var div_list = this . div_list ;
125+
126+ options . list . forEach ( function ( name ) {
127+ var row = document . createElement ( 'div' ) ;
128+ row . style . cssText = "color: rgb(86, 86, 86); font-family: Roboto,Arial,sans-serif; -moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-khtml-user-select: none; font-size: 11px; background-color: rgb(255, 255, 255); padding: 3px; padding-top: 2px; padding-bottom: 2px; line-height: 11px; font-weight: 500;" ;
129+ row . innerHTML = name ;
130+
131+ google . maps . event . addDomListener ( row , 'click' , function ( ) {
132+ if ( ctx . options . callback ( row . innerHTML ) ) {
133+ ctx . header . innerHTML = ( ctx . options . headerPrefix || "" ) + row . innerHTML ;
134+ row . style . fontWeight = "800" ;
135+ row . style . color = "rgb(0,0,0)" ;
136+ }
137+ } ) ;
138+ google . maps . event . addDomListener ( row , 'mouseover' , function ( ) {
139+ if ( ctx . header . innerHTML == ( ctx . options . headerPrefix || "" ) + row . innerHTML ) {
140+ row . style . fontWeight = "800" ;
141+ row . style . color = "rgb(0,0,0)" ;
142+ }
143+ row . style . backgroundColor = "rgb(235,235,235)" ;
144+ } ) ;
145+ google . maps . event . addDomListener ( row , 'mouseout' , function ( ) {
146+ row . style . fontWeight = "500" ;
147+ row . style . color = "rgb(86,86,86)" ;
148+ row . style . backgroundColor = "rgb(255,255,255)" ;
149+ } ) ;
150+
151+ div_list . appendChild ( row ) ;
152+ } ) ;
153+
154+ this . div_ . appendChild ( this . div_list ) ;
155+
156+ // add control
157+ options . map . controls [ options . position ] . push ( this . div_ ) ;
158+
159+ // event for expanding
160+
161+ google . maps . event . addDomListener ( this . div_head , 'click' , function ( ) {
162+ clearTimeout ( ctx . hideTimeout ) ;
163+ div_list . style . display = ( div_list . style . display != 'none' ) ? 'none' : 'block' ;
164+ } ) ;
165+ google . maps . event . addDomListener ( this . div_ , 'mouseout' , function ( ) {
166+ ctx . hideTimeout = setTimeout ( function ( ) { div_list . style . display = 'none' ; } , 1000 ) ;
167+ } ) ;
168+ google . maps . event . addDomListener ( this . div_ , 'mouseover' , function ( ) {
169+ clearTimeout ( ctx . hideTimeout ) ;
170+ } ) ;
171+ } ;
0 commit comments