// JavaScript Document //////// markerwithlabel /** * google-maps-utility-library-v3-markerwithlabel * * @version: 1.1.10 * @author: Gary Little (inspired by code from Marc Ridey of Google). * @contributors: Nicholas McCready * @date: Fri May 13 2016 16:29:58 GMT-0400 (EDT) * @license: Apache License 2.0 */ function inherits(e,t){function i(){}i.prototype=t.prototype,e.superClass_=t.prototype,e.prototype=new i,e.prototype.constructor=e}function MarkerLabel_(e,t,i){this.marker_=e,this.handCursorURL_=e.handCursorURL,this.labelDiv_=document.createElement("div"),this.labelDiv_.style.cssText="position: absolute; overflow: hidden;",this.eventDiv_=document.createElement("div"),this.eventDiv_.style.cssText=this.labelDiv_.style.cssText,this.eventDiv_.setAttribute("onselectstart","return false;"),this.eventDiv_.setAttribute("ondragstart","return false;"),this.crossDiv_=MarkerLabel_.getSharedCross(t)}function MarkerWithLabel(e){e=e||{},e.labelContent=e.labelContent||"",e.labelAnchor=e.labelAnchor||new google.maps.Point(0,0),e.labelClass=e.labelClass||"markerLabels",e.labelStyle=e.labelStyle||{},e.labelInBackground=e.labelInBackground||!1,"undefined"==typeof e.labelVisible&&(e.labelVisible=!0),"undefined"==typeof e.raiseOnDrag&&(e.raiseOnDrag=!0),"undefined"==typeof e.clickable&&(e.clickable=!0),"undefined"==typeof e.draggable&&(e.draggable=!1),"undefined"==typeof e.optimized&&(e.optimized=!1),e.crossImage=e.crossImage||"http"+("https:"===document.location.protocol?"s":"")+"://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png",e.handCursor=e.handCursor||"http"+("https:"===document.location.protocol?"s":"")+"://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur",e.optimized=!1,this.label=new MarkerLabel_(this,e.crossImage,e.handCursor),google.maps.Marker.apply(this,arguments)}inherits(MarkerLabel_,google.maps.OverlayView),MarkerLabel_.getSharedCross=function(e){var t;return"undefined"==typeof MarkerLabel_.getSharedCross.crossDiv&&(t=document.createElement("img"),t.style.cssText="position: absolute; z-index: 1000002; display: none;",t.style.marginLeft="-8px",t.style.marginTop="-9px",t.src=e,MarkerLabel_.getSharedCross.crossDiv=t),MarkerLabel_.getSharedCross.crossDiv},MarkerLabel_.prototype.onAdd=function(){var e,t,i,s,a,r,o,n=this,l=!1,g=!1,p=20,_="url("+this.handCursorURL_+")",h=function(e){e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,e.stopPropagation&&e.stopPropagation()},v=function(){n.marker_.setAnimation(null)};this.getPanes().overlayImage.appendChild(this.labelDiv_),this.getPanes().overlayMouseTarget.appendChild(this.eventDiv_),"undefined"==typeof MarkerLabel_.getSharedCross.processed&&(this.getPanes().overlayImage.appendChild(this.crossDiv_),MarkerLabel_.getSharedCross.processed=!0),this.listeners_=[google.maps.event.addDomListener(this.eventDiv_,"mouseover",function(e){(n.marker_.getDraggable()||n.marker_.getClickable())&&(this.style.cursor="pointer",google.maps.event.trigger(n.marker_,"mouseover",e))}),google.maps.event.addDomListener(this.eventDiv_,"mouseout",function(e){!n.marker_.getDraggable()&&!n.marker_.getClickable()||g||(this.style.cursor=n.marker_.getCursor(),google.maps.event.trigger(n.marker_,"mouseout",e))}),google.maps.event.addDomListener(this.eventDiv_,"mousedown",function(e){g=!1,n.marker_.getDraggable()&&(l=!0,this.style.cursor=_),(n.marker_.getDraggable()||n.marker_.getClickable())&&(google.maps.event.trigger(n.marker_,"mousedown",e),h(e))}),google.maps.event.addDomListener(document,"mouseup",function(t){var i;if(l&&(l=!1,n.eventDiv_.style.cursor="pointer",google.maps.event.trigger(n.marker_,"mouseup",t)),g){if(a){i=n.getProjection().fromLatLngToDivPixel(n.marker_.getPosition()),i.y+=p,n.marker_.setPosition(n.getProjection().fromDivPixelToLatLng(i));try{n.marker_.setAnimation(google.maps.Animation.BOUNCE),setTimeout(v,1406)}catch(r){}}n.crossDiv_.style.display="none",n.marker_.setZIndex(e),s=!0,g=!1,t.latLng=n.marker_.getPosition(),google.maps.event.trigger(n.marker_,"dragend",t)}}),google.maps.event.addListener(n.marker_.getMap(),"mousemove",function(s){var _;l&&(g?(s.latLng=new google.maps.LatLng(s.latLng.lat()-t,s.latLng.lng()-i),_=n.getProjection().fromLatLngToDivPixel(s.latLng),a&&(n.crossDiv_.style.left=_.x+"px",n.crossDiv_.style.top=_.y+"px",n.crossDiv_.style.display="",_.y-=p),n.marker_.setPosition(n.getProjection().fromDivPixelToLatLng(_)),a&&(n.eventDiv_.style.top=_.y+p+"px"),google.maps.event.trigger(n.marker_,"drag",s)):(t=s.latLng.lat()-n.marker_.getPosition().lat(),i=s.latLng.lng()-n.marker_.getPosition().lng(),e=n.marker_.getZIndex(),r=n.marker_.getPosition(),o=n.marker_.getMap().getCenter(),a=n.marker_.get("raiseOnDrag"),g=!0,n.marker_.setZIndex(1e6),s.latLng=n.marker_.getPosition(),google.maps.event.trigger(n.marker_,"dragstart",s)))}),google.maps.event.addDomListener(document,"keydown",function(e){g&&27===e.keyCode&&(a=!1,n.marker_.setPosition(r),n.marker_.getMap().setCenter(o),google.maps.event.trigger(document,"mouseup",e))}),google.maps.event.addDomListener(this.eventDiv_,"click",function(e){(n.marker_.getDraggable()||n.marker_.getClickable())&&(s?s=!1:(google.maps.event.trigger(n.marker_,"click",e),h(e)))}),google.maps.event.addDomListener(this.eventDiv_,"dblclick",function(e){(n.marker_.getDraggable()||n.marker_.getClickable())&&(google.maps.event.trigger(n.marker_,"dblclick",e),h(e))}),google.maps.event.addListener(this.marker_,"dragstart",function(e){g||(a=this.get("raiseOnDrag"))}),google.maps.event.addListener(this.marker_,"drag",function(e){g||a&&(n.setPosition(p),n.labelDiv_.style.zIndex=1e6+(this.get("labelInBackground")?-1:1))}),google.maps.event.addListener(this.marker_,"dragend",function(e){g||a&&n.setPosition(0)}),google.maps.event.addListener(this.marker_,"position_changed",function(){n.setPosition()}),google.maps.event.addListener(this.marker_,"zindex_changed",function(){n.setZIndex()}),google.maps.event.addListener(this.marker_,"visible_changed",function(){n.setVisible()}),google.maps.event.addListener(this.marker_,"labelvisible_changed",function(){n.setVisible()}),google.maps.event.addListener(this.marker_,"title_changed",function(){n.setTitle()}),google.maps.event.addListener(this.marker_,"labelcontent_changed",function(){n.setContent()}),google.maps.event.addListener(this.marker_,"labelanchor_changed",function(){n.setAnchor()}),google.maps.event.addListener(this.marker_,"labelclass_changed",function(){n.setStyles()}),google.maps.event.addListener(this.marker_,"labelstyle_changed",function(){n.setStyles()})]},MarkerLabel_.prototype.onRemove=function(){var e;for(this.labelDiv_.parentNode.removeChild(this.labelDiv_),this.eventDiv_.parentNode.removeChild(this.eventDiv_),e=0;e=0&&this.get("opacity")<=1&&(e.style.opacity=this.get("opacity")),this.get("clickable")===!0&&google.maps.event.addDomListener(e,"click",function(e){google.maps.event.trigger(t,"click",e)}),this.get("draggable")===!0&&(google.maps.event.addDomListener(e,"drag",function(e){google.maps.event.trigger(t,"drag",e)}),google.maps.event.addDomListener(e,"mousedown",function(e){google.maps.event.trigger(t,"dragstart",e),this.style.cursor="move",t.get("map").set("draggable",!1);var i=e;t.moveHandler=google.maps.event.addDomListener(t.get("map").getDiv(),"mousemove",function(e){google.maps.event.trigger(t,"drag",e);var o=i.clientX-e.clientX,n=i.clientY-e.clientY,s=t.getProjection().fromLatLngToDivPixel(t.get("position")),r=t.getProjection().fromDivPixelToLatLng(new google.maps.Point(s.x-o,s.y-n));i=e,t.set("position",r),t.draw()})}),google.maps.event.addDomListener(e,"mouseup",function(e){google.maps.event.trigger(t,"dragend",e),t.get("map").set("draggable",!0),this.style.cursor="default",google.maps.event.removeListener(t.moveHandler)}),google.maps.event.addDomListener(this.get("map").getDiv(),"mouseleave",function(t){google.maps.event.trigger(e,"mouseup",t)})),google.maps.event.addDomListener(e,"mouseover",function(e){google.maps.event.trigger(t,"mouseover",e)}),google.maps.event.addDomListener(e,"mouseout",function(e){google.maps.event.trigger(t,"mouseout",e)});var i=document.createElement("img");if(i.src=this.get("icon").url,i.style.width=this.get("icon").size.width+"px",i.style.height=this.get("icon").size.height+"px",i.style.display="block",i.setAttribute("alt",this.get("title")),e.appendChild(i),""!==this.get("icon").text.content){var o=document.createElement("span");o.textContent=this.get("icon").text.content,o.style.fontFamily=this.get("icon").text.font,o.style.fontSize=this.get("icon").text.size,o.style.fontWeight=this.get("icon").text.weight,o.style.color=this.get("icon").text.color,o.style.position="absolute",o.style.top=this.get("icon").text.position[0]+"px",o.style.left=this.get("icon").text.position[1]+"px",o.style.transform="translate(-50%, -50%)",this.get("container").appendChild(o)}""!==this.get("icon").html&&e.appendChild(this.get("icon").html),this.set("container",e),this.getPanes().overlayImage.appendChild(e)},SVGMarker.prototype.draw=function(){var t=this.getProjection(),e=t.fromLatLngToDivPixel(this.get("position"));this.get("container").style.left=e.x-this.get("icon").anchor.x+"px",this.get("container").style.top=e.y-this.get("icon").anchor.y+"px",this.get("container").style.cursor=this.get("cursor")},SVGMarker.prototype.onRemove=function(){this.get("container").parentNode.removeChild(this.get("container")),this.set("container",null)},SVGMarker.prototype.setZIndex=function(t){this.get("container")&&(this.get("container").style.zIndex=t)},SVGMarker.prototype.setOpacity=function(t){this.get("container")&&(this.get("container").style.opacity=t)},SVGMarker.prototype.hide=function(){this.get("container")&&(this.get("container").style.visibility="hidden")},SVGMarker.prototype.show=function(){this.get("container")&&(this.get("container").style.visibility="visible")},SVGMarker.prototype.toggle=function(){this.get("container")&&("hidden"===this.get("container").style.visibility?this.show():this.hide())},SVGMarker.prototype.getPosition=function(){return this.get("position")},SVGMarker.prototype.toggleDOM=function(){this.getMap()?this.setMap(null):this.setMap(this.get("map"))}; /////svg marker var gmap_styles = [ { "featureType": "landscape", "elementType": "geometry.fill", "stylers": [ { "color": "#f0efe0" } ] }, { "featureType": "landscape.natural", "elementType": "geometry.fill", "stylers": [ { "color": "#e9e8d9" } ] }, { "featureType": "landscape.natural.terrain", "elementType": "geometry.fill", "stylers": [ { "color": "#dbe6d3" } ] }, { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [ { "color": "#cbc5aa" } ] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [ { "color": "#e9ddc6" } ] }, { "featureType": "water", "elementType": "geometry.fill", "stylers": [ { "color": "#b6c7da" } ] }, { "featureType": "poi", "stylers": [ { "visibility": "off" } ] } ]; $(document).ready(function(){ initMap(); $('.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'); console.log('marker click'); break; } } }); }); var businessLat = 31.046374055473596; var businessLng = -81.41999802313995; var bucketPath = 'https://s3.amazonaws.com/themooringsatjekyll'; var addBusinessMarker = true; var theMap, theMap2; var mapCenter = new google.maps.LatLng(31.046374055473596, -81.41999802313995); var mapZoomStart = 15; var zLevelHide = 6; var markersArr = []; var otherMarker = { url: '/themes/moorings/modules/map/markers/map-pin-03.svg', size: new google.maps.Size(40, 40), origin: new google.maps.Point(0, 0), anchor: new google.maps.Point(30, 40) //,scaledSize: new google.maps.Size(30, 30) }; var mapOptions = { zoom: mapZoomStart, center: mapCenter, styles: gmap_styles, scrollwheel: false, mapTypeControl: true, streetViewControl: false }; var infowindow; function initMap() { theMap = new google.maps.Map(document.getElementById('map_canvas_full'), mapOptions); offsetMapCenter(theMap); // add business marker if (typeof markerData !== 'undefined') { addMarkers(markerData); } else { var loadedmarker = new SVGMarker({ map: theMap, position: mapCenter, icon: otherMarker, // custom marker info markerID : 'bizMarker', markerHeadline : 'The Moorings at Jekyll Island', //markerSubhead : '', markerText : '


Jekyll Island, GA

', //image : image1, hasImage : false }); google.maps.event.addListener(loadedmarker, 'click', markerInfoWindow); } var contentString = "

The Moorings at Jekyll Island


Jekyll Island, GA

" infowindow = new google.maps.InfoWindow({ content: contentString, maxWidth: 230, pixelOffset: new google.maps.Size(-10, -10) }); // event listeners theMap.addListener('zoom_changed', function(e) { showHideLabelsOnZoom(e); offsetMapCenter(theMap); }); showHideLabelsOnZoom(); }; // initMap function offsetMapCenter(map){ if ( $(window).width() > 992 ) { var offsetXnew = -(window.innerWidth / 3); map.setCenter(mapCenter); map.panBy(offsetXnew,0); } else { var offsetYnew = 0; map.setCenter(mapCenter); map.panBy(0,offsetYnew); } }; $( window ).resize(function() { offsetMapCenter(theMap); }); function addMarkers(markerData) { var markerTitle; 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.INTRO_TEXT[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 SVGMarker({ map: theMap, position: newLatLng, icon: otherMarker, // custom marker info markerID : markerID, markerHeadline : markerHeadline, markerSubhead : markerSubhead, markerText : marker_text, image : image1, hasImage : hasImage }); console.log(loadedmarker); markersArr.push(loadedmarker); google.maps.event.addListener(loadedmarker, 'click', markerInfoWindow); }//end for loop }//end addMarkers function markerInfoWindow(event) { console.log(this.image); if ( this.hasImage == false ) { var contentString = '
' + this.markerHeadline + '

' + this.markerText + '

'; } else { var contentString = '
' + this.markerHeadline + '

' + this.markerText + '

' + '

' + '
' + '
'; } infowindow.setContent(contentString); infowindow.open(theMap,this); //theMap.setZoom(14); theMap.setCenter(this.getPosition()); theMap.panBy(0,-100); console.log(theMap.getZoom()); offsetMapCenter(theMap); } function T2HInfoWindow(event) { console.log(this.image); if ( this.hasImage == false ) { var contentString = '

' + this.markerHeadline + '

' + this.markerText + '

' + '

'; } else { var contentString = '

' + this.markerHeadline + '

' + this.markerText + '

' + '

' + '
' + '
'; } infowindow.setContent(contentString); infowindow.open(theMap,this); theMap.setZoom(16); theMap.setCenter(this.getPosition()); theMap.panBy(0,-100); } // 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 //////////////// markers //////////////// /////////////// end markers ///////////////