Hello Miguel,
I would like you to review the attached patch. This patch addresses issue
170
http://code.google.com/p/gwt-google-apis/issues/detail?id=170
This change makes InfoWindow extend the ConcreteOverlay class. It also adds
the methods isInfoWindow(), isPolyline(), isPolygon(), and isMarker() to the
Overlay class.
M maps/maps/test/com/google/gwt/maps/client/overlay/OverlayTest.java
M maps/maps/src/com/google/gwt/maps/client/overlay/Overlay.java
--
Eric Z. Ayers - GWT Team - Atlanta, GA USA
http://code.google.com/webtoolkit/
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---
M maps/maps/test/com/google/gwt/maps/client/overlay/OverlayTest.java
M maps/maps/src/com/google/gwt/maps/client/overlay/Overlay.java
Index: maps/maps/test/com/google/gwt/maps/client/overlay/OverlayTest.java
===================================================================
--- maps/maps/test/com/google/gwt/maps/client/overlay/OverlayTest.java (revision 792)
+++ maps/maps/test/com/google/gwt/maps/client/overlay/OverlayTest.java (working copy)
@@ -16,6 +16,8 @@
package com.google.gwt.maps.client.overlay;
import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.maps.client.InfoWindow;
+import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.TestUtilities;
import com.google.gwt.maps.client.geom.LatLng;
@@ -38,6 +40,41 @@
TestUtilities.cleanDom();
}
+ public void testIsInfoWindow() {
+ MapWidget map = new MapWidget();
+ InfoWindow info = map.getInfoWindow();
+ assertTrue(info.isInfoWindow());
+ assertFalse(info.isMarker());
+ assertFalse(info.isPolyline());
+ assertFalse(info.isPolygon());
+ }
+
+ public void testIsMarker() {
+ Marker m = new Marker(LatLng.newInstance(1,1));
+ assertFalse(m.isInfoWindow());
+ assertTrue(m.isMarker());
+ assertFalse(m.isPolyline());
+ assertFalse(m.isPolygon());
+ }
+
+ public void testIsPolygon() {
+ LatLng points[] = {LatLng.newInstance(0,0), LatLng.newInstance(1,0)};
+ Polygon p = new Polygon(points);
+ assertFalse(p.isInfoWindow());
+ assertFalse(p.isMarker());
+ assertFalse(p.isPolyline());
+ assertTrue(p.isPolygon());
+ }
+
+ public void testIsPolyline() {
+ LatLng points[] = {LatLng.newInstance(0,0), LatLng.newInstance(1,0)};
+ Polyline p = new Polyline(points);
+ assertFalse(p.isInfoWindow());
+ assertFalse(p.isMarker());
+ assertTrue(p.isPolyline());
+ assertFalse(p.isPolygon());
+ }
+
public void testOverlayZIndex() {
LatLng atlanta = LatLng.newInstance(33.7814790, -84.3880580);
double result1 = Overlay.getZIndex(atlanta.getLatitude());
@@ -45,6 +82,6 @@
double result2 = Overlay.getZIndex(atlanta.getLatitude() + 1);
assertTrue("expected non-zero value", result2 != 0.0);
assertTrue("expected result1 > result2 ", result1 > result2);
- }
+ }
}
Index: maps/maps/src/com/google/gwt/maps/client/overlay/Overlay.java
===================================================================
--- maps/maps/src/com/google/gwt/maps/client/overlay/Overlay.java (revision 792)
+++ maps/maps/src/com/google/gwt/maps/client/overlay/Overlay.java (working copy)
@@ -21,8 +21,7 @@
import com.google.gwt.maps.jsio.client.Exported;
/**
- * The base class for adding objects at a specific position on top of
- * the map.
+ * The base class for adding objects at a specific position on top of the map.
*/
public abstract class Overlay {
@@ -97,6 +96,50 @@
}
/**
+ * Test to see if this overlay is the
+ * [EMAIL PROTECTED] com.google.gwt.maps.client.InfoWindow} for this map.
+ *
+ * @return <code>true</code> if this overlay is the
+ * [EMAIL PROTECTED] com.google.gwt.maps.client.InfoWindow} for this map.
+ */
+ public boolean isInfoWindow() {
+ return nativeIsInfoWindow(jsoPeer);
+ }
+
+ /**
+ * Test to see if this overlay is the
+ * [EMAIL PROTECTED] com.google.gwt.maps.client.overlay.Marker} for this map.
+ *
+ * @return <code>true</code> if this overlay is the
+ * [EMAIL PROTECTED] com.google.gwt.maps.client.overlay.Marker} for this map.
+ */
+ public boolean isMarker() {
+ return nativeIsMarker(jsoPeer);
+ }
+
+ /**
+ * Test to see if this overlay is the
+ * [EMAIL PROTECTED] com.google.gwt.maps.client.overlay.Polygon} for this map.
+ *
+ * @return <code>true</code> if this overlay is the
+ * [EMAIL PROTECTED] com.google.gwt.maps.client.overlay.Polygon} for this map.
+ */
+ public boolean isPolygon() {
+ return nativeIsPolygon(jsoPeer);
+ }
+
+ /**
+ * Test to see if this overlay is the
+ * [EMAIL PROTECTED] com.google.gwt.maps.client.overlay.Polyline} for this map.
+ *
+ * @return <code>true</code> if this overlay is the
+ * [EMAIL PROTECTED] com.google.gwt.maps.client.overlay.Polyline} for this map.
+ */
+ public boolean isPolyline() {
+ return nativeIsPolyline(jsoPeer);
+ }
+
+ /**
* Returns an uninitialized copy of itself that can be added to the map.
*
* @return an uninitialized copy of itself that can be added to the map.
@@ -134,4 +177,24 @@
@Exported
protected abstract void remove();
+ private native boolean nativeIsInfoWindow(JavaScriptObject jsoPeer) /*-{
+ // The instanceof test won't work, because $wnd.GInfoWindow has no constructor.
+ // Let's see if it quacks like a duck (has similar member functions)...
+ if (!jsoPeer.selectTab || !jsoPeer.getTabs || !jsoPeer.getPixelOffset) {
+ return false;
+ }
+ return true;
+ }-*/;
+
+ private native boolean nativeIsMarker(JavaScriptObject jsoPeer) /*-{
+ return (jsoPeer instanceof $wnd.GMarker);
+ }-*/;
+
+ private native boolean nativeIsPolygon(JavaScriptObject jsoPeer) /*-{
+ return (jsoPeer instanceof $wnd.GPolygon);
+ }-*/;
+
+ private native boolean nativeIsPolyline(JavaScriptObject jsoPeer) /*-{
+ return (jsoPeer instanceof $wnd.GPolyline);
+ }-*/;
}