How to Draw Lines in Google Maps Android API v2
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...
Distributing Android Apps (2014)49,131 Views
Android SDK: Local Data Storage188,823 Views
Connecting Android Apps to RESTful Web Services148,975 Views
Building Adaptive Android Apps with Fragments104,366 Views
Building a Note-Taking App for Android (2013)225,285 Views
PHP with MySQL Essential Training4,283,533 Views