Как я могу получить текущее местоположение с sygic карты в Android?
Я использую 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 ответ
Это может быть возможным решением:
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;
}