Reputation: 6165
In my iOS app I'm using the route me lib to display a map in offline mode. I have some markers on the map, and now I would like to make them draggable. I used this code :
- (void) mapView:(RMMapView *)map didDragMarker:(HotspotMarker*)marker withEvent:(UIEvent *)event
{
UITouch* touch = [[event allTouches] anyObject];
if([[event allTouches] count] == 1 && touch.phase == UITouchPhaseMoved)
{
CGPoint position = [touch locationInView:[touch.view superview]];
CGSize delta = CGSizeMake((position.x-(marker.position.x)),
(position.y-(marker.position.y)));
[marker moveBy: delta];
[marker setProjectedLocation:[[_mapView.contents projection]
latLongToPoint:[_mapView pixelToLatLong:marker.position]]];
}
}
The markers drag well when I move the mouse slowly, but when I move the mouse a little quickly, I loose the track.
So I looked the sample "MapTestbedFlipMaps" project and run it... And encountered the same problem.
Then I tried to do it by myself with a gesture recognizer... but I still have the issue.
Any idea ?
EDIT : the problem doesn't come from the marker's image's size, I tried with a 100x100 image and got the same result.
Upvotes: 0
Views: 449
Reputation: 1
Try This:
- (void) mapView:(RMMapView *)map didDragMarker:(RMMarker *)marker withEvent:(UIEvent *)event
{
CGPoint position = [[[event allTouches] anyObject] locationInView:mapView];
CGRect rect = [marker bounds];
[self.mapView.markerManager moveMarker:marker AtXY:CGPointMake(position.x,position.y +rect.size.height/3)];
}
Upvotes: 0