This code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Google Map API Demo</title> <style> body { font-family: Arial, Helvetica, sans-serif; margin: 6px; height: 100%; padding: 0; } html { height: 100%; } a, a:link, a:visited, a:hover, a:active { text-decoration: underline; cursor: pointer; color: #000; } a:hover { text-decoration: none; cursor: pointer; color: #555; } .Shadow { box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.4); } </style> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBs55G3yMieFPKlyyQS8OxzYc0WAzg_76Y&sensor=false"></script> <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.min.js"></script> <script type="text/javascript"> var GoogleMap = null, GoogleInfoBubble = null, GoogleMarkers = new Array; function PlotAddress(StreetAddress) { var Position = null; var geocoder = new google.maps.Geocoder(); geocoder.geocode({ 'address': StreetAddress }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { Position = results[0].geometry.location; var marker = new google.maps.Marker({ position: Position, map: GoogleMap, animation: google.maps.Animation.DROP }); marker.hidden = false; var ID = GoogleMarkers.push(marker) - 1; google.maps.event.addListener(marker, 'click', function() { var Content = '<table><tr><td nowrap="true">'; Content += StreetAddress; Content += "<div align='center'><a onclick='TogglePin(GoogleMarkers["+ ID +"]);'>Hide Pin</a></div>"; Content += '</td></tr></table>'; GoogleInfoBubble.setContent(Content); GoogleInfoBubble.open(GoogleMap, marker); }); jQuery('#AddedPins').append("<a onclick='TogglePin(GoogleMarkers["+ ID +"]);'>Toggle Pin "+ ID +"</a>, "); } }); } function TogglePin(Pin) { if(Pin.hidden) { Pin.setMap(GoogleMap); Pin.hidden = false; } else { Pin.setMap(null); Pin.hidden = true; } } function ShowHideAll(Which) { for (i in GoogleMarkers) { GoogleMarkers[i].setMap((Which == 'hide' ? null : GoogleMap)); GoogleMarkers[i].hidden = (Which == 'hide' ? true : false); } } /* * This function will either add a single button with the nice * Google drop shadow, or load up an entire <div> into the * Google UI. If you choose to load an entire <div> this function * will replace any %ID% with the word "GoogleMap", this is done * to prevent ID tag collision and keep the ID tags unique. * */ function AddMapUI(Options, OnClick) { if(typeof(OnClick) != "function") OnClick = null; // Making sure OnClick is a function. var MapUI = document.createElement('div'); MapUI.style.padding = (Options.OutsidePadding ? Options.OutsidePadding : '6px 0px'); // Defaults to 6px top & bottom, 0px left & right // Adding the Google Shadow to our UI elements. var controlUI = document.createElement('div'); controlUI.className = 'Shadow'; // Included in style sheet. controlUI.style.background = '#FFF'; controlUI.style.borderStyle = 'solid'; controlUI.style.borderWidth = '1px'; controlUI.style.borderColor = 'rgb(113, 123, 135)'; if(OnClick != null) controlUI.style.cursor = 'pointer'; if(Options.Center != null) controlUI.style.textAlign = 'center'; if(Options.Title != null) controlUI.title = Options.Title; MapUI.appendChild(controlUI); // Set CSS for the control interior. var controlText = document.createElement('div'); controlText.style.padding = (Options.InsidePadding ? Options.InsidePadding : '3px 4px'); // Defaults to 3px top & bottom, 4px left & right controlText.innerHTML = (Options.Text ? Options.Text : (Options.DivID ? jQuery('#'+ Options.DivID).html().replace(/%ID%/g,'GoogleMap') : 'Unknown' )); controlUI.appendChild(controlText); // Setup the click event listeners if(OnClick != null){ google.maps.event.addDomListener(controlUI, 'click', function() { OnClick(); }); } var Where = ( Options.Where == 'TopRight' ? google.maps.ControlPosition.RIGHT_TOP : ( Options.Where == 'BottomRight' ? google.maps.ControlPosition.RIGHT_BOTTOM : ( Options.Where == 'MiddleRight' ? google.maps.ControlPosition.RIGHT_CENTER : google.maps.ControlPosition.TOP_CENTER ))); GoogleMap.controls[Where].push(MapUI); } jQuery('document').ready(function() { var mapOptions = { mapTypeControl: false, center: new google.maps.LatLng('44.208788', '-73.079395'), zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP }; GoogleMap = new google.maps.Map(document.getElementById("google_map_canvas"), mapOptions); // Setting this up to use with our markers. GoogleInfoBubble = new google.maps.InfoWindow(); GoogleInfoBubble.Open = false; }); </script> </head> <body> <div id="GoogleMapsMenu" style="display: none;"> <strong>My Custom Menu:</strong><br /><br /> <a OnClick="ShowHideAll('show');">Show Pins</a><br /> <a OnClick="ShowHideAll('hide');">Hide Pins</a><br /> <br /> <div align="center">Map powered by:<br />Google and Adam!</div> </div> <div id="menu_header" style="width:800px; background-color:#CCC; padding:5px 0;" align="center"> <input id="Address" size="40" type="text" value="Starbucks, 10 Hawthorne Street, Williston, VT 05495" /><input OnClick="PlotAddress(jQuery('#Address').val());" value="Plot" type="button" />, <a OnClick="AddMapUI({DivID: 'GoogleMapsMenu', Where: 'BottomRight'});">Add Full Menu UI</a>, <a href="/tutorials/google-maps/#demos">Return</a> </div> <div id="google_map_canvas_parent" style="width:800px; height:600px;"><div id="google_map_canvas" style="width:100%; height:100%;"></div></div> <div id="AddedPins" style="width:800px;"></div> </body> </html>