Version Notes
you can call store locator on your CMS page by this code
{{block type="storelocator/storelocator" name="storelocator" template="storelocator/storelocator.phtml" }}
Download this release
Release Info
Developer | Sparx |
Extension | Sparx_Storelocator |
Version | 0.1.3 |
Comparing to | |
See all releases |
Code changes from version 0.1.2 to 0.1.3
- app/code/community/Sparx/Storelocator/etc/config.xml +1 -1
- app/code/community/Sparx/Storelocator/etc/system.xml +9 -0
- app/design/frontend/base/default/template/storelocator/storedetail.phtml +8 -1
- app/design/frontend/base/default/template/storelocator/storelocator.phtml +10 -0
- app/etc/modules/Sparx_Storelocator.xml +1 -1
- media/storelocator/images/1480934242_2.jpg +0 -0
- package.xml +9 -9
- skin/frontend/base/default/storelocator/js/jquery.storelocator_1.js +0 -818
app/code/community/Sparx/Storelocator/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Sparx_Storelocator>
|
5 |
-
<version>0.1.
|
6 |
</Sparx_Storelocator>
|
7 |
</modules>
|
8 |
<frontend>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Sparx_Storelocator>
|
5 |
+
<version>0.1.3</version>
|
6 |
</Sparx_Storelocator>
|
7 |
</modules>
|
8 |
<frontend>
|
app/code/community/Sparx/Storelocator/etc/system.xml
CHANGED
@@ -35,6 +35,15 @@
|
|
35 |
<show_in_store>0</show_in_store>
|
36 |
<comment>Enable Store Locator</comment>
|
37 |
</active>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
<jquery translate="label">
|
39 |
<label>Enable jQuery</label>
|
40 |
<frontend_type>select</frontend_type>
|
35 |
<show_in_store>0</show_in_store>
|
36 |
<comment>Enable Store Locator</comment>
|
37 |
</active>
|
38 |
+
<apikey translate="label">
|
39 |
+
<label>Google Map Api Key</label>
|
40 |
+
<frontend_type>text</frontend_type>
|
41 |
+
<sort_order>40</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
+
<comment>Please enter your google map api key</comment>
|
46 |
+
</apikey>
|
47 |
<jquery translate="label">
|
48 |
<label>Enable jQuery</label>
|
49 |
<frontend_type>select</frontend_type>
|
app/design/frontend/base/default/template/storelocator/storedetail.phtml
CHANGED
@@ -11,8 +11,11 @@ if($storeData && $storeData->getId()){
|
|
11 |
if($storeData->getZoomLevel()){
|
12 |
$zoomlevel = $storeData->getZoomLevel();
|
13 |
}
|
14 |
-
}
|
|
|
|
|
15 |
?>
|
|
|
16 |
<div id="store-locator-container store-locator-detail">
|
17 |
|
18 |
<h1><?php echo $this->__("Store Locator"); ?></h1>
|
@@ -43,5 +46,9 @@ if($storeData->getZoomLevel()){
|
|
43 |
jQuery('#map-container').storeLocator({'slideMap' : true, 'originMarker' : true, 'zoomLevel' : <?php echo $zoomlevel; ?>, 'fullMapStart' : true, 'defaultLoc': true, 'defaultLat': '<?php echo $lat; ?>', 'defaultLng' : '<?php echo $lng; ?>' });
|
44 |
});
|
45 |
</script>
|
|
|
|
|
46 |
|
|
|
47 |
|
|
11 |
if($storeData->getZoomLevel()){
|
12 |
$zoomlevel = $storeData->getZoomLevel();
|
13 |
}
|
14 |
+
}
|
15 |
+
|
16 |
+
$apikey = Mage::getStoreConfig('storelocator/settings/apikey',$storeid);
|
17 |
?>
|
18 |
+
<?php if(!empty($apikey)):?>
|
19 |
<div id="store-locator-container store-locator-detail">
|
20 |
|
21 |
<h1><?php echo $this->__("Store Locator"); ?></h1>
|
46 |
jQuery('#map-container').storeLocator({'slideMap' : true, 'originMarker' : true, 'zoomLevel' : <?php echo $zoomlevel; ?>, 'fullMapStart' : true, 'defaultLoc': true, 'defaultLat': '<?php echo $lat; ?>', 'defaultLng' : '<?php echo $lng; ?>' });
|
47 |
});
|
48 |
</script>
|
49 |
+
<script src="https://maps.googleapis.com/maps/api/js?key=<?php echo $apikey;?>"></script>
|
50 |
+
<?php else: ?>
|
51 |
|
52 |
+
<div><?php echo $this->__('Please enter correct google map api key in admin configuration. To know more ')?><a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_blank"><?php echo $this->__('Click here')?></a></div>
|
53 |
|
54 |
+
<?php endif ?>
|
app/design/frontend/base/default/template/storelocator/storelocator.phtml
CHANGED
@@ -5,7 +5,9 @@
|
|
5 |
$storeid = Mage::app()->getStore()->getId();
|
6 |
$lng = Mage::getStoreConfig('storelocator/settings/defaultlon', $storeid);
|
7 |
$lat = Mage::getStoreConfig('storelocator/settings/defaultlat',$storeid);
|
|
|
8 |
?>
|
|
|
9 |
<div id="store-locator-container">
|
10 |
|
11 |
<h1><?php echo $this->__("Store Locator"); ?></h1>
|
@@ -51,4 +53,12 @@ $lat = Mage::getStoreConfig('storelocator/settings/defaultlat',$storeid);
|
|
51 |
</script>
|
52 |
<?php endif ?>
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
5 |
$storeid = Mage::app()->getStore()->getId();
|
6 |
$lng = Mage::getStoreConfig('storelocator/settings/defaultlon', $storeid);
|
7 |
$lat = Mage::getStoreConfig('storelocator/settings/defaultlat',$storeid);
|
8 |
+
$apikey = Mage::getStoreConfig('storelocator/settings/apikey',$storeid);
|
9 |
?>
|
10 |
+
<?php if(!empty($apikey)):?>
|
11 |
<div id="store-locator-container">
|
12 |
|
13 |
<h1><?php echo $this->__("Store Locator"); ?></h1>
|
53 |
</script>
|
54 |
<?php endif ?>
|
55 |
|
56 |
+
<script src="https://maps.googleapis.com/maps/api/js?key=<?php echo $apikey;?>"></script>
|
57 |
+
|
58 |
+
<?php else: ?>
|
59 |
+
|
60 |
+
<div><?php echo $this->__('Please enter correct google map api key in admin configuration. To know more ')?><a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_blank"><?php echo $this->__('Click here')?></a></div>
|
61 |
+
|
62 |
+
<?php endif ?>
|
63 |
+
|
64 |
|
app/etc/modules/Sparx_Storelocator.xml
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
<Sparx_Storelocator>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
-
<version>0.1.
|
8 |
</Sparx_Storelocator>
|
9 |
</modules>
|
10 |
</config>
|
4 |
<Sparx_Storelocator>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
+
<version>0.1.3</version>
|
8 |
</Sparx_Storelocator>
|
9 |
</modules>
|
10 |
</config>
|
media/storelocator/images/1480934242_2.jpg
ADDED
Binary file
|
package.xml
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Sparx_Storelocator</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
-
<license>Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>With the help of store locator your customer can easily find out your stores, dealers and products.</summary>
|
10 |
<description>With the help of store locator your customer can easily find out your stores, dealers and products.</description>
|
11 |
-
<notes>you can call store locator on your CMS page by this code
|
12 |
-
|
13 |
-
{{block type="storelocator/storelocator" name="storelocator" template="storelocator/storelocator.phtml" }}
|
14 |
-
<authors><author><name>
|
15 |
-
<date>
|
16 |
-
<time>
|
17 |
-
<contents><target name="magecommunity"><dir name="Sparx"><dir
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.0.1</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Sparx_Storelocator</name>
|
4 |
+
<version>0.1.3</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="https://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>With the help of store locator your customer can easily find out your stores, dealers and products.</summary>
|
10 |
<description>With the help of store locator your customer can easily find out your stores, dealers and products.</description>
|
11 |
+
<notes>you can call store locator on your CMS page by this code&#xD;
|
12 |
+
&#xD;
|
13 |
+
{{block type="storelocator/storelocator" name="storelocator" template="storelocator/storelocator.phtml" }}</notes>
|
14 |
+
<authors><author><name>Sparx</name><user>Alok</user><email>alok.kumar@sparxtechnologies.com</email></author></authors>
|
15 |
+
<date>2016-12-08</date>
|
16 |
+
<time>11:43:53</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="Sparx"><dir name="Storelocator"><dir name="Block"><dir name="Adminhtml"><file name="Region.php" hash="550d9365a637103d39320d5d4b1b63ca"/><dir name="Storelocator"><dir name="Edit"><file name="Form.php" hash="3c2e5708202cfae1992c0d61f40da235"/><dir name="Tab"><file name="Form.php" hash="d525c8fa9bd4e6137c44a9836ba4a618"/></dir><file name="Tabs.php" hash="6e207bb287097811b88e204b07adcc20"/></dir><file name="Edit.php" hash="1460b5f28c1e9629ae5f5a087829077a"/><file name="Grid.php" hash="5cdc26bd44bfcb742805a21ff34bd5bb"/></dir><file name="Storelocator.php" hash="f4a0bccfe6ccd8d22f90a82f2835f2fa"/></dir><file name="Storelocator.php" hash="7e77614777f610831e7d6ecc5ef62ba4"/></dir><dir name="Helper"><file name="Data.php" hash="86fe7afa9a9a38e79a783e9063b129b4"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Storelocator"><file name="Collection.php" hash="2d6b9966a360ac0b7eeaf7cf05ffdc63"/></dir><file name="Storelocator.php" hash="dafe05d0aa6101a6d03c4c37d7929678"/></dir><file name="Status.php" hash="7d61b3131d0d0fb360710a9e3d6a8f38"/><file name="Storelocator.php" hash="bd9db3c2d5b23c388fa8d5d54591b428"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="StorelocatorController.php" hash="6575bf85d296b055a710fe6c3da397dd"/></dir><file name="IndexController.php" hash="895e294e0ca275e8e16e8c8291327e1f"/><file name="IndexController.php~" hash="0b3228fa8b2c2c37e1df927d67f299a9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="09890d52d2cea540a576f91da0fcbded"/><file name="config.xml" hash="6b4cae0bfc06b452d306530840f570f1"/><file name="config.xml~" hash="c2393b6828e3d2c45964708362b34ca9"/><file name="system.xml" hash="9a91753d90085e9a842dc56ac5973160"/></dir><dir name="sql"><dir name="storelocator_setup"><file name="mysql4-install-0.1.0.php" hash="67b368a2037a4fa5249844aed7e4a0a0"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="bf7758e4f9f38a90eb0e8566d7c4a325"/><file name="mysql4-upgrade-0.1.0-0.1.1.php~" hash="5e3923f18bd6db5c4a49e0cee4cbc350"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="fb575f471387a91889c352c65551e551"/></dir></dir></dir></dir></target><target name="magemedia"><dir name="storelocator"><dir name="images"><dir name="100X100"><file name="1398758372_logo.jpg" hash="fa31e2c7c2a71ee75e75bf033e028e4b"/></dir><dir name="110X120"><file name="1398758372_logo.jpg" hash="be9679b60e6d67ea6227eb844cb5166c"/></dir><file name="1398758372_logo.jpg" hash="c4af7cabd68286e2a38cd87ec9c2cbbf"/><file name="1480934242_2.jpg" hash="3a79ac45f388883e543a06cab03a20e8"/><dir name="175X120"><file name="1398758372_logo.jpg" hash="cc911a117a5efb34ac19e269059ec999"/></dir><dir name="175X175"><file name="1398758372_logo.jpg" hash="d015014d7f420b5a07344b61228f1f2e"/></dir><dir name="250X120"><file name="1398758372_logo.jpg" hash="167e65861e9bfd349db773efebe1c778"/></dir><file name="logo.jpg" hash="c4af7cabd68286e2a38cd87ec9c2cbbf"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="storelocator"><file name="a.js~" hash="d41d8cd98f00b204e9800998ecf8427e"/><dir><dir name="css"><file name="map-style.css" hash="4b4ab7443d3f836737ffc05d3f494e27"/><file name="map-style.less" hash="f5db8b390b0b2dde9eddf8d5f76a827d"/><file name="map.css" hash="1dd18292a08e7ca6c750de6d2388c754"/><file name="mapbackup.css" hash="419f881e975781dce04792865094a9c7"/></dir><dir name="js"><file name="handlebars-1.0.0.min.js" hash="b468988a5773757374f3e1188913e38a"/><file name="jquery-1.10.1.min.js" hash="33d85132f0154466fc017dd05111873d"/><file name="jquery.storelocator.js" hash="62e492542af80446b4713df5fd229c81"/><file name="noConflict.js" hash="3179f2255b046d5f2e9a71e365287bef"/></dir></dir><file name="jquery.storelocator.js~" hash="f04d3c879c93e95e3697781d1633c90a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="storelocator.xml" hash="3adedbd44805fa04c71f6482ef83e636"/></dir><dir name="template"><dir name="storelocator"><file name="region.phtml" hash="915c3f3770c031b51d895428c5c68d78"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="storelocator.xml" hash="684143632172c822ecff6a747ae512dd"/></dir><dir name="template"><dir name="storelocator"><file name="storedetail.phtml" hash="acf796147e82eec9ce67b945c2424694"/><file name="storelocator.phtml" hash="4ccad3ea59e05139ed8f390e34339a02"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Sparx_Storelocator.xml" hash="b745a576f61cd2f552d6a875f7604745"/></dir></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.0.1</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|
skin/frontend/base/default/storelocator/js/jquery.storelocator_1.js
DELETED
@@ -1,818 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* storeLocator v1.4.9 - jQuery Google Maps Store Locator Plugin
|
3 |
-
* (c) Copyright 2013, Bjorn Holine (http://www.bjornblog.com)
|
4 |
-
* Released under the MIT license
|
5 |
-
* Distance calculation function by Chris Pietschmann: http://pietschsoft.com/post/2008/02/01/Calculate-Distance-Between-Geocodes-in-C-and-JavaScript.aspx
|
6 |
-
*/
|
7 |
-
|
8 |
-
(function($){
|
9 |
-
$.fn.storeLocator = function(options) {
|
10 |
-
var url = jQuery("#url").val();
|
11 |
-
var url1 = jQuery("#url1").val();
|
12 |
-
var url2 = jQuery("#url2").val();
|
13 |
-
var settings = $.extend( {
|
14 |
-
'mapDiv': 'map',
|
15 |
-
'listDiv': 'loc-list',
|
16 |
-
'formContainerDiv': 'form-container',
|
17 |
-
'formID': 'user-location',
|
18 |
-
'inputID': 'address',
|
19 |
-
'zoomLevel': 2, //12 = The zoom level of the Google Map. Set to 0 to have the map automatically center and zoom to show all display markers on the map.
|
20 |
-
'pinColor': 'fe7569',
|
21 |
-
'pinTextColor': '000000',
|
22 |
-
'lengthUnit': 'm',
|
23 |
-
'storeLimit': -1, //26 = The number of closest locations displayed at one time. Set to -1 for unlimited.
|
24 |
-
'distanceAlert': -1, //60 = Displays an alert if there are no locations with 60 miles of the user’s location. Set to -1 to disable.
|
25 |
-
'dataType': 'xml',
|
26 |
-
'dataLocation': url,
|
27 |
-
'searchdataLocation': jQuery("#searchurl").val(),
|
28 |
-
'listColor1': 'ffffff',
|
29 |
-
'listColor2': 'eeeeee',
|
30 |
-
'originMarker': false,
|
31 |
-
'originpinColor': 'blue',
|
32 |
-
'bounceMarker': true,
|
33 |
-
'slideMap': true,
|
34 |
-
'modalWindow': false,
|
35 |
-
'overlayDiv': 'overlay',
|
36 |
-
'modalWindowDiv': 'modal-window',
|
37 |
-
'modalContentDiv': 'modal-content',
|
38 |
-
'modalCloseIconDiv': 'close-icon',
|
39 |
-
'defaultLoc': false,
|
40 |
-
'defaultLat': '',
|
41 |
-
'defaultLng': '',
|
42 |
-
'autoGeocode': false,
|
43 |
-
'maxDistance': false,
|
44 |
-
'maxDistanceID': 'maxdistance',
|
45 |
-
'fullMapStart': false,
|
46 |
-
'noForm': false,
|
47 |
-
'loading': false,
|
48 |
-
'loadingDiv': 'loading-map',
|
49 |
-
'featuredLocations': false,
|
50 |
-
'infowindowTemplatePath': url1,
|
51 |
-
'listTemplatePath': url2,
|
52 |
-
//'KMLinfowindowTemplatePath': url+'app/design/frontend/default/ramesh/template/storelocator/templates/kml-infowindow-description.html',
|
53 |
-
//'KMLlistTemplatePath': url+'app/design/frontend/default/ramesh/template/storelocator/templates/kml-location-list-description.html',
|
54 |
-
'callbackBeforeSend': null,
|
55 |
-
'callbackComplete': null,
|
56 |
-
'callbackSuccess': null,
|
57 |
-
'callbackModalOpen': null,
|
58 |
-
'callbackModalClose': null,
|
59 |
-
'jsonpCallback': null,
|
60 |
-
//Language options
|
61 |
-
'geocodeErrorAlert': 'Geocode was not successful for the following reason: ',
|
62 |
-
'addressErrorAlert' : 'Unable to find address',
|
63 |
-
'autoGeocodeErrorAlert': 'Automatic location detection failed. Please fill in your address or zip code.',
|
64 |
-
'distanceErrorAlert': '',
|
65 |
-
'mileLang': 'mile',
|
66 |
-
'milesLang': 'miles',
|
67 |
-
'kilometerLang': 'kilometer',
|
68 |
-
'kilometersLang': 'kilometers'
|
69 |
-
}, options);
|
70 |
-
|
71 |
-
return this.each(function() {
|
72 |
-
|
73 |
-
var $this = $(this);
|
74 |
-
var listTemplate, infowindowTemplate;
|
75 |
-
|
76 |
-
load_templates();
|
77 |
-
|
78 |
-
//First load external templates and compile with Handlebars - make sure the templates are compiled before moving on
|
79 |
-
function load_templates(){
|
80 |
-
|
81 |
-
if(settings.dataType === 'kml'){
|
82 |
-
//KML infowindows
|
83 |
-
$.get(settings.KMLinfowindowTemplatePath, function(template) {
|
84 |
-
var source = template;
|
85 |
-
infowindowTemplate = Handlebars.compile(source);
|
86 |
-
});
|
87 |
-
//KML locations list
|
88 |
-
$.get(settings.KMLlistTemplatePath, function(template) {
|
89 |
-
var source = template;
|
90 |
-
listTemplate = Handlebars.compile(source);
|
91 |
-
|
92 |
-
//After loading move on to the main script
|
93 |
-
locator();
|
94 |
-
});
|
95 |
-
}
|
96 |
-
else{
|
97 |
-
//Infowindows
|
98 |
-
$.get(settings.infowindowTemplatePath, function(template) {
|
99 |
-
var source = template;
|
100 |
-
infowindowTemplate = Handlebars.compile(source);
|
101 |
-
});
|
102 |
-
//Locations list
|
103 |
-
$.get(settings.listTemplatePath, function(template) {
|
104 |
-
var source = template;
|
105 |
-
listTemplate = Handlebars.compile(source);
|
106 |
-
|
107 |
-
//After loading move on to the main script
|
108 |
-
locator();
|
109 |
-
});
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
//The main script
|
114 |
-
function locator(){
|
115 |
-
|
116 |
-
var userinput, olat, olng, marker, letter, storenum;
|
117 |
-
var locationset = [];
|
118 |
-
var featuredset = [];
|
119 |
-
var normalset = [];
|
120 |
-
var markers = [];
|
121 |
-
var prefix = 'storeLocator';
|
122 |
-
|
123 |
-
//Resets for multiple re-submissions
|
124 |
-
function reset(){
|
125 |
-
locationset = [];
|
126 |
-
featuredset = [];
|
127 |
-
normalset = [];
|
128 |
-
markers = [];
|
129 |
-
$(document).off('click.'+prefix, '#' + settings.listDiv + ' li');
|
130 |
-
}
|
131 |
-
|
132 |
-
//Add modal window divs if set
|
133 |
-
if(settings.modalWindow === true){
|
134 |
-
$this.wrap('<div id="' + settings.overlayDiv + '"><div id="' + settings.modalWindowDiv + '"><div id="' + settings.modalContentDiv + '">');
|
135 |
-
$('#' + settings.modalWindowDiv).prepend('<div id="' + settings.modalCloseIconDiv + '"><\/div>');
|
136 |
-
$('#' + settings.overlayDiv).hide();
|
137 |
-
}
|
138 |
-
|
139 |
-
if(settings.slideMap === true){
|
140 |
-
//Let's hide the map container to begin
|
141 |
-
$this.hide();
|
142 |
-
}
|
143 |
-
|
144 |
-
//Calculate geocode distance functions - you could use Google's distance service instead
|
145 |
-
var GeoCodeCalc = {};
|
146 |
-
if(settings.lengthUnit === "km"){
|
147 |
-
//Kilometers
|
148 |
-
GeoCodeCalc.EarthRadius = 6367.0;
|
149 |
-
}
|
150 |
-
else{
|
151 |
-
//Default is miles
|
152 |
-
GeoCodeCalc.EarthRadius = 3956.0;
|
153 |
-
}
|
154 |
-
GeoCodeCalc.ToRadian = function(v) { return v * (Math.PI / 180);};
|
155 |
-
GeoCodeCalc.DiffRadian = function(v1, v2) {
|
156 |
-
return GeoCodeCalc.ToRadian(v2) - GeoCodeCalc.ToRadian(v1);
|
157 |
-
};
|
158 |
-
GeoCodeCalc.CalcDistance = function(lat1, lng1, lat2, lng2, radius) {
|
159 |
-
return radius * 2 * Math.asin( Math.min(1, Math.sqrt( ( Math.pow(Math.sin((GeoCodeCalc.DiffRadian(lat1, lat2)) / 2.0), 2.0) + Math.cos(GeoCodeCalc.ToRadian(lat1)) * Math.cos(GeoCodeCalc.ToRadian(lat2)) * Math.pow(Math.sin((GeoCodeCalc.DiffRadian(lng1, lng2)) / 2.0), 2.0) ) ) ) );
|
160 |
-
};
|
161 |
-
|
162 |
-
start();
|
163 |
-
|
164 |
-
function start(){
|
165 |
-
//If a default location is set
|
166 |
-
if(settings.defaultLoc === true){
|
167 |
-
//The address needs to be determined for the directions link
|
168 |
-
var r = new ReverseGoogleGeocode();
|
169 |
-
var latlng = new google.maps.LatLng(settings.defaultLat, settings.defaultLng);
|
170 |
-
r.geocode(latlng, function(data) {
|
171 |
-
if(data !== null) {
|
172 |
-
var originAddress = data.address;
|
173 |
-
mapping(settings.defaultLat, settings.defaultLng, originAddress);
|
174 |
-
} else {
|
175 |
-
//Unable to geocode
|
176 |
-
alert(settings.addressErrorAlert);
|
177 |
-
}
|
178 |
-
});
|
179 |
-
}
|
180 |
-
|
181 |
-
//If show full map option is true
|
182 |
-
if(settings.fullMapStart === true){
|
183 |
-
//Just do the mapping without an origin
|
184 |
-
mapping();
|
185 |
-
}
|
186 |
-
|
187 |
-
//HTML5 geolocation API option
|
188 |
-
if(settings.autoGeocode === true){
|
189 |
-
if (navigator.geolocation) {
|
190 |
-
navigator.geolocation.getCurrentPosition(autoGeocode_query, autoGeocode_error);
|
191 |
-
}
|
192 |
-
}
|
193 |
-
}
|
194 |
-
|
195 |
-
//Geocode function for the origin location
|
196 |
-
function GoogleGeocode(){
|
197 |
-
geocoder = new google.maps.Geocoder();
|
198 |
-
this.geocode = function(address, callbackFunction) {
|
199 |
-
geocoder.geocode( { 'address': address}, function(results, status) {
|
200 |
-
if (status === google.maps.GeocoderStatus.OK) {
|
201 |
-
var result = {};
|
202 |
-
result.latitude = results[0].geometry.location.lat();
|
203 |
-
result.longitude = results[0].geometry.location.lng();
|
204 |
-
callbackFunction(result);
|
205 |
-
} else {
|
206 |
-
alert(settings.geocodeErrorAlert + status);
|
207 |
-
callbackFunction(null);
|
208 |
-
}
|
209 |
-
});
|
210 |
-
};
|
211 |
-
}
|
212 |
-
|
213 |
-
//Reverse geocode to get address for automatic options needed for directions link
|
214 |
-
function ReverseGoogleGeocode(){
|
215 |
-
geocoder = new google.maps.Geocoder();
|
216 |
-
this.geocode = function(latlng, callbackFunction) {
|
217 |
-
geocoder.geocode( {'latLng': latlng}, function(results, status) {
|
218 |
-
if (status === google.maps.GeocoderStatus.OK) {
|
219 |
-
if (results[0]) {
|
220 |
-
var result = {};
|
221 |
-
result.address = results[0].formatted_address;
|
222 |
-
callbackFunction(result);
|
223 |
-
}
|
224 |
-
} else {
|
225 |
-
alert(settings.geocodeErrorAlert + status);
|
226 |
-
callbackFunction(null);
|
227 |
-
}
|
228 |
-
});
|
229 |
-
};
|
230 |
-
}
|
231 |
-
|
232 |
-
//Used to round miles to display
|
233 |
-
function roundNumber(num, dec){
|
234 |
-
return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
|
235 |
-
}
|
236 |
-
|
237 |
-
//If location is detected automatically
|
238 |
-
function autoGeocode_query(position){
|
239 |
-
//The address needs to be determined for the directions link
|
240 |
-
var r = new ReverseGoogleGeocode();
|
241 |
-
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
|
242 |
-
r.geocode(latlng, function(data) {
|
243 |
-
if(data !== null) {
|
244 |
-
var originAddress = data.address;
|
245 |
-
mapping(position.coords.latitude, position.coords.longitude, originAddress);
|
246 |
-
} else {
|
247 |
-
//Unable to geocode
|
248 |
-
alert(settings.addressErrorAlert);
|
249 |
-
}
|
250 |
-
});
|
251 |
-
}
|
252 |
-
|
253 |
-
function autoGeocode_error(error){
|
254 |
-
//If automatic detection doesn't work show an error
|
255 |
-
alert(settings.autoGeocodeErrorAlert);
|
256 |
-
}
|
257 |
-
|
258 |
-
//Set up the normal mapping
|
259 |
-
function begin_mapping(distance){
|
260 |
-
var searchzipcode='a';
|
261 |
-
//Get the user input and use it
|
262 |
-
var userinput = $('#' + settings.inputID).val();
|
263 |
-
|
264 |
-
if (userinput === ""){
|
265 |
-
start();
|
266 |
-
}
|
267 |
-
else{
|
268 |
-
var g = new GoogleGeocode();
|
269 |
-
var address = userinput;
|
270 |
-
g.geocode(address, function(data) {
|
271 |
-
if(data !== null) {
|
272 |
-
olat = data.latitude;
|
273 |
-
olng = data.longitude;
|
274 |
-
mapping(olat, olng, userinput, distance,searchzipcode);
|
275 |
-
} else {
|
276 |
-
//Unable to geocode
|
277 |
-
alert(settings.addressErrorAlert);
|
278 |
-
}
|
279 |
-
});
|
280 |
-
}
|
281 |
-
}
|
282 |
-
|
283 |
-
//Process form input
|
284 |
-
$(function(){
|
285 |
-
//Handle form submission
|
286 |
-
function get_form_values(e){
|
287 |
-
//Stop the form submission
|
288 |
-
e.preventDefault();
|
289 |
-
|
290 |
-
if(settings.maxDistance === true){
|
291 |
-
var maxDistance = $('#' + settings.maxDistanceID).val();
|
292 |
-
//Start the mapping
|
293 |
-
begin_mapping(maxDistance);
|
294 |
-
}
|
295 |
-
else{
|
296 |
-
//Start the mapping
|
297 |
-
begin_mapping();
|
298 |
-
}
|
299 |
-
}
|
300 |
-
|
301 |
-
//ASP.net or regular submission?
|
302 |
-
if(settings.noForm === true){
|
303 |
-
$(document).on('click.'+prefix, '#' + settings.formContainerDiv + ' #submit', function(e){
|
304 |
-
get_form_values(e);
|
305 |
-
});
|
306 |
-
$(document).on('keyup.'+prefix, function(e){
|
307 |
-
if (e.keyCode === 13 && $('#' + settings.inputID).is(':focus')) {
|
308 |
-
get_form_values(e);
|
309 |
-
}
|
310 |
-
});
|
311 |
-
}
|
312 |
-
else{
|
313 |
-
$(document).on('submit.'+prefix, '#' + settings.formID, function(e){
|
314 |
-
get_form_values(e);
|
315 |
-
});
|
316 |
-
}
|
317 |
-
});
|
318 |
-
|
319 |
-
//Now all the mapping stuff
|
320 |
-
function mapping(orig_lat, orig_lng, origin, maxDistance,s){
|
321 |
-
$(function(){
|
322 |
-
|
323 |
-
// Enable the visual refresh https://developers.google.com/maps/documentation/javascript/basics#VisualRefresh
|
324 |
-
google.maps.visualRefresh = true;
|
325 |
-
|
326 |
-
var dataTypeRead;
|
327 |
-
|
328 |
-
//KML is read as XML
|
329 |
-
if(settings.dataType === 'kml'){
|
330 |
-
dataTypeRead = "xml";
|
331 |
-
}
|
332 |
-
else{
|
333 |
-
dataTypeRead = settings.dataType;
|
334 |
-
}
|
335 |
-
|
336 |
-
var dataurl;
|
337 |
-
var zipcode = $('#' + settings.inputID).val();
|
338 |
-
dataurl = (s)?settings.searchdataLocation+"?zipcode="+zipcode:(settings.dataLocation + (settings.dataType === 'jsonp' ? (settings.dataLocation.match(/\?/) ? '&' : '?') + 'callback=?' : ''));
|
339 |
-
//Process the data
|
340 |
-
$.ajax({
|
341 |
-
type: "GET",
|
342 |
-
url: dataurl,
|
343 |
-
dataType: dataTypeRead,
|
344 |
-
jsonpCallback: (settings.dataType === 'jsonp' ? settings.jsonpCallback : null),
|
345 |
-
beforeSend: function (){
|
346 |
-
// Callback
|
347 |
-
if(settings.callbackBeforeSend){
|
348 |
-
settings.callbackBeforeSend.call(this);
|
349 |
-
}
|
350 |
-
|
351 |
-
//Loading
|
352 |
-
if(settings.loading === true){
|
353 |
-
$('#' + settings.formContainerDiv).append('<div id="' + settings.loadingDiv +'"><\/div>');
|
354 |
-
}
|
355 |
-
|
356 |
-
},
|
357 |
-
complete: function (event, request, options){
|
358 |
-
// Callback
|
359 |
-
if(settings.callbackComplete){
|
360 |
-
settings.callbackComplete.call(this, event, request, options);
|
361 |
-
}
|
362 |
-
|
363 |
-
//Loading remove
|
364 |
-
if(settings.loading === true){
|
365 |
-
$('#' + settings.loadingDiv).remove();
|
366 |
-
}
|
367 |
-
},
|
368 |
-
success: function (data, xhr, options){
|
369 |
-
// Callback
|
370 |
-
if(settings.callbackSuccess){
|
371 |
-
settings.callbackSuccess.call(this, data, xhr, options);
|
372 |
-
}
|
373 |
-
|
374 |
-
//After the store locations file has been read successfully
|
375 |
-
var i = 0;
|
376 |
-
var firstRun;
|
377 |
-
|
378 |
-
//Set a variable for fullMapStart so we can detect the first run
|
379 |
-
if(settings.fullMapStart === true && $('#' + settings.mapDiv).hasClass('mapOpen') === false){
|
380 |
-
firstRun = true;
|
381 |
-
}
|
382 |
-
else{
|
383 |
-
reset();
|
384 |
-
}
|
385 |
-
|
386 |
-
$('#' + settings.mapDiv).addClass('mapOpen');
|
387 |
-
|
388 |
-
//Depending on your data structure and what you want to include in the maps, you may need to change the following variables or comment them out
|
389 |
-
if(settings.dataType === 'json' || settings.dataType === 'jsonp'){
|
390 |
-
//Process JSON
|
391 |
-
$.each(data, function(){
|
392 |
-
var key, value, locationData = {};
|
393 |
-
|
394 |
-
// Parse each data variables
|
395 |
-
for( key in this ){
|
396 |
-
value = this[key];
|
397 |
-
|
398 |
-
if(key === 'web'){
|
399 |
-
if ( value ) value = value.replace("http://",""); // Remove scheme (todo: should NOT be done)
|
400 |
-
}
|
401 |
-
|
402 |
-
locationData[key] = value;
|
403 |
-
}
|
404 |
-
|
405 |
-
if(!locationData['distance']){
|
406 |
-
locationData['distance'] = GeoCodeCalc.CalcDistance(orig_lat,orig_lng,locationData['lat'],locationData['lng'], GeoCodeCalc.EarthRadius);
|
407 |
-
}
|
408 |
-
|
409 |
-
//Create the array
|
410 |
-
if(settings.maxDistance === true && firstRun !== true && maxDistance){
|
411 |
-
if(locationData['distance'] < maxDistance){
|
412 |
-
locationset[i] = locationData;
|
413 |
-
}
|
414 |
-
else{
|
415 |
-
return;
|
416 |
-
}
|
417 |
-
}
|
418 |
-
else{
|
419 |
-
locationset[i] = locationData;
|
420 |
-
}
|
421 |
-
|
422 |
-
i++;
|
423 |
-
});
|
424 |
-
}
|
425 |
-
else if(settings.dataType === 'kml'){
|
426 |
-
//Process KML
|
427 |
-
$(data).find('Placemark').each(function(){
|
428 |
-
var locationData = {
|
429 |
-
'name': $(this).find('name').text(),
|
430 |
-
'lat': $(this).find('coordinates').text().split(",")[1],
|
431 |
-
'lng': $(this).find('coordinates').text().split(",")[0],
|
432 |
-
'description': $(this).find('description').text()
|
433 |
-
};
|
434 |
-
|
435 |
-
locationData['distance'] = GeoCodeCalc.CalcDistance(orig_lat,orig_lng,locationData['lat'],locationData['lng'], GeoCodeCalc.EarthRadius);
|
436 |
-
|
437 |
-
//Create the array
|
438 |
-
if(settings.maxDistance === true && firstRun !== true && maxDistance){
|
439 |
-
if(locationData['distance'] < maxDistance){
|
440 |
-
locationset[i] = locationData;
|
441 |
-
}
|
442 |
-
else{
|
443 |
-
return;
|
444 |
-
}
|
445 |
-
}
|
446 |
-
else{
|
447 |
-
locationset[i] = locationData;
|
448 |
-
}
|
449 |
-
|
450 |
-
i++;
|
451 |
-
});
|
452 |
-
}
|
453 |
-
else{
|
454 |
-
//Process XML
|
455 |
-
$(data).find('marker').each(function(){
|
456 |
-
var locationData = {
|
457 |
-
'storeid': $(this).attr('storeid'),
|
458 |
-
'name': $(this).attr('name'),
|
459 |
-
'lat': $(this).attr('lat'),
|
460 |
-
'lng': $(this).attr('lng'),
|
461 |
-
'address': $(this).attr('address'),
|
462 |
-
'address2': $(this).attr('address2'),
|
463 |
-
'city': $(this).attr('city'),
|
464 |
-
'state': $(this).attr('state'),
|
465 |
-
'postal': $(this).attr('postal'),
|
466 |
-
'country': $(this).attr('country'),
|
467 |
-
'phone': $(this).attr('phone'),
|
468 |
-
'email': $(this).attr('email'),
|
469 |
-
'web': $(this).attr('web'),
|
470 |
-
'hours1': $(this).attr('hours1'),
|
471 |
-
'hours2': $(this).attr('hours2'),
|
472 |
-
'hours3': $(this).attr('hours3'),
|
473 |
-
'category': $(this).attr('category'),
|
474 |
-
'storeimage': $(this).attr('storeimage'),
|
475 |
-
'fax': $(this).attr('fax'),
|
476 |
-
'featured': $(this).attr('featured')
|
477 |
-
};
|
478 |
-
|
479 |
-
if(locationData['web']) locationData['web'] = locationData['web'].replace("http://",""); // Remove scheme (todo: should NOT be done)
|
480 |
-
|
481 |
-
locationData['distance'] = GeoCodeCalc.CalcDistance(orig_lat,orig_lng,locationData['lat'],locationData['lng'], GeoCodeCalc.EarthRadius);
|
482 |
-
|
483 |
-
//Create the array
|
484 |
-
if(settings.maxDistance === true && firstRun !== true && maxDistance){
|
485 |
-
if(locationData['distance'] < maxDistance){
|
486 |
-
locationset[i] = locationData;
|
487 |
-
}
|
488 |
-
else{
|
489 |
-
return;
|
490 |
-
}
|
491 |
-
}
|
492 |
-
else{
|
493 |
-
locationset[i] = locationData;
|
494 |
-
}
|
495 |
-
|
496 |
-
i++;
|
497 |
-
});
|
498 |
-
}
|
499 |
-
|
500 |
-
//Distance sorting function
|
501 |
-
function sort_numerically(locationsarray){
|
502 |
-
locationsarray.sort(function(a, b){
|
503 |
-
return ((a['distance'] < b['distance']) ? -1 : ((a['distance'] > b['distance']) ? 1 : 0));
|
504 |
-
});
|
505 |
-
}
|
506 |
-
|
507 |
-
//Sort the multi-dimensional array by distance
|
508 |
-
sort_numerically(locationset);
|
509 |
-
|
510 |
-
//Featured locations filtering
|
511 |
-
if(settings.featuredLocations === true){
|
512 |
-
//Create array for featured locations
|
513 |
-
featuredset = $.grep(locationset, function(val, i){
|
514 |
-
return val['featured'] === "true";
|
515 |
-
});
|
516 |
-
|
517 |
-
//Create array for normal locations
|
518 |
-
normalset = $.grep(locationset, function(val, i){
|
519 |
-
return val['featured'] !== "true";
|
520 |
-
});
|
521 |
-
|
522 |
-
//Combine the arrays
|
523 |
-
locationset = [];
|
524 |
-
locationset = featuredset.concat(normalset);
|
525 |
-
}
|
526 |
-
|
527 |
-
//Get the length unit
|
528 |
-
var distUnit = (settings.lengthUnit === "km") ? settings.kilometersLang : settings.milesLang ;
|
529 |
-
|
530 |
-
//Check the closest marker
|
531 |
-
if(settings.maxDistance === true && firstRun !== true && maxDistance){
|
532 |
-
if(locationset[0] === undefined || locationset[0]['distance'] > maxDistance){
|
533 |
-
alert(settings.distanceErrorAlert + maxDistance + " " + distUnit);
|
534 |
-
return;
|
535 |
-
}
|
536 |
-
}
|
537 |
-
else{
|
538 |
-
if(settings.distanceAlert !== -1 && locationset[0]['distance'] > settings.distanceAlert){
|
539 |
-
alert(settings.distanceErrorAlert + settings.distanceAlert + " " + distUnit);
|
540 |
-
}
|
541 |
-
}
|
542 |
-
|
543 |
-
//Create the map with jQuery
|
544 |
-
$(function(){
|
545 |
-
|
546 |
-
var key, value, locationData = {};
|
547 |
-
|
548 |
-
//Instead of repeating the same thing twice below
|
549 |
-
function create_location_variables(loopcount){
|
550 |
-
for ( key in locationset[loopcount] ) {
|
551 |
-
value = locationset[loopcount][key];
|
552 |
-
|
553 |
-
if(key === 'distance'){
|
554 |
-
value = roundNumber(value,2);
|
555 |
-
}
|
556 |
-
|
557 |
-
locationData[key] = value;
|
558 |
-
}
|
559 |
-
}
|
560 |
-
|
561 |
-
//Define the location data for the templates
|
562 |
-
function define_location_data(currentMarker){
|
563 |
-
create_location_variables(currentMarker.get("id"));
|
564 |
-
|
565 |
-
var distLength;
|
566 |
-
if(locationData['distance'] <= 1){
|
567 |
-
if(settings.lengthUnit === "km"){
|
568 |
-
distLength = settings.kilometerLang;
|
569 |
-
}
|
570 |
-
else{
|
571 |
-
distLength = settings.mileLang;
|
572 |
-
}
|
573 |
-
}
|
574 |
-
else{
|
575 |
-
if(settings.lengthUnit === "km"){
|
576 |
-
distLength = settings.kilometersLang;
|
577 |
-
}
|
578 |
-
else{
|
579 |
-
distLength = settings.milesLang;
|
580 |
-
}
|
581 |
-
}
|
582 |
-
|
583 |
-
//Set up alpha character
|
584 |
-
var markerId = currentMarker.get("id");
|
585 |
-
//Use dot markers instead of alpha if there are more than 26 locations
|
586 |
-
if(settings.storeLimit === -1 || settings.storeLimit > 26){
|
587 |
-
var indicator = markerId + 1;
|
588 |
-
}
|
589 |
-
else{
|
590 |
-
var indicator = String.fromCharCode("A".charCodeAt(0) + markerId);
|
591 |
-
}
|
592 |
-
|
593 |
-
//Define location data
|
594 |
-
var locations = {
|
595 |
-
location: [$.extend(locationData, {
|
596 |
-
'markerid': markerId,
|
597 |
-
'marker': indicator,
|
598 |
-
'length': distLength,
|
599 |
-
'origin': origin
|
600 |
-
})]
|
601 |
-
};
|
602 |
-
|
603 |
-
return locations;
|
604 |
-
}
|
605 |
-
|
606 |
-
//Slide in the map container
|
607 |
-
if(settings.slideMap === true){
|
608 |
-
$this.slideDown();
|
609 |
-
}
|
610 |
-
//Set up the modal window
|
611 |
-
if(settings.modalWindow === true){
|
612 |
-
// Callback
|
613 |
-
if (settings.callbackModalOpen){
|
614 |
-
settings.callbackModalOpen.call(this);
|
615 |
-
}
|
616 |
-
|
617 |
-
function modalClose(){
|
618 |
-
// Callback
|
619 |
-
if (settings.callbackModalOpen){
|
620 |
-
settings.callbackModalOpen.call(this);
|
621 |
-
}
|
622 |
-
|
623 |
-
$('#' + settings.overlayDiv).hide();
|
624 |
-
}
|
625 |
-
|
626 |
-
//Pop up the modal window
|
627 |
-
$('#' + settings.overlayDiv).fadeIn();
|
628 |
-
//Close modal when close icon is clicked and when background overlay is clicked
|
629 |
-
$(document).on('click.'+prefix, '#' + settings.modalCloseIconDiv + ', #' + settings.overlayDiv, function(){
|
630 |
-
modalClose();
|
631 |
-
});
|
632 |
-
//Prevent clicks within the modal window from closing the entire thing
|
633 |
-
$(document).on('click.'+prefix, '#' + settings.modalWindowDiv, function(e){
|
634 |
-
e.stopPropagation();
|
635 |
-
});
|
636 |
-
//Close modal when escape key is pressed
|
637 |
-
$(document).on('keyup.'+prefix, function(e){
|
638 |
-
if (e.keyCode === 27) {
|
639 |
-
modalClose();
|
640 |
-
}
|
641 |
-
});
|
642 |
-
}
|
643 |
-
|
644 |
-
//Google maps settings
|
645 |
-
if((settings.fullMapStart === true && firstRun === true) || settings.zoomLevel === 0){
|
646 |
-
var myOptions = {
|
647 |
-
mapTypeId: google.maps.MapTypeId.ROADMAP
|
648 |
-
};
|
649 |
-
var bounds = new google.maps.LatLngBounds ();
|
650 |
-
}
|
651 |
-
else{
|
652 |
-
var myOptions = {
|
653 |
-
zoom: settings.zoomLevel,
|
654 |
-
center: new google.maps.LatLng(orig_lat, orig_lng),
|
655 |
-
mapTypeId: google.maps.MapTypeId.ROADMAP
|
656 |
-
};
|
657 |
-
}
|
658 |
-
|
659 |
-
var map = new google.maps.Map(document.getElementById(settings.mapDiv),myOptions);
|
660 |
-
$this.data('map', map);
|
661 |
-
|
662 |
-
//Create one infowindow to fill later
|
663 |
-
var infowindow = new google.maps.InfoWindow();
|
664 |
-
|
665 |
-
//Avoid error if number of locations is less than the default of 26
|
666 |
-
if(settings.storeLimit === -1 || (locationset.length-1) < settings.storeLimit-1){
|
667 |
-
storenum = locationset.length-1;
|
668 |
-
}
|
669 |
-
else{
|
670 |
-
storenum = settings.storeLimit-1;
|
671 |
-
}
|
672 |
-
|
673 |
-
//Add origin marker if the setting is set
|
674 |
-
if(settings.originMarker === true && settings.fullMapStart === false){
|
675 |
-
var originPoint = new google.maps.LatLng(orig_lat, orig_lng);
|
676 |
-
var marker = new google.maps.Marker({
|
677 |
-
position: originPoint,
|
678 |
-
map: map,
|
679 |
-
icon: 'http://maps.google.com/mapfiles/ms/icons/'+ settings.originpinColor +'-dot.png',
|
680 |
-
draggable: false
|
681 |
-
});
|
682 |
-
}
|
683 |
-
|
684 |
-
//Add markers and infowindows loop
|
685 |
-
for(var y = 0; y <= storenum; y++) {
|
686 |
-
var letter = String.fromCharCode("A".charCodeAt(0) + y);
|
687 |
-
var point = new google.maps.LatLng(locationset[y]['lat'], locationset[y]['lng']);
|
688 |
-
marker = createMarker(point, locationset[y]['name'], locationset[y]['address'], letter );
|
689 |
-
marker.set("id", y);
|
690 |
-
markers[y] = marker;
|
691 |
-
if((settings.fullMapStart === true && firstRun === true) || settings.zoomLevel === 0){
|
692 |
-
bounds.extend(point);
|
693 |
-
}
|
694 |
-
//Pass variables to the pop-up infowindows
|
695 |
-
create_infowindow(marker);
|
696 |
-
}
|
697 |
-
|
698 |
-
//Center and zoom if no origin or zoom was provided
|
699 |
-
if((settings.fullMapStart === true && firstRun === true) || settings.zoomLevel === 0){
|
700 |
-
map.fitBounds(bounds);
|
701 |
-
}
|
702 |
-
|
703 |
-
//Create the links that focus on the related marker
|
704 |
-
$("#" + settings.listDiv + ' ul').empty();
|
705 |
-
$(markers).each(function(x, marker){
|
706 |
-
var letter = String.fromCharCode("A".charCodeAt(0) + x);
|
707 |
-
//This needs to happen outside the loop or there will be a closure problem with creating the infowindows attached to the list click
|
708 |
-
var currentMarker = markers[x];
|
709 |
-
listClick(currentMarker);
|
710 |
-
});
|
711 |
-
|
712 |
-
function listClick(marker){
|
713 |
-
//Define the location data
|
714 |
-
var locations = define_location_data(marker);
|
715 |
-
|
716 |
-
//Set up the list template with the location data
|
717 |
-
var listHtml = listTemplate(locations);
|
718 |
-
$('#' + settings.listDiv + ' ul').append(listHtml);
|
719 |
-
}
|
720 |
-
|
721 |
-
//Handle clicks from the list
|
722 |
-
$(document).on('click.'+prefix, '#' + settings.listDiv + ' li', function(){
|
723 |
-
var markerId = $(this).data('markerid');
|
724 |
-
|
725 |
-
var selectedMarker = markers[markerId];
|
726 |
-
|
727 |
-
//Focus on the list
|
728 |
-
$('#' + settings.listDiv + ' li').removeClass('list-focus');
|
729 |
-
$('#' + settings.listDiv + ' li[data-markerid=' + markerId +']').addClass('list-focus');
|
730 |
-
|
731 |
-
map.panTo(selectedMarker.getPosition());
|
732 |
-
var listLoc = "left";
|
733 |
-
if(settings.bounceMarker === true){
|
734 |
-
selectedMarker.setAnimation(google.maps.Animation.BOUNCE);
|
735 |
-
setTimeout(function() { selectedMarker.setAnimation(null); create_infowindow(selectedMarker, listLoc); }, 700);
|
736 |
-
}
|
737 |
-
else{
|
738 |
-
create_infowindow(selectedMarker, listLoc);
|
739 |
-
}
|
740 |
-
});
|
741 |
-
|
742 |
-
//Add the list li background colors
|
743 |
-
$("#" + settings.listDiv + " ul li:even").css('background', "#" + settings.listColor1);
|
744 |
-
$("#" + settings.listDiv + " ul li:odd").css('background', "#" + settings.listColor2);
|
745 |
-
|
746 |
-
//Custom marker function - alphabetical
|
747 |
-
function createMarker(point, name, address, letter){
|
748 |
-
//Set up pin icon with the Google Charts API for all of our markers
|
749 |
-
var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=" + letter + "|" + settings.pinColor + "|" + settings.pinTextColor,
|
750 |
-
new google.maps.Size(21, 34),
|
751 |
-
new google.maps.Point(0,0),
|
752 |
-
new google.maps.Point(10, 34));
|
753 |
-
|
754 |
-
//Create the markers
|
755 |
-
if(settings.storeLimit === -1 || settings.storeLimit > 26){
|
756 |
-
var marker = new google.maps.Marker({
|
757 |
-
position: point,
|
758 |
-
map: map,
|
759 |
-
draggable: false
|
760 |
-
});
|
761 |
-
}
|
762 |
-
else{
|
763 |
-
var marker = new google.maps.Marker({
|
764 |
-
position: point,
|
765 |
-
map: map,
|
766 |
-
icon: pinImage,
|
767 |
-
draggable: false
|
768 |
-
});
|
769 |
-
}
|
770 |
-
|
771 |
-
return marker;
|
772 |
-
}
|
773 |
-
|
774 |
-
//Infowindows
|
775 |
-
function create_infowindow(marker, location){
|
776 |
-
|
777 |
-
//Define the location data
|
778 |
-
var locations = define_location_data(marker);
|
779 |
-
|
780 |
-
//Set up the infowindow template with the location data
|
781 |
-
var formattedAddress = infowindowTemplate(locations);
|
782 |
-
|
783 |
-
//Opens the infowindow when list item is clicked
|
784 |
-
if(location === "left"){
|
785 |
-
infowindow.setContent(formattedAddress);
|
786 |
-
infowindow.open(marker.get('map'), marker);
|
787 |
-
}
|
788 |
-
//Opens the infowindow when the marker is clicked
|
789 |
-
else{
|
790 |
-
google.maps.event.addListener(marker, 'click', function() {
|
791 |
-
infowindow.setContent(formattedAddress);
|
792 |
-
infowindow.open(marker.get('map'), marker);
|
793 |
-
//Focus on the list
|
794 |
-
$('#' + settings.listDiv + ' li').removeClass('list-focus');
|
795 |
-
markerId = marker.get("id");
|
796 |
-
$('#' + settings.listDiv + ' li[data-markerid=' + markerId +']').addClass('list-focus');
|
797 |
-
|
798 |
-
//Scroll list to selected marker
|
799 |
-
var container = $('#' + settings.listDiv),scrollTo = $('#' + settings.listDiv + ' li[data-markerid=' + markerId +']');
|
800 |
-
$('#' + settings.listDiv).animate({
|
801 |
-
scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop()
|
802 |
-
});
|
803 |
-
});
|
804 |
-
}
|
805 |
-
|
806 |
-
}
|
807 |
-
|
808 |
-
});
|
809 |
-
}
|
810 |
-
});
|
811 |
-
});
|
812 |
-
}
|
813 |
-
|
814 |
-
}
|
815 |
-
|
816 |
-
});
|
817 |
-
};
|
818 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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