How to Draw Lines in Google Maps Android API v2


show more Drawing lines provides you with in-depth training on Developer. Taught by David Gassner as part of the Building Mobile Apps with Google Maps Android API v2 show less
please wait ...

Drawing lines

The Google Android SDK includes tools for drawing on the map. You can create circles, polygons and lines, and I'll start in this demo by showing how to draw a simple line between two points. In this version of my project, named Drawing Lines I've added two fields to the main activity class. They're called marker1, and marker2, and they're both data typed as the Marker class. Then, in the method where I'm adding a marker, I've added some logic.

This is the setMarker method down towards the bottom of the class. After creating the marker options object, I then take a look and see which markers have already been created. If marker1 is null, then I create it. But if that marker is already on the map, I check to see if marker2 is null, and if it isn't, I create that. And finally, if both markers have been created, I remove them and then recreate marker1 again. So now I'm going add a little bit of code that will be executed right here after I've created both markers.

And I w...

Drawing lines
Video duration: 8m 48s 3h 50m Intermediate

Viewers:

Drawing lines provides you with in-depth training on Developer. Taught by David Gassner as part of the Building Mobile Apps with Google Maps Android API v2

Subject:
Developer
Software:
Android
Author:
please wait ...