001    package com.google.gwt.maps.client.layers;
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.mvc.MVCObject;
007    
008    /**
009     * A transit layer. This class extends MVCObject. <br>
010     * <br>
011     * See <a href=
012     * "https://developers.google.com/maps/documentation/javascript/reference#TransitLayer"
013     * >TransitLayer API Doc</a>
014     */
015    public class TransitLayer extends MVCObject<TransitLayer> {
016    
017            /**
018             * use newInstance();
019             */
020            protected TransitLayer() {
021            }
022    
023            /**
024             * creates a traffic layer
025             */
026            public static final TransitLayer newInstance() {
027                    return createJso().cast();
028            }
029    
030            private static final native JavaScriptObject createJso() /*-{
031                    return new $wnd.google.maps.TransitLayer();
032            }-*/;
033    
034            /**
035             * Renders the layer on the specified map. If map is set to null, the layer
036             * is removed.
037             * 
038             * @param mapWidget
039             */
040            public final void setMap(MapWidget mapWidget) {
041                    if (mapWidget == null) {
042                            setMapImpl(null);
043                    } else {
044                            setMapImpl(mapWidget.getJso());
045                    }
046            }
047    
048            private final native void setMapImpl(MapImpl map) /*-{
049                    this.setMap(map);
050            }-*/;
051    
052            /**
053             * Get the map on which the layer is being rendered.
054             */
055            public final MapWidget getMap() {
056                    return MapWidget.newInstance(getMapImpl());
057            }
058    
059            private final native MapImpl getMapImpl() /*-{
060                    return this.getMap();
061            }-*/;
062    }