Search in sources :

Example 6 with Image

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

use of com.here.android.mpa.common.Image 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();
                    /* create an image to mark coordinate when tap event happens */
                    m_marker_image = new Image();
                    try {
                        m_marker_image.setImageResource(R.drawable.marker);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    m_mapFragment.getMapGesture().addOnGestureListener(new MapGesture.OnGestureListener() {

                        @Override
                        public void onPanStart() {
                            showMsg("onPanStart");
                        }

                        @Override
                        public void onPanEnd() {
                            /* show toast message for onPanEnd gesture callback */
                            showMsg("onPanEnd");
                        }

                        @Override
                        public void onMultiFingerManipulationStart() {
                        }

                        @Override
                        public void onMultiFingerManipulationEnd() {
                        }

                        @Override
                        public boolean onMapObjectsSelected(List<ViewObject> list) {
                            return false;
                        }

                        @Override
                        public boolean onTapEvent(PointF pointF) {
                            /* show toast message for onPanEnd gesture callback */
                            showMsg("onTapEvent");
                            /*
                                     * add map screen marker at coordinates of gesture. if map
                                     * screen marker already exists, change to new coordinate
                                     */
                            if (m_tap_marker == null) {
                                m_tap_marker = new MapScreenMarker(pointF, m_marker_image);
                                m_map.addMapObject(m_tap_marker);
                            } else {
                                m_tap_marker.setScreenCoordinate(pointF);
                            }
                            return false;
                        }

                        @Override
                        public boolean onDoubleTapEvent(PointF pointF) {
                            return false;
                        }

                        @Override
                        public void onPinchLocked() {
                        }

                        @Override
                        public boolean onPinchZoomEvent(float v, PointF pointF) {
                            return false;
                        }

                        @Override
                        public void onRotateLocked() {
                        }

                        @Override
                        public boolean onRotateEvent(float v) {
                            /* show toast message for onRotateEvent gesture callback */
                            showMsg("onRotateEvent");
                            return false;
                        }

                        @Override
                        public boolean onTiltEvent(float v) {
                            return false;
                        }

                        @Override
                        public boolean onLongPressEvent(PointF pointF) {
                            return false;
                        }

                        @Override
                        public void onLongPressRelease() {
                        }

                        @Override
                        public boolean onTwoFingerTapEvent(PointF pointF) {
                            return false;
                        }
                    }, 0, false);
                } 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) PointF(android.graphics.PointF) IOException(java.io.IOException) OnEngineInitListener(com.here.android.mpa.common.OnEngineInitListener) Image(com.here.android.mpa.common.Image) MapScreenMarker(com.here.android.mpa.mapping.MapScreenMarker) List(java.util.List) File(java.io.File)

Aggregations

Image (com.here.android.mpa.common.Image)7 MapMarker (com.here.android.mpa.mapping.MapMarker)6 IOException (java.io.IOException)6 GeoCoordinate (com.here.android.mpa.common.GeoCoordinate)4 PointF (android.graphics.PointF)2 Map (com.here.android.mpa.mapping.Map)2 RouteWaypoint (com.here.android.mpa.routing.RouteWaypoint)2 List (java.util.List)2 DialogInterface (android.content.DialogInterface)1 Bitmap (android.graphics.Bitmap)1 GeoBoundingBox (com.here.android.mpa.common.GeoBoundingBox)1 OnEngineInitListener (com.here.android.mpa.common.OnEngineInitListener)1 NavigationManager (com.here.android.mpa.guidance.NavigationManager)1 MapRoute (com.here.android.mpa.mapping.MapRoute)1 MapScreenMarker (com.here.android.mpa.mapping.MapScreenMarker)1 PlatformDataItemCollection (com.here.android.mpa.pde.PlatformDataItemCollection)1 PlatformDataRequest (com.here.android.mpa.pde.PlatformDataRequest)1 PlatformDataResult (com.here.android.mpa.pde.PlatformDataResult)1 CoreRouter (com.here.android.mpa.routing.CoreRouter)1 Route (com.here.android.mpa.routing.Route)1