Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<nav id="navbar"> 
  <header id="header">Google Maps Documentation</header>
  <ul class="left-nav">
<li><a class="nav-link" href="#Google_Maps_Home">Google Maps Home</a></li>
  <li><a class="nav-link" href="#Getting_Started">Getting Started</a></li>
  <li><a class="nav-link" href="#Types">Types</a></li>
     <li><a class="nav-link" href="#Zoom">Zoom</a></li>
  <li><a class="nav-link" href="#Localization">Localization</a></li>
  <li><a class="nav-link" href="#UI_Controls">UI Controls</a></li>
     <li><a class="nav-link" href="#Markers">Markers</a></li>
  <li><a class="nav-link" href="#Shapes">Shapes</a></li>
  <li><a class="nav-link" href="#Info_Window">Info Window</a></li>
     <li><a class="nav-link" href="#Symbols">Symbols</a></li>
  <li><a class="nav-link" href="#Events">Events</a></li>
     <li><a class="nav-link" href="#Resources">Resources</a></li>
</ul>
</nav>
  
 <main id="main-doc">
<div id="div-main">
  <section class="main-section" id="Google_Maps_Home">
    <header>Google Maps Home</header>
    <p>Google Maps is a free web mapping service by Google that provides various types of geographical information. Google Maps has a JavaScript API to customize the maps and display them on your webpage. This tutorial is about Google Maps API (Application Programming Interface). It explains how you can integrate Google Maps on your webpage.</p>
    <p>This tutorial is meant for all those readers who would like to learn about Google Maps API. After completing this tutorial, you would be able to integrate Google Maps JavaScript API on your webpage.</p>
    <p>Before proceeding with this tutorial, you should be familiar with JavaScript and the concepts of object-oriented programming. You should also be familiar with Google Maps from a user's point of view.</p>
  </section>
  
    <section class="main-section" id="Getting_Started"><header>Getting Started</header>
      <p>Google Maps is a free web mapping service by Google that provides various types of geographical information. Using Google Maps, one can.</p><ul><li>
      Search for places or get directions from one place to another.</li>
<li>View and navigate through horizontal and vertical panoramic street level images of various cities around the world.</li>
      <li>Get specific information like traffic at a particular point.</li></ul>
<p>Google Maps provides an API using which you can customize the maps and the information displayed on them. This chapter explains how to load a simple Google Map on your web page using HTML and JavaScript.</P>
  <p><strong>Steps to Load the Map on a Webpage</strong></p><p>Follow the steps given below to load a map on your webpage.</p><ol><li>Create an HTML Page-create a basic HTML page with head and body tags.</li>
  <li>Load the API-load or include the Google Maps API using the script tag.</li>
  <li>Create the Container-create a container element using div tag.</li>
  <li>Map Options-create a mapOptions object and set values for map initialization variables which has three main options, namely, centre, zoom, and maptypeid.</li>
    <code>function loadMap() {
   var mapOptions = {
      center:new google.maps.LatLng(17.240498, 82.287598), 
      zoom:9, 
      mapTypeId:google.maps.MapTypeId.ROADMAP
   };
    }</code>
    <li>Create a Map Object-create a map by instantiating the JavaScript class called Map.</li><code>var map = new google.maps.Map(document.getElementById("sample"),mapOptions);</code>
  <li>Load the map-load the map by calling the loadMap() method or by adding DOM listener.</li><br><code>google.maps.event.addDomListener(window, 'load', loadMap);</code>
 </section>
  
    <section class="main-section" id="Types">
      <header>Types</header>
      <p>Google Maps provides four types of maps. They are</p><ul><li>ROADMAP − This is the default type. If you haven't chosen any of the types, this will be displayed. It shows the street view of the selected region.</li>
      <li>SATELLITE − This is the map type that shows the satellite images of the selected region.</li>
      <li>HYBRID − This map type shows the major streets on satellite images.</li>
      <li>TERRAIN − This is the map type that shows the terrain and vegetation.</li></ul><p><strong>Syntax</strong></p><code>var mapOptions = {
   mapTypeId:google.maps.MapTypeId.Id of the required map type
      };</code></section>
  
  <section class="main-section" id="Zoom"><header>Zoom</header>
    <p>You can increase or decrease the zoom value of a map by modifying the value of the zoom attribute in the the map options.</p>
    <p><strong>Syntax</strong></p>
<p>We can increase or decrease the zoom value of the map using the zoom option. Given below is the syntax to change the zoom value of the map.</p>
    <code>var mapOptions = {
  zoom:required zoom value
};</code></section>
    
  <section class="main-section" id="Localization"><header>Localization</header><p>By default, the city names and option names given on the map will be in English. If required, we can display such information in other languages as well. This process is known as localization.</p><p><strong>Localizing a Map</strong></p><p>
You can customize (localize) the language of the map by specifying the language option in the URL as shown below.</p>
    </p>"https://maps.googleapis.com/maps/api/js?language=zh-Hans"</p></section>
  
    <section class="main-section" id="UI_Controls"><header>UI Controls</header><p>Google Maps provides a User Interface with various controls to let the user interact with the map. We can add, customize, and disable these controls.</p>
      <p><strong>Default Controls</strong></p>
      <p>Here is a list of the default controls provided by Google Maps.</p><ul><li>
Zoom − To increase and decease the zoom level of the map, we will have a slider with + and − buttons, by default. This slider will be located at the corner of left hand side of the map.</li>
      <li>Pan − Just above the zoom slider, there will be a pan control for panning the map.</li>
<li>Map Type − You can locate this control at the top right corner of the map. It provides map type options such as Satellite, Roadmap, and Terrain. Users can choose any of these maps.</li>
<li>Street view − Between the pan icon and the zoom slider, we have a pegman icon. Users can drag this icon and place at a particular location to get its street view.</li></ul><p>We can disable the default UI controls provided by Google Maps simply by making the disableDefaultUI value true in the map options.</p><p>In addition to these default controls, Google Maps also provides three more controls as listed below.</p><ul><li>
      Scale − The Scale control displays a map scale element. This control is not enabled by default.</li>
<li>Rotate − The Rotate control contains a small circular icon which allows you to rotate maps containing oblique imagery. This control appears by default at the top left corner of the map.</li>
<li>Overview − To increase and decease the zoom level of the map, we have a slider with + and − buttons, by default. This slider is located at the left corner of the map.</li></ul><p>We can change the appearance of Google Maps controls using its control options. For example, the zoom control can be either reduced or enlarged in size. The MapType control appearance can be varied to a horizontal bar or a drop-down menu.</p></section>
  
    <section class="main-section" id="Markers"><header>Markers</header><p>We can draw objects on the map and bind them to a desired latitude and longitude. These are called overlays. Google Maps provides various overlays as shown below.</p><ul><li>Markers</li>
<li>Polylines</li>
      <li>Polygons</li>
      <li>Circle and rectangle</li>
      <li>Info window</li>
      <li>Symbols</li></ul>
<p>To mark a single location on the map, Google Maps provides markers. These markers use a standard symbol and these symbols can be customized. We can customize, animate, and remove markers.</p><p>You can add a simple marker to the map at a desired location by instantiating the marker class and specifying the position to be marked using latlng.After adding a marker to the map, you can go further and add animations to it such as bounce and drop.</p><p>You can use your own icons instead of the default icon provided by Google Maps. Just set the icon as icon:'ICON PATH'. And you can make this icon draggable by setting draggable:true.</p><p>You can remove an existing marker by setting up the marker to null using the marker.setMap() method.</p></section>
  
    <section class="main-section" id="Shapes"><header>Shapes</header><p>Along with markers, we can also add various shapes such as circles, polygons, rectangles, polylines, etc.</p>
      <p><strong>Polylines</strong></p><p>Polylines, provided by Google Maps, are useful to track different paths. You can add polylines to a map by instantiating the class google.maps.Polyline. While instantiating this class, we have to specify the required values of the properties of a polyline such as StrokeColor, StokeOpacity, and strokeWeight.

We can add a polyline to a map by passing its object to the method setMap(MapObject). We can delete the polyline by passing a null value to the SetMap() method.</p>
      <p><strong>Polygons</strong></p><p>Polygons are used to highlight a particular geographical area of a state or a country. You can create a desired polygon by instantiating the class google.maps.Polygon. While instantiating, we have to specify the desired values to the properties of Polygon such as path, strokeColor, strokeOapacity, fillColor, fillOapacity, etc.</p>
  <p><strong>Rectangles</strong></p> <p>We can use rectangles to highlight the geographical area of a particular region or a state using a rectangular box. We can have a rectangle on a map by instantiating the class google.maps.Rectangle. While instantiating, we have to specify the desired values to the properties of the rectangle such as path, strokeColor, strokeOapacity, fillColor, fillOapacity, strokeWeight, bounds, etc.</p>
      <p><strong>Circles</strong></p> <p>Just as rectangles, we can use Circles to highlight the geographical area of a particular region or a state using a circle by instantiating the class google.maps.Circle. While instantiating, we have to specify the desired values to the properties of the circle such as path, strokeColor, strokeOapacity, fillColor, fillOapacity, strokeWeight, radius, etc.</p>
</section>
  
    <section class="main-section" id="Info_Window"><header>Info Window</header><p>Info Window is used to add any kind of information to the map. For instance, if you want to provide information about a location on the map, you can use an info window. Usually the info window is attached to a marker. You can attach an info window by instantiating the google.maps.InfoWindow class. It has the following properties.</p><ul><li>
      Content − You can pass your content in String format using this option.</li>
      <li>position − You can choose the position of the info window using this option.</li>
<li>maxWidth − By default, the info window's width will be stretched till the text is wrapped. By specifying maxWidth, we can restrict the size of the info window horizontally.</li></ul></section>
  
  <section class="main-section" id="Symbols"><header>Symbols</header><p>Google provides various vector-based images (symbols) that can be used on a marker or a polyline. Just like other overlays, to draw these predefined symbols on a map, we have to instantiate their respective classes. Given below is a list of predefined symbols provided by Google and their class names.</p><ul><li>Circle − google.maps.SymbolPath.CIRCLE</li>
    <li>Backward Pointing arrow (closed) − google.maps.SymbolPath.BACKWARD_CLOSED_ARROW</li>
    <li>Forward Pointing arrow (closed) − google.maps.SymbolPath.FORWARD_CLOSED_ARROW</li>
    <li>Forward Pointing arrow (open) − google.maps.SymbolPath.CIRCLE</li>
    <li>Backward Pointing arrow (open) − google.maps.SymbolPath.CIRCLE</li></ul>
<p>These symbols have the following properties − path, fillColor, fillOpacity, scale, stokeColor, strokeOpacity, and strokeWeight.</p><p>Just like markers, you can add animations such as bounce and drop to the symbols.</p></section>
  
<section class="main-section" id="Events"><header>Events</header><p><strong>Adding an Event Listener</strong></p><p>You can add an event listener using the method addListener(). It accepts parameters such as object name on which we want to add the listener, name of the event, and the handler event.</p><p><strong>Removing the Listener</strong></p><p>You can remove an existing listener using the method removeListener(). This method accepts the listener object, therefore we have to assign the listener to a variable and pass it to this method.</p></section>
  
<section class="main-section" id="Resources"><header>Resources</header><p>The following resources contain additional information on Google Maps. Please use them to get more in-depth knowledge on this topic.</p><p>Useful Links on Google Maps</p><ul><li><a href="https://en.wikipedia.org/wiki/Google_Maps">Google Maps - Quick Guide</a></li>
<li><a href="https://www.google.co.in/maps/@3.2046688,75.6007497,3z?hl=en">Google Maps - Useful Resources</a></li>
</li>
</ul></section>
 </div>

 </main>
              
            
!

CSS

              
                
body {
    margin:0;
  font-family:'Tahoma', Geneva, sans-serif;
}
#navbar {
    margin: 0;
    padding: 0;
    width: 25%;
    background-color: #f1f1f1;
    position: fixed;
    height: 100%;
    overflow: auto;
}
header{
  color:black;
  margin:10px;
  text-align:center;
  font-size:23px;
  font-weight:bold;
}
 #navbar ul{
    list-style-type: none;
     margin: 0;
    width: 200px;
}
#navbar li{
    display: block;
    padding:10px 16px;
    font-size:18px; 
}
#navbar a{
  text-decoration: none;
   color: black;
}
#navbar li a:hover {
    background-color: #555;
  color: white;
}
#main-doc{
  font-size:16px;
}
#main-doc header{
  text-align:left;
  margin:0px;
  padding:5px;
  font-size:20px;
}
#main-doc li{
  list-style-type: square;
}
code{
  display:block;
    text-align: left;
  white-space: pre;
  position: relative;
    word-break: normal;
    word-wrap: normal;
    line-height: 2;
    background-color: #f1f1f1;
  padding:15px;
  margin:10px;
 border-radius:5px;
}
 #div-main{
   margin-left:25%;
    padding:1px 16px;
    height:1000px;
  }

@media only screen and (max-width: 815px) {
  
  #navbar ul{
     list-style-type: none;
     margin: 0;
  }
    #navbar{
      background-color: #f1f1f1;
      position:absolute;
      top:0;
      padding:0;
      margin: 0;
      width:100%;
      max-height:275px;
      border:none;
      z-index:1;
      border-bottom:2px thin;
      text-align:center;
    }
  #main-doc{
    position: relative;
    margin-left:0px;
    margin-top:270px;
  }
}

@media only screen and (max-width: 400px) {
  #main-doc{
    text-align:left;
  }
  code{
    margin-left:-20px;
    width:100%;
    padding:15px;
    padding-left:10px;
    padding-right:25px;
    min-width:233px;
  } 
}
              
            
!

JS

              
                
              
            
!
999px

Console