Search in sources :

Example 11 with OnEngineInitListener

use of com.here.android.mpa.common.OnEngineInitListener 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);
            }
        }
    });
}
Also used : VenueServiceListener(com.here.android.mpa.venues3d.VenueService.VenueServiceListener) DialogInterface(android.content.DialogInterface) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) OnEngineInitListener(com.here.android.mpa.common.OnEngineInitListener) PositionIndicator(com.here.android.mpa.mapping.PositionIndicator) PositioningManager(com.here.android.mpa.common.PositioningManager) InitStatus(com.here.android.mpa.venues3d.VenueService.InitStatus) File(java.io.File)

Example 12 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();
    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();
        }
    });
}
Also used : DialogInterface(android.content.DialogInterface) OnMapRenderListener(com.here.android.mpa.mapping.OnMapRenderListener) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) OnEngineInitListener(com.here.android.mpa.common.OnEngineInitListener) View(android.view.View) RouteWaypoint(com.here.android.mpa.routing.RouteWaypoint) File(java.io.File)

Example 13 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.LINEAR);
                    m_map.setZoomLevel(13.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)

Example 14 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();
    m_mapFragmentContainer = m_activity.findViewById(R.id.mapfragment);
    // 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);
                    m_map.setZoomLevel(13.2);
                } else {
                    new android.app.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 15 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)

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