1
1
/*
2
- * storeLocator v1.4.7 - jQuery Google Maps Store Locator Plugin
2
+ * storeLocator v1.4.8 - jQuery Google Maps Store Locator Plugin
3
3
* (c) Copyright 2013, Bjorn Holine (http://www.bjornblog.com)
4
4
* Released under the MIT license
5
5
* Distance calculation function by Chris Pietschmann: http://pietschsoft.com/post/2008/02/01/Calculate-Distance-Between-Geocodes-in-C-and-JavaScript.aspx
@@ -162,7 +162,7 @@ $.fn.storeLocator = function(options) {
162
162
geocoder = new google . maps . Geocoder ( ) ;
163
163
this . geocode = function ( address , callbackFunction ) {
164
164
geocoder . geocode ( { 'address' : address } , function ( results , status ) {
165
- if ( status == google . maps . GeocoderStatus . OK ) {
165
+ if ( status === google . maps . GeocoderStatus . OK ) {
166
166
var result = { } ;
167
167
result . latitude = results [ 0 ] . geometry . location . lat ( ) ;
168
168
result . longitude = results [ 0 ] . geometry . location . lng ( ) ;
@@ -180,7 +180,7 @@ $.fn.storeLocator = function(options) {
180
180
geocoder = new google . maps . Geocoder ( ) ;
181
181
this . geocode = function ( latlng , callbackFunction ) {
182
182
geocoder . geocode ( { 'latLng' : latlng } , function ( results , status ) {
183
- if ( status == google . maps . GeocoderStatus . OK ) {
183
+ if ( status === google . maps . GeocoderStatus . OK ) {
184
184
if ( results [ 0 ] ) {
185
185
var result = { } ;
186
186
result . address = results [ 0 ] . formatted_address ;
@@ -377,25 +377,25 @@ $.fn.storeLocator = function(options) {
377
377
if ( settings . dataType === 'json' || settings . dataType === 'jsonp' ) {
378
378
//Process JSON
379
379
$ . each ( data , function ( ) {
380
- var key , value , locationData = { } ;
380
+ var key , value , locationData = { } ;
381
381
382
- // Parse each data variables
383
- for ( key in this ) {
384
- value = this [ key ] ;
382
+ // Parse each data variables
383
+ for ( key in this ) {
384
+ value = this [ key ] ;
385
385
386
- if ( key == 'locname' ) {
387
- key = 'name' ; // Translate locname to name (todo: should NOT be done)
388
- }
389
- else if ( key == 'web' ) {
390
- if ( value ) value = value . replace ( "http://" , "" ) ; // Remove scheme (todo: should NOT be done)
391
- }
386
+ if ( key === 'locname' ) {
387
+ key = 'name' ; // Translate locname to name (todo: should NOT be done)
388
+ }
389
+ else if ( key === 'web' ) {
390
+ if ( value ) value = value . replace ( "http://" , "" ) ; // Remove scheme (todo: should NOT be done)
391
+ }
392
392
393
- locationData [ key ] = value ;
394
- }
393
+ locationData [ key ] = value ;
394
+ }
395
395
396
- if ( ! locationData [ 'distance' ] ) {
397
- locationData [ 'distance' ] = GeoCodeCalc . CalcDistance ( orig_lat , orig_lng , locationData [ 'lat' ] , locationData [ 'lng' ] , GeoCodeCalc . EarthRadius ) ;
398
- }
396
+ if ( ! locationData [ 'distance' ] ) {
397
+ locationData [ 'distance' ] = GeoCodeCalc . CalcDistance ( orig_lat , orig_lng , locationData [ 'lat' ] , locationData [ 'lng' ] , GeoCodeCalc . EarthRadius ) ;
398
+ }
399
399
400
400
//Create the array
401
401
if ( settings . maxDistance === true && firstRun !== true ) {
@@ -416,14 +416,14 @@ $.fn.storeLocator = function(options) {
416
416
else if ( settings . dataType === 'kml' ) {
417
417
//Process KML
418
418
$ ( data ) . find ( 'Placemark' ) . each ( function ( ) {
419
- var locationData = {
420
- 'name' : $ ( this ) . find ( 'name' ) . text ( ) ,
421
- 'lat' : $ ( this ) . find ( 'coordinates' ) . text ( ) . split ( "," ) [ 1 ] ,
422
- 'lng' : $ ( this ) . find ( 'coordinates' ) . text ( ) . split ( "," ) [ 0 ] ,
423
- 'description' : $ ( this ) . find ( 'description' ) . text ( )
424
- } ;
419
+ var locationData = {
420
+ 'name' : $ ( this ) . find ( 'name' ) . text ( ) ,
421
+ 'lat' : $ ( this ) . find ( 'coordinates' ) . text ( ) . split ( "," ) [ 1 ] ,
422
+ 'lng' : $ ( this ) . find ( 'coordinates' ) . text ( ) . split ( "," ) [ 0 ] ,
423
+ 'description' : $ ( this ) . find ( 'description' ) . text ( )
424
+ } ;
425
425
426
- locationData [ 'distance' ] = GeoCodeCalc . CalcDistance ( orig_lat , orig_lng , locationData [ 'lat' ] , locationData [ 'lng' ] , GeoCodeCalc . EarthRadius ) ;
426
+ locationData [ 'distance' ] = GeoCodeCalc . CalcDistance ( orig_lat , orig_lng , locationData [ 'lat' ] , locationData [ 'lng' ] , GeoCodeCalc . EarthRadius ) ;
427
427
428
428
//Create the array
429
429
if ( settings . maxDistance === true && firstRun !== true ) {
@@ -444,27 +444,27 @@ $.fn.storeLocator = function(options) {
444
444
else {
445
445
//Process XML
446
446
$ ( data ) . find ( 'marker' ) . each ( function ( ) {
447
- var locationData = {
448
- 'name' : $ ( this ) . attr ( 'name' ) ,
449
- 'lat' : $ ( this ) . attr ( 'lat' ) ,
450
- 'lng' : $ ( this ) . attr ( 'lng' ) ,
451
- 'address' : $ ( this ) . attr ( 'address' ) ,
452
- 'address2' : $ ( this ) . attr ( 'address2' ) ,
453
- 'city' : $ ( this ) . attr ( 'city' ) ,
454
- 'state' : $ ( this ) . attr ( 'state' ) ,
455
- 'postal' : $ ( this ) . attr ( 'postal' ) ,
456
- 'country' : $ ( this ) . attr ( 'country' ) ,
457
- 'phone' : $ ( this ) . attr ( 'phone' ) ,
458
- 'email' : $ ( this ) . attr ( 'email' ) ,
459
- 'web' : $ ( this ) . attr ( 'web' ) ,
460
- 'hours1' : $ ( this ) . attr ( 'hours1' ) ,
461
- 'hours2' : $ ( this ) . attr ( 'hours2' ) ,
462
- 'hours3' : $ ( this ) . attr ( 'hours3' ) ,
463
- 'category' : $ ( this ) . attr ( 'category' ) ,
464
- 'featured' : $ ( this ) . attr ( 'featured' )
465
- } ;
466
-
467
- if ( locationData [ 'web' ] ) locationData [ 'web' ] = locationData [ 'web' ] . replace ( "http://" , "" ) ; // Remove scheme (todo: should NOT be done)
447
+ var locationData = {
448
+ 'name' : $ ( this ) . attr ( 'name' ) ,
449
+ 'lat' : $ ( this ) . attr ( 'lat' ) ,
450
+ 'lng' : $ ( this ) . attr ( 'lng' ) ,
451
+ 'address' : $ ( this ) . attr ( 'address' ) ,
452
+ 'address2' : $ ( this ) . attr ( 'address2' ) ,
453
+ 'city' : $ ( this ) . attr ( 'city' ) ,
454
+ 'state' : $ ( this ) . attr ( 'state' ) ,
455
+ 'postal' : $ ( this ) . attr ( 'postal' ) ,
456
+ 'country' : $ ( this ) . attr ( 'country' ) ,
457
+ 'phone' : $ ( this ) . attr ( 'phone' ) ,
458
+ 'email' : $ ( this ) . attr ( 'email' ) ,
459
+ 'web' : $ ( this ) . attr ( 'web' ) ,
460
+ 'hours1' : $ ( this ) . attr ( 'hours1' ) ,
461
+ 'hours2' : $ ( this ) . attr ( 'hours2' ) ,
462
+ 'hours3' : $ ( this ) . attr ( 'hours3' ) ,
463
+ 'category' : $ ( this ) . attr ( 'category' ) ,
464
+ 'featured' : $ ( this ) . attr ( 'featured' )
465
+ } ;
466
+
467
+ if ( locationData [ 'web' ] ) locationData [ 'web' ] = locationData [ 'web' ] . replace ( "http://" , "" ) ; // Remove scheme (todo: should NOT be done)
468
468
469
469
locationData [ 'distance' ] = GeoCodeCalc . CalcDistance ( orig_lat , orig_lng , locationData [ 'lat' ] , locationData [ 'lng' ] , GeoCodeCalc . EarthRadius ) ;
470
470
@@ -523,27 +523,27 @@ $.fn.storeLocator = function(options) {
523
523
}
524
524
}
525
525
else {
526
- if ( settings . distanceAlert != - 1 && locationset [ 0 ] [ 'distance' ] > settings . distanceAlert ) {
526
+ if ( settings . distanceAlert !== - 1 && locationset [ 0 ] [ 'distance' ] > settings . distanceAlert ) {
527
527
alert ( settings . distanceErrorAlert + settings . distanceAlert + " " + distUnit ) ;
528
528
}
529
529
}
530
530
531
531
//Create the map with jQuery
532
532
$ ( function ( ) {
533
533
534
- var key , value , locationData = { } ;
534
+ var key , value , locationData = { } ;
535
535
536
536
//Instead of repeating the same thing twice below
537
537
function create_location_variables ( loopcount ) {
538
- for ( key in locationset [ loopcount ] ) {
539
- value = locationset [ loopcount ] [ key ] ;
538
+ for ( key in locationset [ loopcount ] ) {
539
+ value = locationset [ loopcount ] [ key ] ;
540
540
541
- if ( key == 'distance' ) {
542
- value = roundNumber ( value , 2 ) ;
543
- }
541
+ if ( key === 'distance' ) {
542
+ value = roundNumber ( value , 2 ) ;
543
+ }
544
544
545
- locationData [ key ] = value ;
546
- }
545
+ locationData [ key ] = value ;
546
+ }
547
547
}
548
548
549
549
//Define the location data for the templates
@@ -571,7 +571,7 @@ $.fn.storeLocator = function(options) {
571
571
//Set up alpha character
572
572
var markerId = currentMarker . get ( "id" ) ;
573
573
//Use dot markers instead of alpha if there are more than 26 locations
574
- if ( settings . storeLimit == - 1 || settings . storeLimit > 26 ) {
574
+ if ( settings . storeLimit === - 1 || settings . storeLimit > 26 ) {
575
575
var indicator = markerId + 1 ;
576
576
}
577
577
else {
@@ -580,13 +580,13 @@ $.fn.storeLocator = function(options) {
580
580
581
581
//Define location data
582
582
var locations = {
583
- location : [ $ . extend ( locationData , {
584
- 'markerid' : markerId ,
585
- 'marker' : indicator ,
586
- 'length' : distLength ,
587
- 'origin' : origin
588
- } ) ]
589
- } ;
583
+ location : [ $ . extend ( locationData , {
584
+ 'markerid' : markerId ,
585
+ 'marker' : indicator ,
586
+ 'length' : distLength ,
587
+ 'origin' : origin
588
+ } ) ]
589
+ } ;
590
590
591
591
return locations ;
592
592
}
@@ -651,7 +651,7 @@ $.fn.storeLocator = function(options) {
651
651
var infowindow = new google . maps . InfoWindow ( ) ;
652
652
653
653
//Avoid error if number of locations is less than the default of 26
654
- if ( settings . storeLimit == - 1 || ( locationset . length - 1 ) < settings . storeLimit - 1 ) {
654
+ if ( settings . storeLimit === - 1 || ( locationset . length - 1 ) < settings . storeLimit - 1 ) {
655
655
storenum = locationset . length - 1 ;
656
656
}
657
657
else {
@@ -749,7 +749,7 @@ $.fn.storeLocator = function(options) {
749
749
new google . maps . Point ( 12 , 35 ) ) ;
750
750
751
751
//Create the markers
752
- if ( settings . storeLimit == - 1 || settings . storeLimit > 26 ) {
752
+ if ( settings . storeLimit === - 1 || settings . storeLimit > 26 ) {
753
753
var marker = new google . maps . Marker ( {
754
754
position : point ,
755
755
map : map ,
@@ -813,4 +813,4 @@ $.fn.storeLocator = function(options) {
813
813
814
814
} ) ;
815
815
} ;
816
- } ) ( jQuery ) ;
816
+ } ) ( jQuery ) ;
0 commit comments