How to get Latitude/Longitude span in Google Map V2 for Android

前端 未结 4 1122
旧时难觅i
旧时难觅i 2020-12-08 22:22

I have a task for move my app to Google Maps Android APIs V2. Now, I need to get Latitude/Longitude span. I used MapView.getLatitudeSpan() and MapView.get

4条回答
  •  隐瞒了意图╮
    2020-12-08 23:05

    Here is the answer

    LatLngBounds bounds = googleMap.getProjection().getVisibleRegion().latLngBounds;
    if (bounds.contains(ROMA)) {
       marker = googleMap.addMarker(
         new MarkerOptions()
          .position(ROMA)
          .title("Hello")
          .snippet("Nice Place")
          .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher))
         );     
       System.out.println("Marker added");
    }
    

    Add the marker only when it falls in the visible region

提交回复
热议问题