Search in sources :

Example 1 with CLE2ProximityRequest

use of com.here.android.mpa.customlocation2.CLE2ProximityRequest 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);
            }
        }
    });
}
Also used : MapMarker(com.here.android.mpa.mapping.MapMarker) CLE2ProximityRequest(com.here.android.mpa.customlocation2.CLE2ProximityRequest) CLE2Request(com.here.android.mpa.customlocation2.CLE2Request) CLE2Geometry(com.here.android.mpa.customlocation2.CLE2Geometry) CLE2Result(com.here.android.mpa.customlocation2.CLE2Result) CLE2PointGeometry(com.here.android.mpa.customlocation2.CLE2PointGeometry) MapCircle(com.here.android.mpa.mapping.MapCircle)

Aggregations

CLE2Geometry (com.here.android.mpa.customlocation2.CLE2Geometry)1 CLE2PointGeometry (com.here.android.mpa.customlocation2.CLE2PointGeometry)1 CLE2ProximityRequest (com.here.android.mpa.customlocation2.CLE2ProximityRequest)1 CLE2Request (com.here.android.mpa.customlocation2.CLE2Request)1 CLE2Result (com.here.android.mpa.customlocation2.CLE2Result)1 MapCircle (com.here.android.mpa.mapping.MapCircle)1 MapMarker (com.here.android.mpa.mapping.MapMarker)1