在GoogleMapSDK上放置标记

时间:2016-04-21 07:15:38

标签: ios objective-c google-maps-sdk-ios

我在两点之间成功绘制折线。但是我想把源点放在地图的左侧和目的地点到地图的右侧,并在它们之间水平画线。

任何想法都非常感激。

3rd column

此折线方法

DF
    V1   V2  V3
    10   2   1
    20   29  0
    30   21  1
    40   60  0

2 个答案:

答案 0 :(得分:1)

要使标记图标中心全部使用地锚。

_marker1 = [[GMSMarker alloc] init];
_marker1.position = CLLocationCoordinate2DMake(12.9716, 77.5946);
_marker1.title = @"sydney";
_marker1.groundAnchor = CGPointMake(0.2, 0.9);
_marker1.appearAnimation = kGMSMarkerAnimationPop;
_marker1.appearAnimation = kGMSMarkerAnimationPop;
_marker1.icon = [UIImage imageNamed:@"Flag Filled -50.png"];

改变地面锚点使其成为中心

答案 1 :(得分:0)

水平多边形线完全取决于纬度值。如果两个位置纬度值相同,则多边形线是水平的。 poly line horizontallu

 _path = [GMSMutablePath path];
[_path addLatitude:12.9716 longitude:77.5946]; // bangalore
[_path addLatitude:12.9716 longitude:78.0]; // tumkur


_marker1 = [[GMSMarker alloc] init];
_marker1.position = CLLocationCoordinate2DMake(12.9716, 77.5946);
_marker1.title = @"Bangalore";
_marker1.groundAnchor = CGPointMake(0.2, 0.9);
_marker1.appearAnimation = kGMSMarkerAnimationPop;
_marker1.appearAnimation = kGMSMarkerAnimationPop;
_marker1.icon = [UIImage imageNamed:@"Flag Filled -50.png"];
_marker1.snippet = @"India";
_marker1.map = _mapView;

_marker2 = [[GMSMarker alloc] init];
_marker2.position = CLLocationCoordinate2DMake(12.9716, 78.0);
_marker2.title = @"Tumkur";
_marker2.groundAnchor = CGPointMake(0.3, 0.9);
_marker2.snippet = @"India";
_marker2.icon = [UIImage imageNamed:@"Flag Filled -50.png"];
_marker2.map = _mapView;
_polyline = [GMSPolyline polylineWithPath:_path];
_polyline.strokeColor = [UIColor blueColor];
_polyline.strokeWidth = 1.f;
_polyline.path = _path;
_polyline.map = _mapView;