Created
December 1, 2015 12:05
-
-
Save carloscabo/cca62ae31a0d42438873 to your computer and use it in GitHub Desktop.
Google Maps show Infowindow on side of the marker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What are left and top values ?