Owd-Larrd / gwt-google-apis

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

getBoundsZoomLevel(bounds) of MapWidget and relative size of map #480

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Found in Release:gwt-maps 1.1.0 with GWT 2.2

Problem Statement:
=================

Why getBoundsZoomLevel() of MapWidget is always returning "0(zero)" value when 
the map width and height is set using relative value(in %) as per the Example-1 
below.

It works fine when  I set the width and height in pixels as per the Example-2

It also works fine when I set the width in pixels and height in % as per 
Example-3

I am trying to make this work with Example-1, Please share your thoughts on the 
same.

I verified it work fine when we we use the Java Script api directly, meaning 
without GWT but here it does not work with GWT and map wrapper API.

Example-1 (Width and Height in relative value (in %)):
=======================================================
{
MapWidget map=new MapWidget();
RootPanel.get().add(map);

map.setSize("100%","100%");

LatLng p1=LatLng.newInstance(22.31,114.2);
LatLng p2=LatLng.newInstance(-5.0,120.0);
LatLng p3=LatLng.newInstance(48.12,16.55);
LatLng[] points=new LatLng[] {p1,p2,p3};

PloyLine line=new PolyLine(points, "red", 4);

map.addOverlay(line);

LatLngBounds bounds=line.getBounds();

int zoomLevel=map.getBoundsZoomLevel(line);

GWT.log("Polyline zoom level:"+zoomLevel);
}

O/P:
-------------------------------------------
[INFO] [mapexample] - Poyline zoom level:0

Example-2 (Width and Height in abosolute value (in px)):
=======================================================
{
MapWidget map=new MapWidget();
RootPanel.get().add(map);

map.setSize("1000px","1000px");

LatLng p1=LatLng.newInstance(22.31,114.2);
LatLng p2=LatLng.newInstance(-5.0,120.0);
LatLng p3=LatLng.newInstance(48.12,16.55);
LatLng[] points=new LatLng[] {p1,p2,p3};

PloyLine line=new PolyLine(points, "red", 4);

map.addOverlay(line);

LatLngBounds bounds=line.getBounds();

int zoomLevel=map.getBoundsZoomLevel(line);

GWT.log("Polyline zoom level:"+zoomLevel);
}

O/P:
------------------------------------------
[INFO] [mapexample] - Poyline zoom level:3

Example-3 (Width (in px) and Height (in %) ):
=============================================
{
MapWidget map=new MapWidget();
RootPanel.get().add(map);

map.setSize("750px","100%");

LatLng p1=LatLng.newInstance(22.31,114.2);
LatLng p2=LatLng.newInstance(-5.0,120.0);
LatLng p3=LatLng.newInstance(48.12,16.55);
LatLng[] points=new LatLng[] {p1,p2,p3};

PloyLine line=new PolyLine(points, "red", 4);

map.addOverlay(line);

LatLngBounds bounds=line.getBounds();

int zoomLevel=map.getBoundsZoomLevel(line);

GWT.log("Polyline zoom level:"+zoomLevel);
}

O/P:
-----------------------------------------
[INFO] [mapexample] - Poyline zoom level:3

Original issue reported on code.google.com by dhana....@gmail.com on 13 Sep 2011 at 8:51

GoogleCodeExporter commented 9 years ago
Maps API v2 has been deprecated

Original comment by zundel@google.com on 28 Oct 2011 at 4:14