高德地图设置中心点 定位 无效问题 只显示北京问题

遇到的问题

1.初始化地图
2.设置地图定位小蓝点

- (void)initMapView
{
    if (self.mapView == nil)
    {
        self.mapView = [[MAMapView alloc] initWithFrame:self.view.bounds];
        self.mapView.delegate = self;
    
    }
    self.mapView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    
    [self.view addSubview:self.mapView];
    
    ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
    self.mapView.showsUserLocation = YES;
    self.mapView.userTrackingMode = 2;
    
    self.mapView.visibleMapRect = MAMapRectMake(220880104, 101476980, 272496, 466656);
}

地图打开后 默认显示在北京 定位小蓝点没有起作用

原因在于

self.mapView.showsUserLocation = YES;
self.mapView.userTrackingMode = 2;

应当放在最后面

- (void)initMapView
{
    if (self.mapView == nil)
    {
        self.mapView = [[MAMapView alloc] initWithFrame:self.view.bounds];
        self.mapView.delegate = self;
    
    }
    self.mapView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    
    [self.view addSubview:self.mapView];
    
    self.mapView.visibleMapRect = MAMapRectMake(220880104, 101476980, 272496, 466656);
    
    ///如果您需要进入地图就显示定位小蓝点,则需要下面两行代码
    self.mapView.showsUserLocation = YES;
    self.mapView.userTrackingMode = 2;
}

地图所有属性都设置完后 再设置定位小蓝点 问题解决

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容