Adam Varhegyi
Adam Varhegyi

Reputation: 9894

How to convert Latitud and Longitud to Google GeoPoint?

How to convert Latitud and Longitud to Google GeoPoint?

My Latitud is: 47.523009954564536 My Long is : 19.01667991207027

And when i try to convert to GeoPoints with:

GeoPoint point = new GeoPoint((int)(latitude * 1e6),
                              (int)(longitude * 1e6));

the results are: 4.7523009E7 1.901671E7

Which is clearly wrong cause im not typing from the Gulf of Guinea (Africa) I need values tarts with the 47 and 19 integers not 4. and 1. decimals.

I saw this kind of convertation in many pages but somehow its not good for me. Help please !

Upvotes: 1

Views: 2940

Answers (2)

MAC
MAC

Reputation: 15847

GeoPoint = new GeoPoint((int)(22.30 * 1E6),(int)(70.80 * 1E6));

try this it works...

Upvotes: 0

Devan Somaia
Devan Somaia

Reputation: 645

There may be a casting error, try and use this method:

public static GeoPoint calculateGeoPoint(double latitude, double longitude) {
    Double latE6 = latitude * 1E6;
    Double lngE6 = longitude * 1E6;
    return  new GeoPoint(latE6.intValue(), lngE6.intValue());
}

taken from this post

thanks.

Upvotes: 1

Related Questions