0

I am making a application in android on Google map using Google API V2. Map show my current location very nicely when click on marker. Now i want to move marker (want to be a car image in place of marker). when ever i move from one location(source/current location) to another(destination). This car image should be move regularly on Map.e.g in below image. And on my destination when i click the car image it show me destination address. I Google it too much for that i found different stackoverflow, tutorails but they didn't meet my requirements exactly. May be i am goggling in wrong direction.

Please help me in form of tutorials, stacksoverflow or any other and also with some detail that how can i complete this task in my application.

enter image description here

user3283148
  • 101
  • 4
  • 13

2 Answers2

0

This topic tells you how to add an image of a car to your marker, using an imageView. Also, you probably want to use an onLocationChanged method within a LocationListener like this:

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tracking);
        LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.requestLocationUpdates(
                    LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
        }

    LocationListener locationListener = new LocationListener() {
        public void onLocationChanged(Location location) {
             latitude = location.getLatitude();
             longitude = location.getLongitude();
             latLng = new LatLng(latitude, longitude);
        }
    }

and add a function within the same onLocationChanged method to set the location of the marker using latLng or latitude and longitude.

This page also has information and an example about custom markers, mostly found at the bottom, just above the simulator image.

Hope this helps!

Community
  • 1
  • 1
Matthijs
  • 71
  • 8
0
  1. Use the image of a car as a marker for your current location.
  2. Request location updates using a LocationListener.
  3. Get location updates in the onLocationChanged method.
  4. Animate the camera to the the new location.
todd
  • 1,266
  • 1
  • 13
  • 20