构造函数GeoPoint(double,double)未定义.这有什么问题?

J.O*_*sen 1 android

我有错误:"构造函数GeoPoint(double,double)未定义".为什么会这样?怎么做对了?据我所知,所有必要的库链接,语法似乎是正确的.

package com.fewpeople.geoplanner;

import android.app.Activity;
import android.os.Bundle;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

public class GeoplannerActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final MapView mMapView = (MapView) findViewById(R.id.mapview);

     MapController mMapController = mMapView.getController();

     double x, y;
     x= 60.113337;
     y= 55.151317;

     mMapController.animateTo(new GeoPoint(x, y));

     mMapController.setZoom(15);

    }

    protected boolean isRouteDisplayed() {
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

Ian*_*ton 5

GeoPoint采用两个整数,它们是微度的coords.为简单起见,我使用此方法:

/**
 * Converts a pair of coordinates to a GeoPoint
 * 
 * @param coords double containing latitude and longitude
 * @return GeoPoint for the same coords
 */
public static GeoPoint coordinatesToGeoPoint(double[] coords) {
    if (coords.length > 2) {
        return null;
    }
    if (coords[0] == Double.NaN || coords[1] == Double.NaN) {
        return null;
    }
    final int latitude = (int) (coords[0] * 1E6);
    final int longitude = (int) (coords[1] * 1E6);
    return new GeoPoint(latitude, longitude);
}
Run Code Online (Sandbox Code Playgroud)

此外,您的Activity应该扩展MapActivity.