Разработка Android-приложений с Augmented Reality - страница 20

Шрифт
Интервал


import android.widget.Toast;


import com.beyondar.android.world.GeoObject;

import com.beyondar.android. world. World;


@SuppressLint («SdCardPath»)

public class CustomWorldHelper {

public static final int LIST_TYPE_EXAMPLE_1 = 1;


public static World sharedWorld;


public static World generateObjects (Context context, Location mCurrentLocation) {

sharedWorld = new World (context);

// The user can set the default bitmap. This is useful if you are

// loading images form Internet and the connection get lost


sharedWorld.setDefaultImage(R.drawable.beyondar_default_unknow_icon);

// User position (you can change it using the GPS listeners form Android

// API)

if (mCurrentLocation== null) {

mCurrentLocation=new Location (»»);

mCurrentLocation.setLatitude (41.90533734214473d);

mCurrentLocation.setLongitude (2.565848038959814d);

}


sharedWorld.setGeoPosition(mCurrentLocation.getLatitude(),mCurrentLocation.getLongitude ());


// Create an object with an image in the app resources.

// And the same goes for the app assets

GeoObject go = new GeoObject (1l);

go.setGeoPosition(mCurrentLocation.getLatitude()+0.00005,mCurrentLocation.getLongitude () -0.0001);

go.setImageUri("assets://creature_7.png»);

go.setName («Image from assets»);


// Add the GeoObjects to the world

sharedWorld.addBeyondarObject (go);


return sharedWorld;

}


}

import android.content.pm.PackageManager;

import android. location. Location;

import android. os. Bundle;

import android.support.annotation.NonNull;

import android.support.annotation.Nullable;

import android.support.v4.app.ActivityCompat;

import android.support.v4.app.FragmentActivity;

import android.widget.Toast;


import com.beyondar.android.plugin. googlemap. GoogleMapWorldPlugin;

import com.beyondar.android.world.GeoObject;

import com.beyondar.android. world. World;

import com.google.android.gms.common.ConnectionResult;

import com.google.android.gms.common. api. GoogleApiClient;

import com.google.android.gms. location. LocationListener;

import com.google.android.gms. location. LocationRequest;

import com.google.android.gms. location. LocationServices;

import com.google.android.gms.maps.CameraUpdateFactory;

import com.google.android.gms.maps. GoogleMap;

import com.google.android.gms.maps. GoogleMap. OnMarkerClickListener;

import com.google.android.gms.maps. OnMapReadyCallback;