use of com.here.android.mpa.venues3d.VenueService.InitStatus in project here-android-sdk-examples by heremaps.
the class Venue3dActivity method initialize.
private void initialize() {
setContentView(R.layout.venues3d);
m_activity = this;
// Search for the map fragment in order to finish setup by calling init().
m_mapFragment = getMapFragment();
m_venueIdEditText = (EditText) findViewById(R.id.venueIdEditText);
m_mainControlLayout = (LinearLayout) findViewById(R.id.venueOpeningLayout);
m_routeInfoLayout = (LinearLayout) findViewById(R.id.routeInfoLayout);
m_routingOptionType = (Spinner) findViewById(R.id.routeOptionType);
m_routingOptionMode = (Spinner) findViewById(R.id.routeOptionMode);
m_routeStartGuideText = (TextView) findViewById(R.id.startLocationGuideText);
m_routeEndGuideText = (TextView) findViewById(R.id.endLocationGuideText);
m_routingFromText = (TextView) findViewById(R.id.startLocationText);
m_routingToText = (TextView) findViewById(R.id.endLocationText);
m_showRouteButton = (Button) findViewById(R.id.buttonShowRoute);
// Fill dropDownList with routing type names.
String[] type_values = new String[] { "Fastest", "Shortest" };
configureSpinner(m_routingOptionType, type_values);
// Fill dropDownList with routing mode names.
String[] mode_values = new String[] { "Car", "Pedestrian", "Public Transport" };
configureSpinner(m_routingOptionMode, mode_values);
// Set default values to: Fastest and Pedestrian.
m_routingOptionType.setSelection(0);
m_routingOptionMode.setSelection(1);
// Set path of disk cache
String diskCacheRoot = m_activity.getFilesDir().getPath() + File.separator + ".isolated-here-maps";
// This will use external storage to save map cache data, it is also possible to set
// private app's path
String path = new File(getExternalFilesDir(null), ".here-map-data").getAbsolutePath();
// This method will throw IllegalArgumentException if provided path is not writable
com.here.android.mpa.common.MapSettings.setDiskCacheRootPath(path);
// Initialise the Map Fragment to have a map created and attached to
// the fragment
m_mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(Error error) {
if (error == Error.NONE) {
// retrieve a reference of the map from the map fragment
m_map = m_mapFragment.getMap();
// Set the map center, zoom level, orientation and tilt
m_map.setCenter(new GeoCoordinate(49.196261, -123.004773, 0.0), Map.Animation.NONE);
} else {
System.out.println("ERROR: Cannot initialize Map Fragment" + error.toString());
new AlertDialog.Builder(m_activity).setMessage("Error : " + error.name() + "\n\n" + error.getDetails()).setTitle(R.string.engine_init_error).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
m_activity.finish();
}
}).create().show();
}
}
}, new VenueServiceListener() {
@Override
public void onInitializationCompleted(InitStatus result) {
if (result == InitStatus.ONLINE_SUCCESS || result == InitStatus.OFFLINE_SUCCESS) {
// Register the activity class as VenueMapFragment.VenueListener
m_mapFragment.addListener(m_activity);
// Set animations on for floor change and venue entering
m_mapFragment.setFloorChangingAnimation(true);
m_mapFragment.setVenueEnteringAnimation(true);
// Ask notification when venue visible; this notification is
// part of VenueMapFragment.VenueListener
m_mapFragment.setVenuesInViewportCallback(true);
// Add listener for onCombinedRouteCompleted.
m_mapFragment.getRoutingController().addListener(m_activity);
// Add listener for map gesture.
m_mapFragment.getMapGesture().addOnGestureListener(m_activity, 0, false);
// Create floor change widget
m_floorsController = new VenueFloorsController(m_activity, m_mapFragment, (ListView) findViewById(R.id.floorListView), R.layout.floor_item, R.id.floorName, R.id.floorGroundSep);
m_initCompleted.set(true);
// Start position tracking
PositioningManager positioningManager = PositioningManager.getInstance();
positioningManager.start(PositioningManager.LocationMethod.GPS_NETWORK_INDOOR);
// Set positioning indicator visible
PositionIndicator positionIndicator = m_mapFragment.getPositionIndicator();
positionIndicator.setVisible(true);
}
}
});
}
Aggregations