2012-07-31 58 views
0

我从使用mylocation类的GPS提供商获取数据。代码是这样的:Android mapview的地点差异模拟器和设备

MyLocation.LocationResult locationResult = new MyLocation.LocationResult() { 
     @Override 
     public void gotLocation(Location location) { 
      //Got the location! 

      // for phone 
      //currentLocation = new GeoPoint((int) (location.getLatitude() * 1000000), 
      // (int) (location.getLongitude() * 1000000)); 

      // for emulator 
      currentLocation = new GeoPoint((int) (location.getLatitude()), 
        (int) (location.getLongitude())); 

      doSomething(); 

     } 
    }; 
    MyLocation myLocation = new MyLocation(); 
    myLocation.getLocation(this, locationResult); 

当我在模拟器(2.3.3)中使用应用程序时,它显示正确的位置而不会乘以任何东西。

但是当我使用它在一个设备(4.0)lat和lon需要乘以1000000.我无法找到原因。我不认为它是因为android的版本。任何人有任何想法?

回答

0

因为MapView的单位使用了microdegress,所以你需要乘以1e6。否则,你出现在非洲海岸 - 基本上LAT长大约0,0

从上GeoPoint的文档:

,不可变的类代表一对纬度和经度,存储为整数微度。

不知道为什么模拟器工作 - 它不应该。

+0

我按照你的说法试过,但它不能在模拟器中工作。如果设备没有问题,如果它只在模拟器上出现问题,那对我来说就没有问题。有没有可能在每个设备上表现出不同的表现?例如对于android 2.3和4.0? – eluleci 2012-07-31 18:20:13

+0

不应该根据文档 – Kaediil 2012-07-31 18:21:52

相关问题