4

すべて-オーバーレイアイテムを使用して地図上に表示するよりも、ユーザーの現在地を取得しようとしています。私の問題は、ユーザーの場所が場所として入力され、オーバーレイ配列がGeoPointのみを受け入れることです。これが私が試したことです:

LocationListener locationListener = new LocationListener() {
        public void onLocationChanged(Location location) {      
            GeoPoint point = new GeoPoint.valueOf(location);
            OverlayItem overlayitem4 = new OverlayItem(point, "You Are Here", "Boulder, CO");               
        }

しかしGeoPoint.valueOf(location);、具体的には次のエラーが発生します。

GeoPoint.valueOfをタイプ`に解決できません

だから私の質問は、どうすれば場所からGeoPointに変換できますか?いつもありがとうございました。

4

2 に答える 2

10

これを試して

LocationListener locationListener = new LocationListener() {

     public void onLocationChanged(Location location) {      
         int lat = (int) (location.getLatitude() * 1E6);
         int lng = (int) (location.getLongitude() * 1E6);
         GeoPoint point = new GeoPoint(lat, lng);
         OverlayItem overlayitem4 = new OverlayItem(point, "You Are Here",   "Boulder, CO"); 
     }
}
于 2012-07-29T17:08:59.217 に答える
2

これは私にとってはうまくいきました、そしてそれははるかに簡単なようです:

GeoPoint geoPoint = new GeoPoint(location);
于 2013-06-30T03:52:32.717 に答える