{"version":3,"file":"Diagram.GoogleMaps.4ce06855.js","sources":["../src/current/js/modules/Diagram.GoogleMaps.js"],"sourcesContent":["export async function DiagramGoogleMaps() {\r\n     window.MapHelper = window.MapHelper || {};\r\n\r\n(function () {\r\n    if (typeof String.prototype.trim !== 'function') {\r\n        String.prototype.trim = function () {\r\n            return this.replace(/^\\s+|\\s+$/g, '');\r\n        }\r\n    }\r\n\r\n    var bounds = new google.maps.LatLngBounds();\r\n    var map;\r\n\r\n    //var gHtml;\r\n    window.MapHelper.gmarkers = [];\r\n    window.MapHelper.htmls = [];\r\n    window.MapHelper.to_htmls = [];\r\n    window.MapHelper.from_htmls = [];\r\n    window.MapHelper.i = 0;\r\n    window.MapHelper.infowindow = [];\r\n    window.MapHelper.bounds = new google.maps.LatLngBounds();\r\n\r\n    MapHelper.mapCreated = false;\r\n\r\n    MapHelper.initMap = function () {\r\n        if (document.documentElement.clientWidth < 768) {\r\n            console.log(\"lower res\");\r\n            function addEventListener(el, eventName, handler) {\r\n                if (el.addEventListener) {\r\n                    el.addEventListener(eventName, handler);\r\n                } else {\r\n                    el.attachEvent('on' + eventName, function () {\r\n                        handler.call(el);\r\n                    });\r\n                }\r\n            }\r\n\r\n            addEventListener(window, 'resize', MapHelper.loadMapOnWide);\r\n        } else {\r\n            console.log(\"higher res\");\r\n            MapHelper.LoadGoogleMap();\r\n        }\r\n    };\r\n\r\n    MapHelper.loadMapOnWide = function () {\r\n        if (document.documentElement.clientWidth >= 768) {\r\n            MapHelper.mapCreated = true;\r\n            function removeEventListener(el, eventName, handler) {\r\n                if (el.removeEventListener)\r\n                    el.removeEventListener(eventName, handler);\r\n                else\r\n                    el.detachEvent('on' + eventName, handler);\r\n            }\r\n            removeEventListener(window, 'resize', MapHelper.loadMapOnWide);\r\n            MapHelper.LoadGoogleMap();\r\n        }\r\n    };\r\n\r\n    MapHelper.LoadGoogleMap = function () {\r\n        var mapOptions = {\r\n            center: new google.maps.LatLng(36.861740, -76.301750),\r\n            zoom: 10, mapTypeId: google.maps.MapTypeId.ROADMAP,\r\n            zoomControl: true,\r\n            panControl: true,\r\n            panControlOptions: { position: google.maps.ControlPosition.TOP_LEFT },\r\n            zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE },\r\n            mapTypeControlOptions: {\r\n                mapTypeIds: [\r\n                    google.maps.MapTypeId.ROADMAP,\r\n                    google.maps.MapTypeId.HYBRID,\r\n                    google.maps.MapTypeId.TERRAIN,\r\n                    google.maps.MapTypeId.SATELLITE\r\n                ]\r\n            }\r\n        };\r\n\r\n        var mapDiv = document.getElementById(\"map_canvas1\");\r\n        console.log(\"map div: \" + mapDiv);\r\n\r\n        var data = JSON.parse(mapDiv.getAttribute(\"data-map-settings\"));\r\n        console.log(\"map data: \" + data);\r\n\r\n        map = new google.maps.Map(mapDiv, mapOptions);\r\n        console.log(\"map: \" + map);\r\n\r\n        \r\n        console.log(\"map options: \" + mapOptions);\r\n\r\n        if (data) {\r\n            for (var k = 0; k < data.length; k++) {\r\n                showAddress(data[k], k);\r\n            }\r\n        }\r\n\r\n        setTimeout(function () {\r\n            map.fitBounds(window.MapHelper.bounds);\r\n            map.setCenter(window.MapHelper.bounds.getCenter());\r\n\r\n            if (window.MapHelper.gmarkers.length == 1 && map.getZoom() > 13) {\r\n                map.setZoom(15);\r\n            }\r\n            else if (window.MapHelper.gmarkers.length > 1 && map.getZoom() > 8) {\r\n                map.setZoom(9);\r\n            }\r\n\r\n        }, 1000);\r\n    }\r\n\r\n    // A function to create the marker and set up the event window\r\n    function createMarker(point, address, index, i) {\r\n        console.log(\"create marker script\");\r\n        var markerOptions = {\r\n            position: point,\r\n            map: map\r\n        };\r\n\r\n        if (index != undefined) {\r\n            // Create a numberd icon for this point using our icon class\r\n            var number = String.fromCharCode(\"1\".charCodeAt(0) + index);\r\n            markerOptions.icon = {\r\n                url: \"/img/ui/map-pins/map-pin-\" + number + \".svg\",\r\n                //url: \"/img/ui/map-pins/map-pin.svg\",\r\n            };\r\n        }\r\n\r\n        console.log(\"markers: \"+  markerOptions);\r\n\r\n        window.MapHelper.gmarkers[i] = new google.maps.Marker(markerOptions);\r\n\r\n        var IsLong = (address.length > 44) ? true : false;\r\n\r\n        // The info window version with the \"to here\" form open\r\n        window.MapHelper.to_htmls[i] = '<div id=\"gmap-info-window\" style=\"width: 250px; height: ' + ((IsLong) ? '150' : '130') + 'px;\"><div style=\"font-size: 12px;\"><strong>Address: </strong><br>' + address + '<br><strong>Driving Directions</strong></div><div style=\"font-size: 12px\"><strong>To here</strong> - <a href=\"javascript:MapHelper.fromhere(' + i + ')\">From here</a></div>' +\r\n            'Start address:<form action=\"https://maps.google.com/maps\" method=\"get\" target=\"_blank\">' +\r\n            '<input class=\"map-info-input\" type=\"text\" maxlength=40 name=\"saddr\" id=\"saddr\" value=\"\" /><br />' +\r\n            '<INPUT class=\"map-info-submit\" style=\"font-size: 1em\" value=\"Get Directions\" type=\"submit\">' +\r\n            '<input type=\"hidden\" name=\"daddr\" value=\"' +\r\n            point.lat() + ',' + point.lng() + \"(\" + address + \")\" + '\"/></div>';\r\n        // The info window version with the \"to here\" form open\r\n        window.MapHelper.from_htmls[i] = '<div id=\"gmap-info-window\" style=\"width: 250px; height: ' + ((IsLong) ? '150' : '130') + 'px;\"><div style=\"font-size: 12px;\"><strong>Address: </strong><br>' + address + '<br><strong>Driving Directions</strong></div><div style=\"font-size: 12px\"><a href=\"javascript:MapHelper.tohere(' + i + ')\">To here</a> - <strong>From here</strong></div>' +\r\n            'End address:<form action=\"https://maps.google.com/maps\" method=\"get\"\" target=\"_blank\">' +\r\n            '<input class=\"map-info-input\" type=\"text\" maxlength=40 name=\"daddr\" id=\"daddr\" value=\"\" /><br />' +\r\n            '<INPUT class=\"map-info-submit\" style=\"font-size: 1em\" value=\"Get Directions\" type=\"submit\">' +\r\n            '<input type=\"hidden\" name=\"saddr\" value=\"' +\r\n            point.lat() + ',' + point.lng() + \"(\" + address + \")\" + '\"/></div>';\r\n        // The inactive version of the direction info\r\n\r\n        window.MapHelper.htmls[i] = '<div id=\"gmap-info-window\" style=\"width: 250px; height: ' + ((IsLong) ? '85' : '70') + 'px;\"><div style=\"font-size: 12px;\"><strong>Address: </strong><br>' + address + '<br><strong>Driving Directions</strong></div><div ><a href=\"javascript:MapHelper.tohere(' + i + ')\">To here</a> - <a href=\"javascript:MapHelper.fromhere(' + i + ')\">From here</a></div></div>';\r\n        // The new marker \"click\" listener\r\n\r\n        window.MapHelper.infowindow[i] = new google.maps.InfoWindow({ disableAutoPan: false });\r\n    }\r\n\r\n    // functions that open the directions forms\r\n    MapHelper.tohere = function (i) {\r\n        window.MapHelper.infowindow[i].setContent('<div class=\"info-window\">' + window.MapHelper.to_htmls[i] + '</div>');\r\n        window.MapHelper.infowindow[i].close();\r\n        window.MapHelper.infowindow[i].open(map, window.MapHelper.gmarkers[i]);\r\n    }\r\n\r\n    MapHelper.fromhere = function (i) {\r\n        window.MapHelper.infowindow[i].setContent('<div class=\"info-window\">' + window.MapHelper.from_htmls[i] + '</div>');\r\n        window.MapHelper.infowindow[i].close();\r\n        window.MapHelper.infowindow[i].open(map, window.MapHelper.gmarkers[i]);\r\n    }\r\n\r\n    function showAddress(data, index) {\r\n        console.log(\"show address function\");\r\n        var point;\r\n        var isMarkerCreated = false;\r\n        (function (i) {\r\n            if (data.lat === \"\" || data.lat == undefined && data.lng === \"\" || data.lng == undefined) {\r\n                isMarkerCreated = true;\r\n                console.log(\"geoencoding address... : \" + data.address.trim());\r\n                var geocoder = new google.maps.Geocoder();\r\n                var address = data.address.trim();\r\n\r\n                geocoder.geocode({ 'address': address }, function (results, status) {\r\n                    if (status === google.maps.GeocoderStatus.OK) {\r\n                        map.setCenter(results[0].geometry.location);\r\n                        var marker = new google.maps.Marker({\r\n                            map: map,\r\n                            position: results[0].geometry.location\r\n                        });\r\n                        console.log(\"Geoencoded address: \" + address);\r\n                    }\r\n                    else {\r\n                        console.log('Geocode was not successful for the following reason: ' + status);\r\n                    }\r\n                });\r\n            }\r\n\r\n            point = new google.maps.LatLng(data.lat, data.lng);\r\n\r\n            if (!isMarkerCreated) {\r\n                window.MapHelper.bounds.extend(point);\r\n                createMarker(point, data.address.trim(), index, i);\r\n            }\r\n\r\n            if (index == 0 && data.address != \"601 Children’s Lane, Norfolk, VA 23507, US\") {\r\n                window.MapHelper.infowindow[i].setContent('<div >' + window.MapHelper.htmls[i] + '</div>');\r\n                //window.MapHelper.infowindow[i].open(map, window.MapHelper.gmarkers[i]);\r\n            }\r\n\r\n            google.maps.event.addListener(window.MapHelper.gmarkers[i], \"click\", function () {\r\n                for (var k = 0; k < window.MapHelper.infowindow.length; k++) {\r\n                    window.MapHelper.infowindow[k].close();\r\n                }\r\n\r\n                //update z index for clicked marker\r\n                window.MapHelper.gmarkers.forEach(marker => marker.setZIndex(marker.findIndex));\r\n                this.setZIndex(google.maps.Marker.MAX_ZINDEX + 1);\r\n\r\n                window.MapHelper.infowindow[i].setContent(window.MapHelper.htmls[i]);\r\n                window.MapHelper.infowindow[i].open(map, window.MapHelper.gmarkers[i]);\r\n            });\r\n\r\n        })(window.MapHelper.i);\r\n\r\n        window.MapHelper.i++;\r\n    }\r\n\r\n    MapHelper.initMap();\r\n})();\r\n};"],"names":["DiagramGoogleMaps","map","addEventListener","el","eventName","handler","removeEventListener","mapOptions","mapDiv","data","k","showAddress","createMarker","point","address","index","i","markerOptions","number","IsLong","isMarkerCreated","geocoder","results","status","marker"],"mappings":"AAAQ,eAAeA,GAAoB,CACtC,OAAO,UAAY,OAAO,WAAa,CAAA,EAE3C,UAAY,CACL,OAAO,OAAO,UAAU,MAAS,aACjC,OAAO,UAAU,KAAO,UAAY,CAChC,OAAO,KAAK,QAAQ,aAAc,EAAE,CACvC,GAGQ,IAAI,OAAO,KAAK,aAC7B,IAAIC,EAGJ,OAAO,UAAU,SAAW,GAC5B,OAAO,UAAU,MAAQ,GACzB,OAAO,UAAU,SAAW,GAC5B,OAAO,UAAU,WAAa,GAC9B,OAAO,UAAU,EAAI,EACrB,OAAO,U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