()
| 203 | } |
| 204 | |
| 205 | function createSearchMarker () { |
| 206 | var searchMarker = new google.maps.Marker({ // need to keep reference. |
| 207 | position: { |
| 208 | lat: centerLat, |
| 209 | lng: centerLng |
| 210 | }, |
| 211 | map: map, |
| 212 | animation: google.maps.Animation.DROP, |
| 213 | draggable: !Store.get('lockMarker'), |
| 214 | icon: null, |
| 215 | optimized: false, |
| 216 | zIndex: google.maps.Marker.MAX_ZINDEX + 1 |
| 217 | }) |
| 218 | |
| 219 | searchMarker.infoWindow = new google.maps.InfoWindow({ |
| 220 | content: '<div><b>Search Location</b></div>', |
| 221 | disableAutoPan: true |
| 222 | }) |
| 223 | |
| 224 | addListeners(searchMarker) |
| 225 | |
| 226 | var oldLocation = null |
| 227 | google.maps.event.addListener(searchMarker, 'dragstart', function () { |
| 228 | oldLocation = searchMarker.getPosition() |
| 229 | }) |
| 230 | |
| 231 | google.maps.event.addListener(searchMarker, 'dragend', function () { |
| 232 | var newLocation = searchMarker.getPosition() |
| 233 | changeSearchLocation(newLocation.lat(), newLocation.lng()) |
| 234 | .done(function () { |
| 235 | oldLocation = null |
| 236 | }) |
| 237 | .fail(function () { |
| 238 | if (oldLocation) { |
| 239 | searchMarker.setPosition(oldLocation) |
| 240 | } |
| 241 | }) |
| 242 | }) |
| 243 | |
| 244 | return searchMarker |
| 245 | } |
| 246 | |
| 247 | var searchControlURI = 'search_control' |
| 248 | function searchControl (action) { |
no test coverage detected