映射路由在Titanium Appcelerator中不起作用

时间:2014-04-07 20:15:04

标签: google-maps google-maps-android-api-2 titanium-mobile appcelerator titanium-alloy

我在Android上使用Maps Route和Maps V2时遇到了一些问题。所以问题是当我提出一条路线时,就像这样:

var cord1= {
    latitude:29.078685,
    longitude:-110.971205,
};
var cord2= {
    latitude:29.081496,
    longitude:-110.959232,
};

var route1 = [cord1, cord2];
var route = MapModule.createRoute({
        points : route1,
        color : "red",
        width : 5.0
});

$.mapview.addRoute(route);

是的,现在我的地图上有一张地图路线,但路线笔直,完全笔直

Picture of the map route

路线没有使用街道,只是一条直线,根本没有黑貂,你能帮助我吗?

我的规格:

  

Mac OS Maverick

     

模块:Ti.map(API V2)

     

Titanium SDK 3.2.2.GA

     

Titanium Studio,版本:3.2.1.201402041146

     

(c)Appcelerator,Inc。2012-2013版权所有。

     

构建:jenkins-titanium-rcp-master-95(origin / master)   日期:2014年2月4日,11:47:38

3 个答案:

答案 0 :(得分:1)

您需要更多的坐标,而不仅仅是一个开始,而是介于两者之间。由于这只是一条路线,因此您的坐标必须连续存储在一个数组中。创建路径时,该数组应用于points属性。以下是来自appecelerator文档的示例,路由示例位于页面的最底部:http://docs.appcelerator.com/titanium/3.0/#!/guide/Native_Maps_and_Annotations

像这样:

var _points = []; // The array used to contain the points in a route
//Your coordinates
var cord1= {
    latitude:29.078685,
    longitude:-110.971205,
};
_points.push(cord1);

var cord2= { 
     latitude:29.081496, 
     longitude:-110.959232, 
};
_points.push(cord2);

// Create your route 
var route = MapModule.createRoute({ 
      points : _points, 
      color : "#f00", 
      width : 5.0 
 });
// Add route to map!
$.mapview.addRoute(route);

答案 1 :(得分:0)

如果你在路线中仅提供两个点,那么它将在这些点之间绘制一条直线。如果你想制作更准确的路线,那么试着提供更多[绳索]点。 try KitchenSink

答案 2 :(得分:0)

我也遇到了同样的问题但是找到了解决方法。解决方案是使用Google Places API,为您提供起点和终点之间的点数,从而在地图上绘制更准确的路线!!!!希望这对您有用。