use of com.here.android.mpa.venues3d.VenueService.VenueServiceListener in project here-android-sdk-examples by heremaps.
the class BasicVenueActivity method startVenueMaps.
/**
* Initializes HERE Venue Maps. Called after permission check.
*/
private void startVenueMaps() {
Log.v(TAG, "InitializeVenueMaps");
mActivity = this;
mVenueMapFragment = getMapFragment();
mLocationInfo = (TextView) findViewById(R.id.textViewLocationInfo);
mVenueMapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(Error error) {
if (error == Error.NONE) {
Log.v(TAG, "InitializeVenueMaps: OnEngineInitializationCompleted");
mVenueService = mVenueMapFragment.getVenueService();
mRoutingController = mVenueMapFragment.getRoutingController();
if (mRoutingController != null) {
mRoutingController.addListener(BasicVenueActivity.this);
}
// Setting venue service content based on menu option
if (!mPrivateVenues) {
// Public only
setVenueServiceContent(false, false);
} else {
// Private + public
setVenueServiceContent(true, true);
}
} else {
new AlertDialog.Builder(BasicVenueActivity.this).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) {
BasicVenueActivity.this.finish();
}
}).create().show();
}
}
}, new VenueServiceListener() {
@Override
public void onInitializationCompleted(VenueService.InitStatus result) {
Log.v(TAG, "VenueServiceListener: OnInitializationCompleted with result: %s", result);
switch(result) {
case IN_PROGRESS:
Log.v(TAG, "Initialization of venue service is in progress...");
Toast.makeText(BasicVenueActivity.this, "Initialization of venue service is in progress...", Toast.LENGTH_SHORT).show();
break;
case OFFLINE_SUCCESS:
case ONLINE_SUCCESS:
// Adding venue listener to map fragment
mVenueMapFragment.addListener(mActivity);
// Set animations on for floor change and venue entering
mVenueMapFragment.setFloorChangingAnimation(true);
mVenueMapFragment.setVenueEnteringAnimation(true);
// Ask notification when venue visible; this notification is
// part of VenueMapFragment.VenueListener
mVenueMapFragment.setVenuesInViewportCallback(true);
// Add Gesture Listener for map fragment
mVenueMapFragment.getMapGesture().addOnGestureListener(mActivity, 0, false);
// retrieve a reference of the map from the map fragment
mMap = mVenueMapFragment.getMap();
mMap.addTransformListener(mActivity);
mMap.setZoomLevel(mMap.getMaxZoomLevel() - 3);
// Create floors controller widget
mFloorsControllerWidget = new FloorsControllerWidget(mActivity, mVenueMapFragment, (ListView) findViewById(R.id.floorListView), R.layout.floor_item, R.id.floorName, R.id.floorGroundSep);
// Start of Position Updates
try {
startPositionUpdates();
mVenueMapFragment.getPositionIndicator().setVisible(true);
} catch (Exception ex) {
Log.w(TAG, "startPositionUpdates: Could not register for location updates: %s", Log.getStackTraceString(ex));
}
if (mLastMapCenter == null) {
mMap.setCenter(new GeoCoordinate(61.497961, 23.763606, 0.0), Map.Animation.NONE);
} else {
mMap.setCenter(mLastMapCenter, Map.Animation.NONE);
}
break;
}
}
});
}
use of com.here.android.mpa.venues3d.VenueService.VenueServiceListener 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