2011-03-23 5 views
0

나는 사용자가 걸은 길을 그리는 코드를 작성하려고합니다. 사용자가 통과 한 모든 좌표를 가져올 수 있으므로 드로잉로드를 구현해야합니다. 그러나 그것을하기 전에 실제 좌표를 픽셀로 BB 화면에 전달하는 방법을 알아야합니다. 그것에 관한 정보를 좀 주시겠습니까? 좌표를 BB 화면 픽셀로 변환하는 방법은 무엇입니까?

여기에 당신에게 내가 길의 모든 좌표를 가지고이 코드를

감사드립니다. 다음

public RoutePaint() { 

    locations = new Vector(); 
    locVector = new ButtonField("Locations Vector", 
      ButtonField.CONSUME_CLICK); 
    locVector.setChangeListener(this); 

    pixel.setChangeListener(this); 
    add(locVector); 
    add(pixel); 

    myCriteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_AUTONOMOUS); 
    try { 
     myProvider = (BlackBerryLocationProvider) LocationProvider 
       .getInstance(myCriteria); 

    } catch (LocationException e) { 

     e.printStackTrace(); 
    } 
    myProvider.setLocationListener(this, 3, -1, -1); 



} 

public void locationUpdated(LocationProvider provider, Location location) { 
    // TODO Auto-generated method stub 
    point = new Point(); 
    latitude = location.getQualifiedCoordinates().getLatitude(); 
    altitude = location.getQualifiedCoordinates().getAltitude(); 
    longitude = location.getQualifiedCoordinates().getLongitude(); 
    velocity = location.getSpeed(); 
    point.x = latitude; 
    point.y = longitude; 

    locations.addElement(point); 

    invalidate(); 
} 

답변

0

픽셀을 화면 좌표로 변환하는 코드 :

우리 변수 _latitude 및 _longitude respectively.integer 변수 X와 Y 변환 된 화면으로 구성에서 해당 위도와 경도를 저장한다고 가정
   XYPoint _xypoint = new XYPoint(); 
      Coordinates coords = getCoordinates(); 
     coords.setLatitude(Double.parseDouble((String) _latitude); 
     coords.setLongitude(Double.parseDouble((String) _longitude); 


     convertWorldToField(coords,_xypoint); 
      int x = _xypoint.x; 
      int y = _xypoint.y; 

픽셀 좌표.

관련 문제