Lesson goal: Draw a trail

Previous: Find distances | Home | Next: Introduction to 3D graphics

In the lesson on markers, you saw how setmarker could be used to place a famous red Google Markers on a map. In this lesson, you'll see how you can draw a smooth trail (or line) through a bunch of latitude,longitude points.

Drawing a trail involves telling the map a bunch of points through which the trail should be drawn. These points are best organized in two arrays: one array for the latitudes, and the other for the longitudes. Thus, we give you drawtrail, that works like this:

Move the mouse over a dotted box for more information.

Now you try. Try out our demonstration, but next, draw a square around your house or school.

Type your code here:

See your results here:

This code will draw a trianglular trail around the Bermuda Triangle. Dismiss.
Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

  1. Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

  2. Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into this page

  3. Then click the "Use on iPhone" button that you'll see.