//获取自定义的经纬度上添加位置气泡,大头钉

    BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];

    CLLocationCoordinate2D coor;

    coor.latitude = 39.915;

    coor.longitude = 116.404;

    annotation.coordinate = coor;

    annotation.title = @"北京";

    annotation.subtitle = @"这里是北京";

    [_mapView addAnnotation:annotation];

    //这样就可以在初始化的时候将 气泡信息弹出

//获取当前位置

    [_mapView selectAnnotation:annotation animated:YES];

_mapView.showsUserLocation = YES;

    CLLocationCoordinate2D coor1;

    BMKUserLocation *userLocation =[[BMKUserLocation alloc] init];

    if (userLocation.location != nil)

    {

        NSLog(@"定位成功");

        coor1 = [[userLocation location] coordinate];

        NSLog(@"%f",coor1.latitude);

        NSLog(@"%f",coor1.longitude);

    }

    coor1 = [[userLocation location] coordinate];

    BMKCoordinateRegion viewRegion = BMKCoordinateRegionMake(coor1, BMKCoordinateSpanMake(0.02f,0.02f));

    BMKCoordinateRegion adjustedRegion = [_mapView regionThatFits:viewRegion];

    [_mapView setRegion:adjustedRegion animated:YES];

相关文章:

  • 2022-02-05
  • 2021-09-13
  • 2021-12-01
  • 2022-12-23
  • 2021-04-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-25
  • 2021-11-11
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
相关资源
相似解决方案