|
19 | 19 | L.Control.Geocoder = L.Control.extend({
|
20 | 20 | options: {
|
21 | 21 | collapsed: true,
|
| 22 | + expand: 'click', |
22 | 23 | position: 'topright',
|
23 | 24 | placeholder: 'Search...',
|
24 | 25 | errorMessage: 'Nothing found.'
|
|
60 | 61 | L.DomEvent.addListener(form, 'submit', this._geocode, this);
|
61 | 62 |
|
62 | 63 | if (this.options.collapsed) {
|
63 |
| - L.DomEvent.addListener(input, 'mouseover', this._expand, this); |
64 |
| - L.DomEvent.addListener(input, 'mouseout', this._collapse, this); |
65 |
| - |
66 |
| - this._map.on('movestart', this._collapse, this); |
| 64 | + if (this.options.expand === 'click') { |
| 65 | + L.DomEvent.addListener(input, 'click', this._toggle, this); |
| 66 | + } else { |
| 67 | + L.DomEvent.addListener(input, 'mouseover', this._expand, this); |
| 68 | + L.DomEvent.addListener(input, 'mouseout', this._collapse, this); |
| 69 | + this._map.on('movestart', this._collapse, this); |
| 70 | + } |
67 | 71 | } else {
|
68 | 72 | this._expand();
|
69 | 73 | }
|
|
111 | 115 | return false;
|
112 | 116 | },
|
113 | 117 |
|
| 118 | + _toggle: function() { |
| 119 | + if (this._container.className.indexOf('leaflet-control-geocoder-expanded') >= 0) { |
| 120 | + this._collapse(); |
| 121 | + } else { |
| 122 | + this._expand(); |
| 123 | + } |
| 124 | + }, |
| 125 | + |
114 | 126 | _expand: function () {
|
115 | 127 | L.DomUtil.addClass(this._container, 'leaflet-control-geocoder-expanded');
|
116 | 128 | },
|
117 | 129 |
|
118 | 130 | _collapse: function () {
|
119 | 131 | this._container.className = this._container.className.replace(' leaflet-control-geocoder-expanded', '');
|
| 132 | + this._alts.style.display = 'none'; |
120 | 133 | },
|
121 | 134 |
|
122 | 135 | _clearResults: function () {
|
|
0 commit comments