【问题标题】:Problems with addRoute on maps (iOS7) with Appcelerator Titanium使用 Appcelerator Titanium 在地图(iOS7)上的 addRoute 问题
【发布时间】:2013-12-27 23:34:09
【问题描述】:

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

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

项目使用Alloy...视图文件(index.xml)很简单:

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

而控制器文件是:

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 上搜索了一个解决方案,但我测试了几个解决方案,但似乎没有一个有效。我没有任何关于如何解决它的线索。

有人可以帮忙吗?

提前致谢!!!

【问题讨论】:

    标签: ios crash maps titanium appcelerator


    【解决方案1】:

    你应该使用 ti.map 对象的 createRoute 方法来添加路由。

    【讨论】:

      【解决方案2】:

      试着去掉括号,让 mySpecialRoute 变成一个对象:

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

      【讨论】:

      • 不...我终于设法更好地阅读了文档,我注意到将路线添加到地图的方式发生了变化。我将发布 WORKING 代码的最终版本。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-13
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多