【问题标题】:how to get the long & lat value of four corners in the mapview in android?如何在android的mapview中获取四个角的经纬度值?
【发布时间】:2010-03-19 10:06:30
【问题描述】:

我正在处理地图视图。我想把覆盖项目放在地图视图上。覆盖项目都取决于当前显示的地图视图和缩放级别。如何获取当前地图视图的四个角的经度和纬度以及如何分析其中有多少叠加项。我们还必须检查你的缩放级别。有什么想法吗?怎么办?

【问题讨论】:

    标签: android google-maps android-mapview overlayitem


    【解决方案1】:

    我认为你必须使用

    mapview.getProjection().frompixel(intx, int y)
    

    对于屏幕的 4 个角(您可以通过 mapView 上的 getwidth 和 getheight 获取它们的坐标,并以 (0,0)、(getwidth(),0)、(0,getheight()) 和 (获取宽度(),获取高度())

    这将为您提供 4 个地理点,您可以从中提取纬度和经度

    【讨论】:

    • 不客气,其实当我看到你的问题时我并不知道答案的答案,但它引起了我的兴趣,我寻找它
    【解决方案2】:

    如果您正在使用 google-play-services 库,尤其是 SupportMapFragment

    this.getMap() 将为您提供GoogleMap 的实例(包装MapView

    那么就:

    map.getProjection().getVisibleRegion();

    【讨论】:

      【解决方案3】:

      你在寻找这样的东西吗?

      Projection proj = mapView.getProjection();
      GeoPoint topLeft = proj.fromPixels(0, 0);
      
      GeoPoint bottomRight = proj.fromPixels(mapView.getWidth()-1, mapView.getHeight()-1);
      
      double topLat = topLeft.getLatitudeE6()/1E6;
      double topLon = topLeft.getLongitudeE6()/1E6;
      double bottomLat = bottomRight.getLatitudeE6()/1E6;
      double bottomLon = bottomRight.getLongitudeE6()/1E6;
      

      希望对你有帮助!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-02
        • 2012-06-30
        • 2021-02-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多