001    package com.google.gwt.maps.client.panoramiolib;
002    
003    import com.google.gwt.core.client.JavaScriptObject;
004    import com.google.gwt.event.shared.HandlerRegistration;
005    import com.google.gwt.maps.client.MapImpl;
006    import com.google.gwt.maps.client.MapWidget;
007    import com.google.gwt.maps.client.events.MapEventType;
008    import com.google.gwt.maps.client.events.MapHandlerRegistration;
009    import com.google.gwt.maps.client.events.panoramiomouse.PanoramioMouseEventFormatter;
010    import com.google.gwt.maps.client.events.panoramiomouse.PanoramioMouseMapHandler;
011    import com.google.gwt.maps.client.mvc.MVCObject;
012    
013    /**
014     * A PanoramioLayer displays photos from Panoramio as a rendered layer. This class extends MVCObject.
015     * <br><br>
016     * See <a href="https://developers.google.com/maps/documentation/javascript/reference#PanoramioLayer">PanoramioLayer API Doc</a>
017     */
018    public class PanoramioLayer extends MVCObject<PanoramioLayer> {
019    
020      /**
021       * use newInstance();
022       */
023      protected PanoramioLayer() {}
024      
025      /**
026       * A PanoramioLayer displays photos from Panoramio as a rendered layer. This class extends MVCObject.
027       * @param options
028       */
029      public static final PanoramioLayer newInstance(PanoramioLayerOptions options) {
030        return createJso(options).cast();
031      }
032    
033      private static final native JavaScriptObject createJso(PanoramioLayerOptions options) /*-{
034        return new $wnd.google.maps.panoramio.PanoramioLayer(options);
035      }-*/;
036      
037      /**
038       * The map on which to display the layer.
039       * @param mapWidget
040       */
041      public final void setMap(MapWidget mapWidget) {
042        setMapImpl(mapWidget.getJso());
043      }
044    
045      private final native void setMapImpl(MapImpl map) /*-{
046        this.map = map;
047      }-*/;
048    
049      /**
050       * The map on which to display the layer.
051       */
052      public final MapWidget getMap() {
053        return MapWidget.newInstance(getMapImpl());
054      }
055    
056      private final native MapImpl getMapImpl() /*-{
057        return this.map;
058      }-*/;
059      
060      /**
061       * A panoramio tag used to filter the photos which are displayed. Only photos which have been tagged with the supplied string will be shown.
062       */
063      public final native String getTag() /*-{
064        return this.getTag();
065      }-*/;
066      
067      /**
068       * A panoramio tag used to filter the photos which are displayed. Only photos which have been tagged with the supplied string will be shown.
069       * @param tag
070       */
071      public final native void setTag(String tag) /*-{
072        this.setTag(tag);
073      }-*/;
074      
075      /**
076       * A Panoramio user ID. If provided, only photos by this user will be displayed on the map. If both a tag and user ID are provided, the tag will take precedence.
077       * @param userId
078       */
079      public final native void setUserId(String userId) /*-{
080        this.userId = userId;
081      }-*/;
082      
083      /**
084       * A Panoramio user ID. If provided, only photos by this user will be displayed on the map. If both a tag and user ID are provided, the tag will take precedence.
085       */
086      public final native String getUserId() /*-{
087        return this.userId;
088      }-*/;
089      
090      /**
091       * This object defines the properties that can be set on a PanoramioLayer object.
092       * @param options
093       */
094      public final native void setOption(PanoramioLayerOptions options) /*-{
095        this.options = options;
096      }-*/;
097      
098      /**
099       * This event is fired when a feature in the layer is clicked.
100       * @param handler
101       */
102      public final HandlerRegistration addClickHandler(PanoramioMouseMapHandler handler) {
103        return MapHandlerRegistration.addHandler(this, MapEventType.CLICK, handler, new PanoramioMouseEventFormatter());
104      }
105    }