3

I'm trying to give google earth api a start point which I get back from Google map Api v3(I have lat and lng). The thing I want to do is give a location to Google Earth and it can automatically moved to street view level.

So far what I did can only move to ground level. The following code is how I try move Google Earth's camera

var lookAt = DS_ge.createLookAt('');
lookAt.setLatitude(myRoute.steps[0].path[0].lat());
lookAt.setLongitude(myRoute.steps[0].path[0].lng());
lookAt.setRange(1000.0); //default is 0.0
DS_ge.getView().setAbstractView(lookAt);

Is there any way to achieve the result like I move the pegman to the location I want and show the street view. I think there's a pegman function make it work but I can't find it. Any suggestion will be helpful thx :)

Fraser
  • 15,275
  • 8
  • 53
  • 104

1 Answers1

3

To programmatically enter StreetView mode you need to add a gx:ViewOptions element to the LookAt element:

var lookAt = ge.createLookAt('');
// ... set your LookAt parameters
// don't forget default Altitude mode is ClampToGround
lookAt.setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND)

// enable Street view option on ViewerOptions and add that to LookAt
var viewerOptions = ge.createViewerOptions('');
viewerOptions.setOption(ge.OPTION_STREET_VIEW, ge.OPTION_STATE_ENABLED);
lookAt.setViewerOptions(viewerOptions);

ge.getView().setAbstractView(lookAt);

To control whether the user can enter Street View using manual navigation controls, call

var navcontrol = ge.getNavigationControl();
navcontrol.setStreetViewEnabled(true);
CodeMonkey
  • 22,825
  • 4
  • 35
  • 75
  • https://developers.google.com/earth/documentation/reference/interface_g_e_plugin#ac5c3007e6ca69cec000d2bbfa18b95c8 – Fraser Mar 27 '13 at 14:29
  • That is why I love stackoverflow! Thanks! – Faizan Mar 01 '15 at 16:34
  • @jasonM1, How do I go about if I want to set the default street view view to main road. When it goes into street view, the camera is always looking at the ground. – Faizan May 10 '15 at 11:31