iPhone route only displayed when user moves the map.
Hi
Does anybody know the problem? The map is displayed. The annotations are also correctly shown. But the user can't see the route. When he starts moving the map, the route appears.
mapView = Titanium.Map.createView({
mapType: Titanium.Map.STANDARD_TYPE,
region: {latitude: 47.95, longitude: 16.29,
latitudeDelta:0.1, longitudeDelta:0.1},
animate:true,
regionFit:true,
userLocation:true,
annotations: objects
});
var routeNeu = {
name:"route",
points: points,
color:"blue",
width:4
};
mapView.addRoute(routeNeu);
win.add(mapView);
Thanks for your help!
Felix
EDIT: If I make a setTimout for about 2 seconds and then move the map to the correct point (initialize with {}), it works… but I don't think, that's a good solution.
3 Answers
-
Accepted Answer
Here is how I fixed it( somehow like you did )
http://developer.appcelerator.com/question/60131/mapview-addroute-bug
-
Nobody has got a solution?
-
You set the region of the map in such a way it contains all the points that defines the route and some margins.
Hee is a code I use, but it's not 100% Titanium( I use my own wrapper ), but will give you an ideavar lons = [],lats=[]; for ( var v in venues ) { // some other code here }); lons.push(venues[v].longitude); lats.push(venues[v].latitude); // venues_map.el.addAnnotation(v_pin.el); } var venues_region = { latitude:array_min(lats)+(array_max(lats) - array_min(lats))/2, longitude:array_min(lons)+(array_max(lons) - array_min(lons))/2, latitudeDelta:(array_max(lats) - array_min(lats))+0.02, longitudeDelta:(array_max(lons) - array_min(lons))+0.02 }; venues_map.set('region',venues_region);
let me know