前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >iOS-百度地图屏幕所显示范围内的经纬度

iOS-百度地图屏幕所显示范围内的经纬度

作者头像
赵哥窟
发布2018-09-13 11:43:01
9660
发布2018-09-13 11:43:01
举报
文章被收录于专栏:日常技术分享

今天用到百度地图获取屏幕范围内的经纬度,在此记录一下。

代码语言:javascript
复制
    // 当前屏幕中心点的经纬度
    double centerLongitude = self.mapView.region.center.longitude;
    double centerLatitude = self.mapView.region.center.latitude;

    //当前屏幕显示范围的经纬度
    CLLocationDegrees pointssLongitudeDelta = self.mapView.region.span.longitudeDelta;
    CLLocationDegrees pointssLatitudeDelta = self.mapView.region.span.latitudeDelta;

    //左上角
    double leftUpLong = centerLongitude - pointssLongitudeDelta/2.0;
    double leftUpLati = centerLatitude - pointssLatitudeDelta/2.0;

    //右上角
    double rightUpLong = centerLongitude + pointssLongitudeDelta/2.0;
    double rightUpLati = centerLatitude - pointssLatitudeDelta/2.0;

    //左下角
    double leftDownLong = centerLongitude - pointssLongitudeDelta/2.0;
    double leftDownlati = centerLatitude + pointssLatitudeDelta/2.0;

    //右下角
    double rightDownLong = centerLongitude + pointssLongitudeDelta/2.0;
    double rightDownLati = centerLatitude + pointssLatitudeDelta/2.0;

    NSLog(@"\n 左上   %f,%f---------\n 右上   %f,%f-------\n 左下  %f,%f----- \n 右下  %f,%f",leftUpLong,leftUpLati,rightUpLong,rightUpLati,leftDownLong,leftDownlati,rightDownLong,rightDownLati);
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018.08.29 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档