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();
}
}
});
}
}
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();
}
}
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);
}
}
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());
}
}
});
}
}
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;
}
Aggregations