简体   繁体   English

iOS路由我的可拖​​动标记失去跟踪(甚至在示例中)

[英]iOS route-me draggable marker looses track (even in samples)

In my iOS app I'm using the route me lib to display a map in offline mode. 在我的iOS应用中,我使用lib我的路线以离线模式显示地图。 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. 因此,我查看了示例“ MapTestbedFlipMaps”项目并运行它...并遇到了相同的问题。

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. 编辑:问题不是来自标记图像的大小,我尝试使用100x100图像并获得了相同的结果。

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

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM