我已经使用surface视图将sygic集成到我的android应用程序中。我想在那个sygic应用程序中导航。我用过这个代码:

SWayPoint wp = new SWayPoint();
wp.Location = new LONGPOSITION(34, 35);
ApplicationAPI.StartNavigation(err, wp, 0, true, false, MAX);

但它不起作用。有什么想法吗?

最佳答案

我曾经在一个应用程序中实现过sygic,这基本上就是我的代码的样子(经过几个小时的调试,因为文档很差…):

// surfaceView for displaying the "map"
SurfaceView mSygicSurface = (SurfaceView) findViewById(R.id.sygic_surface); // surface

// api status
int mSygicAPIStatus = -2;

// start the drive
ApplicationAPI.startDrive(new ApiCallback() {
    public void onRunDrive() {
        mSygicSurface.post(new Runnable() {
            public void run() {
                runDrive(mSygicSurface, getPackageName());
            }
        });
    }

    public void onInitApi() // gets called after runDrive();
    {
        mSygicAPIStatus = ApplicationAPI.InitApi(getPackageName(), true, new ApplicationHandler() { /* nothing relevant here */ }); // api initialization

        if (mSygicAPIStatus != 1) {
            // error
            return;
        }
    }
});

一旦你想在某个地方导航:
GeoPoint point = new GeoPoint(/* ... */, /* ... */);
final SWayPoint wayPoint = new SWayPoint("", point.getLongitudeE6(), point.getLatitudeE6());
SError error = new SError();
final int returnCode = ApplicationAPI.StartNavigation(error, point, NavigationParams.NpMessageAvoidTollRoadsUnable, true, true, 0);

请注意,Sygic使用E6坐标。

07-27 13:56