Example usage for com.google.gwt.maps.client.streetview StreetviewClient StreetviewClient

List of usage examples for com.google.gwt.maps.client.streetview StreetviewClient StreetviewClient

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.streetview StreetviewClient StreetviewClient.

Prototype

public StreetviewClient() 

Source Link

Document

Creates a new instance of StreetviewClient class.

Usage

From source file:com.google.gwt.maps.sample.hellomaps.client.StreetviewDemo.java

License:Apache License

public StreetviewDemo() {
    StreetviewPanoramaOptions options = StreetviewPanoramaOptions.newInstance();
    options.setLatLng(tenthStreet);/*from  ww w . j  ava2  s  . c om*/
    svClient = new StreetviewClient();
    panorama = new StreetviewPanoramaWidget(options);
    panorama.setSize("500px", "300px");

    map = new MapWidget(tenthStreet, 16);
    map.setSize("500px", "300px");
    map.addMapClickHandler(new MapClickHandler() {
        public void onClick(MapClickEvent event) {
            LatLng point = event.getLatLng() == null ? event.getOverlayLatLng() : event.getLatLng();
            if (point != null) {
                svClient.getNearestPanoramaLatLng(point, new LatLngStreetviewCallback() {
                    @Override
                    public void onFailure() {
                    }

                    @Override
                    public void onSuccess(LatLng point) {
                        panorama.setLocationAndPov(point, Pov.newInstance());
                    }
                });
            }
        }
    });

    panorama.addInitializedHandler(new StreetviewInitializedHandler() {
        public void onInitialized(StreetviewInitializedEvent event) {
            currentLatLng = event.getLocation().getLatLng();
            currentPov = event.getLocation().getPov();
            map.setCenter(currentLatLng);
            updatePolyline();
        }
    });

    panorama.addPitchChangedHandler(new StreetviewPitchChangedHandler() {
        public void onPitchChanged(StreetviewPitchChangedEvent event) {
            currentPov.setPitch(event.getPitch());
            updatePolyline();
        }
    });

    panorama.addYawChangedHandler(new StreetviewYawChangedHandler() {
        public void onYawChanged(StreetviewYawChangedEvent event) {
            currentPov.setYaw(event.getYaw());
            updatePolyline();
        }
    });

    panorama.addZoomChangedHandler(new StreetviewZoomChangedHandler() {
        public void onZoomChanged(StreetviewZoomChangedEvent event) {
            currentPov.setZoom(event.getZoom());
            updatePolyline();
        }
    });

    panel = new VerticalPanel();
    panel.add(panorama);
    panel.add(map);
    initWidget(panel);
}