Search in sources :

Example 16 with OnEngineInitListener

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();
                }
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) OnEngineInitListener(com.here.android.mpa.common.OnEngineInitListener) File(java.io.File)

Example 17 with OnEngineInitListener

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();
                }
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) OnEngineInitListener(com.here.android.mpa.common.OnEngineInitListener) File(java.io.File)

Example 18 with OnEngineInitListener

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();
            }
        }
    });
}
Also used : ApplicationContext(com.here.android.mpa.common.ApplicationContext) DialogInterface(android.content.DialogInterface) OnEngineInitListener(com.here.android.mpa.common.OnEngineInitListener)

Example 19 with OnEngineInitListener

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();
                }
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) OnEngineInitListener(com.here.android.mpa.common.OnEngineInitListener) File(java.io.File)

Example 20 with OnEngineInitListener

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();
                }
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) OnEngineInitListener(com.here.android.mpa.common.OnEngineInitListener) File(java.io.File)

Aggregations

OnEngineInitListener (com.here.android.mpa.common.OnEngineInitListener)22 DialogInterface (android.content.DialogInterface)16 GeoCoordinate (com.here.android.mpa.common.GeoCoordinate)16 File (java.io.File)14 ApplicationContext (com.here.android.mpa.common.ApplicationContext)5 ApplicationInfo (android.content.pm.ApplicationInfo)4 PackageManager (android.content.pm.PackageManager)4 Bundle (android.os.Bundle)4 PositioningManager (com.here.android.mpa.common.PositioningManager)3 VenueServiceListener (com.here.android.mpa.venues3d.VenueService.VenueServiceListener)2 PointF (android.graphics.PointF)1 RemoteException (android.os.RemoteException)1 View (android.view.View)1 Image (com.here.android.mpa.common.Image)1 LocationDataSource (com.here.android.mpa.common.LocationDataSource)1 MapEngine (com.here.android.mpa.common.MapEngine)1 MapScreenMarker (com.here.android.mpa.mapping.MapScreenMarker)1 OnMapRenderListener (com.here.android.mpa.mapping.OnMapRenderListener)1 PositionIndicator (com.here.android.mpa.mapping.PositionIndicator)1 RouteWaypoint (com.here.android.mpa.routing.RouteWaypoint)1