2

我正在使用 sygic 地图。当我尝试在 sygic 地图中获取位置时,我什么也得不到。我的代码如下:

boolean satInfo = true;
int maxTime = 0;
GpsPosition gpsPos = new GpsPosition();
gpsPos = ApiNavigation.getActualGpsPosition(satInfo, maxTime);
Position pos = new Position();
pos.setPosition(gpsPos.getLongitude(), gpsPos.getLatitude());
strCurrAddress = ApiLocation.getLocationAddressInfo(pos, maxTime);
Log.e("GpsPosition", "Error code:" + strCurrAddress);
edtAddress.setText(strCurrAddress); 

您的回答将不胜感激。

4

1 回答 1

0

这可能是可能的解决方案:

GetAddress();

void GetAddress()
{
    int lat;
    int lon;
    GetActualGpsPosition(true, out lat, out lon);
    string address = ReverseGeoCode(lat, lon);
    Debug.WriteLine("address:" + address);
}

public void GetActualGpsPosition(bool bSatellitesInfo, out int lat, out int lon)
{
    SError err;
    SGpsPosition gpos = new SGpsPosition();
    int ret = CApplicationAPI.GetActualGpsPosition(out err, out gpos, bSatellitesInfo, 0);
    lat = gpos.Latitude;
    lon = gpos.Longitude;
}

string ReverseGeoCode(int lat, int lon)
{
    string strAddress;
    SError err;
    LONGPOSITION lp = new LONGPOSITION(lon, lat);
    SRoadInfo sri = new SRoadInfo();
    int ret = CApplicationAPI.GetLocationInfo(out err, lp, out strAddress, out sri, 0);
    if (ret != 1)
    {
        return "";
    }
    return strAddress;
}
于 2016-03-09T07:09:41.897 回答