Skip to content

Commit

Permalink
Hidden Lat/Lng/Address fields are cleared when the search address fie…
Browse files Browse the repository at this point in the history
…ld is empty
  • Loading branch information
Tam committed Dec 11, 2015
1 parent 77c873d commit a3efa33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion SimpleMapPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getDescription()

public function getVersion()
{
return '1.0.0';
return '1.0.1';
}

public function getDeveloper()
Expand Down
14 changes: 8 additions & 6 deletions resources/SimpleMap_Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ SimpleMap.prototype.loadMaps = function () {
// Setup Map
SimpleMap.prototype.setupMap = function () {
this.setup = true;
var self = this;

// Geocoder (for address search)
this.geocoder = new google.maps.Geocoder();
Expand All @@ -100,6 +101,10 @@ SimpleMap.prototype.setupMap = function () {
autocomplete.map = this.map;
autocomplete.bindTo('bounds', this.map);

this.address.addEventListener('input', function () {
if (this.value === '') self.clear();
});

// Add marker
this.map.marker = new google.maps.Marker({
draggable: true,
Expand All @@ -114,8 +119,6 @@ SimpleMap.prototype.setupMap = function () {
// Update the marker location & center the map
this.update(lat, lng, false, true).center();

var self = this;

// When the autocomplete place changes
google.maps.event.addListener(autocomplete, 'place_changed', function () {
var address = self.address.value, lat, lng;
Expand Down Expand Up @@ -226,10 +229,9 @@ SimpleMap.prototype.geo = function (latLng, callback) {
};

SimpleMap.prototype.clear = function () {
self.address.value = '';
self.inputs.lat.value = '';
self.inputs.lng.value = '';
self.inputs.address.value = '';
this.inputs.lat.value = '';
this.inputs.lng.value = '';
this.inputs.address.value = '';
};

window.SimpleMap = SimpleMap;

0 comments on commit a3efa33

Please sign in to comment.