‫Welcome again, guys, to our Google Maps course.
‫In this video, we will learn about markers, how to create, customize and display them onto our map.
‫Keep us making new tutorials by rating US five stars on Udemy and subscribing to our YouTube channel.
‫Don't miss the like and subscribe and comment.
‫So what are markers?
‫Markers Identify.
‫Identify locations on the map.
‫The default marker uses a standard icon with the comment that Google Maps look and feel.
‫It's possible to change the icons, color and image or anchor point via API.
‫So markers are objects of type marker.
‫So in the marker class we have inside the Google API and markers are objects of this type.
‫So this is the marker and hit on it, click on it marker in Sydney.
‫Now we are going to add it the map markers learn about them and their properties.
‫In order to add a marker, we first need to specify a lat and long what are lat long?
‫If you are if you hear about coordinates, these are the coordinate system of Android studio and Android
‫maps.
‫So first of all, let's remove this.
‫And if we look on the recently created application, we see here that adding a marker in Sydney and
‫move the camera lat long.
‫This is a class of LAT, an object called Sydney of type lat long new lat long.
‫And here we specify the coordinates that the lat longitude and latitude.
‫Longitude now lat long latitude and longitude.
‫Map and map dot add marker.
‫In this way we are adding the new marker options position and saying, Hey, add a marker on this coordinate
‫called Sydney and put the title called Marker in Sydney.
‫Then allow the map to move the camera towards this recently created marker.
‫Now let's try to change the value of 50 to 50 and I will create here, I will just separate this to
‫look better position.
‫And I will call this marker called anywhere.
‫And anywhere.
‫And I will specify here anywhere.
‫And marker.
‫Unknown.
‫Unknown location.
‫Let's try to run it and see the magic.
‫So.
‫Markers are created in this way.
‫Okay, So it looks like in Kurdistan or Kazakhstan.
‫Now
‫let's create another lat lat long.
‫This an object marker to I will create by creating a new lat long.
‫And I will specify.
‫Let's take ten and ten and let's map.
‫Marker.
‫Position.
‫I will specify the title called M2 Position M2.
‫And I will create also here.
‫For Sydney.
‫Position.
‫Sorry.
‫Anywhere.
‫Okay.
‫This is the marker called anywhere.
‫So what happens now?
‫We have created two objects.
‫Two markers, A to let lungs.
‫And we have created two markers.
‫First.
‫First one called anywhere.
‫I will specify it as M one.
‫And one and M2.
‫Called M2.
‫And two and two, and I will move the camera towards the M1.
‫First.
‫And then we will move the camera to M2.
‫So here is the first one if I click on it title.
‫M1 And here is the second marker called M2.
‫But if you notice that the app first created or create or own map already, it moves the camera towards
‫this and put it into the center.
‫Now let's try to move it to to make the marker to as our center let's create a by changing this.
‫And let's see.
‫And here we go.
‫It is centered and as M2 and here the M1.
‫So moving the camera could be specified by using this line of code.
‫Map, dot move, camera dot, camera, update factory dot new lat long and we specify the marker or
‫the lat long that we are going to see or make it as a center.
‫So.
‫We let's go back and look again about our on our code and see that we have a method called on map ready.
‫So on map ready here is called when the map is ready.
‫And it is very important method that all our program programming on coding will take place inside this
‫method.
‫So forget about oncreate.
‫We have now the on map ready that passes an argument.
‫Of type Google map and object of type.
‫Of type.
‫Google map and called map.
‫Map now.
‫Let's now see that display information about the marker, as I told you.
‫When I click on this method, on this marker, a box is displayed.
‫This box is called this box is called information window.
‫Info window for the marker.
‫So next video will be about making an custom customizable or info windows and for the markers.
‫So please subscribe to our YouTube channel and rate us five stars so you don't miss anything for the
‫next tutorials.
‫Now.
‫Let's continue with the markers and see how powerful are the usage of these markers.
‫Now, I will put here a simple a simple code, making it a draggable.
‫So let's see map.
‫I prefer putting this.
‫We have a lot of a lot of properties now we will see.
‫First of all, draggable draggable equal.
‫True.
‫So.
‫I Now we can make and move the markers on our on our map.
‫So I'm making it a draggable.
‫So I'm one.
‫When I long press on it, it will be at draggable.
‫Now let's create a new one.
‫Alpha.
‫Alpha will specify a float which is or passes a float, which is the the point of or the degree of transparency
‫for this for this marker.
‫Now let's put alpha.
‫Equal set the opacity of the marker.
‫Its default is 1.0 and you see the alpha markers is a is like gone and be white.
‫Let's see again.
‫And now it is brighter.
‫Let's try a.
‫1 or 2.
‫Okay.
‫And here we go.
‫We have a changing the opacity for it.
‫Now.
‫We see that?
‫The marker passes the position, which is a method, and that passes and it is very and it is required
‫method and passes the lat long for displaying this marker.
‫We see the anchor, the alpha and the title.
‫Now let's learn about something new called snippet.
‫So what is snippet additional text that displays below the title?
‫So let's try Welcome.
‫Or subscribe to our channel.
‫Let's.
‫Run it.
‫And see.
‫Whereas snippets are displayed, click on the marker and here we go.
‫Subscribe to our channel.
‫Okay, so this is the functionality for the snippet.
‫Now we have.
‫Also an additional additional properties for it called icon.
‫Icon We can specify icons for for our markers by using this.
‫Draw.
‫Let's r dot drawable dot let's say I launcher and descriptor.
‫It's provided by okay requires type is bitmap descriptor.
‫Okay.
‫You can specify icons.
‫We make a new a let's see.
‫Okay.
‫I have copied this PNG, this icon into my drawable folder and I will create now icon.
‫Dot icon and I will pass Bitmap descriptor factory and I will load it from resources and pass the r
‫dot drawable dot girl.
‫Now let's run it and see the icon for the marker.
‫Okay, it has been changed and if I click on it, it will display.
‫It will display a one.
‫So this is the marker and this is the icon for it.
‫If I remove.
‫It will again comes into its default one.
‫Okay.
‫Now another.
‫Another interesting thing about markers is called visible.
‫Visible.
‫And if I pass it a false, it will not be a allow the user to move the marker set.
‫True.
‫If you want to allow the user to move the marker and default will be false.
‫It is gone.
‫And.
‫A flat or orientation.
‫We can use rotation methods.
‫So in order to rotate that, in order to rotate the marker, we can we can make we can make it as a
‫rotation and anchor.
‫So what our rotation and what is anchor.
‫Now I will pass.
‫I will call rotation method and I will pass a float called Let's 90 degrees.
‫Let's try it.
‫Irritation.
‫Okay.
‫Rotation 90.
‫Let's see.
‫And here we go.
‫We see that the marker is rotated 90 degrees and if I click, it will display a one.
‫There is another special and interesting property called Z Index.
‫So what is Z index?
‫Z index sets the marker Z index on markers of an object by calling the Z index method as shown in or
‫as I will show you in the next step so that the Z index specifies a stack order of this marker relative
‫to other markers on the map.
‫A map or a marker with a high Z index is thrown at top of markers was lower Z index.
‫If you have a cluster or many markers, you can use the Z index.
‫So in order to use it, I will specify here.
‫Dot z index and I will pass 1.0.
‫F is taking or passing a float number.
‫Okay, nothing has changed.
‫But if you want, if you or you have many markers, you will see the difference.
‫We will see in next tutorials how to add a marker click event or marker.
‫Click a marker, drag events, long press and many other tutorials.
‫So if you want to these tutorials, rate us five stars on Udemy, Subscribe to our YouTube channel,
‫hit like and subscribe and you will get them freely.
‫Thank you guys.
‫See you next videos.
‫See you in next videos.
‫See you next video.