我正在尝试使用addRoute函数在iOS7上向 map 添加路线,但应用程序始终崩溃(无效类型传递给index.js的函数)。

我正在使用Titanium SDK 3.2,并在OSX Mavericks(Titanium Studio 3.2)上使用了iOS 7模拟器。

该项目使用Alloy ... View 文件(index.xml)非常简单:

<Alloy>
    <Window id="mainWindow" />
</Alloy>

Controller 文件为:
var MapModule = require('ti.map');

var testPoints = [
    {latitude:38.713794262212076, longitude:-9.13338303565979},
    {latitude:38.763495, longitude:-9.093763},
    {latitude:38.71371054721669, longitude:-9.160258769989014},
    {latitude:38.69162310730725, longitude:-9.215952157974243},
    {latitude:38.7099432709518, longitude:-9.132546186447144},
    {latitude:38.71203413379506, longitude:-9.140643775463104},
];

var mySpecialRoute = ({
    name: 'personal route',
    points: testPoints,
    color: 'red',
    width : 3
});

var mapview = MapModule.createView({
    animate:true,
    mapType: MapModule.NORMAL_TYPE,
    regionFit: true,
    userLocation: true,
});

$.mainWindow.add(mapview);
mapview.addRoute(mySpecialRoute);
$.mainWindow.open();

控制台上的错误输出为:
[ERROR] :  Script Error {
[ERROR] :      backtrace = "#0 () at :0";
[ERROR] :      line = 54;
[ERROR] :      message = "Invalid type passed to function";
[ERROR] :      nativeLocation = "-[TiMapViewProxy addRoute:] (TiMapViewProxy.m:364)";
[ERROR] :      nativeReason = "expected: TiMapRouteProxy, was: Object";
[ERROR] :      sourceId = 323619520;
[ERROR] :      sourceURL = "file:///Volumes/UserData/carlosserrao/Library/Application%20Support/iPhone%20Simulator/7.0.3/Applications/6B21A7E6-1636-473E-9F45-33A70158A0CE/hugacity.app/alloy/controllers/routemap.js";
[ERROR] :  }

我已经在Internet上搜索了一种解决方案,但是我已经测试了几种解决方案,但似乎没有一个可行。我没有任何解决办法的线索。

有人可以帮忙吗?

提前致谢!!!

最佳答案

尝试删除括号,以使“特殊路线”成为对象:

var mySpecialRoute = {
    name: 'personal route',
    points: testPoints,
    color: 'red',
    width : 3
};

关于ios - 使用Appcelerator Titanium的 map (iOS7)上的addRoute问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20809271/

10-11 22:16
查看更多