Chapter 7 — Extending the Google API Examples 119
Obviously, this is a less-than-efficient method of adding a route to the map, but it does
demonstrate the basic principle. As with the bounding box, the sequence is to add points to an
array and then construct the polyline and overlay it on your map.
Remember that polylines are plotted according to the sequence of points. If you want to draw
two shapes, you must create two arrays and two polylines; otherwise, you will have a line con-
necting the two shapes.
Note that the GPolylineclass creates a new object, so just as with the markers you created
earlier, the polyline route could be recorded in a variable and added, modified, or hidden on the
map at will.
The resulting route is shown in Figure 7-9.
FIGURE7-9: Adding a route to a map.
Polylines can have different colors, sizes, and opacities (or transparencies, depending on your
preferred start position!). However, specification of these colors is made at the time the
GPolylineobject is instantiated, which means that to create a box with sides of different col-
ors or opacities actually requires the creation of different polylines.