Recent Maps API Update causing canvas warning with Polygon fillOpacity option

57 views
Skip to first unread message

Lawrence

unread,
Apr 25, 2011, 7:59:55 PM4/25/11
to Google Maps JavaScript API v3
Hi there,

This is something I've only recently noticed and can only think it was
brought on by an API update. Not sure if it's a bug, but thought I
should bring it up in case someone else runs into the same issue.

I had a polygon construct with the following options:

myPoly = new google.maps.Polygon({
paths: someCoordinates,
strokeColor: "#0000ff",
strokeOpacity: 0.9,
strokeWeight: 2,
fillColor: "#0000ff",
fillOpacity: 0.0
});

What I noticed recently was that Firebug would display the following
warning:

"canvas: an attempt to set strokeStyle or fillStyle to a value that is
neither a string, a CanvasGradient, or a CanvasPattern was ignored"

Again I know that Firebug did not used to throw this warning so figure
it must be a recent API update that brought this up.

Anyways, I tried other values for the fillOpacity option and found
that it just didn't like zero (0 or 0.0). Any other value was fine. So
in the end my "fix" is to change the fillOpacity from 0.0 to 0.01.

-Lawrence.

R Konig

unread,
Apr 25, 2011, 9:21:23 PM4/25/11
to Google Maps JavaScript API v3
I got the same Firebug warning when using polylines. Lawrence's
solution for polygons works for polylines too:

BEFORE
mypolyline = new google.maps.Polyline({
strokeWeight: 2,
strokeColor:"#0000ff",
strokeOpacity:0.5
});
mypolyline.setMap(map);
mypolyline.setPath(new google.maps.MVCArray([path]));

AFTER
mypolyline = new google.maps.Polyline({
strokeWeight: 2,
strokeColor:"#0000ff",
strokeOpacity:0.5,
fillColor: "#ffffff",
fillOpacity: 0.01
});
mypolyline.setMap(map);
mypolyline.setPath(new google.maps.MVCArray([path]));

Esa

unread,
Apr 26, 2011, 7:41:43 AM4/26/11
to Google Maps JavaScript API v3
{fillOpacity: "0"}

did the trick for me. Use string instead of a number.

Esa

unread,
Apr 26, 2011, 8:07:13 AM4/26/11
to Google Maps JavaScript API v3
Just noticed that there is a conflict between documentation and the
JavaScript warning that is thrown.

Documentation states data type "number" for fillOpacity,
strokeOpacity, strokeWeight and zIndex.

Lawrence

unread,
Apr 26, 2011, 1:33:37 PM4/26/11
to Google Maps JavaScript API v3
Hi Esa,

You are right using a string instead of a number can also do the
trick. However I was hesitant to go this route as it was not described
in the documentation.

So maybe the docucmentation needs to be updated?

Looks like it was the 4/14 API update that brought this issue up as
they reconfigured the polys to render with the canvas element.

http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/6310d4992ce4b2ab

-Lawrence.

Esa

unread,
Apr 26, 2011, 7:24:28 PM4/26/11
to Google Maps JavaScript API v3
It seems to be fixed now when version was changed to 3.4.11

My advice to use strings was good only for < 24 hours. Now the
arguments must be passed as numbers.
Reply all
Reply to author
Forward
0 new messages