Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • jQuery Tutorial
  • jQuery Selectors
  • jQuery Events
  • jQuery Effects
  • jQuery Traversing
  • jQuery HTML & CSS
  • jQuery AJAX
  • jQuery Properties
  • jQuery Examples
  • jQuery Interview Questions
  • jQuery Plugins
  • jQuery Cheat Sheet
  • jQuery UI
  • jQuery Mobile
  • jQWidgets
  • Easy UI
  • Web Technology
Open In App
Next Article:
How to create a news ticker using jQuery ?
Next article icon

How to create a simple map using jQuery ?

Last Updated : 06 Jul, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

jQuery is an open-source JavaScript library that simplifies the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM), and JavaScript.

What are Google Maps?

Google Map is a free web-based mapping service application and technology provided by Google. The application provides comprehensive information about geographical regions, street maps, and the route planner for traveling by car, foot, or public transportation Satellite views of the countries around the globe.

HTML Google Map can be used to display the maps on webpage. One can simply add a map  HTML page.

Syntax:

<!DOCTYPE html> <html>  <body>     <h1Map Example</h1>     <div id="map">Enter text</div> </body>

Set the Map Size

Syntax:

<div id="map"       style="width:400px;height:400px;background:grey"> </div>

Create a function to set the map properties

The map properties can be set by creating a function. We have to use the functionalities of Google Maps API provided by a JavaScript library located at Google.

<script src= "https://maps.googleapis.com/maps/api/js?callback=myMap"> </script>

Create A Map

  • In the above example, we will use Google API to load google map.
<script src = "https://maps.googleapis.com/maps/api/js"></script>
  • Following are the steps required to get an API key:
    • Go to the below-mentioned link https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,places_backend&reusekey=true
    • Create a new project or select from your existing projects.
    • Click Continue to enable the API.
    • On the Credentials page, get an API key (and set the API key restrictions).
    • Replace the value of the key parameter in the URL with your own API key
  • To customize the maps:
let CustomOp = {     center: new google.maps.LatLng(28.502212, 77.405603),     zoom: 17,     mapTypeId: google.maps.MapTypeId.ROADMAP };
  • In this case, CustomOp is an object that contains 3 options, centre, zoom, and maptypeid.
    • centre: This property is used to set the specific point in maps.
    • zoom: This property is used to specify the zoom level on a specific point.
    • maptypeid: This property is used to specify the type of map. (ROADMAP, SATELLITE, HYBRID, TERRAIN)

To customize the Google map, there are four types of maps provided.

  • ROADMAP: This type of map shows the street view of a specific area. It is the default type of map.
  • SATELLITE: This type of map shows satellite images of a specific area.
  • HYBRID: This type of map shows the major streets of the specific area.
  • TERRAIN: This type of map shows the terrain and vegetation.

Example 1: ROADMAP 

html
<!DOCTYPE html> <html>  <head>     <title>         Google Maps | Types     </title>      <!-- Add Google map API source -->     <script src= "https://maps.googleapis.com/maps/api/js">     </script>      <script>         function GFG() {             let CustomOp = {                 center: new google.maps.LatLng(                     28.502212, 77.405603),                 zoom: 17,                 mapTypeId: google.maps.MapTypeId.ROADMAP             };              // Map object             let map = new google.maps.Map(                 document.getElementById("DivID"),                 CustomOp             );         }     </script> </head>  <!-- Function that execute when page load -->  <body onload="GFG()">     <center>         <h1 style="color:green">             GeeksforGeeks         </h1>          <h3>Google Maps</h3>          <!-- Basic Container -->         <div id="DivID"               style="width:400px; height:300px;">         </div>     </center> </body>  </html> 

Output: 

 

Example 2: SATELLITE 

html
<!DOCTYPE html> <html>  <head>     <title>         Google Maps | Types     </title>      <!-- Add Google map API source -->     <script src= "https://maps.googleapis.com/maps/api/js">     </script>      <script>         function GFG() {             let CustomOp = {                 center: new google.maps.LatLng(                     28.502212, 77.405603),                 zoom: 17,                 mapTypeId: google.maps.MapTypeId.SATELLITE             };              // Map object             let map = new google.maps.Map(                 document.getElementById("DivID"),                 CustomOp             );         }     </script> </head>  <!-- Function that execute when page load -->  <body onload="GFG()">     <center>         <h1 style="color:green">             GeeksforGeeks         </h1>          <h3>Google Maps</h3>          <!-- Basic Container -->         <div id="DivID"               style="width:400px; height:300px;">         </div>     </center> </body>  </html> 

Output:

  

Example 3: HYBRID 

html
<!DOCTYPE html> <html>  <head>     <title>         Google Maps | Types     </title>      <!-- Add Google map API source -->     <script src= "https://maps.googleapis.com/maps/api/js">     </script>      <script>         function GFG() {             let CustomOp = {                 center: new google.maps.LatLng(                     28.502212, 77.405603),                 zoom: 17,                 mapTypeId: google.maps.MapTypeId.HYBRID             };              // Map object             let map = new google.maps.Map(                 document.getElementById("DivID"),                 CustomOp             );         }     </script> </head>  <!-- Function that execute when page load -->  <body onload="GFG()">     <center>         <h1 style="color:green">             GeeksforGeeks         </h1>          <h3>Google Maps</h3>          <!-- Basic Container -->         <div id="DivID"               style="width:400px; height:300px;">         </div>     </center> </body>  </html> 

Output:

  

Example 4: TERRAIN 

html
<!DOCTYPE html> <html>  <head>     <title>         Google Maps | Types     </title>      <!-- Add Google map API source -->     <script src= "https://maps.googleapis.com/maps/api/js">     </script>      <script>         function GFG() {             let CustomOp = {                 center: new google.maps.LatLng(                     28.502212, 77.405603),                 zoom: 17,                 mapTypeId: google.maps.MapTypeId.TERRAIN             };              // Map object             let map = new google.maps.Map(                 document.getElementById("DivID"),                 CustomOp             );         }     </script> </head>  <!-- Function that execute when page load -->  <body onload="GFG()">     <center>         <h1 style="color:green">             GeeksforGeeks         </h1>          <h3>Google Maps</h3>          <!-- Basic Container -->         <div id="DivID"               style="width:400px; height:300px;">         </div>     </center> </body>  </html> 

Output:

 


Next Article
How to create a news ticker using jQuery ?

S

sharmaanushka
Improve
Article Tags :
  • Web Technologies
  • HTML
  • JQuery
  • HTML-Misc
  • jQuery-Misc

Similar Reads

  • How to create a news ticker using jQuery ?
    A news ticker is a text-based display either in the form of a graphic that displays news scrolling text running from up to down or right to left. In this article, we will use a jQuery plugin called easy-ticker to create a news ticker in a simple manner. To use this plugin, simply add the CDN link in
    3 min read
  • How to create a Grid icon using jQuery Mobile ?
    jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. In this article, we will be making a Grid icon using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel="stylesheet" hr
    1 min read
  • How to create a Search Input using jQuery Mobile ?
    jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be creating a search input using jQuery Mobile. Approach: First, we add the jQuery Mobile scripts needed for the project. <link rel=”styl
    1 min read
  • Create a Tic-Tac-Toe Game using jQuery
    In this post, we are going to implement 2-player tic-tac-toe using jQuery. It is quite easy to develop with some simple validations and error checks. Player-1 starts playing the game and both the players make their moves in consecutive turns. The player who makes a straight 3-block chain wins the ga
    5 min read
  • How to create Left arrow icon using jQuery Mobile ?
    jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. In this article, we will be making a left arrow icon using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel=”styleshe
    1 min read
  • How to make a JSON call using jQuery ?
    Use the getJSON() function in jQuery to load JSON data. The getJSON() function uses a GET HTTP request to retrieve JSON-encoded data from the server. In this article, we will learn about the jQuery getJSON() function and its implementation through examples. Syntax: $(selector).getJSON(url, data, suc
    3 min read
  • How to create Right arrow icon using jQuery Mobile ?
    jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be making Right arrow icon using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel="stylesheet
    1 min read
  • How to Create a Custom Image Magnifier using jQuery ?
    Glimpse of Image magnifier: An image magnifier is the zooming capability of your cursor point. Where you placed your cursor in the define div the image will be popped out in zoom mode. Like in the shopping sites, when you want to purchase any kind of cloth and want to check the material or print on
    4 min read
  • How to create a Mini sized selects using jQuery Mobile ?
    jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. In this article, we will be creating a Mini sized selects using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel="sty
    1 min read
  • How to create lists and links using jQuery EasyUI Mobile ?
    In this article we will learn how to design lists, group them and create links for easy navigation using jQuery EasyUI Mobile. EasyUI is a HTML5 framework for using user interface components based on jQuery, React, Angular and Vue technologies. It helps in building features for interactive web and m
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences