use of com.here.android.mpa.common.OnEngineInitListener in project here-android-sdk-examples by heremaps.
the class MapFragmentView method initMapFragment.
private void initMapFragment() {
/* Locate the mapFragment UI element */
m_mapFragment = getMapFragment();
// This will use external storage to save map cache data, it is also possible to set
// private app's path
String path = new File(m_activity.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);
if (m_mapFragment != null) {
/* Initialize the AndroidXMapFragment, results will be given via the called back. */
m_mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
if (error == Error.NONE) {
/*
* If no error returned from map fragment initialization, the map will be
* rendered on screen at this moment.Further actions on map can be provided
* by calling Map APIs.
*/
m_map = m_mapFragment.getMap();
/*
* Set the map center to the 4350 Still Creek Dr Burnaby BC (no animation).
*/
m_map.setCenter(new GeoCoordinate(49.259149, -123.008555, 0.0), Map.Animation.NONE);
/* Set the zoom level to the average between min and max zoom level. */
m_map.setZoomLevel(14);
m_activity.supportInvalidateOptionsMenu();
/*
* Set up a handler for handling MapMarker drag events.
*/
m_mapFragment.setMapMarkerDragListener(new OnDragListenerHandler());
} else {
Log.e(this.getClass().toString(), "onEngineInitializationCompleted: " + "ERROR=" + error.getDetails(), error.getThrowable());
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();
}
}
});
}
}
use of com.here.android.mpa.common.OnEngineInitListener in project here-android-sdk-examples by heremaps.
the class MapFragmentView method initMapFragment.
private void initMapFragment() {
/* Locate the mapFragment UI element */
m_mapFragment = getMapFragment();
// This will use external storage to save map cache data, it is also possible to set
// private app's path
String path = new File(m_activity.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);
if (m_mapFragment != null) {
/* Initialize the AndroidXMapFragment, results will be given via the called back. */
m_mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
if (error == Error.NONE) {
/*
* If no error returned from map fragment initialization, the map will be
* rendered on screen at this moment.Further actions on map can be provided
* by calling Map APIs.
*/
m_map = m_mapFragment.getMap();
/*
* Map center can be set to a desired location at this point.
* It also can be set to the current location ,which needs to be delivered by the PositioningManager.
* Please refer to the user guide for how to get the real-time location.
*/
m_map.setCenter(new GeoCoordinate(49.258576, -123.008268), Map.Animation.NONE);
} else {
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();
}
}
});
}
}
use of com.here.android.mpa.common.OnEngineInitListener in project here-android-sdk-examples by heremaps.
the class MainActivity method initSDK.
private void initSDK() {
ApplicationContext appContext = new ApplicationContext(this);
MapEngine.getInstance().init(appContext, new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(Error error) {
if (error == Error.NONE) {
startPositioningManager();
startNavigationManager();
activateSpeedLimitFragment();
} else {
Log.e("MainActivity", " init error: " + error + ", " + error.getDetails(), error.getThrowable());
new AlertDialog.Builder(MainActivity.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) {
MainActivity.this.finish();
}
}).create().show();
}
}
});
}
use of com.here.android.mpa.common.OnEngineInitListener in project here-android-sdk-examples by heremaps.
the class MapFragmentView method initMapFragment.
private void initMapFragment() {
/* Locate the mapFragment UI element */
m_mapFragment = getMapFragment();
// This will use external storage to save map cache data, it is also possible to set
// private app's path
String path = new File(m_activity.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);
if (m_mapFragment != null) {
/* Initialize the AndroidXMapFragment, results will be given via the called back. */
m_mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
if (error == Error.NONE) {
m_map = m_mapFragment.getMap();
m_map.setCenter(new GeoCoordinate(49.259149, -123.008555), Map.Animation.NONE);
// Put this call in Map.onTransformListener if the animation(Linear/Bow)
// is used in setCenter()
m_map.setZoomLevel(13.2);
/*
* Get the NavigationManager instance.It is responsible for providing voice
* and visual instructions while driving and walking
*/
m_navigationManager = NavigationManager.getInstance();
} else {
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();
}
}
});
}
}
use of com.here.android.mpa.common.OnEngineInitListener in project here-android-sdk-examples by heremaps.
the class MapFragmentView method initMapFragment.
private void initMapFragment() {
m_mapFragment = getMapFragment();
// This will use external storage to save map cache data, it is also possible to set
// private app's path
String path = new File(m_activity.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);
if (m_mapFragment != null) {
/* Initialize the AndroidXMapFragment, results will be given via the called back. */
m_mapFragment.init(new OnEngineInitListener() {
@Override
public void onEngineInitializationCompleted(OnEngineInitListener.Error error) {
/*
* if no error returned from map fragment initialization, then set map center
* and zoom level.
*/
if (error == Error.NONE) {
/* get the map object */
m_map = m_mapFragment.getMap();
/* Set the map center to the Berlin region (no animation). */
m_map.setCenter(new GeoCoordinate(52.500556, 13.398889, 0.0), Map.Animation.NONE);
/* Set the zoom level to the average between min and max zoom level. */
m_map.setZoomLevel((m_map.getMaxZoomLevel() + m_map.getMinZoomLevel()) / 2);
} else {
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();
}
}
});
}
}
Aggregations