Advertisement
Guest User

store-locator.min.js

a guest
Jan 22nd, 2015
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function($) {
  2.     /*
  3.  
  4.  
  5.      Copyright 2012 Google Inc.
  6.  
  7.      Licensed under the Apache License, Version 2.0 (the "License");
  8.      you may not use this file except in compliance with the License.
  9.      You may obtain a copy of the License at
  10.  
  11.          http://www.apache.org/licenses/LICENSE-2.0
  12.  
  13.      Unless required by applicable law or agreed to in writing, software
  14.      distributed under the License is distributed on an "AS IS" BASIS,
  15.      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.      See the License for the specific language governing permissions and
  17.      limitations under the License.
  18.     */
  19.     var storeLocator = function() {};
  20.     window.storeLocator = storeLocator;
  21.     storeLocator.toRad_ = function(a) {
  22.         return a * Math.PI / 180
  23.     };
  24.     storeLocator.Feature = function(a, b) {
  25.         this.id_ = a;
  26.         this.name_ = b
  27.     };
  28.     storeLocator.Feature = storeLocator.Feature;
  29.     storeLocator.Feature.prototype.getId = function() {
  30.         return this.id_
  31.     };
  32.     storeLocator.Feature.prototype.getDisplayName = function() {
  33.         return this.name_
  34.     };
  35.     storeLocator.Feature.prototype.toString = function() {
  36.         return this.getDisplayName()
  37.     };
  38.     storeLocator.FeatureSet = function(a) {
  39.         this.array_ = [];
  40.         this.hash_ = {};
  41.         for (var b = 0, c; c = arguments[b]; b++) this.add(c)
  42.     };
  43.     storeLocator.FeatureSet = storeLocator.FeatureSet;
  44.     storeLocator.FeatureSet.prototype.toggle = function(a) {
  45.         this.contains(a) ? this.remove(a) : this.add(a)
  46.     };
  47.     storeLocator.FeatureSet.prototype.contains = function(a) {
  48.         return a.getId() in this.hash_
  49.     };
  50.     storeLocator.FeatureSet.prototype.getById = function(a) {
  51.         return a in this.hash_ ? this.array_[this.hash_[a]] : null
  52.     };
  53.     storeLocator.FeatureSet.prototype.add = function(a) {
  54.         a && (this.array_.push(a), this.hash_[a.getId()] = this.array_.length - 1)
  55.     };
  56.     storeLocator.FeatureSet.prototype.remove = function(a) {
  57.         this.contains(a) && (this.array_[this.hash_[a.getId()]] = null, delete this.hash_[a.getId()])
  58.     };
  59.     storeLocator.FeatureSet.prototype.asList = function() {
  60.         for (var a = [], b = 0, c = this.array_.length; b < c; b++) {
  61.             var d = this.array_[b];
  62.             null !== d && a.push(d)
  63.         }
  64.         return a
  65.     };
  66.     storeLocator.FeatureSet.NONE = new storeLocator.FeatureSet;
  67.     storeLocator.GMEDataFeed = function(a) {
  68.         this.tableId_ = a.tableId;
  69.         this.apiKey_ = a.apiKey;
  70.         a.propertiesModifier && (this.propertiesModifier_ = a.propertiesModifier)
  71.     };
  72.     storeLocator.GMEDataFeed = storeLocator.GMEDataFeed;
  73.     storeLocator.GMEDataFeed.prototype.getStores = function(a, b, c) {
  74.         var d = this,
  75.             e = a.getCenter();
  76.         a = "(ST_INTERSECTS(geometry, " + this.boundsToWkt_(a) + ") OR ST_DISTANCE(geometry, " + this.latLngToWkt_(e) + ") \x3c 20000)";
  77.         $.getJSON("https://www.googleapis.com/mapsengine/v1/tables/" + this.tableId_ + "/features?callback\x3d?", {
  78.             key: this.apiKey_,
  79.             where: a,
  80.             version: "published",
  81.             maxResults: 300
  82.         }, function(a) {
  83.             a = d.parse_(a);
  84.             d.sortByDistance_(e, a);
  85.             c(a)
  86.         })
  87.     };
  88.     storeLocator.GMEDataFeed.prototype.latLngToWkt_ = function(a) {
  89.         return "ST_POINT(" + a.lng() + ", " + a.lat() + ")"
  90.     };
  91.     storeLocator.GMEDataFeed.prototype.boundsToWkt_ = function(a) {
  92.         var b = a.getNorthEast();
  93.         a = a.getSouthWest();
  94.         return ["ST_GEOMFROMTEXT('POLYGON ((", a.lng(), " ", a.lat(), ", ", b.lng(), " ", a.lat(), ", ", b.lng(), " ", b.lat(), ", ", a.lng(), " ", b.lat(), ", ", a.lng(), " ", a.lat(), "))')"].join("")
  95.     };
  96.     storeLocator.GMEDataFeed.prototype.parse_ = function(a) {
  97.         if (a.error) return window.alert(a.error.message), [];
  98.         a = a.features;
  99.         if (!a) return [];
  100.         for (var b = [], c = 0, d; d = a[c]; c++) {
  101.             var e = d.geometry.coordinates,
  102.                 e = new google.maps.LatLng(e[1], e[0]);
  103.             d = this.propertiesModifier_(d.properties);
  104.             d = new storeLocator.Store(d.id, e, null, d);
  105.             b.push(d)
  106.         }
  107.         return b
  108.     };
  109.     storeLocator.GMEDataFeed.prototype.propertiesModifier_ = function(a) {
  110.         return a
  111.     };
  112.     storeLocator.GMEDataFeed.prototype.sortByDistance_ = function(a, b) {
  113.         b.sort(function(b, d) {
  114.             return b.distanceTo(a) - d.distanceTo(a)
  115.         })
  116.     };
  117.     storeLocator.GMEDataFeedOptions = function() {};
  118.     storeLocator.Panel = function(a, b) {
  119.         this.el_ = $(a);
  120.         this.el_.addClass("storelocator-panel");
  121.         this.settings_ = $.extend({
  122.             locationSearch: !0,
  123.             locationSearchLabel: "Where are you?",
  124.             featureFilter: !0,
  125.             directions: !0,
  126.             view: null
  127.         }, b);
  128.         this.directionsRenderer_ = new google.maps.DirectionsRenderer({
  129.             draggable: !0
  130.         });
  131.         this.directionsService_ = new google.maps.DirectionsService;
  132.         this.init_()
  133.     };
  134.     storeLocator.Panel = storeLocator.Panel;
  135.     storeLocator.Panel.prototype = new google.maps.MVCObject;
  136.     storeLocator.Panel.prototype.init_ = function() {
  137.         var a = this;
  138.         this.itemCache_ = {};
  139.         this.settings_.view && this.set("view", this.settings_.view);
  140.         this.filter_ = $('\x3cform class\x3d"storelocator-filter"/\x3e');
  141.         this.el_.append(this.filter_);
  142.         this.settings_.locationSearch && (this.locationSearch_ = $('\x3cdiv class\x3d"location-search"\x3e\x3ch4\x3e' + this.settings_.locationSearchLabel + "\x3c/h4\x3e\x3cinput\x3e\x3c/div\x3e"), this.filter_.append(this.locationSearch_), "undefined" != typeof google.maps.places ? this.initAutocomplete_() :
  143.             this.filter_.submit(function() {
  144.                 var b = $("input", a.locationSearch_).val();
  145.                 a.searchPosition(b)
  146.             }), this.filter_.submit(function() {
  147.                 return !1
  148.             }), google.maps.event.addListener(this, "geocode", function(b) {
  149.                 if (b.geometry) {
  150.                     this.directionsFrom_ = b.geometry.location;
  151.                     a.directionsVisible_ && a.renderDirections_();
  152.                     var c = a.get("view");
  153.                     c.highlight(null);
  154.                     var d = c.getMap();
  155.                     b.geometry.viewport ? d.fitBounds(b.geometry.viewport) : (d.setCenter(b.geometry.location), d.setZoom(13));
  156.                     c.refreshView();
  157.                     a.listenForStoresUpdate_()
  158.                 } else a.searchPosition(b.name)
  159.             }));
  160.         if (this.settings_.featureFilter) {
  161.             this.featureFilter_ = $('\x3cdiv class\x3d"feature-filter"/\x3e');
  162.             for (var b = this.get("view").getFeatures().asList(), c = 0, d = b.length; c < d; c++) {
  163.                 var e = b[c],
  164.                     f = $('\x3cinput type\x3d"checkbox"/\x3e');
  165.                 f.data("feature", e);
  166.                 $("\x3clabel/\x3e").append(f).append(e.getDisplayName()).appendTo(this.featureFilter_)
  167.             }
  168.             this.filter_.append(this.featureFilter_);
  169.             this.featureFilter_.find("input").change(function() {
  170.                 var b = $(this).data("feature");
  171.                 a.toggleFeatureFilter_(b);
  172.                 a.get("view").refreshView()
  173.             })
  174.         }
  175.         this.storeList_ =
  176.             $('\x3cul class\x3d"store-list"/\x3e');
  177.         this.el_.append(this.storeList_);
  178.         this.settings_.directions && (this.directionsPanel_ = $('\x3cdiv class\x3d"directions-panel"\x3e\x3cform\x3e\x3cinput class\x3d"directions-to"/\x3e\x3cinput type\x3d"submit" value\x3d"Find directions"/\x3e\x3ca href\x3d"#" class\x3d"close-directions"\x3eClose\x3c/a\x3e\x3c/form\x3e\x3cdiv class\x3d"rendered-directions"\x3e\x3c/div\x3e\x3c/div\x3e'), this.directionsPanel_.find(".directions-to").attr("readonly", "readonly"), this.directionsPanel_.hide(),
  179.             this.directionsVisible_ = !1, this.directionsPanel_.find("form").submit(function() {
  180.                 a.renderDirections_();
  181.                 return !1
  182.             }), this.directionsPanel_.find(".close-directions").click(function() {
  183.                 a.hideDirections()
  184.             }), this.el_.append(this.directionsPanel_))
  185.     };
  186.     storeLocator.Panel.prototype.toggleFeatureFilter_ = function(a) {
  187.         var b = this.get("featureFilter");
  188.         b.toggle(a);
  189.         this.set("featureFilter", b)
  190.     };
  191.     storeLocator.geocoder_ = new google.maps.Geocoder;
  192.     storeLocator.Panel.prototype.listenForStoresUpdate_ = function() {
  193.         var a = this,
  194.             b = this.get("view");
  195.         this.storesChangedListener_ && google.maps.event.removeListener(this.storesChangedListener_);
  196.         this.storesChangedListener_ = google.maps.event.addListenerOnce(b, "stores_changed", function() {
  197.             a.set("stores", b.get("stores"))
  198.         })
  199.     };
  200.     storeLocator.Panel.prototype.searchPosition = function(a) {
  201.         var b = this;
  202.         a = {
  203.             address: a,
  204.             bounds: this.get("view").getMap().getBounds()
  205.         };
  206.         storeLocator.geocoder_.geocode(a, function(a, d) {
  207.             d == google.maps.GeocoderStatus.OK && google.maps.event.trigger(b, "geocode", a[0])
  208.         })
  209.     };
  210.     storeLocator.Panel.prototype.setView = function(a) {
  211.         this.set("view", a)
  212.     };
  213.     storeLocator.Panel.prototype.view_changed = function() {
  214.         var a = this.get("view");
  215.         this.bindTo("selectedStore", a);
  216.         var b = this;
  217.         this.geolocationListener_ && google.maps.event.removeListener(this.geolocationListener_);
  218.         this.zoomListener_ && google.maps.event.removeListener(this.zoomListener_);
  219.         this.idleListener_ && google.maps.event.removeListener(this.idleListener_);
  220.         a.getMap().getCenter();
  221.         var c = function() {
  222.             a.clearMarkers();
  223.             b.listenForStoresUpdate_()
  224.         };
  225.         this.geolocationListener_ = google.maps.event.addListener(a, "load",
  226.             c);
  227.         this.zoomListener_ = google.maps.event.addListener(a.getMap(), "zoom_changed", c);
  228.         this.idleListener_ = google.maps.event.addListener(a.getMap(), "idle", function() {
  229.             return b.idle_(a.getMap())
  230.         });
  231.         c();
  232.         this.bindTo("featureFilter", a);
  233.         this.autoComplete_ && this.autoComplete_.bindTo("bounds", a.getMap())
  234.     };
  235.     storeLocator.Panel.prototype.initAutocomplete_ = function() {
  236.         var a = this,
  237.             b = $("input", this.locationSearch_)[0];
  238.         this.autoComplete_ = new google.maps.places.Autocomplete(b);
  239.         this.get("view") && this.autoComplete_.bindTo("bounds", this.get("view").getMap());
  240.         google.maps.event.addListener(this.autoComplete_, "place_changed", function() {
  241.             google.maps.event.trigger(a, "geocode", this.getPlace())
  242.         })
  243.     };
  244.     storeLocator.Panel.prototype.idle_ = function(a) {
  245.         this.center_ ? a.getBounds().contains(this.center_) || (this.center_ = a.getCenter(), this.listenForStoresUpdate_()) : this.center_ = a.getCenter()
  246.     };
  247.     storeLocator.Panel.NO_STORES_HTML_ = '\x3cli class\x3d"no-stores"\x3eThere are no stores in this area.\x3c/li\x3e';
  248.     storeLocator.Panel.NO_STORES_IN_VIEW_HTML_ = '\x3cli class\x3d"no-stores"\x3eThere are no stores in this area. However, stores closest to you are listed below.\x3c/li\x3e';
  249.     storeLocator.Panel.prototype.stores_changed = function() {
  250.         if (this.get("stores")) {
  251.             var a = this.get("view"),
  252.                 b = a && a.getMap().getBounds(),
  253.                 c = this.get("stores"),
  254.                 d = this.get("selectedStore");
  255.             this.storeList_.empty();
  256.             c.length ? b && !b.contains(c[0].getLocation()) && this.storeList_.append(storeLocator.Panel.NO_STORES_IN_VIEW_HTML_) : this.storeList_.append(storeLocator.Panel.NO_STORES_HTML_);
  257.             for (var b = function() {
  258.                     a.highlight(this.store, !0)
  259.                 }, e = 0, f = Math.min(10, c.length); e < f; e++) {
  260.                 var g = c[e].getInfoPanelItem();
  261.                 g.store = c[e];
  262.                 d && c[e].getId() == d.getId() && $(g).addClass("highlighted");
  263.                 g.clickHandler_ || (g.clickHandler_ = google.maps.event.addDomListener(g, "click", b));
  264.                 this.storeList_.append(g)
  265.             }
  266.         }
  267.     };
  268.     storeLocator.Panel.prototype.selectedStore_changed = function() {
  269.         $(".highlighted", this.storeList_).removeClass("highlighted");
  270.         var a = this,
  271.             b = this.get("selectedStore");
  272.         if (b) {
  273.             this.directionsTo_ = b;
  274.             this.storeList_.find("#store-" + b.getId()).addClass("highlighted");
  275.             this.settings_.directions && this.directionsPanel_.find(".directions-to").val(b.getDetails().title);
  276.             var c = a.get("view").getInfoWindow().getContent(),
  277.                 d = $("\x3ca/\x3e").text("Directions").attr("href", "#").addClass("action").addClass("directions"),
  278.                 e = $("\x3ca/\x3e").text("Zoom here").attr("href",
  279.                     "#").addClass("action").addClass("zoomhere"),
  280.                 f = $("\x3ca/\x3e").text("Street view").attr("href", "#").addClass("action").addClass("streetview");
  281.             d.click(function() {
  282.                 a.showDirections();
  283.                 return !1
  284.             });
  285.             e.click(function() {
  286.                 a.get("view").getMap().setOptions({
  287.                     center: b.getLocation(),
  288.                     zoom: 16
  289.                 })
  290.             });
  291.             f.click(function() {
  292.                 var c = a.get("view").getMap().getStreetView();
  293.                 c.setPosition(b.getLocation());
  294.                 c.setVisible(!0)
  295.             });
  296.             $(c).append(d).append(e).append(f)
  297.         }
  298.     };
  299.     storeLocator.Panel.prototype.hideDirections = function() {
  300.         this.directionsVisible_ = !1;
  301.         this.directionsPanel_.fadeOut();
  302.         this.featureFilter_.fadeIn();
  303.         this.storeList_.fadeIn();
  304.         this.directionsRenderer_.setMap(null)
  305.     };
  306.     storeLocator.Panel.prototype.showDirections = function() {
  307.         var a = this.get("selectedStore");
  308.         this.featureFilter_.fadeOut();
  309.         this.storeList_.fadeOut();
  310.         this.directionsPanel_.find(".directions-to").val(a.getDetails().title);
  311.         this.directionsPanel_.fadeIn();
  312.         this.renderDirections_();
  313.         this.directionsVisible_ = !0
  314.     };
  315.     storeLocator.Panel.prototype.renderDirections_ = function() {
  316.         var a = this;
  317.         if (this.directionsFrom_ && this.directionsTo_) {
  318.             var b = this.directionsPanel_.find(".rendered-directions").empty();
  319.             this.directionsService_.route({
  320.                 origin: this.directionsFrom_,
  321.                 destination: this.directionsTo_.getLocation(),
  322.                 travelMode: google.maps.DirectionsTravelMode.DRIVING
  323.             }, function(c, d) {
  324.                 if (d == google.maps.DirectionsStatus.OK) {
  325.                     var e = a.directionsRenderer_;
  326.                     e.setPanel(b[0]);
  327.                     e.setMap(a.get("view").getMap());
  328.                     e.setDirections(c)
  329.                 }
  330.             })
  331.         }
  332.     };
  333.     storeLocator.Panel.prototype.featureFilter_changed = function() {
  334.         this.listenForStoresUpdate_()
  335.     };
  336.     storeLocator.PanelOptions = function() {};
  337.     storeLocator.StaticDataFeed = function() {
  338.         this.stores_ = []
  339.     };
  340.     storeLocator.StaticDataFeed = storeLocator.StaticDataFeed;
  341.     storeLocator.StaticDataFeed.prototype.setStores = function(a) {
  342.         this.stores_ = a;
  343.         this.firstCallback_ ? this.firstCallback_() : delete this.firstCallback_
  344.     };
  345.     storeLocator.StaticDataFeed.prototype.getStores = function(a, b, c) {
  346.         if (this.stores_.length) {
  347.             for (var d = [], e = 0, f; f = this.stores_[e]; e++) f.hasAllFeatures(b) && d.push(f);
  348.             this.sortByDistance_(a.getCenter(), d);
  349.             c(d)
  350.         } else {
  351.             var g = this;
  352.             this.firstCallback_ = function() {
  353.                 g.getStores(a, b, c)
  354.             }
  355.         }
  356.     };
  357.     storeLocator.StaticDataFeed.prototype.sortByDistance_ = function(a, b) {
  358.         b.sort(function(b, d) {
  359.             return b.distanceTo(a) - d.distanceTo(a)
  360.         })
  361.     };
  362.     /*
  363.  
  364.       Latitude/longitude spherical geodesy formulae & scripts
  365.       (c) Chris Veness 2002-2010
  366.       www.movable-type.co.uk/scripts/latlong.html
  367.     */
  368.     storeLocator.Store = function(a, b, c, d) {
  369.         this.id_ = a;
  370.         this.location_ = b;
  371.         this.features_ = c || storeLocator.FeatureSet.NONE;
  372.         this.props_ = d || {}
  373.     };
  374.     storeLocator.Store = storeLocator.Store;
  375.     storeLocator.Store.prototype.setMarker = function(a) {
  376.         this.marker_ = a;
  377.         google.maps.event.trigger(this, "marker_changed", a)
  378.     };
  379.     storeLocator.Store.prototype.getMarker = function() {
  380.         return this.marker_
  381.     };
  382.     storeLocator.Store.prototype.getId = function() {
  383.         return this.id_
  384.     };
  385.     storeLocator.Store.prototype.getLocation = function() {
  386.         return this.location_
  387.     };
  388.     storeLocator.Store.prototype.getFeatures = function() {
  389.         return this.features_
  390.     };
  391.     storeLocator.Store.prototype.hasFeature = function(a) {
  392.         return this.features_.contains(a)
  393.     };
  394.     storeLocator.Store.prototype.hasAllFeatures = function(a) {
  395.         if (!a) return !0;
  396.         a = a.asList();
  397.         for (var b = 0, c = a.length; b < c; b++)
  398.             if (!this.hasFeature(a[b])) return !1;
  399.         return !0
  400.     };
  401.     storeLocator.Store.prototype.getDetails = function() {
  402.         return this.props_
  403.     };
  404.     storeLocator.Store.prototype.generateFieldsHTML_ = function(a) {
  405.         for (var b = [], c = 0, d = a.length; c < d; c++) {
  406.             var e = a[c];
  407.             this.props_[e] && (b.push('\x3cdiv class\x3d"'), b.push(e), b.push('"\x3e'), b.push(this.props_[e]), b.push("\x3c/div\x3e"))
  408.         }
  409.         return b.join("")
  410.     };
  411.     storeLocator.Store.prototype.generateFeaturesHTML_ = function() {
  412.         var a = [];
  413.         a.push('\x3cul class\x3d"features"\x3e');
  414.         for (var b = this.features_.asList(), c = 0, d; d = b[c]; c++) a.push("\x3cli\x3e"), a.push(d.getDisplayName()), a.push("\x3c/li\x3e");
  415.         a.push("\x3c/ul\x3e");
  416.         return a.join("")
  417.     };
  418.     storeLocator.Store.prototype.getInfoWindowContent = function() {
  419.         if (!this.content_) {
  420.             var a = ['\x3cdiv class\x3d"store"\x3e'];
  421.             a.push(this.generateFieldsHTML_(["title", "address", "phone", "misc", "web"]));
  422.             a.push(this.generateFeaturesHTML_());
  423.             a.push("\x3c/div\x3e");
  424.             this.content_ = a.join("")
  425.         }
  426.         return this.content_
  427.     };
  428.     storeLocator.Store.prototype.getInfoPanelContent = function() {
  429.         return this.getInfoWindowContent()
  430.     };
  431.     storeLocator.Store.infoPanelCache_ = {};
  432.     storeLocator.Store.prototype.getInfoPanelItem = function() {
  433.         var a = storeLocator.Store.infoPanelCache_,
  434.             b = this.getId();
  435.         if (!a[b]) {
  436.             var c = this.getInfoPanelContent();
  437.             a[b] = $('\x3cli class\x3d"store" id\x3d"store-' + this.getId() + '"\x3e' + c + "\x3c/li\x3e")[0]
  438.         }
  439.         return a[b]
  440.     };
  441.     storeLocator.Store.prototype.distanceTo = function(a) {
  442.         var b = this.getLocation(),
  443.             c = storeLocator.toRad_(b.lat()),
  444.             d = storeLocator.toRad_(b.lng()),
  445.             b = storeLocator.toRad_(a.lat()),
  446.             e = storeLocator.toRad_(a.lng());
  447.         a = b - c;
  448.         d = e - d;
  449.         c = Math.sin(a / 2) * Math.sin(a / 2) + Math.cos(c) * Math.cos(b) * Math.sin(d / 2) * Math.sin(d / 2);
  450.         return 12742 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c))
  451.     };
  452.     storeLocator.DataFeed = function() {};
  453.     storeLocator.DataFeed = storeLocator.DataFeed;
  454.     storeLocator.DataFeed.prototype.getStores = function(a, b, c) {};
  455.     storeLocator.View = function(a, b, c) {
  456.         this.map_ = a;
  457.         this.data_ = b;
  458.         this.settings_ = $.extend({
  459.             updateOnPan: !0,
  460.             geolocation: !0,
  461.             features: new storeLocator.FeatureSet
  462.         }, c);
  463.         this.init_();
  464.         google.maps.event.trigger(this, "load");
  465.         this.set("featureFilter", new storeLocator.FeatureSet)
  466.     };
  467.     storeLocator.View = storeLocator.View;
  468.     storeLocator.View.prototype = new google.maps.MVCObject;
  469.     storeLocator.View.prototype.geolocate_ = function() {
  470.         var a = this;
  471.         window.navigator && navigator.geolocation && navigator.geolocation.getCurrentPosition(function(b) {
  472.             b = new google.maps.LatLng(b.coords.latitude, b.coords.longitude);
  473.             a.getMap().setCenter(b);
  474.             a.getMap().setZoom(11);
  475.             google.maps.event.trigger(a, "load")
  476.         }, void 0, {
  477.             maximumAge: 6E4,
  478.             timeout: 1E4
  479.         })
  480.     };
  481.     storeLocator.View.prototype.init_ = function() {
  482.         this.settings_.geolocation && this.geolocate_();
  483.         this.markerCache_ = {};
  484.         this.infoWindow_ = new google.maps.InfoWindow;
  485.         var a = this,
  486.             b = this.getMap();
  487.         this.set("updateOnPan", this.settings_.updateOnPan);
  488.         google.maps.event.addListener(this.infoWindow_, "closeclick", function() {
  489.             a.highlight(null)
  490.         });
  491.         google.maps.event.addListener(b, "click", function() {
  492.             a.highlight(null);
  493.             a.infoWindow_.close()
  494.         })
  495.     };
  496.     storeLocator.View.prototype.updateOnPan_changed = function() {
  497.         this.updateOnPanListener_ && google.maps.event.removeListener(this.updateOnPanListener_);
  498.         if (this.get("updateOnPan") && this.getMap()) {
  499.             var a = this,
  500.                 b = this.getMap();
  501.             this.updateOnPanListener_ = google.maps.event.addListener(b, "idle", function() {
  502.                 a.refreshView()
  503.             })
  504.         }
  505.     };
  506.     storeLocator.View.prototype.addStoreToMap = function(a) {
  507.         var b = this.getMarker(a);
  508.         a.setMarker(b);
  509.         var c = this;
  510.         b.clickListener_ = google.maps.event.addListener(b, "click", function() {
  511.             c.highlight(a, !1)
  512.         });
  513.         b.getMap() != this.getMap() && b.setMap(this.getMap())
  514.     };
  515.     storeLocator.View.prototype.createMarker = function(a) {
  516.         a = {
  517.             position: a.getLocation()
  518.         };
  519.         var b = this.settings_.markerIcon;
  520.         b && (a.icon = b);
  521.         return new google.maps.Marker(a)
  522.     };
  523.     storeLocator.View.prototype.getMarker = function(a) {
  524.         var b = this.markerCache_,
  525.             c = a.getId();
  526.         b[c] || (b[c] = this.createMarker(a));
  527.         return b[c]
  528.     };
  529.     storeLocator.View.prototype.getInfoWindow = function(a) {
  530.         if (!a) return this.infoWindow_;
  531.         a = $(a.getInfoWindowContent());
  532.         this.infoWindow_.setContent(a[0]);
  533.         return this.infoWindow_
  534.     };
  535.     storeLocator.View.prototype.getFeatures = function() {
  536.         return this.settings_.features
  537.     };
  538.     storeLocator.View.prototype.getFeatureById = function(a) {
  539.         if (!this.featureById_) {
  540.             this.featureById_ = {};
  541.             for (var b = 0, c; c = this.settings_.features[b]; b++) this.featureById_[c.getId()] = c
  542.         }
  543.         return this.featureById_[a]
  544.     };
  545.     storeLocator.View.prototype.featureFilter_changed = function() {
  546.         google.maps.event.trigger(this, "featureFilter_changed", this.get("featureFilter"));
  547.         this.get("stores") && this.clearMarkers()
  548.     };
  549.     storeLocator.View.prototype.clearMarkers = function() {
  550.         for (var a in this.markerCache_) {
  551.             this.markerCache_[a].setMap(null);
  552.             var b = this.markerCache_[a].clickListener_;
  553.             b && google.maps.event.removeListener(b)
  554.         }
  555.     };
  556.     storeLocator.View.prototype.refreshView = function() {
  557.         var a = this;
  558.         this.data_.getStores(this.getMap().getBounds(), this.get("featureFilter"), function(b) {
  559.             var c = a.get("stores");
  560.             if (c)
  561.                 for (var d = 0, e = c.length; d < e; d++) google.maps.event.removeListener(c[d].getMarker().clickListener_);
  562.             a.set("stores", b)
  563.         })
  564.     };
  565.     storeLocator.View.prototype.stores_changed = function() {
  566.         for (var a = this.get("stores"), b = 0, c; c = a[b]; b++) this.addStoreToMap(c)
  567.     };
  568.     storeLocator.View.prototype.getMap = function() {
  569.         return this.map_
  570.     };
  571.     storeLocator.View.prototype.highlight = function(a, b) {
  572.         var c = this.getInfoWindow(a);
  573.         a ? (c = this.getInfoWindow(a), a.getMarker() ? c.open(this.getMap(), a.getMarker()) : (c.setPosition(a.getLocation()), c.open(this.getMap())), b && this.getMap().panTo(a.getLocation()), this.getMap().getStreetView().getVisible() && this.getMap().getStreetView().setPosition(a.getLocation())) : c.close();
  574.         this.set("selectedStore", a)
  575.     };
  576.     storeLocator.View.prototype.selectedStore_changed = function() {
  577.         google.maps.event.trigger(this, "selectedStore_changed", this.get("selectedStore"))
  578.     };
  579.     storeLocator.ViewOptions = function() {};
  580. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement