ClickCease /*<![CDATA[*/ var markers = []; // Array where to store the markers var openInfoWindow; // Variable to hold the open info window so we never have more that one open function bindInfoWindow(marker, map, infoWindow, content) { google.maps.event.addListener(marker, 'click', function() { if(openInfoWindow) { // Check if an info window is already open openInfoWindow.close(); // Close the existing info window } infoWindow.setContent(content); // Set the content of the info window //map.panTo(marker.getPosition()); infoWindow.open(map, marker); // Open the info window for this marker openInfoWindow = infoWindow; // Set the openInfoWindow to this marker's info window }); /* google.maps.event.addListener(marker, 'mouseover', function() { if(openInfoWindow) { // Check if an info window is already open openInfoWindow.close(); // Close the existing info window } infoWindow.setContent(content); // Set the content of the info window infoWindow.open(map, marker); // Open the info window for this marker openInfoWindow = infoWindow; // Set the openInfoWindow to this marker's info window }); google.maps.event.addListener(marker, 'mouseout', function() { openInfoWindow.close(); // Close the existing info window }); */ } function openMarker(id){ google.maps.event.trigger(markers[id], 'click'); } function initialize() { var officeLocationMap; // Set a variable for the map // Setup the map options var mapOptions = { center : new google.maps.LatLng(44.0378939,-92.4605057), zoom : 14, scrollwheel: false, draggable: false, mapTypeId : google.maps.MapTypeId.ROADMAP }; // Create the map var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); // Locations - This is an array of objects that contain the data used to generate the markers and the infoWindows var locations = [ { name: "", lat: 44.0378939, lng: -92.4605057, phone: '800-551-3292', local: '507-424-3700', fax: '320-252-0971', address: { addr1: '1500 1st Ave NE, Suite 111-B', addr2: null, city: 'Rochester', state: 'MN', zip: '55906' } } ]; // Loop through each location for (var i=0; i<locations.length; i++) { // Get the current location from the array var loc = locations[i]; // Create the location var latLng = new google.maps.LatLng(loc.lat, loc.lng); // Create the marker var marker = new google.maps.Marker({ position: latLng, map: map, title: loc.name, //icon: markerIcon }); // Push the marker to the 'markers' array markers.push(marker); var lnkPhone = ''; // Create the html for this marker's info window var html = '

'+loc.name+'

'; if(loc.phone) { lnkPhone = loc.phone; html += 'Toll Free: '+loc.phone+''; } if(loc.local) { lnkPhone = loc.local; html += 'Local: '+loc.local+''; } if(loc.fax) { html += 'Fax: '+loc.fax+''; } html += '
'; html += '

Address:

'; html += ''+loc.address.addr1+''; if(loc.address.addr2) { html += ''+loc.address.addr2+''; } html += ''; html += ''+loc.address.city+''; html += ''+loc.address.state+''; html += ''+loc.address.zip+''; html += ''; html += '
'; html = '
'+html+'
'; // Create the info window for this marker var infoWindow = new google.maps.InfoWindow({content: html}); // Setup a listener to open the info window bindInfoWindow(marker, map, infoWindow, html); // Could also use a custom infoBox // http://stackoverflow.com/questions/7616666/google-maps-api-v3-custom-styles-for-infowindow/7628522#7628522 // Add location to map list var mapLink = ''+loc.name+''; jQuery('#map-list').append(mapLink); /*google.maps.event.addListener($('#mapLink'+i), 'click', function() { map.panTo(marker.getPosition()); infowindow.open(map,marker); });*/ /*$('#mapLink'+i).click(function(e) { e.preventDefault(); map.setCenter(marker.getPosition()); infoWindow.open(map,marker); return false; });*/ //bindMapLink($('#mapLink'+i), map, infoWindow, html); } google.maps.event.addListener(map, "click", function (event) { var latitude = event.latLng.lat(); var longitude = event.latLng.lng(); var center = map.getCenter(); console.log( 'click coords: ' + latitude + ', ' + longitude ); console.log( 'center coords: ' + center.lat() + ', ' + center.lng() ); }); var drawingManager = new google.maps.drawing.DrawingManager({ //drawingMode: google.maps.drawing.OverlayType.POLYGON, // Set default tool drawingControl: true, drawingControlOptions: { position: google.maps.ControlPosition.TOP_CENTER, drawingModes: [ //google.maps.drawing.OverlayType.MARKER, //google.maps.drawing.OverlayType.CIRCLE, google.maps.drawing.OverlayType.POLYGON, //google.maps.drawing.OverlayType.POLYLINE, //google.maps.drawing.OverlayType.RECTANGLE ] }, markerOptions: { icon: 'images/beachflag.png' }, circleOptions: { fillColor: '#ffff00', fillOpacity: 1, strokeWeight: 5, clickable: false, editable: true, zIndex: 1 }, polygonOptions: { editable: true, } }); drawingManager.setMap(map); google.maps.event.addListener(drawingManager, 'polygoncomplete', function (polygon) { google.maps.event.addListener(polygon, "click", function (event) { console.log('beerShape clicked'); var coordinates = (polygon.getPath().getArray()); jQuery('#map-coords').text(coordinates).fadeIn(); if ( polygon.getEditable() ) { console.log('disabling edit mode - beerShape'); polygon.setOptions({ editable:false, zIndex:1, fillOpacity:0.35 }); jQuery('#map-coords').text(coordinates).fadeIn(); } else { console.log('enabeling edit mode - beerShape'); polygon.setOptions({ editable:true, zIndex:1, fillOpacity:0.65 }); jQuery('#map-coords').text(coordinates).fadeOut(); } }); }); } google.maps.event.addDomListener(window, 'load', initialize); /*]]>*/
Free Bankruptcy Consultation