2

My code:

Point p1 = supportMapFragment
              .getMap()
              .getProjection()
              .toScreenLocation(new LatLng(20,20));

The problem is p1 returns like: Point(0, 0). There is a solution here, but that's useless for me. I keep that points in an arrayList. When I want to bring points from inside arrayList, it returns []. I think the reason of that waiting the addOnGlobalLayoutListener. For this reason I should to find another and fast solution to get true values of points.

Community
  • 1
  • 1
ilgooz
  • 19
  • 1
  • 5

1 Answers1

0

You can try onWindowFocusChanged()
for example:

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    Point p1 = supportMapFragment
          .getMap()
          .getProjection()
          .toScreenLocation(new LatLng(20,20));
}

At least I got it done using this method

M.Guo
  • 115
  • 1
  • 7