Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps API v3: Custom styles for infowindow

I've tried many of the examples from the google maps reference and from other stackoverflow questions, but I haven't been able to get custom styles on my infowindow.

I am using something very similar to what was done in this other stackoverflow answer

Here it is working/editable: http://jsfiddle.net/3VMPL/

In particular, I would like to have square corners instead of the rounded.

like image 658
CloudMagick Avatar asked Sep 30 '11 22:09

CloudMagick


People also ask

How do I edit InfoWindow on Google Maps?

You can modify the whole InfoWindow using jquery alone... var popup = new google. maps. InfoWindow({ content:'<p id="hook">Hello World!

How do I customize InfoWindow in Google Maps flutter?

Please try custom_info_window. It is a package that allows widget based custom info window for google_maps_flutter. By using this, you will be able to move your widget like info window on the top of the map's marker.

What is InfoWindow in Google map?

An InfoWindow displays content (usually text or images) in a popup window above the map, at a given location. The info window has a content area and a tapered stem. The tip of the stem is attached to a specified location on the map. Info windows appear as a Dialog to screen readers.


1 Answers

Update: Refer to this answer for the state of the infobox source code migration to github.


How about using the Infobox plugin rather than using the usual Infowindow? I put up a complete example in a jsfiddle example here. The main thing about the infobox is that you can create your infobox within your page's html, giving you complete control over how it looks using css (and some javascript options, if necessary). Here's the html for the infobox:

<div class="infobox-wrapper">     <div id="infobox1">         Infobox is very easy to customize because, well, it's your code     </div> </div> 

The idea here is the "infobox-wrapper" div will be hidden (i.e., display:none in your css) and then in your javascript you will initialize an Infobox object and give it a reference to your "infobox" (inside the hidden wrapper) like so:

infobox = new InfoBox({     content: document.getElementById("infobox1"),     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.75,                 width: "280px"         },     closeBoxMargin: "12px 4px 2px 2px",     closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",     infoBoxClearance: new google.maps.Size(1, 1) }); 

This is just an example of some of the available options. The only required key is content - the reference to the infobox.

And to open the info window:

google.maps.event.addListener(marker, 'click', function() {     infobox.open(map, this);     map.panTo(loc); }); 

And to further demonstrate the flexibility of the InfoBox, this jsfiddle has an image with a css transition as the "info box".

And one final tip: Don't use the class "infobox" in your html. It is rather unfortunately used by the plugin when the infobox is actually generated.

like image 116
uɥƃnɐʌuop Avatar answered Oct 07 '22 19:10

uɥƃnɐʌuop