Drawing Objects on Android App Maps – Developer.com

Google Maps provides the programmatic ability to draw objects on the maps, such as lines and circles. This can be useful to demonstrate paths, or mark areas that might be impacted by any event like a music concert. We can draw polygons, lines, and circles on the maps. We use the PolylineOptions and CircleOptions classes to describe the shapes and then add them to the map by using the Map.addPolyLine and Map.addCircle APIs. Change the default contents of the layout file activity_draw_objects.xml to what is shown in the following code segment. In the preceding layout file, we are adding three buttons. The first one will add markers on the Statue of Liberty and New York, the second button is intended to draw a line between the markers when it is clicked, and the third button, when clicked, will draw a circle around Marker 1. In the code file for the activity, DrawObjectsActivity.java, include the following import statements. Our application is now ready. When we run this application and click the button to draw the markers, the map centers in on New York and adds a couple of markers: one for the Empire State Building and the other for the Statue of Liberty. When we click the Draw Lines and Draw Circle buttons, we draw the objects on the map. In this article, we learned how to draw objects on Google Maps programmatically. I hope you have found this information useful. Vipul Patel is a technology geek based in Seattle. He can be reached at vipul.patel@hotmail.com. You can visit his LinkedIn profile at https://www.linkedin.com/pub/vipul-patel/6/675/508. Source.


Яндекс.Метрика Рейтинг@Mail.ru Free Web Counter
page counter
Last Modified: April 23, 2016 @ 6:02 pm