Оценить:
 Рейтинг: 0

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

Год написания книги
2017
<< 1 ... 3 4 5 6 7 8 9 10 11 ... 22 >>
На страницу:
7 из 22
Настройки чтения
Размер шрифта
Высота строк
Поля

super. onResume ();

// When the activity is resumed it is time to enable the

// BeyondarLocationManager

BeyondarLocationManager. enable ();

}

@Override

protected void onPause () {

super. onPause ();

// To avoid unnecessary battery usage disable BeyondarLocationManager

// when the activity goes on pause.

BeyondarLocationManager. disable ();

}

@Override

public void onClick (View v) {

// When the user clicks on the button we animate the map to the user

// location

LatLng userLocation = new LatLng(mWorld.getLatitude (), mWorld.getLongitude ());

mMap.moveCamera(CameraUpdateFactory.newLatLngZoom (userLocation, 15));

mMap.animateCamera (CameraUpdateFactory. zoomTo (19), 2000, null);

}

@Override

public void onMapReady (GoogleMap googleMap) {

mMap=googleMap;

// We create the world and fill the world

mWorld = CustomWorldHelper.generateObjects (this);

// As we want to use GoogleMaps, we are going to create the plugin and

// attach it to the World

mGoogleMapPlugin = new GoogleMapWorldPlugin (this);

// Then we need to set the map in to the GoogleMapPlugin

mGoogleMapPlugin.setGoogleMap (mMap);

// Now that we have the plugin created let’s add it to our world.

// NOTE: It is better to load the plugins before start adding object in

// to the world.

mWorld.addPlugin (mGoogleMapPlugin);

mMap.setOnMarkerClickListener (this);

mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mGoogleMapPlugin.getLatLng (), 15));

mMap.animateCamera (CameraUpdateFactory. zoomTo (19), 2000, null);

// Lets add the user position to the map

GeoObject user = new GeoObject (1000l);

user.setGeoPosition(mWorld.getLatitude (), mWorld.getLongitude ());

user.setImageResource (R. drawable. flag);

user.setName («User position»);

mWorld.addBeyondarObject (user);

BeyondarLocationManager.addWorldLocationUpdate (mWorld);

BeyondarLocationManager.addGeoObjectLocationUpdate (user);

// We need to set the LocationManager to the BeyondarLocationManager.

BeyondarLocationManager

.setLocationManager ((LocationManager) getSystemService (Context. LOCATION_SERVICE));

}

}
<< 1 ... 3 4 5 6 7 8 9 10 11 ... 22 >>
На страницу:
7 из 22