001    package com.google.gwt.maps.client.adsense;
002    
003    import com.google.gwt.core.client.JavaScriptObject;
004    import com.google.gwt.maps.client.MapImpl;
005    import com.google.gwt.maps.client.MapWidget;
006    import com.google.gwt.maps.client.controls.ControlPosition;
007    
008    /**
009     * ad unit options
010     * <br><br>
011     * See <a href="https://developers.google.com/maps/documentation/javascript/reference#AdUnitOptions">AdUnitOptions API Doc</a>
012     */
013    public class AdUnitOptions extends JavaScriptObject {
014    
015      /**
016       * creates options for adunit
017       */
018      public static final AdUnitOptions newInstance() {
019        return JavaScriptObject.createObject().cast();
020      }
021      
022      /**
023       * use newInstance();
024       */
025      protected AdUnitOptions() {}
026      
027      /**
028       * The AdSense For Content channel number for tracking the performance of this AdUnit. It must be stored as a string as it will typically be a large UINT64. (Optional)
029       */
030      public final native String getChannelNumber() /*-{
031        return this.channelNumber;
032      }-*/;
033      
034      /**
035       * The Format of the AdUnit.
036       * <br><br>
037       * See <a href="https://google.com/adsense/adformats">AdFormats</a>
038       */
039      public final AdFormat getFormat() {
040        return AdFormat.fromValue(getFormatImpl());
041      }
042      
043      private final native String getFormatImpl() /*-{
044        return this.format;
045      }-*/;
046      
047      /**
048       * The map associated with this AdUnit. Ads will be targeted to the location the map's viewport. (Required)
049       */
050      public final MapWidget getMap() {
051        return MapWidget.newInstance(getMapImpl());
052      }
053      
054      private final native MapImpl getMapImpl() /*-{
055        return this.map;
056      }-*/;
057      
058      /**
059       * The position of the AdUnit. If specified, the AdUnit will be displayed at this position. Otherwise, it will not be added to the map. (Optional)
060       */
061      public final ControlPosition getPosition() {
062        return ControlPosition.fromValue(getPositionImpl());
063      }
064    
065      private final native int getPositionImpl() /*-{
066        return this.position;
067      }-*/;
068      
069      /**
070       * Your AdSense for Content publisher ID. Required and must be set at the time of initialization. (Required)
071       */
072      public final native String getPublisherId() /*-{
073        return this.publisherId;
074      }-*/;
075    
076      /**
077       * set The AdSense For Content channel number for tracking the performance of this AdUnit. It must be stored as a string as it will typically be a large UINT64. (Optional)
078       * @param channelNumber
079       */
080      public final native void setChannelNumber(String channelNumber) /*-{
081        this.channelNumber = channelNumber;
082      }-*/;
083      
084      /**
085       * the Format of the AdUnit.
086       * <br><br>
087       * See <a href="https://google.com/adsense/adformats">AdFormats</a>
088       * @param format
089       */
090      public final void setFormat(AdFormat format) {
091        setFormatImpl(format.value());
092      };
093      
094      private final native void setFormatImpl(String format) /*-{
095        this.format = format;
096      }-*/;
097      
098      /**
099       * The map associated with this AdUnit. Ads will be targeted to the location the map's viewport. (Required)
100       * @param mapWidget
101       */
102      public final void setMap(MapWidget mapWidget) {
103        setMapImpl(mapWidget.getJso());
104      }
105      
106      private final native void setMapImpl(MapImpl map) /*-{
107        this.map = map;
108      }-*/;
109      
110      /**
111       * The position of the AdUnit. If specified, the AdUnit will be displayed at this position. Otherwise, it will not be added to the map. (Optional)
112       * @param position
113       */
114      public final void setPosition(ControlPosition position) {
115        setPositionImpl(position.value());
116      }
117      
118      private final native void setPositionImpl(int position) /*-{
119        this.position = position;
120      }-*/;
121      
122      /**
123       * Your AdSense for Content publisher ID. Required and must be set at the time of initialization. (Required)
124       * @param publisherId
125       */
126      public final native void setPublisherId(String publisherId) /*-{
127        this.publisherId = publisherId;
128      }-*/;
129    
130    }