PixelCalculator without creating an Overlay

Tutorials that use the MapActivity. Many using GPS functionality.

PixelCalculator without creating an Overlay

Postby temo » Fri Apr 18, 2008 7:16 pm

Hi...I was wondering if it was possible to create a PixelCalculator object without creating an Overlay.
I am just interested in finding out the xyCoordinates of two long/lat points, but don't want to draw anything.

I keep seeing people telling others to use the PixelCalculator class for xy, but i am not sure how to create one without creating an overlay.

Thanks.
temo
Freshman
Freshman
 
Posts: 3
Joined: Fri Apr 18, 2008 7:14 pm

Top

Postby temo » Sun Apr 27, 2008 3:11 am

i came up with rough estimate...the math is probably different from how the official calc does it (its off a little by what appears to be rounding)...anyways it seems sufficient to me and i figured other people may find it useful...also it probably only works in north america (northern/western hemisphere...lol)


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         private void getPointXY(MapView map, Point p, int[] xy){
  3.  
  4.                 Point mapCenter = map.getMapCenter();
  5.  
  6.                
  7.  
  8.                 int mapWidth = map.getWidth();
  9.  
  10.                 int longSpan = map.getLongitudeSpan();
  11.  
  12.                 xy[0] = (int) (mapWidth*(p.getLongitudeE6()-mapCenter.getLongitudeE6()+longSpan/2.0)/longSpan);
  13.  
  14.                
  15.  
  16.                 int mapHeight = map.getHeight();       
  17.  
  18.                 int latSpan = map.getLatitudeSpan();
  19.  
  20.                 xy[1] = (int) (mapHeight*(-p.getLatitudeE6()+mapCenter.getLatitudeE6()+latSpan/2.0)/latSpan);
  21.  
  22.         }
  23.  
  24.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
temo
Freshman
Freshman
 
Posts: 3
Joined: Fri Apr 18, 2008 7:14 pm

Top

Return to Map Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests