I’ve been attempting to style my Google Maps InfoWindow, but the documentation is very limited on this topic. How do you style an InfoWindow?
I’ve been attempting to style my Google Maps InfoWindow , but the documentation is
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Google wrote some code to assist with this. Here are some examples: Example using InfoBubble, Styled markers and Info Window Custom (using OverlayView).
The code in the links above take different routes to achieve similar results. The gist of it is that it is not easy to style InfoWindows directly, and it might be easier to use the additional InfoBubble class instead of InfoWindow, or to override GOverlay. Another option would be to modify the elements of the InfoWindow using javascript (or jQuery), like later ATOzTOA suggested.
Possibly the simplest of these examples is using InfoBubble instead of InfoWindow. InfoBubble is available by importing this file (which you should host yourself):
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/src/infobubble.jsInfoBubble’s Github project page.
InfoBubble is very stylable, compared to InfoWindow:
You can also call it with a given map and marker to open on:
As another example, the Info Window Custom example extends the GOverlay class from the Google Maps API and uses this as a base for creating a more flexible info window. It first creates the class:
after which it proceeds to override GOverlay:
You should then override the methods you need:
createElement,draw,removeandpanMap. It gets rather involved, but in theory you are just drawing a div on the map yourself now, instead of using a normal Info Window.