use of com.here.android.mpa.mapping.OnMapRenderListener in project here-android-sdk-examples by heremaps.
the class MapFragmentView method initMapFragment.
private void initMapFragment() {
m_mapFragment = getMapFragment();
m_laneInfoView = m_activity.findViewById(R.id.laneInfoLayout);
// 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 == OnEngineInitListener.Error.NONE) {
m_mapFragment.getMapGesture().addOnGestureListener(gestureListener, 100, true);
// retrieve a reference of the map from the map fragment
m_map = m_mapFragment.getMap();
m_map.setZoomLevel(19);
m_map.addTransformListener(onTransformListener);
PositioningManager.getInstance().start(PositioningManager.LocationMethod.GPS_NETWORK);
} 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();
}
}
});
m_mapFragment.addOnMapRenderListener(new OnMapRenderListener() {
@Override
public void onPreDraw() {
if (m_positionIndicatorFixed != null) {
if (NavigationManager.getInstance().getMapUpdateMode().equals(NavigationManager.MapUpdateMode.ROADVIEW)) {
if (!m_returningToRoadViewMode) {
// when road view is active, we set the position indicator to align
// with the current map transform center to synchronize map and map
// marker movements.
GeoCoordinate geoCoordinate = m_map.pixelToGeo(m_mapTransformCenter);
if (geoCoordinate != null && geoCoordinate.isValid()) {
m_positionIndicatorFixed.setCoordinate(geoCoordinate);
}
}
}
}
}
@Override
public void onPostDraw(boolean var1, long var2) {
}
@Override
public void onSizeChanged(int var1, int var2) {
}
@Override
public void onGraphicsDetached() {
}
@Override
public void onRenderBufferCreated() {
}
});
}
m_activity.findViewById(R.id.calculate).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
calculateAndStartNavigation();
}
});
}
Aggregations