SlideShare a Scribd company logo
1 of 15
ADDING A GOOGLE MAP
TO YOUR WEBSITE
By

Rajeev Ranjan


Adding a Google Map to your web page is very easy, once
you've been shown how! That's what we're going to do in
this lesson - we'll go over each step of creating a basic
Google Map using the JavaScript API.
WHAT YOU'LL NEED






You don't need much to create a Google Maps API
webpage:
A text editor. Windows machines generally include
Notepad; Mac OS X comes with TextEdit; Linux machines
come with a variety of applications, including gedit, vim, or
KWrite.
A web browser. We heart Google Chrome, but there are
many web browsers available for various platforms:
Firefox, Safari, and Internet Explorer are some of the bestknown options.
TRY IT OUT





The basic HTML page:Because everything on the web is made up of HTML, we'll
start there. The following code creates the simplest of web
pages:

None of this is specific to Google Maps - it's the basis for
any HTML page. Open your text editor and add this code,
then save the file to your desktop as google-maps.html (or
any other filename that ends with .html).


Your Google Map requires a page element in which to
appear; add a div tag to the body with an id attribute of
map canvas. This creates a container that we'll reference
later in the lesson.


Set the width and height of the div element using CSS. By
default, a div has a height of 0, meaning that any map you place
inside it won't be visible. Use a style tag in the head to set the
map to any size; in this case 500 pixels wide and 400 pixels high.





Load the HTML file in a web browser by dragging it from
your desktop into the address bar of your browser. You'll
notice that nothing is displayed - there's nothing in the div
yet. If you'd like to see the div on your page, add a
background-color CSS declaration to your existing <style>
tag:

Reloading the page will display a grey box; that's your div.
To bring forth a map, you must add two pieces of
JavaScript to your page. The first loads the Google Maps
JavaScript API; the second creates and configures the map.
LOADING THE API




Load the Google Maps API by adding a <script> tag to the <head>
section of your HTML. This script downloads the code required to
display maps on your page.

Notice that the URL contains a sensor parameter, which is set to false.
This example does not use any GPS device or sensor to detect the user's
location; if you're using any sort of geolocation in your application, this
must be changed to true
CREATE AND CONFIGURE THE MAP




The final piece of code is the JavaScript that creates the
map. The code contains a function to run once the page has
loaded. In this example, and all of the examples in the
Maps API documentation, this function is named initialize.

Add this code immediately after the <script> tag you
created in the last step.
THE GOOGLE.MAPS.MAP OBJECT






The first thing the initialize function needs to do is create a
new Google Maps object:

The Map object constructor takes two arguments:






center is a Google Maps LatLng object that tells the the API
where to center the map.
zoom is a number between 0 (farthest) and 22 that sets the
zoom level of the map.
mapTypeId is used to specify what type of map to use. Your
choices are ROADMAP, SATELLITE, HYBRID, or TERRAIN.
EXECUTING THE JAVASCRIPT FUNCTION


Add an event listener to the window object that will call the
initialize function once the page has loaded. Calling initialize
before the page has finished loading will cause problems,
since the div it's looking for may not have been created yet;
this function waits until the HTML elements on the page
have been created before calling initialize.
THE FINISHED CODE


This is the final code you've put together in this
lesson. It:



Creates a div, and gives it a size.



Loads the Google Maps JavaScript API v3.



Creates and displays a Google Map in the div.



Final Full code is in next slide….
Code to Add Google Map to Websites
Code to Add Google Map to Websites

More Related Content

What's hot

AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...
AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...
AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...Tracy Lee
 
Angular2 + Ng-Lightning + Lightning Design System = Great Apps
Angular2 + Ng-Lightning + Lightning Design System = Great AppsAngular2 + Ng-Lightning + Lightning Design System = Great Apps
Angular2 + Ng-Lightning + Lightning Design System = Great AppsEmily Hurn
 
Angular2 + New Firebase in Action
Angular2 + New Firebase in ActionAngular2 + New Firebase in Action
Angular2 + New Firebase in ActionRuben Chavarri
 
Build your first android mobile app
Build your first android mobile appBuild your first android mobile app
Build your first android mobile appekipaco
 
30 days GCP GDSC info session
30 days GCP GDSC info session30 days GCP GDSC info session
30 days GCP GDSC info sessionDomendra Sahu
 
Creating BananaJS with Angular 2, Angular CLI, and Material Design
Creating BananaJS with Angular 2, Angular CLI, and Material DesignCreating BananaJS with Angular 2, Angular CLI, and Material Design
Creating BananaJS with Angular 2, Angular CLI, and Material DesignTracy Lee
 
Réaliser un jeu cross plateformes avec WebGL et babylon.js
Réaliser un jeu cross plateformes avec WebGL et babylon.jsRéaliser un jeu cross plateformes avec WebGL et babylon.js
Réaliser un jeu cross plateformes avec WebGL et babylon.jsdavrous
 
Make your animations perform well - Anna Migas - Codemotion Rome 2017
Make your animations perform well - Anna Migas - Codemotion Rome 2017Make your animations perform well - Anna Migas - Codemotion Rome 2017
Make your animations perform well - Anna Migas - Codemotion Rome 2017Codemotion
 
Minko - Windows App Meetup Nov. 2013
Minko - Windows App Meetup Nov. 2013Minko - Windows App Meetup Nov. 2013
Minko - Windows App Meetup Nov. 2013Minko3D
 
Android App Development 20150409
Android App Development 20150409Android App Development 20150409
Android App Development 20150409Hideo Kadowaki
 
GAS Session
GAS SessionGAS Session
GAS SessionBVCOE
 
Optimizing and Deploying Angular
Optimizing and Deploying AngularOptimizing and Deploying Angular
Optimizing and Deploying AngularJohn Papa
 
Migrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityMigrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityDenis Radin
 
Mobile backends with Google Cloud Platform (MBLTDev'14)
Mobile backends with Google Cloud Platform (MBLTDev'14)Mobile backends with Google Cloud Platform (MBLTDev'14)
Mobile backends with Google Cloud Platform (MBLTDev'14)Natalia Efimtseva
 
Application Craft Tutorial for Google Map
Application Craft Tutorial for Google MapApplication Craft Tutorial for Google Map
Application Craft Tutorial for Google MapBarton Hammond
 
Real-time image sharing
Real-time image sharingReal-time image sharing
Real-time image sharingJerry Jalava
 

What's hot (20)

AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...
AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...
AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...
 
Angular2 + Ng-Lightning + Lightning Design System = Great Apps
Angular2 + Ng-Lightning + Lightning Design System = Great AppsAngular2 + Ng-Lightning + Lightning Design System = Great Apps
Angular2 + Ng-Lightning + Lightning Design System = Great Apps
 
Angular2 + New Firebase in Action
Angular2 + New Firebase in ActionAngular2 + New Firebase in Action
Angular2 + New Firebase in Action
 
Vue.js Component Tools
Vue.js Component ToolsVue.js Component Tools
Vue.js Component Tools
 
Build your first android mobile app
Build your first android mobile appBuild your first android mobile app
Build your first android mobile app
 
30 days GCP GDSC info session
30 days GCP GDSC info session30 days GCP GDSC info session
30 days GCP GDSC info session
 
Creating BananaJS with Angular 2, Angular CLI, and Material Design
Creating BananaJS with Angular 2, Angular CLI, and Material DesignCreating BananaJS with Angular 2, Angular CLI, and Material Design
Creating BananaJS with Angular 2, Angular CLI, and Material Design
 
Réaliser un jeu cross plateformes avec WebGL et babylon.js
Réaliser un jeu cross plateformes avec WebGL et babylon.jsRéaliser un jeu cross plateformes avec WebGL et babylon.js
Réaliser un jeu cross plateformes avec WebGL et babylon.js
 
Make your animations perform well - Anna Migas - Codemotion Rome 2017
Make your animations perform well - Anna Migas - Codemotion Rome 2017Make your animations perform well - Anna Migas - Codemotion Rome 2017
Make your animations perform well - Anna Migas - Codemotion Rome 2017
 
Minko - Windows App Meetup Nov. 2013
Minko - Windows App Meetup Nov. 2013Minko - Windows App Meetup Nov. 2013
Minko - Windows App Meetup Nov. 2013
 
Android App Development 20150409
Android App Development 20150409Android App Development 20150409
Android App Development 20150409
 
GAS Session
GAS SessionGAS Session
GAS Session
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
App script
App scriptApp script
App script
 
Optimizing and Deploying Angular
Optimizing and Deploying AngularOptimizing and Deploying Angular
Optimizing and Deploying Angular
 
Migrating your Web app to Virtual Reality
Migrating your Web app to Virtual RealityMigrating your Web app to Virtual Reality
Migrating your Web app to Virtual Reality
 
Mobile backends with Google Cloud Platform (MBLTDev'14)
Mobile backends with Google Cloud Platform (MBLTDev'14)Mobile backends with Google Cloud Platform (MBLTDev'14)
Mobile backends with Google Cloud Platform (MBLTDev'14)
 
Web Os Hands On
Web Os Hands OnWeb Os Hands On
Web Os Hands On
 
Application Craft Tutorial for Google Map
Application Craft Tutorial for Google MapApplication Craft Tutorial for Google Map
Application Craft Tutorial for Google Map
 
Real-time image sharing
Real-time image sharingReal-time image sharing
Real-time image sharing
 

Viewers also liked

Um residencial com plantas espaçosas, acabamento Vip e localização nobre.
Um residencial com plantas espaçosas, acabamento Vip e localização nobre.Um residencial com plantas espaçosas, acabamento Vip e localização nobre.
Um residencial com plantas espaçosas, acabamento Vip e localização nobre.Marcelo Maia
 
Actitud de las autoridades educativas privadas en el uso de plataforma web
Actitud de las autoridades educativas privadas en el uso de plataforma webActitud de las autoridades educativas privadas en el uso de plataforma web
Actitud de las autoridades educativas privadas en el uso de plataforma webJuan Hernandez
 
Android Application on Location sharing and message sender
Android Application on Location sharing and message senderAndroid Application on Location sharing and message sender
Android Application on Location sharing and message senderKavita Sharma
 
Must Know Google Map Features for your Web application
Must Know Google Map Features  for your Web applicationMust Know Google Map Features  for your Web application
Must Know Google Map Features for your Web applicationAppsbee
 
CATALÀ - Llinatges mapa activitat
CATALÀ  - Llinatges mapa activitatCATALÀ  - Llinatges mapa activitat
CATALÀ - Llinatges mapa activitatjoanpol
 
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...Bala Subra
 
Android MapView and MapActivity
Android MapView and MapActivityAndroid MapView and MapActivity
Android MapView and MapActivityAhsanul Karim
 
Location sharing and automatic message sender Android Application
Location sharing and automatic message sender Android ApplicationLocation sharing and automatic message sender Android Application
Location sharing and automatic message sender Android ApplicationKavita Sharma
 
Los derechos de la mujer dominicana
Los derechos de la mujer dominicanaLos derechos de la mujer dominicana
Los derechos de la mujer dominicanamichell pozo
 
Google Maps API for Android
Google Maps API for AndroidGoogle Maps API for Android
Google Maps API for AndroidMaksim Golivkin
 
Vehicle tracking system using gps and google map
Vehicle tracking system using gps and google mapVehicle tracking system using gps and google map
Vehicle tracking system using gps and google mapsanchit bhargava
 
Final year project presentation in android application
Final year project presentation in android applicationFinal year project presentation in android application
Final year project presentation in android applicationChirag Thaker
 
Presentation on Android application
Presentation on Android applicationPresentation on Android application
Presentation on Android applicationAtibur Rahman
 
Android Project Presentation
Android Project PresentationAndroid Project Presentation
Android Project PresentationLaxmi Kant Yadav
 
Mobile Application Development
Mobile Application DevelopmentMobile Application Development
Mobile Application Developmentjini james
 

Viewers also liked (20)

Um residencial com plantas espaçosas, acabamento Vip e localização nobre.
Um residencial com plantas espaçosas, acabamento Vip e localização nobre.Um residencial com plantas espaçosas, acabamento Vip e localização nobre.
Um residencial com plantas espaçosas, acabamento Vip e localização nobre.
 
Actitud de las autoridades educativas privadas en el uso de plataforma web
Actitud de las autoridades educativas privadas en el uso de plataforma webActitud de las autoridades educativas privadas en el uso de plataforma web
Actitud de las autoridades educativas privadas en el uso de plataforma web
 
Android Application on Location sharing and message sender
Android Application on Location sharing and message senderAndroid Application on Location sharing and message sender
Android Application on Location sharing and message sender
 
Secure my ng-app
Secure my ng-appSecure my ng-app
Secure my ng-app
 
Must Know Google Map Features for your Web application
Must Know Google Map Features  for your Web applicationMust Know Google Map Features  for your Web application
Must Know Google Map Features for your Web application
 
Google Map API
Google Map APIGoogle Map API
Google Map API
 
CATALÀ - Llinatges mapa activitat
CATALÀ  - Llinatges mapa activitatCATALÀ  - Llinatges mapa activitat
CATALÀ - Llinatges mapa activitat
 
Client-Server
Client-ServerClient-Server
Client-Server
 
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
 
Android MapView and MapActivity
Android MapView and MapActivityAndroid MapView and MapActivity
Android MapView and MapActivity
 
Location sharing and automatic message sender Android Application
Location sharing and automatic message sender Android ApplicationLocation sharing and automatic message sender Android Application
Location sharing and automatic message sender Android Application
 
Los derechos de la mujer dominicana
Los derechos de la mujer dominicanaLos derechos de la mujer dominicana
Los derechos de la mujer dominicana
 
Google Maps API for Android
Google Maps API for AndroidGoogle Maps API for Android
Google Maps API for Android
 
Vehicle tracking system using gps and google map
Vehicle tracking system using gps and google mapVehicle tracking system using gps and google map
Vehicle tracking system using gps and google map
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Final year project presentation in android application
Final year project presentation in android applicationFinal year project presentation in android application
Final year project presentation in android application
 
Presentation on Android application
Presentation on Android applicationPresentation on Android application
Presentation on Android application
 
Android Project Presentation
Android Project PresentationAndroid Project Presentation
Android Project Presentation
 
Mobile Application Development
Mobile Application DevelopmentMobile Application Development
Mobile Application Development
 
Android ppt
Android pptAndroid ppt
Android ppt
 

Similar to Code to Add Google Map to Websites

Progressive Web Application by Citytech
Progressive Web Application by CitytechProgressive Web Application by Citytech
Progressive Web Application by CitytechRitwik Das
 
Link your HTML Form to Google Sheet in just 3 Steps.pdf
Link your HTML Form to Google Sheet in just 3 Steps.pdfLink your HTML Form to Google Sheet in just 3 Steps.pdf
Link your HTML Form to Google Sheet in just 3 Steps.pdfBe Problem Solver
 
Google Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScriptGoogle Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScriptwesley chun
 
Android
AndroidAndroid
Androidscottw
 
ArcGIS API for Javascript Tutorial
ArcGIS API for Javascript TutorialArcGIS API for Javascript Tutorial
ArcGIS API for Javascript TutorialMohammed Mahmoud
 
Google Apps Script for Beginners- Amazing Things with Code
Google Apps Script for Beginners- Amazing Things with CodeGoogle Apps Script for Beginners- Amazing Things with Code
Google Apps Script for Beginners- Amazing Things with CodeLaurence Svekis ✔
 
Everything about flutter web development
Everything about flutter web developmentEverything about flutter web development
Everything about flutter web developmentKaty Slemon
 
What is Objective-j
What is Objective-jWhat is Objective-j
What is Objective-jJoe Terry
 
How to build and deploy app on Replit
How to build and deploy app on ReplitHow to build and deploy app on Replit
How to build and deploy app on Replitmatiasfund
 
Build Android App using GCE & GAE
Build Android App using GCE & GAEBuild Android App using GCE & GAE
Build Android App using GCE & GAELove Sharma
 
Ez Community Gandbox.fr
Ez Community Gandbox.frEz Community Gandbox.fr
Ez Community Gandbox.frGilles Guirand
 
Integrate Google Map SDK in iOS App
Integrate Google Map SDK in iOS AppIntegrate Google Map SDK in iOS App
Integrate Google Map SDK in iOS AppHitesh Kumar Singh
 
IE9 for developers
IE9 for developersIE9 for developers
IE9 for developersShaymaa
 
Introduction to App Engine Development
Introduction to App Engine DevelopmentIntroduction to App Engine Development
Introduction to App Engine DevelopmentRon Reiter
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidgetHiron Das
 

Similar to Code to Add Google Map to Websites (20)

Progressive Web Application by Citytech
Progressive Web Application by CitytechProgressive Web Application by Citytech
Progressive Web Application by Citytech
 
Link your HTML Form to Google Sheet in just 3 Steps.pdf
Link your HTML Form to Google Sheet in just 3 Steps.pdfLink your HTML Form to Google Sheet in just 3 Steps.pdf
Link your HTML Form to Google Sheet in just 3 Steps.pdf
 
Google Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScriptGoogle Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScript
 
Intro To Google Maps
Intro To Google MapsIntro To Google Maps
Intro To Google Maps
 
Android
AndroidAndroid
Android
 
ArcGIS API for Javascript Tutorial
ArcGIS API for Javascript TutorialArcGIS API for Javascript Tutorial
ArcGIS API for Javascript Tutorial
 
Google Apps Script for Beginners- Amazing Things with Code
Google Apps Script for Beginners- Amazing Things with CodeGoogle Apps Script for Beginners- Amazing Things with Code
Google Apps Script for Beginners- Amazing Things with Code
 
Everything about flutter web development
Everything about flutter web developmentEverything about flutter web development
Everything about flutter web development
 
What is Objective-j
What is Objective-jWhat is Objective-j
What is Objective-j
 
How to build and deploy app on Replit
How to build and deploy app on ReplitHow to build and deploy app on Replit
How to build and deploy app on Replit
 
Build Android App using GCE & GAE
Build Android App using GCE & GAEBuild Android App using GCE & GAE
Build Android App using GCE & GAE
 
Google Maps API 101
Google Maps API 101Google Maps API 101
Google Maps API 101
 
Ez Community Gandbox.fr
Ez Community Gandbox.frEz Community Gandbox.fr
Ez Community Gandbox.fr
 
@Ionic native/google-maps
@Ionic native/google-maps@Ionic native/google-maps
@Ionic native/google-maps
 
Integrate Google Map SDK in iOS App
Integrate Google Map SDK in iOS AppIntegrate Google Map SDK in iOS App
Integrate Google Map SDK in iOS App
 
IE9 for developers
IE9 for developersIE9 for developers
IE9 for developers
 
Introduction to App Engine Development
Introduction to App Engine DevelopmentIntroduction to App Engine Development
Introduction to App Engine Development
 
Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidget
 
Location Based Services Without the Cocoa
Location Based Services Without the CocoaLocation Based Services Without the Cocoa
Location Based Services Without the Cocoa
 

More from Fortune Innovations Dublin (6)

Sample SEO Audit Report
Sample SEO Audit ReportSample SEO Audit Report
Sample SEO Audit Report
 
On page optimization
On page optimizationOn page optimization
On page optimization
 
Off page optimization
Off page optimization Off page optimization
Off page optimization
 
Drupal theme development
Drupal theme developmentDrupal theme development
Drupal theme development
 
Seo Presentation
Seo PresentationSeo Presentation
Seo Presentation
 
Humming bird update ppt
Humming bird update pptHumming bird update ppt
Humming bird update ppt
 

Recently uploaded

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Code to Add Google Map to Websites

  • 1. ADDING A GOOGLE MAP TO YOUR WEBSITE By Rajeev Ranjan
  • 2.  Adding a Google Map to your web page is very easy, once you've been shown how! That's what we're going to do in this lesson - we'll go over each step of creating a basic Google Map using the JavaScript API.
  • 3. WHAT YOU'LL NEED    You don't need much to create a Google Maps API webpage: A text editor. Windows machines generally include Notepad; Mac OS X comes with TextEdit; Linux machines come with a variety of applications, including gedit, vim, or KWrite. A web browser. We heart Google Chrome, but there are many web browsers available for various platforms: Firefox, Safari, and Internet Explorer are some of the bestknown options.
  • 4. TRY IT OUT    The basic HTML page:Because everything on the web is made up of HTML, we'll start there. The following code creates the simplest of web pages: None of this is specific to Google Maps - it's the basis for any HTML page. Open your text editor and add this code, then save the file to your desktop as google-maps.html (or any other filename that ends with .html).
  • 5.  Your Google Map requires a page element in which to appear; add a div tag to the body with an id attribute of map canvas. This creates a container that we'll reference later in the lesson.
  • 6.  Set the width and height of the div element using CSS. By default, a div has a height of 0, meaning that any map you place inside it won't be visible. Use a style tag in the head to set the map to any size; in this case 500 pixels wide and 400 pixels high.
  • 7.    Load the HTML file in a web browser by dragging it from your desktop into the address bar of your browser. You'll notice that nothing is displayed - there's nothing in the div yet. If you'd like to see the div on your page, add a background-color CSS declaration to your existing <style> tag: Reloading the page will display a grey box; that's your div. To bring forth a map, you must add two pieces of JavaScript to your page. The first loads the Google Maps JavaScript API; the second creates and configures the map.
  • 8. LOADING THE API   Load the Google Maps API by adding a <script> tag to the <head> section of your HTML. This script downloads the code required to display maps on your page. Notice that the URL contains a sensor parameter, which is set to false. This example does not use any GPS device or sensor to detect the user's location; if you're using any sort of geolocation in your application, this must be changed to true
  • 9. CREATE AND CONFIGURE THE MAP   The final piece of code is the JavaScript that creates the map. The code contains a function to run once the page has loaded. In this example, and all of the examples in the Maps API documentation, this function is named initialize. Add this code immediately after the <script> tag you created in the last step.
  • 10. THE GOOGLE.MAPS.MAP OBJECT    The first thing the initialize function needs to do is create a new Google Maps object: The Map object constructor takes two arguments:
  • 11.    center is a Google Maps LatLng object that tells the the API where to center the map. zoom is a number between 0 (farthest) and 22 that sets the zoom level of the map. mapTypeId is used to specify what type of map to use. Your choices are ROADMAP, SATELLITE, HYBRID, or TERRAIN.
  • 12. EXECUTING THE JAVASCRIPT FUNCTION  Add an event listener to the window object that will call the initialize function once the page has loaded. Calling initialize before the page has finished loading will cause problems, since the div it's looking for may not have been created yet; this function waits until the HTML elements on the page have been created before calling initialize.
  • 13. THE FINISHED CODE  This is the final code you've put together in this lesson. It:  Creates a div, and gives it a size.  Loads the Google Maps JavaScript API v3.  Creates and displays a Google Map in the div.  Final Full code is in next slide….