【问题标题】:iOS route-me draggable marker looses track (even in samples)iOS route-me 可拖动标记丢失轨道(即使在样本中)
【发布时间】:2012-11-07 14:03:44
【问题描述】:

在我的 iOS 应用程序中,我使用 route me lib 在离线模式下显示地图。 我在地图上有一些标记,现在我想让它们可拖动。我使用了这段代码:

- (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]]];
    }
}

当我缓慢移动鼠标时,标记可以很好地拖动,但是当我稍微快速移动鼠标时,我会松开轨道。

所以我查看了示例“MapTestbedFlipMaps”项目并运行它...遇到了同样的问题。

然后我尝试用手势识别器自己做......但我仍然有问题。

有什么想法吗?

编辑:问题不在于标记的图像大小,我尝试使用 100x100 图像并得到相同的结果。

【问题讨论】:

    标签: ios objective-c draggable marker route-me


    【解决方案1】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多