I was able to successfully make mapView move to a given latlong using
move. However, I am not able to make the move animate smoothly (like
in the native maps app).
I was able to get animation itself to work but not in conjunction with
movetolatlong. Here's my code. What am I doing wrong?
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3.0];
[UIView setAnimationDelay:0.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDidStopSelector:nil];
[UIView setAnimationRepeatAutoreverses:true];
// [mapView moveToLatLong:targetLocation]; //no animation but
moves to the right location
mapView.center = [mapView latLongToPixel:targetLocation];// this
at least does some animation but in the wrong direction
[UIView commitAnimations];
I do see some route-me based apps getting it right. So it must be
possible, hopefully just by calling some API I might be overlooking?
Any thoughts?
Vlad.
> --
> You received this message because you are subscribed to the Google Groups "route-me" group.
> To post to this group, send email to route-...@googlegroups.com.
> To unsubscribe from this group, send email to route-me-map...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/route-me-map?hl=en.
>
Thanks
On Dec 6, 8:06 am, Vladimir Vyskocil <vladimir.vysko...@gmail.com>
wrote:
queue = [[NSOperationQueue alloc] init];
[queue setMaxConcurrentOperationCount:1];
- (void)moveToTargetWithAnimation {
// if we are on the move, return right away. we want the current move to finish.
if (is_moving)
return;
// remember that we are moving
is_moving = true;
// get the current location
from = [mapView pixelToLatLong:mapView.center];
// initialize step and steps (member variables)
step = 1;
nsteps = 12;
// create 'nsteps' operation objects that will be executed in the queue thread
for (int i = 0; i < nsteps; i++) {
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(moveToLocationWithOperation)
object:nil];
[queue addOperation:operation];
[operation release];
}
}
- (void) moveToLocationWithOperation {
[self performSelectorOnMainThread:@selector(makeMapViewChange) withObject:nil waitUntilDone:NO];
usleep(20000); // adjust for your tastes
step++;
// not moving anymore if we reached the desired number of steps
if (step == nsteps)
is_moving = false;
}
- (void) makeMapViewChange {
// intermediate target
CLLocationCoordinate2D tmpTarget;
float p = (1.0 * (nsteps - step)) / nsteps;
float q = (1.0 * step) / nsteps;
// this is a linear function. could get fancy with p and q depending on step.
tmpTarget.latitude = from.latitude * p + target.latitude * q;
tmpTarget.longitude = from.longitude * p + target.longitude * q;
[self.mapView moveToLatLong:tmpTarget];
if (step == nsteps) {
[self.mapView moveToLatLong:target];
}
}
- (IBAction)moveToLocation:(id)sender {
target.latitude = <latitude you want to go to>;
target.longitude = <longitude you want to go to>;
[self moveToTargetWithAnimation];
}
--
Justin R. Miller
Development Seed, Inc.
jus...@developmentseed.org
--
Justin R. Miller
Development Seed, Inc.
jus...@developmentseed.org
On Dec 16, 2:41 pm, "Justin R. Miller" <jus...@developmentseed.org>
wrote:
On Dec 19, 4:01 am, Ariel Camus Villalobos <sargento.ar...@gmail.com>
wrote:
--
You received this message because you are subscribed to the Google Groups "route-me" group.