001 package com.google.gwt.maps.client.streetview;
002
003 import com.google.gwt.core.client.JsArray;
004 import com.google.gwt.dom.client.Element;
005 import com.google.gwt.event.shared.HandlerRegistration;
006 import com.google.gwt.maps.client.base.LatLng;
007 import com.google.gwt.maps.client.events.closeclick.CloseClickMapHandler;
008 import com.google.gwt.maps.client.events.links.LinksChangeMapHandler;
009 import com.google.gwt.maps.client.events.pano.PanoChangeMapHandler;
010 import com.google.gwt.maps.client.events.position.PositionChangeMapHandler;
011 import com.google.gwt.maps.client.events.pov.PovChangeMapHandler;
012 import com.google.gwt.maps.client.events.resize.ResizeMapHandler;
013 import com.google.gwt.maps.client.events.visible.VisibleChangeMapHandler;
014 import com.google.gwt.maps.client.mvc.MVCArray;
015 import com.google.gwt.maps.client.mvc.MVCObjectWidget;
016 import com.google.gwt.user.client.DOM;
017
018 /**
019 * Displays the panorama for a given LatLng or panorama ID. A StreetViewPanorama object provides a Street View "viewer" which can be stand-alone within a separate <code><div></code> or bound to a Map. This class extends MVCObject.
020 * <br><br>
021 * See <a href="https://developers.google.com/maps/documentation/javascript/reference#StreetViewPanorama">StreetViewPanorama API Doc</a>
022 */
023 public class StreetViewPanoramaWidget extends MVCObjectWidget<StreetViewPanoramaImpl> {
024
025 private StreetViewPanoramaImpl impl;
026
027 /**
028 * create widget from a previous jso implementation
029 * @param impl
030 */
031 public static StreetViewPanoramaWidget newInstance(StreetViewPanoramaImpl impl) {
032 return new StreetViewPanoramaWidget(impl);
033 }
034
035 /**
036 * Displays the panorama for a given LatLng or panorama ID. A StreetViewPanorama object provides a Street View "viewer" which can be stand-alone within a separate <code><div></code> or bound to a Map. This class extends MVCObject.
037 */
038 public StreetViewPanoramaWidget(StreetViewPanoramaOptions options) {
039 Element div = DOM.createDiv();
040 setElement(div);
041 impl = StreetViewPanoramaImpl.newInstance(div, options);
042 setStyleName("gwt-map-StreetViewPanoramaWidget-div");
043 }
044
045 /**
046 * create a widget from a previous jso implementation
047 * @param impl
048 */
049 private StreetViewPanoramaWidget(StreetViewPanoramaImpl impl) {
050 this.impl = impl;
051 Element div = DOM.createDiv(); // setup a new div only option.
052 setElement(div);
053 setStyleName("gwt-map-StreetViewPanoramaWidget-div");
054 }
055
056 /**
057 * get the JavaScriptObject overlay
058 */
059 public StreetViewPanoramaImpl getJso() {
060 return impl;
061 };
062
063 /**
064 * Returns the set of navigation links for the Street View panorama.
065 */
066 public JsArray<StreetViewLink> getLinks() {
067 return impl.getLinks();
068 };
069
070 /**
071 * Returns the current panorama ID for the Street View panorama. This id is stable within the browser's current session only.
072 */
073 public String getPano() {
074 return impl.getPano();
075 };
076
077 /**
078 * Returns the current LatLng position for the Street View panorama.
079 */
080 public LatLng getPosition() {
081 return impl.getPosition();
082 };
083
084 /**
085 * Returns the current point of view for the Street View panorama.
086 */
087 public StreetViewPov getPov() {
088 return impl.getPov();
089 };
090
091 /**
092 * Returns true if the panorama is visible. It does not specify whether Street View imagery is available at the specified position.
093 */
094 public boolean getVisible() {
095 return impl.getVisible();
096 };
097
098 /**
099 * Set the custom panorama provider called on pano change to load custom panoramas.
100 * @param provider
101 */
102 public void registerPanoProvider(StreetViewPanoramaProvider provider) {
103 impl.registerPanoProvider(provider);
104 };
105
106 /**
107 * Sets the current panorama ID for the Street View panorama.
108 * @param pano
109 */
110 public void setPano(String pano) {
111 impl.setPano(pano);
112 };
113
114 /**
115 * Sets the current LatLng position for the Street View panorama.
116 * @param latlng
117 */
118 public void setPosition(LatLng latlng) {
119 impl.setPosition(latlng);
120 };
121
122 /**
123 * Sets the point of view for the Street View panorama.
124 * @param pov
125 */
126 public void setPov(StreetViewPov pov) {
127 impl.setPov(pov);
128 };
129
130 /**
131 * Sets to true to make the panorama visible. If set to false, the panorama will be hidden whether it is embedded in the map or in its own <code><div></code>.
132 * @param visible
133 */
134 public void setVisible(boolean visible) {
135 impl.setVisible(visible);
136 };
137
138
139
140
141 /**
142 * TODO
143 * Additional controls to attach to the panorama. To add a control to the panorama, add the control's <code><div></code> to the MVCArray corresponding to the ControlPosition where it should be rendered.
144 * @param controls
145 */
146 public void setControls(MVCArray<Element> controls) {
147 // impl.controls = controls; //TODO
148 }
149
150
151
152
153
154 /**
155 * This event is fired when the close button is clicked.
156 * @param handler
157 */
158 public HandlerRegistration addCloseClickHandler(CloseClickMapHandler handler) {
159 return impl.addCloseClickHandler(handler);
160 }
161
162 /**
163 * This event is fired when the panorama's links change. The links change asynchronously following a pano id change.
164 * @param handler
165 */
166 public HandlerRegistration addLinksChangeHandler(LinksChangeMapHandler handler) {
167 return impl.addLinksChangeHandler(handler);
168 }
169
170 /**
171 * This event is fired when the panorama's pano id changes. The pano may change as the user navigates through the panorama or the position is manually set. Note that not all position changes trigger a pano_changed.
172 * @param handler
173 */
174 public HandlerRegistration addPanoChangeHandler(PanoChangeMapHandler handler) {
175 return impl.addPanoChangeHandler(handler);
176 }
177
178 /**
179 * This event is fired when the panorama's position changes. The position changes as the user navigates through the panorama or the position is set manually.
180 * @param handler
181 */
182 public HandlerRegistration addPositionChangeHandler(PositionChangeMapHandler handler) {
183 return impl.addPositionChangeHandler(handler);
184 }
185
186 /**
187 * This event is fired when the panorama's point-of-view changes. The point of view changes as the pitch, zoom, or heading changes.
188 * @param handler
189 */
190 public HandlerRegistration addPovChangeHandler(PovChangeMapHandler handler) {
191 return impl.addPovChangeHandler(handler);
192 }
193
194 /**
195 * Developers should trigger this event on the panorama when its div changes size: google.maps.event.trigger(panorama, 'resize').
196 * @param handler
197 */
198 public HandlerRegistration addResizeHandler(ResizeMapHandler handler) {
199 return impl.addResizeHandler(handler);
200 }
201
202 /**
203 * This event is fired when the panorama's visibility changes. The visibility is changed when the Pegman id dragged onto the map, the close button is clicked, or setVisible() is called.
204 * @param handler
205 */
206 public HandlerRegistration addVisibleChangeHandler(VisibleChangeMapHandler handler) {
207 return impl.addVisibleChangeHandler(handler);
208 }
209 }