Google Maps API Add style infowindow on google maps

submit to reddit

In this example you will learn how to add style to infowindow on google map.

Here you can view the output of the example and you can also "try it yourself" by clicking on "Live Demo" button given at the bottom.

Syntax

var infobox = new InfoBox({
         content: document.getElementById("infobox"),
         disableAutoPan: false,
         maxWidth: 150,
         pixelOffset: new google.maps.Size(-140, 0),
         zIndex: null,
         boxStyle: {
            background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/examples/tipbox.gif') no-repeat",
            opacity: 0.90,
            width: "300px"
        },
        closeBoxMargin: "12px 4px 2px 2px",
        closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
        infoBoxClearance: new google.maps.Size(1, 1)
    });
    
    google.maps.event.addListener(marker, 'click', function() {
        infobox.open(map, this);
        map.panTo(lat_lng);
    });

Example Add Style to Info Window

<!DOCTYPE html>  
<html>  
<head><!-- www.techstrikers.com --> 
<title>Add Style Info Window on Google Map</title>
  <style>
     html, body {  
        height: 100%;  
        margin: 0;  
        padding: 0;  
      }  
      #map {  
        height: 99%; 
         width: 99%;
      }
      .infobox-wrapper {
    display:none;
}
    .infobox-wrapper {
    display:none;
}
#infobox {
    border:2px solid black;
    margin-top: 8px;
    background:#098;
    color:#FFF;
    font-family:Arial, Helvetica, sans-serif;
    font-size:12px;
    padding: .5em 1em;
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    border-radius: 2px;
    text-shadow:0 -1px #000000;
    -webkit-box-shadow: 0 0  8px #000;
    box-shadow: 0 0 8px #000;
}
</style>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox.js"></script>
<script type="text/javascript">
function initialize() {
    var lat_lng = {lat: 17.08672, lng: 78.42444}; 
    
    var map = new google.maps.Map(document.getElementById("map"), {
         zoom: 6,
         center: lat_lng,
         mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    
    var marker = new google.maps.Marker({
        map: map,
        position: lat_lng,
        visible: true
    });

    var infobox = new InfoBox({
         content: document.getElementById("infobox"),
         disableAutoPan: false,
         maxWidth: 150,
         pixelOffset: new google.maps.Size(-140, 0),
         zIndex: null,
         boxStyle: {
            background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/examples/tipbox.gif') no-repeat",
            opacity: 0.90,
            width: "300px"
        },
        closeBoxMargin: "12px 4px 2px 2px",
        closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
        infoBoxClearance: new google.maps.Size(1, 1)
    });
    
    google.maps.event.addListener(marker, 'click', function() {
        infobox.open(map, this);
        map.panTo(lat_lng);
    });
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
  <div class="infobox-wrapper">
    <div id="infobox">
        TechStrikers is developed to help you to begin HTML,CSS,XML,JavaScript,  
   DOM,jQuery,ASP.NET,PHP,SQL Server, MySQL,colors,tutorial,programming,development,  
  training,learning,reference,examples,source code,demos,tips,color table,  
   cascading style sheets,asp.net, csharp, c#.net,ADO.NET, OOPS, Entity  
   Framework, KnockoutJS, MVC, LINQ, WEB API, Google Map API, Design Patterns etc.
   <p><a href="http://www.techstrikers.com">http://www.techstrikers.com</a></p>
</div>
</div>
<div id="map"></div>
<br>
</body>
</html>

Above example will produce following output

Try Now

More Google Map Infowindow Examples

 
 
SHARE THIS IF YOU LIKE!
submit to reddit

SUBSCRIBE FOR LATEST UPDATES
HAVE WE CONNECTED ON FACEBOOK?
TOP TUTORIALSTOP CODE EXAMPLESTOP LIVE DEMOLINKSSTAY CONNECTED
HTML Tutorial
HTML5 Tutorial
Bootstrap3 Tutorial
Javascript Tutorial
TypeScript Tutorial
AngularJS Tutorial
CSharp Tutorial
PHP Tutorial
Developer Tools
Javascript
AngularJS
Google MAP API V3
ASP.NET
Javascript
AngularJS
Google MAP API V3
Contact Us
Advertise with Us
Privacy Policy
Disclaimer
Stay connected. We actually like you. If you want to get up to the minute updates, then connect with us on your fav below.
 
Twitter   Linkedin   Facebook   Google+    RSS   Pinterest
 
Protected by Copyscape Original Content Checker
 
 
Copyright ©2017 www.techstrikers.com Unauthorized reproduction/replication of any part of this site is prohibited.