// JavaScript Document $(document).ready(function(){ initMap(); }); var businessLat = 32.407819510794155; var businessLng = -80.65795976263801; var theMap; var mapCenter; var zLevelHide = 16; var markersArr = []; var infowindow; var sitePlanOverlay; var markerData; var bucketPath; var otherMarker = { url: '/themes/atlanticedge/modules/map/markers/map-pin.svg', anchor: new google.maps.Point(25, 60) }; function initMap() { mapCenter = new google.maps.LatLng(businessLat,businessLng); var mapOptions = { zoom: mapZoomStart, center: mapCenter, styles: gmap_styles, scrollwheel: false, mapTypeControl: false, streetViewControl: false }; // Create a map object and specify the DOM element for display. theMap = new google.maps.Map(document.getElementById('map_canvas_full'), mapOptions); addMarkers(markerData); var contentString = `

Atlantic Edge Insurance

134-B Lady's Island Drive
Beaufort, SC 29901

`; infowindow = new google.maps.InfoWindow({ content: contentString, maxWidth: 300, pixelOffset: new google.maps.Size(-10, -10) }); // make list of locations clickable $('.location-link').click(function(e) { e.preventDefault(); $this = $(this); var theID = $this.data('id'); console.log(theID); for (var i=0; i < markersArr.length; i++) { if (markersArr[i].markerID === theID) { google.maps.event.trigger(markersArr[i], 'click'); break; } } }); google.maps.event.addListenerOnce(theMap, 'idle', function() { offsetMapCenter(theMap); }); // Add an event listener for the zoom_changed event to keep the map centered on the offset point google.maps.event.addListener(theMap, 'zoom_changed', function() { offsetMapCenter(theMap); }); }; // initMap function offsetMapCenter(map){ const mapContainer = document.getElementById('map_canvas_full'); const mapWidth = mapContainer.offsetWidth; const mapOverlayWidth = $('.map-overlay').width(); const mapVisibleWidth = mapWidth - mapOverlayWidth; let offsetXnew = 0; let offsetYnew = 0; if ( $(window).width() > 769 ) { offsetXnew = -(mapVisibleWidth / 2); map.setCenter(mapCenter); map.panBy(offsetXnew,offsetYnew); console.log('offsetXnew',offsetXnew); } else if ( $(window).width() > 500 ){ offsetXnew = -250; map.setCenter(mapCenter); map.panBy(offsetXnew,offsetYnew); }else { offsetXnew = 100; offsetYnew = 75; map.setCenter(mapCenter); map.panBy(0,offsetYnew); } }; $( window ).resize(function() { offsetMapCenter(theMap); }); function addMarkers(markerData) { if( markerData != undefined) { var markerTitle; var bounds = new google.maps.LatLngBounds(); for(var i = 0; i < markerData.ROWCOUNT; i++){ var hasImage = true; var markerID = markerData.DATA.ID[i]; var markerHeadline = markerData.DATA.HEADLINE[i]; var markerSubhead = markerData.DATA.SUBHEAD[i]; var marker_text = String(markerData.DATA.PAGETEXT[i]); marker_text = marker_text; var image1 = markerData.DATA.DOCUMENT_FILE_PATH[i] + 'thumb_' + markerData.DATA.DOCUMENT_FILE[i]; var newLatLng = new google.maps.LatLng(markerData.DATA.LATITUDE[i],markerData.DATA.LONGITUDE[i]); if ( markerData.DATA.DOCUMENT_FILE[i] == null){ hasImage = false; } var loadedmarker = new google.maps.Marker({ map: theMap, position: newLatLng, icon: otherMarker, // custom marker info markerID : markerID, markerHeadline : markerHeadline, markerSubhead : markerSubhead, markerText : marker_text, image : image1, hasImage : hasImage }); markersArr.push(loadedmarker); google.maps.event.addListener(loadedmarker, 'click', markerInfoWindow); bounds.extend(newLatLng); }//end for loop if(markerData.ROWCOUNT > 1){ theMap.fitBounds(bounds); } }// end if undefined }//end addMarkers function markerInfoWindow(event) { //console.log(this); if ( this.hasImage == false ) { var contentString = `

${this.markerHeadline}

${this.markerSubhead}
${this.markerText}

`; } else { var contentString = `

${this.markerHeadline}

${this.markerSubhead}
${this.markerText}

`; } infowindow.setContent(contentString); infowindow.open(theMap,this); theMap.setCenter(this.getPosition()); offsetMapCenter(theMap); } // show/hide markers function setMapOnAll(theMap) { for (var i = 0; i < markersArr.length; i++) { markersArr[i].setMap(theMap); } }; // Removes the markers from the map, but keeps them in the array. function clearMarkers() { setMapOnAll(null); } // Shows any markers currently in the array. function showMarkers() { setMapOnAll(map); } // show/hide marker labels function showLabels() { for (var i = 0; i < markersArr.length; i++) { markersArr[i].set('labelVisible', true); } }; function hideLabels() { for (var i = 0; i < markersArr.length; i++) { markersArr[i].set('labelVisible', false); } }; function showHideLabelsOnZoom() { if ( theMap.getZoom() < zLevelHide ) { hideLabels(); } else { showLabels(); } }; function findLatInPoints(pointArr,inLat) { // return number of times lat appears in points var result = $.grep(pointArr, function(e){ return e.lat() === inLat; }); return result.length; }// findLat //////////////// overlay //////////////// /////////////// end overlay /////////////// var gmap_styles = [ { "elementType": "geometry", "stylers": [ { "color": "#f5f5f5" } ] }, { "elementType": "labels.icon", "stylers": [ { "visibility": "off" } ] }, { "elementType": "labels.text.fill", "stylers": [ { "color": "#616161" } ] }, { "elementType": "labels.text.stroke", "stylers": [ { "color": "#f5f5f5" } ] }, { "featureType": "administrative.land_parcel", "elementType": "labels", "stylers": [ { "visibility": "off" } ] }, { "featureType": "administrative.land_parcel", "elementType": "labels.text.fill", "stylers": [ { "color": "#bdbdbd" } ] }, { "featureType": "poi", "elementType": "geometry", "stylers": [ { "color": "#eeeeee" } ] }, { "featureType": "poi", "elementType": "labels.text", "stylers": [ { "visibility": "on" } ] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [ { "color": "#757575" } ] }, { "featureType": "poi.business", "stylers": [ { "visibility": "on" } ] }, { "featureType": "poi.park", "elementType": "geometry", "stylers": [ { "color": "#e5e5e5" } ] }, { "featureType": "poi.park", "elementType": "labels.text", "stylers": [ { "visibility": "on" } ] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [ { "color": "#9e9e9e" } ] }, { "featureType": "road", "elementType": "geometry", "stylers": [ { "color": "#ffffff" } ] }, { "featureType": "road.arterial", "elementType": "labels", "stylers": [ { "visibility": "on" } ] }, { "featureType": "road.arterial", "elementType": "labels.text.fill", "stylers": [ { "color": "#757575" } ] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [ { "color": "#dadada" } ] }, { "featureType": "road.highway", "elementType": "labels", "stylers": [ { "visibility": "off" } ] }, { "featureType": "road.highway", "elementType": "labels.text.fill", "stylers": [ { "color": "#616161" } ] }, { "featureType": "road.local", "stylers": [ { "visibility": "on" } ] }, { "featureType": "road.local", "elementType": "labels", "stylers": [ { "visibility": "on" } ] }, { "featureType": "road.local", "elementType": "labels.text.fill", "stylers": [ { "color": "#9e9e9e" } ] }, { "featureType": "transit.line", "elementType": "geometry", "stylers": [ { "color": "#e5e5e5" } ] }, { "featureType": "transit.station", "elementType": "geometry", "stylers": [ { "color": "#eeeeee" } ] }, { "featureType": "water", "elementType": "geometry", "stylers": [ { "color": "#c9c9c9" } ] }, { "featureType": "water", "elementType": "geometry.fill", "stylers": [ { "color": "#9dc1d1" } ] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [ { "color": "#9e9e9e" } ] } ];