The Google Map below shows a fractal path across North Carolina represented as an encoded polyline. As you zoom in, you will notice that the complexity of the path increases to accomodate the zoom level. The full blown path is determined by 390,626 points.
The polyline is encoded in the following format:
new GPolyline.fromEncoded({
color: "#0000ff",
weight: 4,
opacity: 0.8,
points: pointString,
levels: levelString,
zoomFactor: 4,
numLevels: 9
});
The pointString and levelString are quite complicated, but you can view them by looking at this Javascript file. Since the path is determined by exactly 390,626 vertices, the levelString is a string with 390,626 characters. The character in a particular postion in the level string indicates at which zoom level the corresponding vertex should be turned on. Roughly, a vertex appears according to the following scheme:
Note, however, that this scheme varies a bit depending on broswer configuration.
The encoding of the levels string was determined using the self-similar structure of the path, which consists of five copies of itself each scaled by the factor 1/4. This is why the zoomFactor is set to be 4. A zoomFactor of 4 implies that numLevels should be 9 (since there are 18 levels differing in magnification by a factor of 2 between the levels). A zeroth level approximation is simply a straight line segment.
The Gs indicate that the endpoints should appear at every level of magnification. At the next level of approximation, the segment is replaced by five segments as so
The new points should be encoded with an F in the levelString. Here is the next level; the new points should be encoded with an E in the levels string.
The number of segments increases by the factor 5 with each step. The path in the map is the eighth step, thus it consists of 5^8 = 390,625 segments.