Search in sources :

Example 36 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();
                    /*
                         * 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 37 with GeoCoordinate

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

the class MapFragmentView method showSelectedMap.

private void showSelectedMap() {
    if (m_mapDataPrefetcher != null) {
        m_map.removeAllMapObjects();
        m_mapFragment.getPositionIndicator().setVisible(false);
        MapEngine.setOnline(true);
    }
    if (m_selectedOption == OptionType.MAP_BOUNDING_BOX) {
        if (m_progressBar.getVisibility() == View.VISIBLE) {
            boolean b = true;
        }
        m_map.setZoomLevel(11.73);
        m_map.setCenter(new GeoCoordinate(52.531003, 13.384783), Map.Animation.NONE);
        changeState(State.PREFETCH_MAP);
    } else {
        showRoute();
    }
}
Also used : GeoCoordinate(com.here.android.mpa.common.GeoCoordinate)

Example 38 with GeoCoordinate

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

the class MapFragmentView method prefetchMap.

private void prefetchMap(OptionType selectedOption) {
    m_mapDataPrefetcher = MapDataPrefetcher.getInstance();
    m_mapDataPrefetcher.addListener(new PrefetchMapDataListener());
    changeState(State.DEFAULT);
    MapDataPrefetcher.Request prefetchRequest;
    if (selectedOption == OptionType.MAP_BOUNDING_BOX) {
        GeoCoordinate m_geoCoordinate = new GeoCoordinate(53.34187, -6.28635);
        m_geoBoundingBox = new GeoBoundingBox(m_geoCoordinate, BOUNDING_BOX_HEIGHT, BOUNDING_BOX_WIDTH);
        m_mapDataPrefetcher.estimateMapDataSize(m_geoBoundingBox);
        prefetchRequest = m_mapDataPrefetcher.fetchMapData(m_geoBoundingBox);
    } else {
        m_mapDataPrefetcher.estimateMapDataSize(m_route, ROUTE_RADIUS);
        prefetchRequest = m_mapDataPrefetcher.fetchMapData(m_route, ROUTE_RADIUS);
    }
}
Also used : MapDataPrefetcher(com.here.android.mpa.prefetcher.MapDataPrefetcher) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) GeoBoundingBox(com.here.android.mpa.common.GeoBoundingBox)

Example 39 with GeoCoordinate

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

the class MapFragmentView method showCapitals.

/**
 * Method contains logic for extracting data about capitals and placing it on a map
 */
private void showCapitals() {
    /*
         * Create an image for marker
         */
    final int[] colorArray = new int[25 * 25];
    for (int i = 0; i < colorArray.length; i++) {
        colorArray[i] = Color.GREEN;
    }
    Bitmap bitmap = Bitmap.createBitmap(colorArray, 25, 25, Bitmap.Config.ARGB_8888);
    final Image image = new Image();
    image.setBitmap(bitmap);
    /*
         * Create list of PDE layers to extract
         */
    Set<String> layers = new HashSet<>(Arrays.asList(CITY_POI_LAYER));
    GeoBoundingBox bbox = map.getBoundingBox();
    /*
         * Check that bounding box is valid
         */
    if (bbox == null || bbox.isEmpty()) {
        Log.e(TAG, "PDE bbox is null or empty!");
        Toast.makeText(this.activity.getApplicationContext(), "Current zoom level is too low. Please zoom closer.", Toast.LENGTH_LONG).show();
    } else {
        /*
             * Create and send PDE request
             */
        final PlatformDataRequest request = PlatformDataRequest.createBoundingBoxRequest(layers, bbox);
        request.execute(new PlatformDataRequest.Listener<PlatformDataResult>() {

            @Override
            public void onCompleted(PlatformDataResult platformDataResult, PlatformDataRequest.Error error) {
                if (error == null) {
                    /*
                         * Process PDE request response
                         */
                    PlatformDataItemCollection result = platformDataResult.get(CITY_POI_LAYER);
                    List<MapObject> markers = new ArrayList<>();
                    for (java.util.Map<String, String> entry : result.extract()) {
                        double lat = Double.parseDouble(entry.get("LAT")) / 100_000;
                        double lon = Double.parseDouble(entry.get("LON")) / 100_000;
                        MapMarker marker = new MapMarker();
                        marker.setCoordinate(new GeoCoordinate(lat, lon));
                        marker.setIcon(image);
                        markers.add(marker);
                    }
                    /*
                         * Add list of map markers on map
                         */
                    map.addMapObjects(markers);
                    /*
                         * Set the zoom level.
                         */
                    map.setZoomLevel(3.95);
                } else {
                    /*
                         * Process PDE request error
                         */
                    Log.i(TAG, "PDE error: " + error.getFaultCode());
                    Log.i(TAG, "PDE error: " + error.getMessage());
                    Log.i(TAG, "PDE error: " + error.getResponseCode());
                    Log.i(TAG, "PDE error: " + error.getType().toString());
                }
            }
        });
    }
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) PlatformDataItemCollection(com.here.android.mpa.pde.PlatformDataItemCollection) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) Image(com.here.android.mpa.common.Image) RouteWaypoint(com.here.android.mpa.routing.RouteWaypoint) Bitmap(android.graphics.Bitmap) PlatformDataRequest(com.here.android.mpa.pde.PlatformDataRequest) PlatformDataResult(com.here.android.mpa.pde.PlatformDataResult) ArrayList(java.util.ArrayList) List(java.util.List) GeoBoundingBox(com.here.android.mpa.common.GeoBoundingBox) HashMap(java.util.HashMap) Map(com.here.android.mpa.mapping.Map) HashSet(java.util.HashSet)

Example 40 with GeoCoordinate

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

the class BasicVenueActivity method onTapEvent.

@Override
public boolean onTapEvent(PointF p) {
    if (mMap == null) {
        Toast.makeText(BasicVenueActivity.this, "Initialization of venue service is in progress...", Toast.LENGTH_SHORT).show();
        return false;
    }
    GeoCoordinate touchLocation = mMap.pixelToGeo(p);
    double lat = touchLocation.getLatitude();
    double lon = touchLocation.getLongitude();
    String StrGeo = String.format("%.6f, %.6f", lat, lon);
    Toast.makeText(getApplicationContext(), StrGeo, Toast.LENGTH_SHORT).show();
    mUserControl = true;
    invalidateOptionsMenu();
    return false;
}
Also used : GeoCoordinate(com.here.android.mpa.common.GeoCoordinate)

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