Closed GoogleCodeExporter closed 9 years ago
Here is a very primitive (!) workaround (does not work with lower zoom levels):
public Point LatLng2Point(LatLng ll) {
double n = mapWidget.getBounds().getNorthEast().getLatitude();
double s = mapWidget.getBounds().getSouthWest().getLatitude();
double e = mapWidget.getBounds().getNorthEast().getLongitude();
double w = mapWidget.getBounds().getSouthWest().getLongitude();
double lat = ll.getLatitude();
double lng = ll.getLongitude();
int height = mapWidget.getSize().getHeight();
int width = mapWidget.getSize().getWidth();
int offy = mapWidget.getAbsoluteTop();
int offx = mapWidget.getAbsoluteLeft();
long fx = Math.round((lng-w)/(e-w)*width);
String sx = String.valueOf(fx);
int x = Integer.valueOf(sx);
x += offx;
long fy = Math.round((lat-n)/(s-n)*height);
String sy = String.valueOf(fy);
int y = Integer.valueOf(sy);
y += offy;
return Point.newInstance(x, y);
}
Original comment by claudiushauptmann.com@gmail.com
on 30 Oct 2008 at 4:16
Apparently, the Maps API has another method for this:
fromLatLngToContainerPixel().
Original comment by galgwt.reviews@gmail.com
on 30 Oct 2008 at 5:24
Attachments:
Original comment by galgwt.reviews@gmail.com
on 30 Oct 2008 at 5:25
Original comment by galgwt.reviews@gmail.com
on 24 Nov 2008 at 4:20
Original comment by galgwt.reviews@gmail.com
on 11 Dec 2008 at 3:11
Updating account names
Original comment by zundel@google.com
on 21 Dec 2009 at 2:00
Original issue reported on code.google.com by
claudiushauptmann.com@gmail.com
on 30 Oct 2008 at 4:10