Markers–Google Maps Android API v2

This Android tutorial will show how to use markers to display positions using Google maps Android API v2. We will also see features related to using markers like changing the default color, replacing the default icon with a custom icon-image, allow user to drag the marker, show our current position using marker and related event listeners like on-marker-click and on-marker-drag.

Allow User to move Android Marker

Show Current Location using Marker

To add a marker to the current location, we need to know the LatLng. Refer the get current location in Android tutorial to find the current LatLng and using that we can add the marker easily as shown above.

Marker Event Listeners

Lets see two main event listeners related to markers OnMarkerClickListener and OnMarkerDragListener. We need to implement these interfaces and add its instance to the GoogleMap instance to track the events.

On Marker Click

OnMarkerClickListener has one method onMarkerClick to be implemented. Using the Marker instance passed as argument we can know which marker is clicked.

On Marker Drag

OnMarkerDragListener has got three methods to be implemented. onMarkerDragStart, onMarkerDrag and onMarkerDragEnd. Use onMarkerDrag method cautiously as it will be invoked all through the drag position.

hi buddy there is problem .when i add the location name then marker at that location is drawn but below google map is not shown .. i have integrated the map in the app but it is visible up to limited area ..if i enter the location name shown on the map on below screen then marker is drawn n the map is visible too but if i enter the location name which is not visible on the map below at the current time then the map will move to that location n draw marker on that but map is not changing it still visible to that area at the begining time what is the problem how can i show the map on the desired location

Really very nice tutorial, I try all the sample google application. Everything Working fine Joe, Thank for you turtorial. Will you post application using BashAdapter and Sliding. It will really helpful us…

sir v nice tutorial ,i wanted to ask you , can you help me in showing distance inside the infowindow ??
like when i click on the marker , it shows the places names but i also want to display the distance : 2km below the name of the place
Do you have such tutorial ?
thanking you