Commits

gensth  committed 45de2d6

support Google Maps API 3.x (tested with 3.2 and 3.5)

  • Participants
  • Parent commits d7cbfd5

Comments (0)

Files changed (3)

File gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/layer/GMapType.java

 package org.gwtopenmaps.openlayers.client.layer;
 
-import org.gwtopenmaps.openlayers.client.OpenLayersObjectWrapper;
-import org.gwtopenmaps.openlayers.client.util.JSObject;
+/**
+ * @author Max Gensthaler
+ */
+public enum GMapType {
+	/** This map type shows Google Earth satellite images. */
+	G_SATELLITE_MAP(GMapTypeImpl.G_SATELLITE_MAP()),
+	/** Normal street map type. */
+	G_NORMAL_MAP(GMapTypeImpl.G_NORMAL_MAP()),
+	/** This map type transposes street maps and labels over satellite images. */
+	G_HYBRID_MAP(GMapTypeImpl.G_HYBRID_MAP()),
+	/** A terrain map type. */
+	G_TERRAIN_MAP(GMapTypeImpl.G_TERRAIN_MAP());
 
-/**
- * @author Aaron Novstrup - Stottler Henke Associates, Inc.
- *
- */
-public class GMapType extends OpenLayersObjectWrapper
-{
-   /**
-    * This map type shows Google Earth satellite images.
-    */
-   static final public GMapType G_SATELLITE_MAP = 
-         narrowToGMapType(GMapTypeImpl.G_SATELLITE_MAP());
-   
-   /**
-    * Normal street map type.
-    */
-   static final public GMapType G_NORMAL_MAP = 
-         narrowToGMapType(GMapTypeImpl.G_NORMAL_MAP());
-   
-   /**
-    * This map type transposes street maps and labels over satellite images.
-    */
-   static final public GMapType G_HYBRID_MAP = 
-         narrowToGMapType(GMapTypeImpl.G_HYBRID_MAP());
-   
-   protected GMapType(JSObject element)
-   {
-      super(element);
-   }
-   
-   protected static GMapType narrowToGMapType(JSObject element)
-   {
-      return (element == null)? null : new GMapType(element);
-   }
+	private final String type;
+
+	private GMapType(String type) {
+		this.type = type;
+	}
+
+	/**
+	 * Returns the type.
+	 *
+	 * @return the type
+	 */
+	public String getNativeType() {
+		return type;
+	}
 }

File gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/layer/GMapTypeImpl.java

 package org.gwtopenmaps.openlayers.client.layer;
 
-import org.gwtopenmaps.openlayers.client.util.JSObject;
 
 /**
  * @author Aaron Novstrup - Stottler Henke Associates, Inc.
 class GMapTypeImpl
 {
 // Constants
-// Constants Description 
+// Constants Description
 
    /*
     * G_NORMAL_MAP  This is the normal street map type.
     */
-   native static public JSObject G_NORMAL_MAP()/*-{
-      return $wnd.G_NORMAL_MAP ? $wnd.G_NORMAL_MAP : null;
+   native static public String G_NORMAL_MAP()/*-{
+      if ($wnd.google.maps.MapTypeId.RADMAP) return $wnd.google.maps.MapTypeId.RADMAP; // google maps api 3.x
+      // is JSObject: else if ($wnd.G_NORMAL_MAP) return $wnd.G_NORMAL_MAP; // google maps api 2.x
+      else return null;
    }-*/;
-   
+
    /*
     * G_SATELLITE_MAP  This map type shows Google Earth satellite images.
     */
-   native static public JSObject G_SATELLITE_MAP()/*-{
-      return $wnd.G_SATELLITE_MAP ? $wnd.G_SATELLITE_MAP : null;
+   native static public String G_SATELLITE_MAP()/*-{
+      if ($wnd.google.maps.MapTypeId.SATELLITE) return $wnd.google.maps.MapTypeId.SATELLITE; // google maps api 3.x
+      // is JSObject: else if ($wnd.G_SATELLITE_MAP) return $wnd.G_SATELLITE_MAP; // google maps api 2.x
+      else return null;
    }-*/;
-   
+
    /*
     * G_HYBRID_MAP  This map type shows transparent street maps over Google Earth satellite images.
     */
-   native static public JSObject G_HYBRID_MAP()/*-{
-      return $wnd.G_HYBRID_MAP ? $wnd.G_HYBRID_MAP : null;
-   }-*/; 
+   native static public String G_HYBRID_MAP()/*-{
+      if ($wnd.google.maps.MapTypeId.HYBRID) return $wnd.google.maps.MapTypeId.HYBRID; // google maps api 3.x
+      // is JSObject: else if ($wnd.G_HYBRID_MAP) return $wnd.G_HYBRID_MAP; // google maps api 2.x
+      else return null;
+   }-*/;
+
+   /*
+    * G_TERRAIN_MAP  This map type shows transparent street maps over Google Earth satellite images.
+    */
+   native static public String G_TERRAIN_MAP()/*-{
+      if ($wnd.google.maps.MapTypeId.TERRAIN) return $wnd.google.maps.MapTypeId.TERRAIN; // google maps api 3.x
+      // non existent in google maps api 2.x
+      else return null;
+   }-*/;
 }

File gwt-openlayers-client/src/main/java/org/gwtopenmaps/openlayers/client/layer/GoogleOptions.java

 public class GoogleOptions extends EventPaneOptions {
 
 	public void setType(GMapType type) {
-		getJSObject().setProperty("type", type.getJSObject());
+		getJSObject().setProperty("type", type.getNativeType());
 	}
 
 	public void setSphericalMercator(boolean value) {