The documentation for the google.maps.Size function says:
Size(width:number, height:number, widthUnit?:string, heightUnit?:string)
The default for the widthUnit and heightUnit arguments seems to be pixels. The function works properly if it is called as new google.maps.Size(30,30,"px","px")
I would like to know what other unit types are supported.
Andrew is correct. All the CSS length units that a particular browser supports are also supported by google.maps.Size. For many of its uses, this is because the string you get by concatenating the number and unit is used directly in styling by setting it as the value on CSS width, height, etc properties (in other cases, the Maps API calculates what those sizes would be in that context if it wants to (for instance) use absolute units or draw to a canvas).
If you want to use relative lengths, remember that they'll be interpreted relative to their place in the cascade. Depending on the object whose size you're setting, the end result might not be what you expect. Since the Maps API places your content in a variety of places in the DOM tree it creates, the size may be dependent on implementation details that aren't guaranteed to stay stable between versions of the API. Similarly, '%' often works as a unit (even though it technically isn't a CSS length type), but it may end up defining your size relative to a DOM element you have no control over. At the very least, test carefully!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With