@@ -81,6 +81,7 @@ SimpleMap.prototype.loadMaps = function () {
8181// Setup Map
8282SimpleMap . prototype . setupMap = function ( ) {
8383 this . setup = true ;
84+ var self = this ;
8485
8586 // Geocoder (for address search)
8687 this . geocoder = new google . maps . Geocoder ( ) ;
@@ -100,6 +101,10 @@ SimpleMap.prototype.setupMap = function () {
100101 autocomplete . map = this . map ;
101102 autocomplete . bindTo ( 'bounds' , this . map ) ;
102103
104+ this . address . addEventListener ( 'input' , function ( ) {
105+ if ( this . value === '' ) self . clear ( ) ;
106+ } ) ;
107+
103108 // Add marker
104109 this . map . marker = new google . maps . Marker ( {
105110 draggable : true ,
@@ -114,8 +119,6 @@ SimpleMap.prototype.setupMap = function () {
114119 // Update the marker location & center the map
115120 this . update ( lat , lng , false , true ) . center ( ) ;
116121
117- var self = this ;
118-
119122 // When the autocomplete place changes
120123 google . maps . event . addListener ( autocomplete , 'place_changed' , function ( ) {
121124 var address = self . address . value , lat , lng ;
@@ -226,10 +229,9 @@ SimpleMap.prototype.geo = function (latLng, callback) {
226229} ;
227230
228231SimpleMap . prototype . clear = function ( ) {
229- self . address . value = '' ;
230- self . inputs . lat . value = '' ;
231- self . inputs . lng . value = '' ;
232- self . inputs . address . value = '' ;
232+ this . inputs . lat . value = '' ;
233+ this . inputs . lng . value = '' ;
234+ this . inputs . address . value = '' ;
233235} ;
234236
235237window . SimpleMap = SimpleMap ;
0 commit comments