Hi, I'm using a module called de.codewire.google.directions. basically it transforms an address into an abstract object to be used by addRoute() method for the Map view.
I tried the demo, and it worked, afterwards I tried to implement it in my app and it seems to work, because the resulting object is the right one
{name: "name", color: "#FF0000", points: [points], width: 2}but, the route is not traced on the map view. it doesn't show up.
here is the code:
directions: function () { Titanium.Geolocation.getCurrentPosition(function(e) { var s = e.coords; // example {latitude: 000.000, longitute: 000.000} var dx = "W Sahara Avenue, Las Vegas Nevada USA"; //location for test purposes Directions.map.getRoute({ //Directions is the class, map is the module origin : s, destination : dx, color : 'blue', mode : Directions.map.travelModes.driving, name : 'route', width : 5, callback : function(response) { if(response.status == 'OK') //the response IS OK { Directions.mv.setRegion({ //a pointer to the MapView object latitude : response.route.points[0].latitude, longitude : response.route.points[0].longitude, longitudeDelta : 0.04, latitudeDelta : 0.04 }); Directions.mv.addRoute(response.route); } else { alert(response.msg); } } }); }); }Do I have to add the Map view to another view or window and show it before executing this function?
this is the how the mapView is created:
Directions.mv = Titanium.Map.createView({ top:0, height: 400, userLocation: false, mapType: Titanium.Map.HYBRID_TYPE, regionFit: true }); Directions.map = require("de.codewire.google.directions"); Directions.add(Directions.mv); //equivalent to Titanium.UI.View.add() Directions.directions(); //the call to the function above is made at this point
1 Answer
Accepted Answer
What I can see so far your code looks well. Make sure your route has a unique name, Ti uses it as an id to acces them. If you want you can email us timodules@codewire.de with more relevant code.
Your Answer
This question has been locked and cannot accept new answers.