Question

i'm having some trouble with Maps Route y Maps V2 on Android. So the problem is when i put a route, like this:

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);

And yeah, now i have a map route in my map, but the route is straight, totally straight

Picture of the map route!

The route is not using the streets, is just a straight line, not sable at all, can you help me?

My specifications:

Mac OS Maverick

Module: Ti.map (API V2)

Titanium SDK 3.2.2.GA

Titanium Studio, build: 3.2.1.201402041146

(c) Copyright 2012-2013 by Appcelerator, Inc. All rights reserved.

Build: jenkins-titanium-rcp-master-95 (origin/master) Date: 04 February 2014, 11:47:38

Was it helpful?

Solution

You need more coordinates not just a start an end but many points in between. Since this is just one route, your coordinates must be stored in an array consecutively. That array should be used for the points property when creating a route. Here's an example from appecelerator's documents and the route examples are at the very bottom of the page: http://docs.appcelerator.com/titanium/3.0/#!/guide/Native_Maps_and_Annotations

Like this:

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);

OTHER TIPS

In titanium if you provide only two points in route then it will draw a straight line between those points. If you want to make more accurate route, then try to provide more [cords] points. try KitchenSink

I too was stuck with the same problem But find a solution to this . The solution is using a Google Places API that provides you points between your starting and destination points as a result a more accurate route is drawn on the map!!!!Hope this works for you .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top