Problem with getLatitudeSpan() and getLongitudeSpan()

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

Problem with getLatitudeSpan() and getLongitudeSpan()

Postby dilorc » Mon Oct 06, 2008 10:35 pm

I'm having a problem with getLatitudeSpan() and getLongitudeSpan(). When I use them, they are returning a span of 0 for latitude and 360000000 for long. That is not accurate :)

Here's the code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(R.layout.basic_map);
  2.  
  3.                 mMapView=(MapView) findViewById(R.id.basic_map);
  4.  
  5.                 Log.v("GeoCacheMapActivity","lat span="+mMapView.getLatitudeSpan());
  6.  
  7.                 Log.v("GeoCacheActivity","lon span="+mMapView.getLongitudeSpan());
  8.  
  9.                
  10.  
  11.                 LinearLayout zoomLayout=(LinearLayout) findViewById(R.id.basic_map_zoom);
  12.  
  13.                 zoomLayout.addView(mMapView.getZoomControls(), new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
  14.  
  15.                
  16.  
  17.                 GeoPoint p=new GeoPoint(39156460,-77169915);
  18.  
  19.         MapController mc=mMapView.getController();
  20.  
  21.         mc.setCenter(p);
  22.  
  23.         mc.setZoom(14);
  24.  
  25.         Log.v("GeoCacheMapActivity","lat span="+mMapView.getLatitudeSpan());
  26.  
  27.         Log.v("GeoCacheMapActivity","lon span="+mMapView.getLongitudeSpan());
Parsed in 0.033 seconds, using GeSHi 1.0.8.4



As you can see, I'm trying to get the values twice. Both times they return the values above. The map displays fine...it centered where I wanted and the zoom is right. getMapCenter() (or whatever the method is) works with no problem.

Help!

Thanks.
dilorc
Freshman
Freshman
 
Posts: 2
Joined: Mon Oct 06, 2008 10:29 pm

Top

Postby plusminus » Tue Oct 07, 2008 3:55 am

Hey dilorc,

I personally gave up using the rawvalues returned from getLatitudeSpan/getLongitudeSpan, they just were not accurate enough. But they have not yet been that bad ;)

Maybe they are not updated instantly after setting zoom and centering. So maybe add the request to a button-click or sth...

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Re: Problem with getLatitudeSpan() and getLongitudeSpan()

Postby pedroteixeira07 » Sat Jun 26, 2010 4:29 pm

does anyone have a solution for this yet? Or another way to get the bounds of the screen?
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Re: Problem with getLatitudeSpan() and getLongitudeSpan()

Postby bikeroute » Sat Jun 26, 2010 7:38 pm

There's a question on stackoverflow that's relevant to your problem and a somewhat hacky solution - http://stackoverflow.com/questions/2667 ... ot-working

Where are you calling getLatitudeSpan() etc?
User avatar
bikeroute
Freshman
Freshman
 
Posts: 4
Joined: Sat Jun 26, 2010 2:51 pm
Location: UK

Re: Problem with getLatitudeSpan() and getLongitudeSpan()

Postby pedroteixeira07 » Sat Jun 26, 2010 8:06 pm

onCreate()
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Re: Problem with getLatitudeSpan() and getLongitudeSpan()

Postby pedroteixeira07 » Sat Jun 26, 2010 8:16 pm

I've checked the post.. I'm afraid my Android knowledge isn't enough to go from there.. sounds very hacky.. I was hoping for this to be advanced enough to get the results as we need it.. Do you think if I load the map.. and then create some kind of event to trigger the code that uses the spans would work, like that it would give time to start etc? Though it wasn't my initial idea.. I'm spending so much time in this part I'm desperate..
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Top

Re: Problem with getLatitudeSpan() and getLongitudeSpan()

Postby pedroteixeira07 » Sat Jun 26, 2010 8:22 pm

I've searched for Zoom/pan event listeners but I guess that's something which is lacking also still..
pedroteixeira07
Experienced Developer
Experienced Developer
 
Posts: 74
Joined: Sun Oct 18, 2009 6:06 pm
Location: Funchal

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 5 guests