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