‫In this tutorial we are going to work with Polylines in Google Maps.
‫Hello my friends, and welcome to the complete Android developer course and them and master coding channel.
‫We will continue with learning how to create and customize the polylines in Google Maps.
‫So first of all, what is Polylines?
‫The polyline class defines a set of connected line segments on the map.
‫A polyline object consists of a set of lat long locations and create a series of line segments that
‫connect those locations in an ordered sequence.
‫So what does this means?
‫We are going now to the Android studio and we will start making an polyline.
‫So first of all, on the map, ready?
‫I will create here polyline.
‫Polyline and we will start by polyline options.
‫This is for customization and I will create a one of rect option, equal new polyline options, and
‫I will pass the data.
‫So what are these data?
‫As I told you, this is a set of lat long.
‫So first of all, I will pass my lat long that have I have created before which is called M one.
‫Now I will add another one.
‫Left lung.
‫I will copy this.
‫Left lung.
‫M2.
‫And I will make it like 25, 20 or 25.
‫And I will make it a 45 and I will copy.
‫Also left lung.
‫I will created it at as M4 and sorry, M3 and I will make it like 30 and here 50 which is left lung
‫and I will create a lat long another lat long called M4 equal to new lat lat long and called 55 and
‫55.
‫Now I will add this collection of or set of lat long in the polyline options I will create also add
‫M2 to also add M3 and add M4.
‫In this way we are going to add or we have added the options or the points for the polyline that we
‫have created.
‫So now polyline.
‫Class, I will create an object of it called polyline and my map, map, map, dot add here equal and
‫call.
‫Add polyline and I will pass rect options.
‫Okay, now let's run our everyday virtual device and let's see the magic.
‫So if you want to learn and learn Android coding and master master languages and coding languages.
‫So you came to the right place.
‫Here we go.
‫Just subscribe to our YouTube channel and hit five stars and hit like for us and rate us five stars
‫on Udemy.
‫So.
‫And this is our line.
‫It is passing like this.
‫So.
‫Let's create another one for called M5.
‫I will create it as 60 and.
‫100.
‫Sorry.
‫90.
‫Let's see.
‫So, guys, it's okay.
‫I missed to add it here.
‫Am five.
‫Okay, so in this way we are creating the polyline.
‫Okay, so here we go.
‫Let's see, -40 and -80.
‫Let's see where we go.
‫Okay.
‫Guys.
‫It's near chilly.
‫Okay?
‫It's the fastest and the simplest way to add the poly line to the maps.
‫Now.
‫One thing that I should tell you about polyline options.
‫By default, polylines are not clickable, so you can enable and disable the clickability by calling
‫polyline dot set clickable.
‫So polyline here.
‫Polyline.
‫And we have many, many methods with visible, geodesic and clickable.
‫And here we go is clickable and we pass through.
‫And is clickable and clickable now.
‫Polyline you can receive on polyline Click event.
‫So it's clickable.
‫We can click, but we can specify the clickability a.
‫Like like this.
‫It is clickable, but we are not specifying what happens if we click on it.
‫So in order to do that, we are we should implement the on on polyline click listener here and add implement
‫the methods and specify the the.
‫That click
‫on.
‫Polyline.
‫Polyline Click Listener.
‫Click Listener on Polyline.
‫Click Listener.
‫And we pass this.
‫Okay, Google Maps on polyline, Click listener and we pass this.
‫Certain you.
‫Implement the methods.
‫And click okay.
‫On polyline.
‫In this way we can polyline click and we can remove this now.
‫No.
‫Okay.
‫We have to remove this and we can specify the polyline action here when it is clicked.
‫Okay.
‫But this is not usable in the future because many apps don't use the Click listeners for the polylines.
‫Now.
‫Let's see where another another things for.
‫Okay.
‫Get in the set.
‫These are the.
‫These are the methods.
‫Now, uh, let us go back to the polyline options.
‫We can specify the color, and we we here, we can add our dot color, dot color accent.
‫Let's see.
‫We can change the color of the polyline.
‫This here.
‫Got primary.
‫Let's see.
‫It's not changed, okay.
‫Because we need to specify the end end.
‫Okay, let's copy the end from here.
‫Okay.
‫It's not working.
‫We need to specify that color dot color primary.
‫Let's see.
‫Now.
‫Maybe we need to reset them.
‫Okay.
‫It's working.
‫The color.
‫Now we can specify also, like the width parent, the joint type and the width.
‫I will should pass a pass the float.
‫I will make it ten.
‫Let's see what happens if passing ten.
‫Okay.
‫It's bigger.
‫And the shape, the color is changed.
‫Now let's see.
‫Let's add the clickable add and cap visible at the index.
‫As I told you at the of the Z index is when you have many, many shapes on the map.
‫The higher Z index, the the of the object, it will be displayed in the forward position over there.
‫Other objects like markers, like shapes, like circles, like polylines and polygons.
‫We'll see later in the in the project.
‫So get points and here are the classes and methods.
‫This is the polyline in general, and it's a very, very good practice because we are going to see how
‫to use them in later and complex applications in future.
‫So guys, if you if you want to learn Android coding and other coding tutorials from Zero to Hero and
‫become a real developer, you came to the right place.
‫Just rate us five stars on Udemy.
‫You will get free coupons and subscribe to our YouTube channel so you get the free tutorials.
‫Thank you guys.
‫If you want us to continue making tutorials, do subscribing and rating five stars.
‫Thank you guys.
‫See you in next.
‫Videos about polygons, circles and other shapes.
‫Thank you.