Search in sources :

Example 46 with GeoCoordinate

use of com.here.android.mpa.common.GeoCoordinate in project here-android-sdk-examples by heremaps.

the class MapFragmentView method addMarkerAtPlace.

private void addMarkerAtPlace(PlaceLink placeLink) {
    Image img = new Image();
    try {
        img.setImageResource(R.drawable.marker);
    } catch (IOException e) {
        e.printStackTrace();
    }
    MapMarker mapMarker = new MapMarker();
    mapMarker.setIcon(img);
    mapMarker.setCoordinate(new GeoCoordinate(placeLink.getPosition()));
    m_map.addMapObject(mapMarker);
    m_mapObjectList.add(mapMarker);
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) IOException(java.io.IOException) Image(com.here.android.mpa.common.Image)

Example 47 with GeoCoordinate

use of com.here.android.mpa.common.GeoCoordinate 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 48 with GeoCoordinate

use of com.here.android.mpa.common.GeoCoordinate 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)

Example 49 with GeoCoordinate

use of com.here.android.mpa.common.GeoCoordinate 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 Berlin Germany.
                         */
                    m_map.setCenter(new GeoCoordinate(52.500556, 13.398889, 0.0), Map.Animation.NONE);
                    /* Set the zoom level. */
                    m_map.setZoomLevel(8);
                } 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 50 with GeoCoordinate

use of com.here.android.mpa.common.GeoCoordinate in project here-android-sdk-examples by heremaps.

the class MapFragmentView method initFloatPropertyButton.

/**
 * Initialize change float property button to add customizable scheme which customizes country
 * boundary 's width.
 */
private void initFloatPropertyButton() {
    m_floatBtn = (Button) m_activity.findViewById(R.id.float_button);
    m_floatBtn.setOnClickListener(new View.OnClickListener() {

        // if customizable scheme named "floatScheme" does not exist yet, create one
        // and set customizable scheme 's country boundary width to be 10.0f for specific range
        // and set it to be current map scheme.
        @Override
        public void onClick(View v) {
            // if customizable scheme named with floatScheme does not exist, create one
            if (m_map != null && m_map.getCustomizableScheme(m_floatSchemeName) == null) {
                m_map.createCustomizableScheme(m_floatSchemeName, m_map.getMapScheme());
                m_floatScheme = m_map.getCustomizableScheme(m_floatSchemeName);
            }
            // create zoom range
            ZoomRange range = new ZoomRange(m_map.getMinZoomLevel(), m_map.getMaxZoomLevel());
            // set country property'width to be 10.0f
            m_floatScheme.setVariableValue(CustomizableVariables.CountryBoundary.WIDTH, 10.0f, range);
            // set customizable scheme to be current map scheme.
            m_map.setMapScheme(m_floatScheme);
            // set current center and zoom level to have a better view.
            m_map.setCenter(new GeoCoordinate(52.500556, 13.398889, 0.0), Map.Animation.NONE);
            m_map.setZoomLevel(5);
        }
    });
}
Also used : GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) ZoomRange(com.here.android.mpa.mapping.customization.ZoomRange) View(android.view.View)

Aggregations

GeoCoordinate (com.here.android.mpa.common.GeoCoordinate)50 OnEngineInitListener (com.here.android.mpa.common.OnEngineInitListener)17 DialogInterface (android.content.DialogInterface)12 RouteWaypoint (com.here.android.mpa.routing.RouteWaypoint)11 File (java.io.File)10 GeoBoundingBox (com.here.android.mpa.common.GeoBoundingBox)9 ArrayList (java.util.ArrayList)9 MapMarker (com.here.android.mpa.mapping.MapMarker)7 CoreRouter (com.here.android.mpa.routing.CoreRouter)7 List (java.util.List)7 MapRoute (com.here.android.mpa.mapping.MapRoute)6 RoutePlan (com.here.android.mpa.routing.RoutePlan)6 RouteOptions (com.here.android.mpa.routing.RouteOptions)5 RouteResult (com.here.android.mpa.routing.RouteResult)5 RoutingError (com.here.android.mpa.routing.RoutingError)5 ApplicationInfo (android.content.pm.ApplicationInfo)4 PackageManager (android.content.pm.PackageManager)4 Bundle (android.os.Bundle)4 GeoPolyline (com.here.android.mpa.common.GeoPolyline)4 Image (com.here.android.mpa.common.Image)4