Geopoint error

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Geopoint error

Postby maverick1989 » Thu Oct 14, 2010 9:55 pm

I am using geopoint to assign latitude and longitude coordinates to a geopoint object (code below)
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         GeoPoint point = new GeoPoint(
  2.                                         (int)(location.getLatitude() * 1E6),
  3.                                         (int)(location.getLongitude() * 1E6));
  4.                         mapController.animateTo(point);
  5.                         mapController.setZoom(17);
  6.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


I am using the DDMS to change my location since I am working on the emulator. The lat and long values that are returned from the DDMS are different from the lat and long values that my map centers to. There are too many places after the decimal point in the actual value returned and as a result the map is moving to a different location than what I want it to.

Is this a DDMS issue? Will this work fine on a real phone?

Thanks.
maverick1989
Junior Developer
Junior Developer
 
Posts: 14
Joined: Wed Feb 24, 2010 4:11 am

Top

Re: Geopoint error

Postby so.r.u » Fri Oct 15, 2010 10:02 am

I think I got a similar problem, but I'm not using DDMS. My code looks like this:
Code: Select all
GeoPoint toGo = new GeoPoint(52, -2);
mapView.getController().animateTo(toGo);
Log.d(TAG,"Set to: lat = " + toGo.getLatitudeE6()+ ", lng = " + toGo.getLongitudeE6());
Log.d(TAG,"center now: lat = " + mapView.getMapCenterLatitudeE6()+ ", lng = " + mapView.getMapCenterLongitudeE6());


So I for example wanna set the map center to 52./-2., but the LogCat output shows it doesn't do what I want :(

Code: Select all
10-15 10:59:56.175: DEBUG/MapActivity(14337): Set to: lat = 52000000, lng = -2000000
10-15 10:59:58.169: DEBUG/MapActivity(14337): center now: lat = 1406108, lng = -1406250


Anyone an idea?
Thanks!
so.r.u


edit: it works when not in debugging mode..!

edit2: but it doesn't work when called in onCreate()
so.r.u
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Mar 01, 2010 2:02 pm

Re: Geopoint error

Postby maverick1989 » Fri Oct 15, 2010 4:53 pm

Your error has to do with the fact that you are hardcoding your lat and long values. Geopoint takes them microdegrees and then multiplies them by 1E6. Try putting in 0.000056 and -0.000002.
maverick1989
Junior Developer
Junior Developer
 
Posts: 14
Joined: Wed Feb 24, 2010 4:11 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests