2013-12-18 167 views
1

我在我的iPhone project.I使用Google Map iOS sdk拖動圓形視圖連接一個形象這個問題,我可以darw圈而是從一個位置到另一個position.I我用下面的代碼不能拖動圈用於繪製circle.I需要查看圖像節目,還需要拖動圓形area.Please幫我如何在谷歌地圖iOS版SDK

CLLocationCoordinate2D circleCenter = CLLocationCoordinate2DMake(-33.85, 151.20); 
GMSCircle *circ = [GMSCircle circleWithPosition:circleCenter 
             radius:1000]; 
circ.fillColor = [UIColor grayColor]; 
circ.strokeColor = [UIColor redColor]; 
circ.strokeWidth = 5; 
circ.map = mapView; 

enter image description here

+0

好吧,我相信你應該不斷改變圓心,將移動circle.Since你提到把它移動按拖動動作的協調話,我不認爲它可以實現,我不這樣做的目的找。 – Allamaprabhu

+0

你好@Jasper,你有沒有找到解決辦法?我也想要相同類型的功能。而我的半徑不固定。用戶可以拖動,調整大小,縮放圓圈 – Apple

回答

2

我調查這幾個小時,但沒有直接的解決方法沒有找到這樣遠。但是,我找到了一種方法來實現這一點。解決方法是清除圓圈並拖動時重新繪製新的圓。

如果一個圓圈圍繞GMSMaker拉,拖圈可以達到實現拖動標記物稱爲委託方法:

-(void)mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *)marker { 
    [mapView clear]; 

    // Re-draw marker 
    marker.map = mapView; 

    // Create your circle with the new marker 
    GMSCircle *circ = [GMSCircle circleWithPosition:marker.position radius:1000]; 
    circ.fillColor = [UIColor grayColor]; 
    circ.strokeColor = [UIColor redColor]; 
    circ.strokeWidth = 5; 
    circ.map = mapView; 
} 

編輯:

注意[mapView clear]清除所有覆蓋(包括製造商)。有時候這可能不是一個好的解決方案。

0

如果你有固定的半徑。在photoshop中創建圖像。將其分配給標記。並將屬性設置爲拖放到標記。所以你現在可以隨意拖動標記了。