我尝试在 iOS7 上使用 addRoute 函数向 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 上搜索了一种解决方案,但我测试了几种解决方案,但似乎没有一个有效。我不知道如何解决它。
有人可以帮忙吗?
提前致谢!!!
最佳答案
您应该使用 ti.map 对象的 createRoute 方法来添加路线。
关于ios - 使用 Appcelerator Titanium 在 map (iOS7) 上添加路线的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20809271/