Maps API v3 Custom infoWindow
http://stackoverflow.com/questions/27831966
by Ryan Brackett
HTML
<script src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=geometry,places&ext=.js"></script>
<div id="googleMap" style="height: 600px;">
</div>
<!-- Scripts -->
CSS
#googleMap {
margin: auto;
max-width: 900px;
}
.gm-style-iw-parent {
width: 250px !important;
/*height: 83px !important;*/
}
.gm-style-iw {
width: 250px !important;
top: 0 !important;
left: 0 !important;
border-radius: 2px 2px 0 0;
}
.gm-style-iw+div {
right: -5px !important;
top: -5px !important;
border-radius: 5px !important;
background-color: #ff4b4b !important;
}
.gm-style-iw+div:after {
content: "X";
color: #fff;
padding: 0 3px;
}
.gm-style-iw+div img {
display: none !important;
}
.mapCard {
width: 240px;
float: left;
overflow: hidden;
background-color: #fff;
border-radius: 4px;
box-shadow: 0 0px 5px rgba(0, 0, 0, 0.6);
min-height: 80px;
margin: 5px;
}
.mapCard img {
float: left;
margin-right: 15px;
border-radius: 4px 0 0 4px;
}
.mapCard .text {
display: block;
padding-left: 135px;
word-break: break-word;
padding: 5px;
}
.mapCard h3 {
padding: 0;
margin: 0;
}
.gm-style-iw-parent>div:first-child {
top: auto !important;
bottom: 0 !important;
}
.gm-style-iw-parent>div:first-child>div {
top: auto !important;
left: 245px !important;
z-index: 1;
transform: rotate(-90deg) !important;
transform-origin: top left;
bottom: 56px !important;
}
.gm-style-iw-parent>div:first-child>div:first-child {
display: none;
}
JavaScript
var icon = {
path: "M-10,0a10,10 0 1,0 20,0a10,10 0 1,0 -20,0",
fillColor: '#FF0000',
fillOpacity: .8,
anchor: new google.maps.Point(0, 0),
strokeWeight: 0,
scale: 1,
//anchor: new google.maps.Point(0, 10) // anchor
}
var icon2 = {
path: "M-10,0a10,10 0 1,0 20,0a10,10 0 1,0 -20,0",
fillColor: '#FF0000',
fillOpacity: .8,
anchor: new google.maps.Point(0, 0),
strokeWeight: 0,
scale: 1.2,
//anchor: new google.maps.Point(0, 10) // anchor
}
var getGoogleClusterInlineSvg = function(color) {
var encoded = window.btoa('<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50"><defs><radialGradient cy="0.5" cx="0.5" r="0.5" spreadMethod="pad" id="svg_7"><stop offset="0.011719" stop-opacity="0.996094" stop-color="#ffffff"/><stop offset="1" stop-color="' + color + '"/></radialGradient></defs><title>background</title><rect fill="none" id="canvas_background" height="52" width="52" y="-1" x="-1"/><g display="none" overflow="visible" y="0" x="0" height="100%" width="100%" id="canvasGrid"><rect fill="url(#gridpattern)" stroke-width="0" y="0" x="0" height="100%" width="100%"/></g><title>Layer 1</title><ellipse stroke="null" fill-opacity="0.51" ry="20.5625" rx="20.5625" id="svg_6" cy="25.000001" cx="25.000001" stroke-width="1.5" fill="url(#svg_7)"/><ellipse stroke="null" fill-opacity="0.51" ry="24.249999" rx="24.249999" id="svg_9" cy="25" cx="25" stroke-width="1.5" fill="url(#svg_7)"/><ellipse stroke="null" ry="16.124999" rx="16.124999" id="svg_10" cy="25" cx="24.999999" stroke-width="1.5" fill="' + color + '"/></svg>');
return ('data:image/svg+xml;base64,' + encoded);
};
var cluster_styles = [{
width: 50,
height: 50,
url: getGoogleClusterInlineSvg('red'),
textColor: 'white',
textSize: 12
},
{
width: 50,
height: 50,
url: getGoogleClusterInlineSvg('#a90000'),
textColor: 'white',
textSize: 14
},
{
width: 60,
height: 60,
url: getGoogleClusterInlineSvg('#820000'),
textColor:...