{"version":3,"sources":["JavaScript/InitializeLocatorMap.js"],"names":["initializeLocatorMap","$","window","Engage","Locator","Messaging","Map","initialize","apiKey","Settings","GoogleMapsApiKey","$loadingIndicator","messaging","publishZipCodeValidationResult","status","data","payload","publish","messageTypes","zipCodeValidationResult","subscribe","validateZipCode","messageType","address","addressProcessor","ajax","type","url","concat","dataType","done","response","matches","map","results","locationMatch","name","formatted_address","latitude","geometry","location","lat","longitude","lng","length","match","error","fail","_","defaultLng","oneSecond","mapOptions","zoom","center","google","maps","LatLng","panControl","panControlOptions","position","ControlPosition","BOTTOM_LEFT","zoomControl","zoomControlOptions","style","ZoomControlStyle","LARGE","RIGHT_CENTER","scaleControl","zeMap","document","getElementById","markerArr","publishBoxUpdate","bounds","getBounds","northEastLatitude","getNorthEast","northEastLongitude","southWestLatitude","getSouthWest","southWestLongitude","locationTopRight","locationBottomLeft","getCenter","defaultMarkerIcon","path","fillColor","fillOpacity","scale","labelOrigin","Point","createMapMarker","coords","zeContent","sortPosition","locationName","_Engage$Locator$Map$c","self","icon","getMapMarkerIcon","customIcon","marker","Marker","title","label","color","fontSize","fontWeight","text","toString","infoWindow","InfoWindow","content","addListener","open","i","close","customizeMapMarker","extend","dragendTimer","processingLocations","receivedNewLocations","event","clearTimeout","setTimeout","getZoom","boundingBoxUpdate","zoomChangedTimer","messageTypesThatCauseSearchUpdates","locationUpdate","newQueryFilters","showLoading","locatorMessagePrefix","indexOf","removeClass","addClass","resetSearchFrom","setCenter","setZoom","ShowSearchLocationPin","_ref","_ref$data","newLocations","_ref2","locations","setMap","LatLngBounds","push","template","order","getPosition","fitBounds","jQuery"],"mappings":"CAMM,SAASA,EAAqBC,GACnC,aAKA,GAHAC,OAAOC,OAASD,OAAOC,QAAU,CAAC,EAClCA,OAAOC,QAAUD,OAAOC,SAAW,CAAC,EAE/BD,OAAOC,QAAQC,UASpBF,OAAOC,QAAQE,IAAMH,OAAOC,QAAQE,KAAO,CAAC,EAS5CH,OAAOC,QAAQE,IAAI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A,EAAI5C,EAAU5B,OAAQwE,IACrC5C,EAAU4C,GAAGd,OAAO4C,OAAO,MAE5B1E,EAAY,GAEZ,IAAME,EAAS,IAAIpB,OAAOC,KAAK4F,aAC/B,GAAIF,EAAUrG,OAAS,EAAG,CACzB,IAAK,IAAIwE,EAAI,EAAGA,EAAI6B,EAAUrG,OAAQwE,IACrCM,GAAuB,EACvBlD,EAAU4E,KACTxD,EACC,CACCnD,IAAKwG,EAAU7B,GAAG9E,SAClBK,IAAKsG,EAAU7B,GAAG1E,WAEnBuG,EAAU7B,GAAGiC,SACbJ,EAAU7B,GAAGkC,MACbL,EAAU7B,GAAGhF,OAGfsC,EAAO6C,OAAO/C,EAAU4C,GAAGd,OAAOiD,eAGtB,sBAAT7H,GACH2C,EAAMmF,UAAU9E,GAEjBgD,GAAuB,CACxB,CAEA/G,EAAkB4H,YAAY,iCAC9B5H,EAAkB6H,SAAS,kCAhC3B,CAiCD,GAEF,MAjkBA,CAECX,YAAW,WAAA,OAAM7H,EAAqBC,EAAE,GADrB,GAGpB,CA8jBD,CAxkBM,CAwkBHwJ","file":"JavaScript\\InitializeLocatorMap.min.js","sourcesContent":["/* global Engage, jQuery, google */\r\n\r\n/**\r\n * @description Initializes the core map module for the Engage Locator.\r\n * @param {jQuery} $ - A reference to the global jQuery namespace.\r\n */\r\nvoid (function initializeLocatorMap($) {\r\n\t'use strict';\r\n\r\n\twindow.Engage = window.Engage || {};\r\n\tEngage.Locator = Engage.Locator || {};\r\n\r\n\tif (!Engage.Locator.Messaging) {\r\n\t\tconst retryDelay = 20;\r\n\t\tsetTimeout(() => initializeLocatorMap($), retryDelay);\r\n\t\treturn;\r\n\t}\r\n\r\n\t/**\r\n\t * @namespace Window.Engage.Locator.Map\r\n\t */\r\n\tEngage.Locator.Map = Engage.Locator.Map || {};\r\n\r\n\t/**\r\n\t * @function initialize\r\n\t * @description Initializes the Google Map and Geolocation library used by the Engage Locator.\r\n\t * @example\r\n\t * Engage.Locator.Map();\r\n\t * @memberof Window.Engage.Locator.Map\r\n\t */\r\n\tEngage.Locator.Map.initialize = () => {\r\n\t\tconst apiKey = Engage.Locator.Settings.GoogleMapsApiKey;\r\n\t\tconst $loadingIndicator = $('.engage-locator__loading');\r\n\t\tconst geocodeApiEndPoint =\r\n\t\t\t'https://maps.googleapis.com/maps/api/geocode/json';\r\n\t\tconst messaging = Engage.Locator.Messaging;\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @function publishZipCodeValidationResult\r\n\t\t * @description Published a {Window.Engage.Locator.Messaging.messageTypes.zipCodeValidationResult} message\r\n\t\t * with the payload provided by the {data} parameter.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @param {string} status - The message type status to publish to\r\n\t\t * {Window.Engage.Locator.Messaging.messageTypes.zipCodeValidationResult}\r\n\t\t * @param {Object} data - The payload data to publish with the message.\r\n\t\t */\r\n\t\tfunction publishZipCodeValidationResult(status, data) {\r\n\t\t\tconst payload = {\r\n\t\t\t\tstatus,\r\n\t\t\t\tdata,\r\n\t\t\t};\r\n\t\t\tmessaging.publish(\r\n\t\t\t\tmessaging.messageTypes.zipCodeValidationResult,\r\n\t\t\t\tpayload,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @function geocodeAddressPromise\r\n\t\t * @description Geocode the provided address using the Google API.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @param {string} address - The address to geocode with the Google API.\r\n\t\t * @returns {jQuery} A jQuery promise created by making a AJAX request to the Google API.\r\n\t\t */\r\n\t\tfunction geocodeAddressPromise(address) {\r\n\t\t\tif (Engage.Locator.Map.addressProcessor) {\r\n\t\t\t\taddress = Engage.Locator.Map.addressProcessor(address);\r\n\t\t\t}\r\n\t\t\treturn $.ajax({\r\n\t\t\t\ttype: 'GET',\r\n\t\t\t\turl: `${geocodeApiEndPoint}?address=${address}&key=${apiKey}`,\r\n\t\t\t\tdataType: 'json',\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @name validateZipCodeSubscriptionCallback\r\n\t\t * @typedef subscriptionCallback\r\n\t\t * @description Handles all {Window.Engage.Locator.Messaging.messageTypes.validateZipCode} messages.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @param {string} messageType - The type of message requesting publish.\r\n\t\t * @param {Object} payload - The object payload for the message requesting publish.\r\n\t\t */\r\n\t\tmessaging.subscribe(\r\n\t\t\tmessaging.messageTypes.validateZipCode,\r\n\t\t\t(messageType, payload) => {\r\n\t\t\t\tif (\r\n\t\t\t\t\tmessageType !== messaging.messageTypes.validateZipCode ||\r\n\t\t\t\t\t!payload.address\r\n\t\t\t\t) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tgeocodeAddressPromise(payload.address)\r\n\t\t\t\t\t.done((response) => {\r\n\t\t\t\t\t\tif (!response) {\r\n\t\t\t\t\t\t\tpublishZipCodeValidationResult('ERROR', {\r\n\t\t\t\t\t\t\t\tstatus: 200,\r\n\t\t\t\t\t\t\t\terror: 'Could not find your location from the supplied address.',\r\n\t\t\t\t\t\t\t\taddress: payload.address,\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif (response.status !== 'OK') {\r\n\t\t\t\t\t\t\tlet error = '';\r\n\t\t\t\t\t\t\tswitch (response.status) {\r\n\t\t\t\t\t\t\t\tcase 'ZERO_RESULTS':\r\n\t\t\t\t\t\t\t\t\tpublishZipCodeValidationResult(\r\n\t\t\t\t\t\t\t\t\t\t'NO_MATCHES_FOUND',\r\n\t\t\t\t\t\t\t\t\t\t{ address: payload.address },\r\n\t\t\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t\t\tcase 'OVER_QUERY_LIMIT':\r\n\t\t\t\t\t\t\t\t\terror =\r\n\t\t\t\t\t\t\t\t\t\t'Attempting to find a location after exceeding your quota.';\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\tcase 'REQUEST_DENIED':\r\n\t\t\t\t\t\t\t\t\terror =\r\n\t\t\t\t\t\t\t\t\t\t'The request to find your location has been denied.';\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\tcase 'INVALID_REQUEST':\r\n\t\t\t\t\t\t\t\t\terror =\r\n\t\t\t\t\t\t\t\t\t\t'Attempting to find a location with an invalid request.';\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\tcase 'UNKNOWN_ERROR':\r\n\t\t\t\t\t\t\t\t\terror =\r\n\t\t\t\t\t\t\t\t\t\t'An unknown error occurred when trying to find your location.';\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t\t\t\terror =\r\n\t\t\t\t\t\t\t\t\t\t'Could not find your location from the supplied address.'; // eslint-disable-line max-len\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tpublishZipCodeValidationResult('ERROR', {\r\n\t\t\t\t\t\t\t\tstatus: 200,\r\n\t\t\t\t\t\t\t\terror,\r\n\t\t\t\t\t\t\t\taddress: payload.address,\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tconst matches = $.map(\r\n\t\t\t\t\t\t\tresponse.results,\r\n\t\t\t\t\t\t\t(locationMatch) => ({\r\n\t\t\t\t\t\t\t\tname: locationMatch.formatted_address,\r\n\t\t\t\t\t\t\t\tlatitude: locationMatch.geometry.location.lat,\r\n\t\t\t\t\t\t\t\tlongitude: locationMatch.geometry.location.lng,\r\n\t\t\t\t\t\t\t}),\r\n\t\t\t\t\t\t);\r\n\r\n\t\t\t\t\t\tif (matches.length === 1) {\r\n\t\t\t\t\t\t\tpublishZipCodeValidationResult(\r\n\t\t\t\t\t\t\t\t'EXACT_MATCH_FOUND',\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tmatch: matches[0],\r\n\t\t\t\t\t\t\t\t\taddress: payload.address,\r\n\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tpublishZipCodeValidationResult(\r\n\t\t\t\t\t\t\t'MULTIPLE_MATCHES_FOUND',\r\n\t\t\t\t\t\t\t{ matches, address: payload.address },\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t})\r\n\t\t\t\t\t.fail((_, status, error) => {\r\n\t\t\t\t\t\tpublishZipCodeValidationResult('ERROR', {\r\n\t\t\t\t\t\t\tstatus,\r\n\t\t\t\t\t\t\terror,\r\n\t\t\t\t\t\t\taddress: payload.address,\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t});\r\n\t\t\t},\r\n\t\t);\r\n\r\n\t\tconst defaultZoom = 4;\r\n\t\tconst minimumZoomForLocationsRefresh = 7;\r\n\t\tconst defaultLat = 39.5;\r\n\t\tconst defaultLng = -98.35;\r\n\t\tconst oneSecond = 1000;\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @name mapOptions\r\n\t\t * @description Defines all the static configuration options for the map.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @property {number} zoom - The default zoom level for the map.\r\n\t\t * @property {Object} center - An object defining the center latitude and longitude for the map.\r\n\t\t * @property {bool} panControl - Defines whether to show the pan controls.\r\n\t\t * @property {Object} panControlOptions - An object defining the position for the pan controls if shown.\r\n\t\t * @property {bool} zoomControl - Defines whether to show the zoom controls.\r\n\t\t * @property {Object} zoomControlOptions - An object defining the style and position for hte zoom controls\r\n\t\t * if shown.\r\n\t\t * @property {bool} scaleControl - Defines whether to show the scale controls.\r\n\t\t */\r\n\t\tconst mapOptions = {\r\n\t\t\tzoom: defaultZoom,\r\n\t\t\tcenter: new google.maps.LatLng(defaultLat, defaultLng),\r\n\t\t\tpanControl: false,\r\n\t\t\tpanControlOptions: {\r\n\t\t\t\tposition: google.maps.ControlPosition.BOTTOM_LEFT,\r\n\t\t\t},\r\n\t\t\tzoomControl: true,\r\n\t\t\tzoomControlOptions: {\r\n\t\t\t\tstyle: google.maps.ZoomControlStyle.LARGE,\r\n\t\t\t\tposition: google.maps.ControlPosition.RIGHT_CENTER,\r\n\t\t\t},\r\n\t\t\tscaleControl: false,\r\n\t\t};\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @const {Object} zeMap - Defines the Google Maps object.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t */\r\n\t\tconst zeMap = new google.maps.Map(\r\n\t\t\tdocument.getElementById('LocatorMap'),\r\n\t\t\tmapOptions,\r\n\t\t);\r\n\r\n\t\tlet markerArr = [];\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @function publishBoxUpdate\r\n\t\t * @description Publishes a message with the current map bounds as the payload.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @param {string} messageType - The message to publish the update map bounds.\r\n\t\t */\r\n\t\tfunction publishBoxUpdate(messageType) {\r\n\t\t\tconst bounds = zeMap.getBounds();\r\n\t\t\tconst northEastLatitude = bounds.getNorthEast().lat();\r\n\t\t\tconst northEastLongitude = bounds.getNorthEast().lng();\r\n\t\t\tconst southWestLatitude = bounds.getSouthWest().lat();\r\n\t\t\tconst southWestLongitude = bounds.getSouthWest().lng();\r\n\t\t\tmessaging.publish(messageType, {\r\n\t\t\t\tlocationTopRight: {\r\n\t\t\t\t\tlatitude: northEastLatitude,\r\n\t\t\t\t\tlongitude: northEastLongitude,\r\n\t\t\t\t},\r\n\t\t\t\tlocationBottomLeft: {\r\n\t\t\t\t\tlatitude: southWestLatitude,\r\n\t\t\t\t\tlongitude: southWestLongitude,\r\n\t\t\t\t},\r\n\t\t\t\tcenter: {\r\n\t\t\t\t\tlatitude: zeMap.getCenter().lat(),\r\n\t\t\t\t\tlongitude: zeMap.getCenter().lng(),\r\n\t\t\t\t},\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @const {number} xOffset - The default X coordinate offset for the default map marker label.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t */\r\n\t\tconst xOffset = 105;\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @const {number} yOffset - The default Y coordinate offset for the default map marker label.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t */\r\n\t\tconst yOffset = 110;\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @const {Object} defaultMarkerIcon - The default google maps marker icon to use for the map POI's.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t */\r\n\t\tconst defaultMarkerIcon = {\r\n\t\t\tpath: 'M72.1,214H7a4,4,0,0,1-4-4V7A4,4,0,0,1,7,3H210a4,4,0,0,1,4,4V210a4,4,0,0,1-4,4H145.18l-36.54,61.9Z',\r\n\t\t\tfillColor: '#5ea9ce',\r\n\t\t\tfillOpacity: 1,\r\n\t\t\tscale: 0.15,\r\n\t\t\tlabelOrigin: new google.maps.Point(xOffset, yOffset),\r\n\t\t};\r\n\r\n\t\tif (!Engage.Locator.Map.getMapMarkerIcon) {\r\n\t\t\t/**\r\n\t\t\t * @function getMapMarkerIcon\r\n\t\t\t * @description Creates the object for the map maker to send to google maps.\r\n\t\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t\t * @param {Object} coords - The latitude and longitude coordinates for the map marker.\r\n\t\t\t * @param {string} content - The optional content to display in the InfoWindow.\r\n\t\t\t * @param {number} sortPosition - The label that will be rendered on the map.\r\n\t\t\t * @returns {Object} The marker icon to send over to google maps.\r\n\t\t\t */\r\n\t\t\tEngage.Locator.Map.getMapMarkerIcon = (\r\n\t\t\t\tcoords,\r\n\t\t\t\tcontent,\r\n\t\t\t\tsortPosition,\r\n\t\t\t) => {\r\n\t\t\t\tif (sortPosition > -1) {\r\n\t\t\t\t\treturn defaultMarkerIcon;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn $.extend({}, defaultMarkerIcon, {\r\n\t\t\t\t\tfillColor: '#ff0000',\r\n\t\t\t\t});\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @function createMapMarker\r\n\t\t * @description Create a Google.maps.Marker and optionally attaches a Google.maps.InfoWindow if content\r\n\t\t * is supplied.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @param {Object} coords - The latitude and longitude coordinates for the map marker.\r\n\t\t * @param {string} zeContent - The optional content to display in the InfoWindow.\r\n\t\t * @param {number} sortPosition - The label that will be rendered on the map.\r\n\t\t * @param {string} locationName - The name of the location.\r\n\t\t * @returns {Object} An object containing the Google.maps.Marker and optionally attaches a\r\n\t\t * Google.maps.InfoWindow if content is supplied.\r\n\t\t */\r\n\t\tfunction createMapMarker(\r\n\t\t\tcoords,\r\n\t\t\tzeContent,\r\n\t\t\tsortPosition,\r\n\t\t\tlocationName,\r\n\t\t) {\r\n\t\t\tconst self = {};\r\n\t\t\tlet icon = defaultMarkerIcon;\r\n\r\n\t\t\tif (Engage.Locator.Map.getMapMarkerIcon) {\r\n\t\t\t\tconst customIcon = Engage.Locator.Map.getMapMarkerIcon(\r\n\t\t\t\t\tcoords,\r\n\t\t\t\t\tzeContent,\r\n\t\t\t\t\tsortPosition,\r\n\t\t\t\t\tlocationName,\r\n\t\t\t\t);\r\n\t\t\t\tif (customIcon) {\r\n\t\t\t\t\ticon = customIcon;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tself.marker = new google.maps.Marker({\r\n\t\t\t\tposition: coords,\r\n\t\t\t\tmap: zeMap,\r\n\t\t\t\ttitle: locationName,\r\n\t\t\t\tlabel:\r\n\t\t\t\t\tsortPosition > -1\r\n\t\t\t\t\t\t? {\r\n\t\t\t\t\t\t\t\tcolor: '#fff',\r\n\t\t\t\t\t\t\t\tfontSize: '12px',\r\n\t\t\t\t\t\t\t\tfontWeight: '600',\r\n\t\t\t\t\t\t\t\ttext: sortPosition.toString(),\r\n\t\t\t\t\t\t }\r\n\t\t\t\t\t\t: null,\r\n\t\t\t\ticon,\r\n\t\t\t});\r\n\r\n\t\t\tif (zeContent) {\r\n\t\t\t\tself.infoWindow = new google.maps.InfoWindow({\r\n\t\t\t\t\tcontent: zeContent,\r\n\t\t\t\t});\r\n\r\n\t\t\t\tself.marker.addListener('click', () => {\r\n\t\t\t\t\tself.infoWindow.open(zeMap, self.marker);\r\n\t\t\t\t\tfor (let i = 0; i < markerArr.length; i++) {\r\n\t\t\t\t\t\tif (markerArr[i] !== self) {\r\n\t\t\t\t\t\t\tmarkerArr[i].infoWindow.close(\r\n\t\t\t\t\t\t\t\tzeMap,\r\n\t\t\t\t\t\t\t\tmarkerArr[i].marker,\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tif (Engage.Locator.Map.customizeMapMarker) {\r\n\t\t\t\treturn Engage.Locator.Map.customizeMapMarker(self) ?? self;\r\n\t\t\t}\r\n\r\n\t\t\treturn self;\r\n\t\t}\r\n\r\n\t\tlet processingLocations = false;\r\n\t\tlet receivedNewLocations = false;\r\n\r\n\t\tlet dragendTimer;\r\n\r\n\t\t/**\r\n\t\t * @global\r\n\t\t * @description Defines the structure of the callback for all Google Map API callbacks.\r\n\t\t * @callback GoogleMapCallback\r\n\t\t */\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @name dragEndEventHandler\r\n\t\t * @description Handles all dragend events from the Google Map.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @param {Object} zeMap - The instance of the Google Map.\r\n\t\t * @param {string} eventName - The event name to bind to the map.\r\n\t\t * @param {GoogleMapCallback} callBack - The callback to handle the event that was passed into {eventName}.\r\n\t\t */\r\n\t\tgoogle.maps.event.addListener(zeMap, 'dragend', () => {\r\n\t\t\twindow.clearTimeout(dragendTimer);\r\n\r\n\t\t\tif (processingLocations) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (receivedNewLocations) {\r\n\t\t\t\treceivedNewLocations = false;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tdragendTimer = window.setTimeout(() => {\r\n\t\t\t\tconst newZoomLevel = zeMap.getZoom();\r\n\t\t\t\tif (newZoomLevel >= minimumZoomForLocationsRefresh) {\r\n\t\t\t\t\tprocessingLocations = true;\r\n\t\t\t\t\tpublishBoxUpdate(messaging.messageTypes.boundingBoxUpdate);\r\n\t\t\t\t\tprocessingLocations = false;\r\n\t\t\t\t}\r\n\t\t\t}, oneSecond);\r\n\t\t});\r\n\r\n\t\tlet zoomChangedTimer;\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @name zoomChangeEventHandler\r\n\t\t * @description Handles all dragend events from the Google Map.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @param {Object} zeMap - The instance of the Google Map.\r\n\t\t * @param {string} eventName - The event name to bind to the map.\r\n\t\t * @param {GoogleMapCallback} callBack - The callback to handle the event that was passed into {eventName}.\r\n\t\t */\r\n\t\tgoogle.maps.event.addListener(zeMap, 'zoom_changed', () => {\r\n\t\t\twindow.clearTimeout(zoomChangedTimer);\r\n\r\n\t\t\tif (processingLocations) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (receivedNewLocations) {\r\n\t\t\t\treceivedNewLocations = false;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tdragendTimer = window.setTimeout(() => {\r\n\t\t\t\tconst newZoomLevel = zeMap.getZoom();\r\n\t\t\t\tif (newZoomLevel >= minimumZoomForLocationsRefresh) {\r\n\t\t\t\t\tprocessingLocations = true;\r\n\t\t\t\t\tpublishBoxUpdate(messaging.messageTypes.boundingBoxUpdate);\r\n\t\t\t\t\tprocessingLocations = false;\r\n\t\t\t\t}\r\n\t\t\t}, oneSecond + oneSecond);\r\n\t\t});\r\n\r\n\t\tfunction addMarkerForZipCodeValidationResult(\r\n\t\t\tmessageType,\r\n\t\t\t{ data = {} },\r\n\t\t) {\r\n\t\t\tif (\r\n\t\t\t\tmessageType !==\r\n\t\t\t\t\tmessaging.messageTypes.zipCodeValidationResult ||\r\n\t\t\t\t!data\r\n\t\t\t) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (!data.match) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst match = data.match;\r\n\t\t\tconst content = '';\r\n\t\t\tconst sortPosition = -1;\r\n\t\t\tconst locationName = match.name || data.address;\r\n\t\t\tcreateMapMarker(\r\n\t\t\t\t{ lat: match.latitude, lng: match.longitude },\r\n\t\t\t\tcontent,\r\n\t\t\t\tsortPosition,\r\n\t\t\t\tlocationName,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @const {string[]} messageTypesThatCauseSearchUpdates - An array of all messages types that mark a search\r\n\t\t * action has been completed.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t */\r\n\t\tconst messageTypesThatCauseSearchUpdates = [\r\n\t\t\tmessaging.messageTypes.locationUpdate,\r\n\t\t\tmessaging.messageTypes.newQueryFilters,\r\n\t\t\tmessaging.messageTypes.boundingBoxUpdate,\r\n\t\t\tmessaging.messageTypes.showLoading,\r\n\t\t];\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @name messageTypesThatCauseSearchUpdatesSubscriptionCallback\r\n\t\t * @typedef subscriptionCallback\r\n\t\t * @description Subscribe to all messages in the Engage Locator, only handle messages\r\n\t\t * that exist in the {messageTypesThatCauseSearchUpdates} member.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @param {string} messageType - The type of message requesting publish.\r\n\t\t * @param {Object} payload - The object payload for the message requesting publish.\r\n\t\t */\r\n\t\tmessaging.subscribe(messaging.locatorMessagePrefix, (messageType) => {\r\n\t\t\tif (\r\n\t\t\t\tmessageTypesThatCauseSearchUpdates.indexOf(messageType) === -1\r\n\t\t\t) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t$loadingIndicator.removeClass('engage-locator__loading__hidden');\r\n\t\t\t$loadingIndicator.addClass('engage-locator__loading__show');\r\n\t\t});\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @name resetSearchFromSubscriptionCallback\r\n\t\t * @typedef subscriptionCallback\r\n\t\t * @description Handles all {Window.Engage.Locator.Messaging.messageTypes.resetSearchFrom} messages.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @param {string} messageType - The type of message requesting publish.\r\n\t\t * @param {Object} payload - The object payload for the message requesting publish.\r\n\t\t */\r\n\t\tmessaging.subscribe(messaging.messageTypes.resetSearchFrom, () => {\r\n\t\t\tzeMap.setCenter(new google.maps.LatLng(defaultLat, defaultLng));\r\n\t\t\tzeMap.setZoom(defaultZoom);\r\n\t\t});\r\n\r\n\t\tif (Engage.Locator.Settings.ShowSearchLocationPin) {\r\n\t\t\tmessaging.subscribe(\r\n\t\t\t\tmessaging.messageTypes.zipCodeValidationResult,\r\n\t\t\t\taddMarkerForZipCodeValidationResult,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * @private\r\n\t\t * @name newLocationsSubscriptionCallback\r\n\t\t * @typedef subscriptionCallback\r\n\t\t * @description Handles all {Window.Engage.Locator.Messaging.messageTypes.newLocations} messages.\r\n\t\t * @memberof Window.Engage.Locator.Map\r\n\t\t * @param {string} messageType - The type of message requesting publish.\r\n\t\t * @param {Object} payload - The object payload for the message requesting publish.\r\n\t\t */\r\n\t\tmessaging.subscribe(\r\n\t\t\tmessaging.messageTypes.newLocations,\r\n\t\t\t(_, { type, locations }) => {\r\n\t\t\t\tif (processingLocations) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfor (let i = 0; i < markerArr.length; i++) {\r\n\t\t\t\t\tmarkerArr[i].marker.setMap(null);\r\n\t\t\t\t}\r\n\t\t\t\tmarkerArr = [];\r\n\r\n\t\t\t\tconst bounds = new google.maps.LatLngBounds();\r\n\t\t\t\tif (locations.length > 0) {\r\n\t\t\t\t\tfor (let i = 0; i < locations.length; i++) {\r\n\t\t\t\t\t\treceivedNewLocations = true;\r\n\t\t\t\t\t\tmarkerArr.push(\r\n\t\t\t\t\t\t\tcreateMapMarker(\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tlat: locations[i].latitude,\r\n\t\t\t\t\t\t\t\t\tlng: locations[i].longitude,\r\n\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\tlocations[i].template,\r\n\t\t\t\t\t\t\t\tlocations[i].order,\r\n\t\t\t\t\t\t\t\tlocations[i].name,\r\n\t\t\t\t\t\t\t),\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\tbounds.extend(markerArr[i].marker.getPosition());\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (type !== 'BoundingBoxSearch') {\r\n\t\t\t\t\t\tzeMap.fitBounds(bounds);\r\n\t\t\t\t\t}\r\n\t\t\t\t\treceivedNewLocations = false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t$loadingIndicator.removeClass('engage-locator__loading__show');\r\n\t\t\t\t$loadingIndicator.addClass('engage-locator__loading__hidden');\r\n\t\t\t},\r\n\t\t);\r\n\t};\r\n})(jQuery);\r\n"]}