如何从sygic地图获取当前位置到android?

时间:2016-03-09 07:06:03

标签: android geolocation sygic

我正在使用sygic map。当我试图在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); 

您的回答将不胜感激。

1 个答案:

答案 0 :(得分: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;
}