001 package com.google.gwt.maps.client.streetview;
002
003 import com.google.gwt.core.client.JavaScriptObject;
004 import com.google.gwt.maps.client.base.LatLng;
005
006 /**
007 * A StreetViewService object performs searches for Street View data.
008 * <br><br>
009 * See <a href="https://developers.google.com/maps/documentation/javascript/reference#StreetViewService">StreetViewService API Doc</a>
010 */
011 public class StreetViewService extends JavaScriptObject {
012
013 /**
014 * use newInstance();
015 */
016 protected StreetViewService() {}
017
018 /**
019 * A StreetViewService object performs searches for Street View data.
020 */
021 public static final StreetViewService newInstnace() {
022 return createJso().cast();
023 }
024
025 private static final native JavaScriptObject createJso() /*-{
026 return new $wnd.google.maps.StreetViewService();
027 }-*/;
028
029 /**
030 * Retrieves the data for the given pano id and passes it to the provided callback as a StreetViewPanoramaData object. Pano ids are unique per panorama and stable for the lifetime of a session, but are liable to change between sessions.
031 * @param pano
032 * @param handler
033 */
034 public final native void getPanoramaById(String pano, PanoramaIdHandler handler) /*-{ //
035 var callback = function(data, status) {
036 @com.google.gwt.maps.client.streetview.StreetViewService::getPanoramaByIdImpl(Lcom/google/gwt/maps/client/streetview/StreetViewPanoramaData;Ljava/lang/String;Lcom/google/gwt/maps/client/streetview/PanoramaIdHandler;)(data, status, handler);
037 };
038 this.getPanoramaById(pano, callback);
039 }-*/;
040
041 private static final void getPanoramaByIdImpl(StreetViewPanoramaData data, String status, PanoramaIdHandler handler) {
042 handler.onCallback(data, StreetViewStatus.fromValue(status));
043 }
044
045 /**
046 * Retrieves the StreetViewPanoramaData for a panorama within a given radius of the given LatLng. The StreetViewPanoramaData is passed to the provided callback. If the radius is less than 50 meters, the nearest panorama will be returned.
047 * @param latlng
048 * @param radius
049 * @param handler
050 */
051 public final native void getPanoramaByLocation(LatLng latlng, double radius, PanoramaByLocationHandler handler) /*-{
052 var callback = function(data, status) {
053 @com.google.gwt.maps.client.streetview.StreetViewService::getPanoramaByLocationImpl(Lcom/google/gwt/maps/client/streetview/StreetViewPanoramaData;Ljava/lang/String;Lcom/google/gwt/maps/client/streetview/PanoramaByLocationHandler;)(data, status, handler);
054 };
055 this.getPanoramaByLocation(latlng, radius, callback);
056 }-*/;
057
058 private static final void getPanoramaByLocationImpl(StreetViewPanoramaData data, String status, PanoramaByLocationHandler handler) {
059 handler.onCallback(data, StreetViewStatus.fromValue(status));
060 }
061
062 }