Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What corresponds geopoint in Android Google Map API V2?

Previously, I created a class that extends GeoPoint in Android Map API v1:

class CyclePoint extends GeoPoint {
    public float accuracy;
    public double altitude;
    public float speed;
    public double time;

    public CyclePoint(int lat, int lgt, double currentTime) {
        super(lat, lgt);
        this.time = currentTime;
    }

    public CyclePoint(int lat, int lgt, double currentTime, float accuracy) {
        super(lat, lgt);
        this.time = currentTime;
        this.accuracy = accuracy;
    }

    public CyclePoint(int lat, int lgt, double currentTime, float accuracy, double altitude, float speed) {
    super(lat, lgt);
    this.time = currentTime;
    this.accuracy = accuracy;
    this.altitude = altitude;
    this.speed = speed;
    }
}

Now I am switching to V2, what should I extend? Should it be LatLng? But when I switch to LatLng, it says: The type CyclePoint cannot subclass the final class LatLng. Can anyone help me with this? Thanks so much!

like image 688
Anhong Avatar asked Oct 30 '13 17:10

Anhong


Video Answer


2 Answers

The LatLng object! http://developer.android.com/reference/com/google/android/gms/maps/model/LatLng.html

this object is very useful! u just have to create a instance

ex:
    LatLng home = new LatLng(-34.3232,-8.31331); // instanciate a new Latlng
    home.getLatitude();  // get latitude
    home.getLongitude(); // get longitude

ps: Latitude and Longitude have to be double type.

like image 199
Thiago Souto Avatar answered Oct 04 '22 20:10

Thiago Souto


Use composition instead of inheritance, i.e. make LatLng a field in your CyclePoint.

like image 32
MaciejGórski Avatar answered Oct 04 '22 20:10

MaciejGórski