{"version":3,"names":[],"mappings":"","sources":["locationSearch.js"],"sourcesContent":["const MAX_Z_INDEX = 1000000; // Used to bring an active/hovered location to the top\r\nconst LOCATION_Z_INDEX = 100000; // Used to keep Branch Locations above ATM markers\r\n\r\nvar allMarkers = [];\r\nvar markerLookup = {};\r\nvar avgLat = 0;\r\nvar avgLng = 0;\r\nvar bounds = null;\r\nvar map = null;\r\n\r\nasync function initMap() {\r\n const { Map, InfoWindow } = await google.maps.importLibrary(\"maps\");\r\n bounds = new google.maps.LatLngBounds();\r\n var map = new Map(document.getElementById('map'), {\r\n center: { lat: mapLocations[0].Latitude, lng: mapLocations[0].Longitude },\r\n zoom: 13,\r\n mapId: \"198b76f34fd6f2\",\r\n styles: [{\r\n \"featureType\": \"administrative\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"visibility\": \"on\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"administrative\",\r\n \"elementType\": \"labels.text.fill\",\r\n \"stylers\": [{\r\n \"color\": \"#565656\"\r\n },\r\n {\r\n \"visibility\": \"on\"\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"landscape\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"color\": \"#f2f2f2\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"landscape\",\r\n \"elementType\": \"geometry.fill\",\r\n \"stylers\": [{\r\n \"color\": \"#f3f3f3\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"landscape\",\r\n \"elementType\": \"labels\",\r\n \"stylers\": [{\r\n \"visibility\": \"on\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"landscape\",\r\n \"elementType\": \"labels.text.fill\",\r\n \"stylers\": [{\r\n \"color\": \"#565656\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"poi\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"visibility\": \"off\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"poi\",\r\n \"elementType\": \"geometry.fill\",\r\n \"stylers\": [{\r\n \"visibility\": \"on\"\r\n },\r\n {\r\n \"color\": \"#e1e1e1\"\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"poi.park\",\r\n \"elementType\": \"labels\",\r\n \"stylers\": [{\r\n \"visibility\": \"off\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"poi.park\",\r\n \"elementType\": \"labels.text\",\r\n \"stylers\": [{\r\n \"visibility\": \"on\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"poi.park\",\r\n \"elementType\": \"labels.text.fill\",\r\n \"stylers\": [{\r\n \"color\": \"#afafaf\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"road\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"saturation\": -100\r\n },\r\n {\r\n \"lightness\": 45\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"road.highway\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"visibility\": \"simplified\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"road.highway\",\r\n \"elementType\": \"geometry.fill\",\r\n \"stylers\": [{\r\n \"color\": \"#d5d5d5\"\r\n },\r\n {\r\n \"weight\": \"2.94\"\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"road.highway\",\r\n \"elementType\": \"labels.icon\",\r\n \"stylers\": [{\r\n \"visibility\": \"off\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"road.arterial\",\r\n \"elementType\": \"labels.icon\",\r\n \"stylers\": [{\r\n \"visibility\": \"off\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"transit\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"visibility\": \"off\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"transit\",\r\n \"elementType\": \"geometry.fill\",\r\n \"stylers\": [{\r\n \"visibility\": \"on\"\r\n },\r\n {\r\n \"color\": \"#ebebeb\"\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"water\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"color\": \"#AAB8CE\"\r\n },\r\n {\r\n \"visibility\": \"on\"\r\n }\r\n ]\r\n }\r\n ]\r\n });\r\n\r\n const infoWindow = new InfoWindow();\r\n\r\n for (var i = 0; i < mapLocations.length; i++) {\r\n if (mapLocations[i].Latitude && mapLocations[i].Longitude) {\r\n var latLng = new google.maps.LatLng(mapLocations[i].Latitude, mapLocations[i].Longitude);\r\n // init markers\r\n let markerImage = document.createElement('img');\r\n markerImage.src = mapLocations[i].IsATM ? '/static/images/icon-co-op-location-marker-red-sm.png' : '/static/images/icon-selco-location-marker-blue-sm.png';\r\n\r\n var marker = new google.maps.marker.AdvancedMarkerElement({\r\n position: new google.maps.LatLng(mapLocations[i].Latitude, mapLocations[i].Longitude),\r\n map: map,\r\n title: mapLocations[i].Title,\r\n content: markerImage,\r\n zIndex: mapLocations[i].IsATM ? null : LOCATION_Z_INDEX\r\n });\r\n bounds.extend(latLng);\r\n allMarkers.push(marker);\r\n markerLookup[mapLocations[i].ContentLink] = marker;\r\n\r\n (function (marker, i) {\r\n marker.addListener('click', () => {\r\n resetAllMarkersToDefault();\r\n infoWindow.close();\r\n infoWindow.setContent(\r\n '
' +\r\n '
' +\r\n '
' +\r\n '

' + mapLocations[i].Name +'

' +\r\n '' + mapLocations[i].Address + '
' +\r\n mapLocations[i].Address2 + '
' +\r\n '
' +\r\n '\"\"' +\r\n 'Get Directions' +\r\n '
' +\r\n '
' +\r\n (mapLocations[i].Image !== null ?\r\n '
' +\r\n '\"\"' +\r\n '
' \r\n : '')\r\n +\r\n '
' +\r\n '
'\r\n );\r\n infoWindow.open(map, marker);\r\n\r\n map.setCenter({lat: marker.position.lat, lng: marker.position.lng});\r\n \r\n let markerImage = document.createElement('img');\r\n markerImage.src = mapLocations[i].IsATM ? '/static/images/icon-co-op-location-marker-gold-sm.png' : '/static/images/icon-selco-location-marker-gold-sm.png';\r\n marker.content = markerImage;\r\n marker.zIndex = MAX_Z_INDEX;\r\n\r\n var locationCard = document.querySelector(\"[data-location='\" + mapLocations[i].ContentLink + \"']\");\r\n var activeCard = $(\"[data-location='\" + mapLocations[i].ContentLink + \"']\");\r\n\r\n // locationCard.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\r\n\r\n var scrollTop = $(window).scrollTop(),\r\n elementOffset = $(activeCard).offset().top,\r\n distance = (elementOffset - scrollTop),\r\n headHeight = 230, //base height of sticky header\r\n headHeight = $('.site-header').height() + 30;\r\n $('html, body').animate({\r\n scrollTop: ($(activeCard).offset().top - headHeight)\r\n }, 250);\r\n\r\n var previousLocationId = $('.location-page__location-item.active[data-location]').data('location');\r\n\r\n if (typeof previousLocationId !== 'undefined' && mapLocations[i].ContentLink !== previousLocationId) {\r\n $('.location-page__location-item.active').removeClass('active');\r\n var previousMarker = markerLookup[previousLocationId];\r\n var mapLocation = mapLocations.find(x => x.Latitude === previousMarker.position.lat && x.Longitude === previousMarker.position.lng);\r\n \r\n let markerImage = document.createElement('img');\r\n markerImage.src = mapLocation.IsATM ? '/static/images/icon-co-op-location-marker-red-sm.png' : '/static/images/icon-selco-location-marker-blue-sm.png';\r\n \r\n previousMarker.content = markerImage;\r\n previousMarker.zIndex = previousMarker.IsATM ? null : LOCATION_Z_INDEX;\r\n }\r\n\r\n locationCard.classList.add(\"active\");\r\n });\r\n })(marker, i);\r\n }\r\n }\r\n\r\n infoWindow.addListener('closeclick', () => {\r\n resetAllMarkersToDefault();\r\n $('.location-page__location-item.active').removeClass('active');\r\n });\r\n}\r\n\r\nfunction initEmptyMap() {\r\n // Styles the map.\r\n var map = new google.maps.Map(document.getElementById('map'), {\r\n center: {\r\n lat: 45.552304771688995,\r\n lng: -122.66164782399251\r\n },\r\n zoom: 13,\r\n mapId: \"198b76f34fd6f2\",\r\n styles: [{\r\n \"featureType\": \"administrative\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"visibility\": \"on\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"administrative\",\r\n \"elementType\": \"labels.text.fill\",\r\n \"stylers\": [{\r\n \"color\": \"#565656\"\r\n },\r\n {\r\n \"visibility\": \"on\"\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"landscape\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"color\": \"#f2f2f2\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"landscape\",\r\n \"elementType\": \"geometry.fill\",\r\n \"stylers\": [{\r\n \"color\": \"#f3f3f3\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"landscape\",\r\n \"elementType\": \"labels\",\r\n \"stylers\": [{\r\n \"visibility\": \"on\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"landscape\",\r\n \"elementType\": \"labels.text.fill\",\r\n \"stylers\": [{\r\n \"color\": \"#565656\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"poi\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"visibility\": \"off\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"poi\",\r\n \"elementType\": \"geometry.fill\",\r\n \"stylers\": [{\r\n \"visibility\": \"on\"\r\n },\r\n {\r\n \"color\": \"#e1e1e1\"\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"poi.park\",\r\n \"elementType\": \"labels\",\r\n \"stylers\": [{\r\n \"visibility\": \"off\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"poi.park\",\r\n \"elementType\": \"labels.text\",\r\n \"stylers\": [{\r\n \"visibility\": \"on\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"poi.park\",\r\n \"elementType\": \"labels.text.fill\",\r\n \"stylers\": [{\r\n \"color\": \"#afafaf\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"road\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"saturation\": -100\r\n },\r\n {\r\n \"lightness\": 45\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"road.highway\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"visibility\": \"simplified\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"road.highway\",\r\n \"elementType\": \"geometry.fill\",\r\n \"stylers\": [{\r\n \"color\": \"#d5d5d5\"\r\n },\r\n {\r\n \"weight\": \"2.94\"\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"road.highway\",\r\n \"elementType\": \"labels.icon\",\r\n \"stylers\": [{\r\n \"visibility\": \"off\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"road.arterial\",\r\n \"elementType\": \"labels.icon\",\r\n \"stylers\": [{\r\n \"visibility\": \"off\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"transit\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"visibility\": \"off\"\r\n }]\r\n },\r\n {\r\n \"featureType\": \"transit\",\r\n \"elementType\": \"geometry.fill\",\r\n \"stylers\": [{\r\n \"visibility\": \"on\"\r\n },\r\n {\r\n \"color\": \"#ebebeb\"\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"water\",\r\n \"elementType\": \"all\",\r\n \"stylers\": [{\r\n \"color\": \"#AAB8CE\"\r\n },\r\n {\r\n \"visibility\": \"on\"\r\n }\r\n ]\r\n }\r\n ]\r\n });\r\n}\r\n\r\n\r\nfunction resetAllMarkersToDefault() {\r\n self.allMarkers.forEach(function (marker) {\r\n var mapLocation = mapLocations.find(x => x.Latitude === marker.position.lat && x.Longitude === marker.position.lng);\r\n\r\n let markerImage = document.createElement('img');\r\n markerImage.src = mapLocation.IsATM ? '/static/images/icon-co-op-location-marker-red-sm.png' : '/static/images/icon-selco-location-marker-blue-sm.png';\r\n\r\n marker.content = markerImage;\r\n marker.zIndex = mapLocation.IsATM ? null : LOCATION_Z_INDEX;\r\n });\r\n}\r\n\r\nfunction locationHover(e) {\r\n\r\n var locationId = $(this).data(\"location\");\r\n var marker = markerLookup[locationId];\r\n var mapLocation = mapLocations.find(x => x.Latitude === marker.position.lat && x.Longitude === marker.position.lng);\r\n \r\n let markerImage = document.createElement('img');\r\n markerImage.src = mapLocation.IsATM ? '/static/images/icon-co-op-location-marker-red-sm.png' : '/static/images/icon-selco-location-marker-blue-sm.png';\r\n\r\n // When hovering over a location, bring its marker to the top\r\n if (e.type === \"mouseenter\") {\r\n marker.zIndex = MAX_Z_INDEX;\r\n }\r\n else if (!$(this).hasClass('active')) {\r\n marker.content = markerImage;\r\n marker.zIndex = mapLocation.IsATM ? null : LOCATION_Z_INDEX;\r\n }\r\n}\r\n\r\n$(document).ready(function () {\r\n\r\n if (typeof mapLocations !== 'undefined' && mapLocations.length) {\r\n initMap();\r\n }\r\n else{\r\n initEmptyMap();\r\n }\r\n\r\n $('.location-page__location-item').on('mouseenter mouseleave', locationHover);\r\n\r\n $('.location-item__name a').on('click', function (e) {\r\n $('.location-page__location-item.active').removeClass('active');\r\n e.preventDefault();\r\n var $this = $(this);\r\n var locationId = $this.closest('.location-page__location-item').data('location');\r\n var activeMarker = markerLookup[locationId];\r\n new google.maps.event.trigger(activeMarker, 'click');\r\n });\r\n\r\n $(\"#use-my-location\").on('click', function () {\r\n if (navigator.geolocation) {\r\n navigator.geolocation.getCurrentPosition(function (position) {\r\n if ($(\"#user-latitude\").length) {\r\n $(\"#user-latitude\").val(position.coords.latitude);\r\n }\r\n else {\r\n $('#location-search-form').prepend('');\r\n\r\n }\r\n if ($(\"#user-longitude\").length) {\r\n $('#user-longitude').val(position.coords.longitude);\r\n }\r\n else {\r\n $('#location-search-form').prepend('');\r\n }\r\n $(\"#user-latitude\").closest(\"form\").submit();\r\n });\r\n } else {\r\n x.innerHTML = \"Geolocation is not supported by this browser.\";\r\n }\r\n });\r\n\r\n // toggle state of pediatrician filter button for FAD\r\n $(\"#atmToggle\").on(\"click\", function (e) {\r\n if ($(this).attr('aria-checked') === 'false') {\r\n $('#include-atm').val('false');\r\n } else {\r\n $('#include-atm').val('true')\r\n }\r\n $('#include-atm').closest(\"form\").submit();\r\n });\r\n\r\n});\r\n"],"file":"locationSearch.js"}