Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn2404 committed Dec 16, 2014
2 parents 70857e0 + fb931ea commit 8eb120b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 23 deletions.
24 changes: 14 additions & 10 deletions dist/assets/js/plugins/storeLocator/jquery.storelocator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jQuery Google Maps Store Locator - v2.0.3 - 2014-12-11
/*! jQuery Google Maps Store Locator - v2.0.4 - 2014-12-15
* http://www.bjornblog.com/web/jquery-store-locator-plugin
* Copyright (c) 2014 Bjorn Holine; Licensed MIT */

Expand Down Expand Up @@ -430,7 +430,7 @@
// If a default location is set
if (this.settings.defaultLoc === true) {
// The address needs to be determined for the directions link
var r = new this.reverseGoogleGeocode();
var r = new this.reverseGoogleGeocode(this);
var latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
r.geocode({'latLng': latlng}, function (data) {
if (data !== null) {
Expand Down Expand Up @@ -472,8 +472,8 @@
/**
* Geocode function used to geocode the origin (entered location)
*/
googleGeocode: function () {
var _this = this;
googleGeocode: function (thisObj) {
var _this = thisObj;
var geocoder = new google.maps.Geocoder();
this.geocode = function (request, callbackFunction) {
geocoder.geocode(request, function (results, status) {
Expand All @@ -493,8 +493,8 @@
/**
* Reverse geocode to get address for automatic options needed for directions link
*/
reverseGoogleGeocode: function () {
var _this = this;
reverseGoogleGeocode: function (thisObj) {
var _this = thisObj;
var geocoder = new google.maps.Geocoder();
this.geocode = function (request, callbackFunction) {
geocoder.geocode(request, function (results, status) {
Expand Down Expand Up @@ -641,6 +641,7 @@
* @returns {string}
*/
_paginationOutput: function(currentPage, totalPages) {

currentPage = parseFloat(currentPage);
var output = '';
var nextPage = currentPage + 1;
Expand All @@ -652,7 +653,7 @@
}

// Add the numbers
for (var p = 0; p < totalPages; p++) {
for (var p = 0; p < Math.ceil(totalPages); p++) {
var n = p + 1;

if (p === currentPage) {
Expand Down Expand Up @@ -935,7 +936,7 @@
var _this = this;
var mappingObj = {};
// The address needs to be determined for the directions link
var r = new this.reverseGoogleGeocode();
var r = new this.reverseGoogleGeocode(this);
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
r.geocode({'latLng': latlng}, function (data) {
if (data !== null) {
Expand Down Expand Up @@ -1122,7 +1123,7 @@
this._start();
}
else if(addressInput !== '') {
var g = new this.googleGeocode();
var g = new this.googleGeocode(this);
g.geocode({'address': addressInput, 'region': region}, function (data) {
if (data !== null) {
olat = data.latitude;
Expand Down Expand Up @@ -1151,7 +1152,6 @@
* Checks distance of each location and setups up the locationset array
*
* @param data {Object} location data object
* @param l {number} iterator from the loop processing the data in the mapping function below
* @param lat {number} origin latitude
* @param lng {number} origin longitude
* @param firstRun {boolean} initial load check
Expand Down Expand Up @@ -1663,6 +1663,10 @@
storeNumToShow = _this.settings.locationsPerPage;
storeStart = page * _this.settings.locationsPerPage;

if( (storeStart + storeNumToShow) > locationset.length ) {
storeNumToShow = _this.settings.locationsPerPage - ((storeStart + storeNumToShow) - locationset.length);
}

locationset = locationset.slice(storeStart, storeStart + storeNumToShow);
storeNum = locationset.length;
}
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-storelocator-plugin",
"version": "2.0.3",
"version": "2.0.4",
"description": "This jQuery plugin takes advantage of Google Maps API version 3 to create an easy to implement store locator. No back-end programming is required, you just need to feed it KML, XML, or JSON data with all the location information.",
"repository": {
"type": "git",
Expand Down
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ for even faster loading.

## Changelog

### Version 2.0.4

* Fixed bug with maxDistance and pagination setting combination. The last page of of the pagination results was set to
use the locationsPerPage setting instead of the remaining number, which could have resulted in the plugin trying to
load undefined locations.
* Fixed bugs with googleGeocode and reverseGoogleGeocode methods in which references to "this" were undefined.

### Version 2.0.3

* Fixed bug with maxDistance setting - updated locationsSetup method so that the locationset array uses array.push
Expand Down
22 changes: 13 additions & 9 deletions src/js/jquery.storelocator.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@
// If a default location is set
if (this.settings.defaultLoc === true) {
// The address needs to be determined for the directions link
var r = new this.reverseGoogleGeocode();
var r = new this.reverseGoogleGeocode(this);
var latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
r.geocode({'latLng': latlng}, function (data) {
if (data !== null) {
Expand Down Expand Up @@ -470,8 +470,8 @@
/**
* Geocode function used to geocode the origin (entered location)
*/
googleGeocode: function () {
var _this = this;
googleGeocode: function (thisObj) {
var _this = thisObj;
var geocoder = new google.maps.Geocoder();
this.geocode = function (request, callbackFunction) {
geocoder.geocode(request, function (results, status) {
Expand All @@ -491,8 +491,8 @@
/**
* Reverse geocode to get address for automatic options needed for directions link
*/
reverseGoogleGeocode: function () {
var _this = this;
reverseGoogleGeocode: function (thisObj) {
var _this = thisObj;
var geocoder = new google.maps.Geocoder();
this.geocode = function (request, callbackFunction) {
geocoder.geocode(request, function (results, status) {
Expand Down Expand Up @@ -639,6 +639,7 @@
* @returns {string}
*/
_paginationOutput: function(currentPage, totalPages) {

currentPage = parseFloat(currentPage);
var output = '';
var nextPage = currentPage + 1;
Expand All @@ -650,7 +651,7 @@
}

// Add the numbers
for (var p = 0; p < totalPages; p++) {
for (var p = 0; p < Math.ceil(totalPages); p++) {
var n = p + 1;

if (p === currentPage) {
Expand Down Expand Up @@ -933,7 +934,7 @@
var _this = this;
var mappingObj = {};
// The address needs to be determined for the directions link
var r = new this.reverseGoogleGeocode();
var r = new this.reverseGoogleGeocode(this);
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
r.geocode({'latLng': latlng}, function (data) {
if (data !== null) {
Expand Down Expand Up @@ -1120,7 +1121,7 @@
this._start();
}
else if(addressInput !== '') {
var g = new this.googleGeocode();
var g = new this.googleGeocode(this);
g.geocode({'address': addressInput, 'region': region}, function (data) {
if (data !== null) {
olat = data.latitude;
Expand Down Expand Up @@ -1149,7 +1150,6 @@
* Checks distance of each location and setups up the locationset array
*
* @param data {Object} location data object
* @param l {number} iterator from the loop processing the data in the mapping function below
* @param lat {number} origin latitude
* @param lng {number} origin longitude
* @param firstRun {boolean} initial load check
Expand Down Expand Up @@ -1661,6 +1661,10 @@
storeNumToShow = _this.settings.locationsPerPage;
storeStart = page * _this.settings.locationsPerPage;

if( (storeStart + storeNumToShow) > locationset.length ) {
storeNumToShow = _this.settings.locationsPerPage - ((storeStart + storeNumToShow) - locationset.length);
}

locationset = locationset.slice(storeStart, storeStart + storeNumToShow);
storeNum = locationset.length;
}
Expand Down
2 changes: 1 addition & 1 deletion storelocator.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "jQuery Google Maps Store Locator",
"description": "This jQuery plugin takes advantage of Google Maps API version 3 to create an easy to implement store locator. No back-end programming is required, you just need to feed it KML, XML, or JSON data with all the location information.",
"keywords": ["jquery","locator","store", "location", "locations", "maps", "map", "stores", "find"],
"version": "2.0.3",
"version": "2.0.4",
"author": {
"name": "Bjorn Holine",
"url": "http://www.bjornblog.com/"
Expand Down

0 comments on commit 8eb120b

Please sign in to comment.