Skip to content

Commit bf8213b

Browse files
committed
Replaced .serialize with .val on line 169 and added the line directly below, which encodes the string in UTF-8. This should solve special character issues with foreign addresses. Also updated geocode.js with the same thing.
1 parent 24b8913 commit bf8213b

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

js/geocode.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ $(function() {
2323
//Stop the form submission
2424
e.preventDefault();
2525
//Get the user input and use it
26-
var userinput = $('form').serialize();
27-
userinput = userinput.replace("address=","");
26+
var userinput = $('form #address').val();
27+
//Convert to utf-8
28+
userinput = unescape(encodeURIComponent(userinput));
2829
if (userinput == "")
2930
{
3031
alert("The input box was blank.");
3132
}
3233

3334
var g = new GoogleGeocode();
3435
var address = userinput;
36+
3537
g.geocode(address, function(data) {
3638
if(data != null) {
3739
olat = data.latitude;
@@ -45,8 +47,5 @@ $(function() {
4547
}
4648
});
4749

48-
//Replace spaces in user input
49-
userinput = userinput.replace(" ","+");
50-
5150
});
5251
});

js/jquery.storelocator.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* storeLocator v1.3 - jQuery store locator plugin
2+
* storeLocator v1.3.1 - jQuery store locator plugin
33
* (c) Copyright 2012, Bjorn Holine (http://www.bjornblog.com)
44
* Released under the MIT license
55
* Distance calculation function by Chris Pietschmann: http://pietschsoft.com/post/2008/02/01/Calculate-Distance-Between-Geocodes-in-C-and-JavaScript.aspx
@@ -68,6 +68,7 @@ $.fn.storeLocator = function(options) {
6868
function GoogleGeocode() {
6969
geocoder = new google.maps.Geocoder();
7070
this.geocode = function(address, callbackFunction) {
71+
address = unescape(encodeURIComponent(address));
7172
geocoder.geocode( { 'address': address}, function(results, status) {
7273
if (status == google.maps.GeocoderStatus.OK) {
7374
var result = {};
@@ -165,8 +166,9 @@ $.fn.storeLocator = function(options) {
165166
//Stop the form submission
166167
e.preventDefault();
167168
//Get the user input and use it
168-
var userinput = $('#' + settings.formID + ' #' + settings.inputID).serialize();
169-
userinput = userinput.replace("address=","");
169+
var userinput = $('#' + settings.formID + ' #' + settings.inputID).val();
170+
//Convert to utf-8 - special character issue fix
171+
userinput = unescape(encodeURIComponent(userinput));
170172
if (userinput == "")
171173
{
172174
//Show alert and stop processing

js/jquery.storelocator.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ A note on the distance calculation: this plugin currently uses a distance functi
88

99
## Changelog
1010

11+
### Version 1.3.1
12+
13+
Replaced .serialize with .val on line 169 and added the line directly below, which encodes the string in UTF-8. This should solve special character issues with international addresses.
14+
1115
### Version 1.3
1216

1317
Added directions links to left column location list and HTML5 geolocation API option. Also did a little cleanup.

0 commit comments

Comments
 (0)