use of com.here.android.mpa.customlocation2.CLE2Geometry in project here-android-sdk-examples by heremaps.
the class MapFragmentView method proximitySearch.
/**
* Demonstration of the proximity search feature.
* Search for all geometries from the center of the map in the desired search radius.
*/
private void proximitySearch() {
clearMap();
MapCircle searchCircle = new MapCircle(m_radiusSeekBar.getProgress() + 1, m_map.getCenter());
searchCircle.setFillColor(Color.argb(64, 0, 0, 255));
m_map.addMapObject(searchCircle);
// create proximity search request using map center as center.
CLE2ProximityRequest request = new CLE2ProximityRequest(m_layerEdit.getText().toString(), m_map.getCenter(), m_radiusSeekBar.getProgress() + 1);
// set desired connectivity mode
// if the connectivity mode is OFFLINE, the geometries will be searched in local storage,
// otherwise in remote storage.
request.setConnectivityMode((CLE2Request.CLE2ConnectivityMode) m_connectivityModeSpinner.getSelectedItem());
// execute the reques
request.execute(new CLE2Request.CLE2ResultListener() {
@Override
public void onCompleted(@Nullable CLE2Result cle2Result, @NonNull String error) {
if (!error.equalsIgnoreCase("none") || cle2Result == null) {
Toast.makeText(m_activity, "Error : " + error, Toast.LENGTH_LONG).show();
return;
}
for (CLE2Geometry geometry : cle2Result.getGeometries()) {
CLE2PointGeometry pointGeometry = (CLE2PointGeometry) geometry;
m_geometryList.add(pointGeometry);
MapMarker mapMarker = new MapMarker(pointGeometry.getPoint());
m_map.addMapObject(mapMarker);
}
}
});
}
use of com.here.android.mpa.customlocation2.CLE2Geometry in project here-android-sdk-examples by heremaps.
the class MapFragmentView method downloadLayer.
/**
* Download all layer data to remote storage
*/
private void downloadLayer() {
clearMap();
// get instance of the data manager
final CLE2DataManager dataManager = CLE2DataManager.getInstance();
final String layerName = m_layerEdit.getText().toString();
// create download layer task
CLE2Task<CLE2OperationResult> task = dataManager.newDownloadLayerTask(layerName);
// start downloading
task.start(new CLE2Task.Callback<CLE2OperationResult>() {
@Override
public void onTaskFinished(@Nullable CLE2OperationResult cle2OperationResult, @NonNull CLE2Request.CLE2Error cle2Error) {
if (cle2Error.getErrorCode() != CLE2Request.CLE2Error.CLE2ErrorCode.NONE || cle2OperationResult == null) {
Toast.makeText(m_activity, "Error : " + cle2Error.getErrorMessage(), Toast.LENGTH_LONG).show();
return;
}
Toast.makeText(m_activity, "Operation completed successfully.\n" + "Number of downloaded objects is " + cle2OperationResult.getAffectedItemCount(), Toast.LENGTH_SHORT).show();
// now fetch geometry from local storage
CLE2Task<List<CLE2Geometry>> fetchTask = dataManager.newFetchLocalLayersTask(Collections.singletonList(layerName));
fetchTask.start(new CLE2Task.Callback<List<CLE2Geometry>>() {
@Override
public void onTaskFinished(@Nullable List<CLE2Geometry> cle2Geometries, @NonNull CLE2Request.CLE2Error cle2Error) {
if (cle2Error.getErrorCode() != CLE2Request.CLE2Error.CLE2ErrorCode.NONE || cle2Geometries == null) {
Toast.makeText(m_activity, "Error : " + cle2Error.getErrorMessage(), Toast.LENGTH_LONG).show();
return;
}
for (CLE2Geometry geometry : cle2Geometries) {
CLE2PointGeometry pointGeometry = (CLE2PointGeometry) geometry;
m_geometryList.add(pointGeometry);
MapMarker mapMarker = new MapMarker(pointGeometry.getPoint());
m_map.addMapObject(mapMarker);
}
}
});
}
});
}
Aggregations