使用PhoneGap(iOS)为Sygic创建一个itenerary

时间:2015-06-15 13:58:00

标签: java c# ios cordova sygic

研究早期的帖子我知道我正在尝试通过它的自定义URL方案创建一个到Sygic的预定义路由。基础工作。我在我非常基本的PhoneGap中添加了这个命令:

<a href="com.sygic.aura://coordinate|5.6784149|52.8759607|drive">

这将打开应用程序并启动路线计算。是啊!第一步完成;)

现在我想添加一个via点。 Sygic网站给了我两个选项,但如何在我的phonegap中实现这些?任何帮助表示赞赏

1:C#

NavigateToItinerary("Itinerary1");

void NavigateToItinerary(string strName)
{
SError err;
int flags = 0;
bool bShowApplication = true;
int maxTime = 0;

SStopOffPoint[] points = new SStopOffPoint[3]; //an array of SStopOffPoint

points[0] = new SStopOffPoint();        //initialization
points[0].Location.lX = 1341555;        //GPS position, x-coordinate multiplied by 100 000
points[0].Location.lY = 5252462;        //GPS position, y-coordinate multiplied by 100 000
points[0].nPointType = 3;               //type 3 = start
points[0].SetCaption("Starting point"); //caption

points[1] = new SStopOffPoint();
points[1].Location.lX = 1340753;
points[1].Location.lY = 5252390;
points[1].nPointType = 2;               // type 2 = finish point
points[1].SetCaption("Finish point");

points[2] = new SStopOffPoint();
points[2].Location.lX = 1340780;
points[2].Location.lY = 5251871;
points[2].nPointType = 1;                //type = 1 for visible waypoint, 4 for invisible waypoint
points[2].SetCaption("Via Point");

int ret = CApplicationAPI.AddItinerary(out err, points, strName, maxTime); //API function for adding itinerary
if (ret == 1)
    Debug.WriteLine("Itinerary created successfully.");

ret = CApplicationAPI.SetRoute(out err, strName, flags, bShowApplication, maxTime);
if (ret == 1)
    Debug.WriteLine("Routing finished successfully.");
}

或2:Java

import com.sygic.sdk.remoteapi.Api;
import com.sygic.sdk.remoteapi.ApiItinerary;
import com.sygic.sdk.remoteapi.exception.GeneralException;
import com.sygic.sdk.remoteapi.model.StopOffPoint;
...
try {
String strItineraryName = "Itinerary1"; //itinerary name
int MaxTime = 0;
int flags = 0;
ArrayList<StopOffPoint> PointArr = new ArrayList<StopOffPoint>();
PointArr.add(new StopOffPoint(false, false, StopOffPoint.PointType.START, 1710726, 4814623, -1, 0, "", "ba", ""));
PointArr.add(new StopOffPoint(false, false, StopOffPoint.PointType.VIAPOINT, 1739716, 4821671, -1, 0, "", "senec", ""));
PointArr.add(new StopOffPoint(false, false, StopOffPoint.PointType.FINISH, 1759511, 4837351, -1, 0, "", "trnava", ""));
ApiItinerary.addItinerary(PointArr, strItineraryName, MaxTime);
ApiItinerary.setRoute(strItineraryName, flags, MaxTime);
} catch (GeneralException e) {
Log.e("Itinerary", "Error code:"+ e.getCode());
}

0 个答案:

没有答案