Search in sources :

Example 11 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class MapActivity method parseLaunchIntentLocation.

protected void parseLaunchIntentLocation() {
    Intent intent = getIntent();
    if (intent != null && intent.getData() != null) {
        Uri data = intent.getData();
        if (("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme())) && data.getHost() != null && data.getHost().contains("osmand.net") && data.getPath() != null && data.getPath().startsWith("/go")) {
            String lat = data.getQueryParameter("lat");
            String lon = data.getQueryParameter("lon");
            if (lat != null && lon != null) {
                try {
                    double lt = Double.parseDouble(lat);
                    double ln = Double.parseDouble(lon);
                    String zoom = data.getQueryParameter("z");
                    int z = settings.getLastKnownMapZoom();
                    if (zoom != null) {
                        z = Integer.parseInt(zoom);
                    }
                    settings.setMapLocationToShow(lt, ln, z, new PointDescription(PointDescription.POINT_TYPE_MARKER, getString(R.string.shared_location)));
                } catch (NumberFormatException e) {
                    LOG.error("error", e);
                }
            }
        }
    }
}
Also used : PointDescription(net.osmand.data.PointDescription) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Uri(android.net.Uri) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) QuadPoint(net.osmand.data.QuadPoint) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint)

Example 12 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class SearchAddressFragment method select.

public void select(int mode) {
    if (searchPoint == null) {
        Toast.makeText(getActivity(), R.string.please_select_address, Toast.LENGTH_SHORT).show();
        return;
    }
    AddressInformation ai = new AddressInformation();
    PointDescription pointDescription = ai.getHistoryName();
    if (!Algorithms.isEmpty(street2) && !Algorithms.isEmpty(street)) {
        ai = AddressInformation.build2StreetIntersection(getActivity(), osmandSettings);
        pointDescription.setName(street2);
        pointDescription.setTypeName(getRegionName() + ", " + city);
    } else if (!Algorithms.isEmpty(building)) {
        ai = AddressInformation.buildBuilding(getActivity(), osmandSettings);
        pointDescription.setName(street + ", " + building);
        pointDescription.setTypeName(getRegionName() + ", " + city);
    } else if (!Algorithms.isEmpty(street)) {
        ai = AddressInformation.buildStreet(getActivity(), osmandSettings);
        pointDescription.setName(street);
        pointDescription.setTypeName(getRegionName() + ", " + city);
    } else if (!Algorithms.isEmpty(city)) {
        ai = AddressInformation.buildCity(getActivity(), osmandSettings);
        pointDescription.setName(city);
        pointDescription.setTypeName(getRegionName());
    }
    if (mode == SELECT_POINT) {
        Intent intent = getActivity().getIntent();
        intent.putExtra(SELECT_ADDRESS_POINT_INTENT_KEY, ai.objectName);
        intent.putExtra(SELECT_ADDRESS_POINT_LAT, searchPoint.getLatitude());
        intent.putExtra(SELECT_ADDRESS_POINT_LON, searchPoint.getLongitude());
        getActivity().setResult(SELECT_ADDRESS_POINT_RESULT_OK, intent);
        getActivity().finish();
    } else {
        if (mode == SHOW_ON_MAP) {
            osmandSettings.setMapLocationToShow(searchPoint.getLatitude(), searchPoint.getLongitude(), ai.zoom, pointDescription);
            MapActivity.launchMapActivityMoveToTop(getActivity());
        }
    }
}
Also used : PointDescription(net.osmand.data.PointDescription) Intent(android.content.Intent)

Example 13 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class SearchAddressOnlineFragment method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Place item = adapter.getItem(position);
    LatLon location = new LatLon(item.lat, item.lon);
    settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), Math.max(15, settings.getLastKnownMapZoom()), new PointDescription(PointDescription.POINT_TYPE_ADDRESS, item.displayName), true, // $NON-NLS-1$
    item);
    MapActivity.launchMapActivityMoveToTop(getActivity());
}
Also used : LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription)

Example 14 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class SearchByNameAbstractActivity method select.

protected void select(int mode) {
    LatLon searchPoint = settings.getLastSearchedPoint();
    AddressInformation ai = getAddressInformation();
    if (ai != null && searchPoint != null) {
        if (mode == ADD_TO_FAVORITE) {
            Bundle b = new Bundle();
            Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), b);
            dlg.show();
            FavoriteDialogs.prepareAddFavouriteDialog(getActivity(), dlg, b, searchPoint.getLatitude(), searchPoint.getLongitude(), new PointDescription(PointDescription.POINT_TYPE_ADDRESS, ai.objectName));
        } else if (mode == NAVIGATE_TO) {
            DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), searchPoint.getLatitude(), searchPoint.getLongitude(), ai.getHistoryName());
        } else if (mode == SHOW_ON_MAP) {
            showOnMap(searchPoint, ai);
        }
    }
}
Also used : LatLon(net.osmand.data.LatLon) AddressInformation(net.osmand.plus.activities.search.SearchAddressFragment.AddressInformation) Bundle(android.os.Bundle) Dialog(android.app.Dialog) PointDescription(net.osmand.data.PointDescription)

Example 15 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class SearchHistoryFragment method udpateHistoryItem.

public static void udpateHistoryItem(final HistoryEntry historyEntry, View row, LatLon location, Activity activity, OsmandApplication app) {
    TextView nameText = (TextView) row.findViewById(R.id.name);
    TextView distanceText = (TextView) row.findViewById(R.id.distance);
    ImageView direction = (ImageView) row.findViewById(R.id.direction);
    IconsCache ic = app.getIconsCache();
    direction.setImageDrawable(ic.getIcon(R.drawable.ic_direction_arrow, R.color.color_distance));
    String distance = "";
    if (location != null) {
        int dist = (int) (MapUtils.getDistance(location, historyEntry.getLat(), historyEntry.getLon()));
        distance = OsmAndFormatter.getFormattedDistance(dist, (OsmandApplication) activity.getApplication()) + "  ";
    }
    distanceText.setText(distance);
    PointDescription pd = historyEntry.getName();
    nameText.setText(pd.getSimpleName(activity, false), BufferType.SPANNABLE);
    ImageView icon = ((ImageView) row.findViewById(R.id.icon));
    icon.setImageDrawable(ic.getThemedIcon(getItemIcon(historyEntry.getName())));
    String typeName = historyEntry.getName().getTypeName();
    if (typeName != null && !typeName.isEmpty()) {
        ImageView group = (ImageView) row.findViewById(R.id.type_name_icon);
        group.setVisibility(View.VISIBLE);
        group.setImageDrawable(ic.getThemedIcon(R.drawable.ic_small_group));
        ((TextView) row.findViewById(R.id.type_name)).setText(typeName);
    } else {
        row.findViewById(R.id.type_name_icon).setVisibility(View.GONE);
        ((TextView) row.findViewById(R.id.type_name)).setText("");
    }
}
Also used : PointDescription(net.osmand.data.PointDescription) TextView(android.widget.TextView) ImageView(android.widget.ImageView) IconsCache(net.osmand.plus.IconsCache)

Aggregations

PointDescription (net.osmand.data.PointDescription)72 LatLon (net.osmand.data.LatLon)44 View (android.view.View)16 ImageView (android.widget.ImageView)13 TextView (android.widget.TextView)13 ArrayList (java.util.ArrayList)13 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)13 FavouritePoint (net.osmand.data.FavouritePoint)12 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)11 OsmandApplication (net.osmand.plus.OsmandApplication)10 OsmandSettings (net.osmand.plus.OsmandSettings)10 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)8 Amenity (net.osmand.data.Amenity)7 WptPt (net.osmand.plus.GPXUtilities.WptPt)7 RoutingHelper (net.osmand.plus.routing.RoutingHelper)7 Intent (android.content.Intent)6 Paint (android.graphics.Paint)6 LinearLayout (android.widget.LinearLayout)6 Location (net.osmand.Location)6 DialogInterface (android.content.DialogInterface)5