The syntax to create an encoded polygon is similar to the syntax to create an encoded polyline, but a bit more complicated. Here is a simple example generated by the form.
new GPolygon.fromEncoded({
polylines: [
{points: "ihglFxjiuMkAeSzMkHbJxMqFfQaOoB",
levels: "PFHFGP",
color: "#0000ff",
opacity: 0.7,
weight: 3,
numLevels: 18,
zoomFactor: 2},
{points: "cbglFhciuMY{FtDqBfCvD{AbFgEm@",
levels: "PDFDEP",
color: "#0000ff",
opacity: 0.7,
weight: 3,
numLevels: 18,
zoomFactor: 2}],
fill: true,
color: "#0000ff",
opacity: 0.4,
outline: true
});
The fill property is a boolean specifying whether or not
to fill the polygon according to the color and
opacity properties. The outline
property specifies whether or not to draw the boundary according
to any style directive in polylines.
The polylines property is an array of objects in JSON
notation describing the boundary of the polygon; each element of this
array could be an argument to GPolyline.fromEncoded. If
you've got a collection of polygons that form a cohesive unit (like a
group of islands), then it make sense to lump them together into one
GPolygon for efficiency of rendering. Furthermore,
overlapping regions in the same encoded polygon can be used to generate
a hole in a polygon. In fact, the illusrative example above uses this
behavior to outline the Pentagon as shown below.
Note that the behavior between two overlapping regions in the same encoded polygon is distinct from overlapping regions from different encoded polygons. As an example, here are two are two overlapping nearly circular polygons contained in the same encoded polygon as above. The intersection is missing.
More generally, a region which is outlined an odd number of times by paths in the same polygon will be opaque, but a region outlined an even number of times will be clear.
Here's a similar picture, but now the regions are contained in different encoded polygons. Note that the regions now re-enforce one another.