Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

start virtual tour with gmaps v2 for android

is there a way to open a virtual tour with google maps api v2 for Android? (something similar to this: https://www.google.com/maps/@37.772031,-122.432005,3a,75y,12.85h,79.63t/data=!3m5!1e1!3m3!1srR8mp3c5XZoAAAAGOphoBg!2e0!3e2 )

I would like to click on a place in a gmap and offer the possibility (among other informations) to open a virtual tour (even in a webview, but how can I create the above link?)

like image 410
jiraya85 Avatar asked Mar 25 '14 12:03

jiraya85


People also ask

How do you make a virtual tour without a 360 camera?

Google Tour Creator is a tool designed to simplify the process of creating a virtual tour. After launching on May 9, Google Tour Creator has added support for photos from the Cardboard Camera app on August 7, making it possible to create a tour with unique photos without actually owning a 360 camera.


Video Answer


1 Answers

Photo Sphere is an Android camera feature that allows you to create immersive 360 degree panoramas - similar to Street View. You can take a series of photos and automatically turn them into a seamless 360 degree panorama. Then, you can easily share your photo sphere with Google Maps.

enter image description here

In order to have the Google maps displayed into your App, you should include it into your activity:

MainActivity.java
public class MainActivity extends Activity {

    // Google Map
    private GoogleMap googleMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try {
            // Loading map
            initilizeMap();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * function to load map. If map is not created it will create it for you
     * */
    private void initilizeMap() {
        if (googleMap == null) {
            googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                    R.id.map)).getMap();

            // check if map is created successfully or not
            if (googleMap == null) {
                Toast.makeText(getApplicationContext(),
                        "Sorry! unable to create maps", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        initilizeMap();
    }

}

enter image description here

And also include to your code a marker for where you want to open your virtual tour:

// latitude and longitude
double latitude = ;
double longitude = ;

// create marker
MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Hello Maps ");

// adding marker
googleMap.addMarker(marker);

enter image description here

Then update it to interact accordingly to the current position coordinates provided:

 public boolean onMarkerClick(Marker marker) {

  if(markerClicked){

   if(polyline != null){
    polyline.remove();
    polyline = null;
   }

   rectOptions.add(marker.getPosition());
   rectOptions.color(Color.RED);
   polyline = myMap.addPolyline(rectOptions);
  }else{
   if(polyline != null){
    polyline.remove();
    polyline = null;
   }

   rectOptions = new PolylineOptions().add(marker.getPosition());
   markerClicked = true;
  }

  return true;
 }

}

enter image description here

Once a Photo Sphere was made as an open format, anyone can create and view them on the web or on mobile devices, only having to use Panorama Class/Interface for that:

// This listener will be called with information about the given panorama.
OnPanoramaInfoLoadedListener infoLoadedListener =
  new OnPanoramaInfoLoadedListener() {
    @Override
    public void onPanoramaInfoLoaded(ConnectionResult result,
                                     Intent viewerIntent) {
        if (result.isSuccess()) {
            // If the intent is not null, the image can be shown as a
            // panorama.
            if (viewerIntent != null) {
                // Use the given intent to start the panorama viewer.
                startActivity(viewerIntent);
            }
        }

        // If viewerIntent is null, the image is not a viewable panorama.
    }
};

// Create client instance and connect to it.
PanoramaClient client = ...
...

// Once connected to the client, initiate the asynchronous check on whether
// the image is a viewable panorama.
client.loadPanoramaInfo(infoLoadedListener, panoramaUri);

enter image description here

Which will allow you to have a Photo Sphere viewer as part of your App.

like image 136
Avanz Avatar answered Sep 27 '22 21:09

Avanz