-
Title:
Show Shapes Code
-
Description:
-
So I'm just going to show how I added
the polyline to the map with all my
-
different ice rinks.
-
So to draw the polyline, I set up
the latitudes and longitudes for
-
all the different ice rinks, Renton,
Kirkland, Everett, Lynnwood, etc.
-
And this time I'm just setting
them as LatLng objects.
-
Earlier they were marker options,
but now they're just latitudes and
-
longitudes.
-
I set up my camera position to be
exactly as I did in the earlier sample.
-
Now in my onMapReady, I just move
the camera to my camera position,
-
which is Seattle.
-
And then to draw the polyline
I just call map.Polyline.
-
It's a new Polyline object,
geodesic true,
-
and then I just add all
of the latitudes and
-
longitudes that I had created earlier,
Renton, Kirkland, Everett, Lynnwood.
-
Notice that I begin at Renton and
I also add Renton at the end.
-
And then this just closes the shape.
-
Because what will happen when you draw a
polyline is it will draw from Renton to
-
Kirkland, from Kirkland to Everett,
from Everett to Lynnwood, etc.
-
So, if I want to close the shape,
-
I just want to go back to
the initial one at the end.
-
And then I will get all my rinks drawn
into a polygon like shape by adding
-
a polyline.
-
And this is what it will look like.
-
Here you can see on my tablet I
have the same map of Seattle, and
-
I have all the endpoints
of the different rinks.
-
My home rink of Renton that I showed
earlier on is the beginning and
-
ending point, and then the polylines
get drawn from Renton to other rinks.
-
So for example,
this is the rink in Kingsgate.
-
You can see,
Kingsgate highlighted there.
-
Or I can go all the way
the rink in Everett, etc.
-
So, these are the polylines that I've
drawn from me connecting the rinks.
-
And because I just joined the last rink
at ShoWare back to Renton in my code
-
the shape gets completed.
-
And as you can see here,
my second last one was ShoWare.
-
I then added Renton and
the shape got completed.
-
So my polyline actually
became a polygon.
-
You can actually also
do a map.addPolygon and
-
specify the endpoints and
it will auto close it for you.