Google Maps Info Windows is used to add a window to display the information of the specific area. Usually, the info window is attached to a marker. You can attach an info window by instantiating the google.maps.InfoWindow class.
Syntax:
var infowindow = new google.maps.InfoWindow({content: "Content String"});
infowindow.open(map, marker);
Property Values:
- Content: Used to pass content in String format.
- pixelOffset: It contains an offset from the tip of the info window to the location on which the info window is anchored, it is optional.
- position: Used to choose the position of the info window.
- maxWidth: To restrict the size of the info window horizontally. By default, the info window’s width will be stretched till the text is wrapped.
Example:
HTML
<!DOCTYPE html> <html> <head> <!-- Loading map API --> <script src= </script> <script> function GFG() { var CustomOp = { center: new google.maps.LatLng(28.502212, 77.405603), zoom: 17, }; // Map object var map = new google.maps .Map(document.getElementById("DivID"), CustomOp); var marker = new google.maps.Marker({ position: new google.maps.LatLng(28.502211, 77.405512), map: map, draggable: true, icon: }); marker.setMap(map); var infowindow = new google.maps.InfoWindow({ content: "5th Floor, A-118,Sector-136,"+ " Noida, Uttar Pradesh - 201305", }); infowindow.open(map, marker); } </script> </head> <!-- load map --> <body onload="GFG()"> <center> <h1 style="color: green;">GeeksforGeeks</h1> <h3>Google Maps Info Windows</h3> <!-- Basic Container --> <div id="DivID" style="width: 400px; height: 300px;"></div> </center> </body> </html> |
chevron_right
filter_none
Output:
Recommended Posts:
- How To Add Google Maps With A Marker to a Website
- Google Maps | Introduction
- Google Maps | Types
- Google Maps | Localization
- Google Maps | Zoom
- Google Maps Markers
- PHP | ReflectionExtension info() Function
- Node.js console.info() Method
- HTML | DOM console.info() Method
- Using Leaflet.js to show maps in a webpage
- Installation of Node.js on Windows
- Introduction and Installation of Heroku CLI on Windows machine
- Why Linux Hosting is Cheaper than Windows Hosting ?
- How to install XAMPP on Windows ?
- How to set PHP development environment in windows ?
- How to Setup Sublime Text 3 for Python in Windows?
- Windows Taskbar Operations in ElectronJS
- How to export sites with Google Takeout in New Google Sites ?
- How to Add Google Custom Search Engine in New Google Sites ?
- How to embed Google Forms in New Google Sites ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


