gpt4 book ai didi

ios - GMSMapView GroundOverlay 覆盖整个 MapView 边界

转载 作者:行者123 更新时间:2023-11-28 21:55:01 26 4
gpt4 key购买 nike

我已经设置了一个 UIView 以使用 Google map 显示 map 的特定区域。我现在想在这个选定区域的顶部添加一个图像叠加层,但我不知道如何为此计算正确的坐标。我已将 map 设置为中心坐标,但叠加层需要西北和东南坐标。有人可以帮忙吗?我正在尝试将赛道的图像放在某些道路上。

下面是我目前的代码:

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:14.5809268
longitude:120.975319
zoom:16.5
bearing:90
viewingAngle:0];

// Indicating the map frame bounds
mapView_ = [GMSMapView mapWithFrame:self.mapViewOnScreen.bounds camera: camera];
mapView_.myLocationEnabled = YES;

// Add as subview the mapview
[self.mapViewOnScreen addSubview: mapView_];


//this is where I need to figure out the coordinates but get stuck...

CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(40.712216,-74.22655);
CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(40.773941,-74.12544);
GMSCoordinateBounds *overlayBounds = [[GMSCoordinateBounds alloc] initWithCoordinate:southWest
coordinate:northEast];


//Add track image over the road map to show a race track - roads need to match up

UIImage *icon = [UIImage imageNamed:@"Track.jpg"];
GMSGroundOverlay *overlay =
[GMSGroundOverlay groundOverlayWithBounds:overlayBounds icon:icon];
overlay.bearing = 0;
overlay.map = mapView_;

// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(14.5809268, 120.975319);
marker.title = @"Race Day";
marker.snippet = @"Manila";
marker.map = mapView_;

}

最佳答案

我还没有尝试过,但在对 API 进行了一些研究之后,我认为您可以通过执行以下操作来实现您想要的:

GMSProjection *projection = mapView_.projection;
GMSVisibleRegion visibleRegion = [projection visibleRegion];
GMSCoordinateBounds *coordinateBounds = [[GMSCoordinateBounds alloc] initWithRegion:visibleRegion];
CLLocationCoordinate2D northEast = coordinateBounds.northEast;
CLLocationCoordinate2D southWest = coordinateBounds.southWest;

希望这对您有所帮助。

关于ios - GMSMapView GroundOverlay 覆盖整个 MapView 边界,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26867596/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com