Skip to content

Instantly share code, notes, and snippets.

@carloscabo
Created December 1, 2015 12:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carloscabo/cca62ae31a0d42438873 to your computer and use it in GitHub Desktop.
Save carloscabo/cca62ae31a0d42438873 to your computer and use it in GitHub Desktop.
Google Maps show Infowindow on side of the marker
// 1. You must create the infowindows with pixelOffset setting
var iw = new google.maps.InfoWindow({
content: 'HTML_CONTENT_HERE',
pixelOffset: new google.maps.Size(left, top)
});
// 2. On first infowindow is shown we add a class to the infowindow container
// So we can add styles to it overriding default ones
// $map is JQuery selector with map container
if ($map.find('.gm-style-iw-container').length === 0) {
$map.find('.gm-style-iw').parent().addClass('gm-style-iw-container');
}
// Custom iw that moves the arrow to the left side
.gm-style-iw-container {
// Background
> div {
// Arrow shadow
> div:first-child {
border-top-color: transparent !important; // Disable
}
// Box shadow
> div:nth-child(2) {
// background-color: cyan !important;
// box-shadow: rgba(0, 0, 0, 0.298039) 0px 1px 4px -1px !important;
}
// Arrow image
> div:nth-child(3) {
transform: rotate(90deg);
left: 0 !important;
top: 75px !important;
}
}
.gm-style-iw {
// background-color: pink;
}
}
@hacking-robot
Copy link

What are left and top values ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment