yugalatea / gwt-google-apis

Automatically exported from code.google.com/p/gwt-google-apis
0 stars 0 forks source link

mapWidget.convertLatLngToDivPixel returns incorrect values #205

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Found in Release:
1.0.1 (Maps)
1.5.3 (GWT)
MacOS X 10.5.5

Detailed description:
convertLatLngToDivPixel returns incorrect values after moving or zooming
the map:
Point point = mapWidget.convertLatLngToDivPixel(marker.getLatLng());

Workaround if you have one:
none

Links to the relevant GWT Developer Forum posts:

Original issue reported on code.google.com by claudiushauptmann.com@gmail.com on 30 Oct 2008 at 4:10

GoogleCodeExporter commented 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

GoogleCodeExporter commented 9 years ago
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:

GoogleCodeExporter commented 9 years ago

Original comment by galgwt.reviews@gmail.com on 30 Oct 2008 at 5:25

GoogleCodeExporter commented 9 years ago

Original comment by galgwt.reviews@gmail.com on 24 Nov 2008 at 4:20

GoogleCodeExporter commented 9 years ago

Original comment by galgwt.reviews@gmail.com on 11 Dec 2008 at 3:11

GoogleCodeExporter commented 9 years ago
Updating account names

Original comment by zundel@google.com on 21 Dec 2009 at 2:00