use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.
the class MapActions method initSearchLocationHandler.
private void initSearchLocationHandler(final boolean isStartP, final boolean fromFavourite) {
int viewID = R.id.map_nav_settings_to_search;
if (isStartP) {
viewID = R.id.map_nav_settings_from_search;
}
if (fromFavourite) {
viewID = R.id.map_nav_settings_to_favorite;
if (isStartP) {
viewID = R.id.map_nav_settings_from_favorite;
}
}
final ViewGroup pointItem = (ViewGroup) activity.findViewById(viewID);
pointItem.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
setBgColor(pointItem, R.color.my_primary_light);
return true;
case MotionEvent.ACTION_UP:
setBgColor(pointItem, R.color.my_primary);
Intent intent = new Intent(activity, GeocodeActivity.class);
OnClickAddressListener callbackListener = new OnClickAddressListener() {
@Override
public void onClick(Address addr) {
GeoPoint newPos = new GeoPoint(addr.getLatitude(), addr.getLongitude());
if (isStartP) {
Destination.getDestination().setStartPoint(newPos);
fromLocalET.setText(Destination.getDestination().getStartPointToString());
addFromMarker(Destination.getDestination().getStartPoint());
navSettingsFromVP.setVisibility(View.INVISIBLE);
} else {
Destination.getDestination().setEndPoint(newPos);
toLocalET.setText(Destination.getDestination().getEndPointToString());
addToMarker(Destination.getDestination().getEndPoint());
navSettingsToVP.setVisibility(View.INVISIBLE);
}
boolean showingNavigator = activeNavigator();
if (!showingNavigator) {
navSettingsVP.setVisibility(View.VISIBLE);
}
MapHandler.getMapHandler().centerPointOnMap(newPos, 0, 0, 0);
}
};
GeoPoint[] points = null;
if (fromFavourite) {
points = new GeoPoint[3];
points[0] = Destination.getDestination().getStartPoint();
points[1] = Destination.getDestination().getEndPoint();
Location curLoc = MapActivity.getmCurrentLocation();
if (curLoc != null) {
points[2] = new GeoPoint(curLoc.getLatitude(), curLoc.getLongitude());
}
}
GeocodeActivity.setPre(callbackListener, points);
activity.startActivity(intent);
return true;
}
return false;
}
});
}
use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.
the class MapActions method searchBtnActions.
/**
* perform actions when search btn is clicked
* <p>
* 1. check edit text and convert value to start point or end point
*/
private void searchBtnActions() {
String fls = fromLocalET.getText().toString();
String tls = toLocalET.getText().toString();
GeoPoint fl = null, tl = null;
if (fls.length() > 2) {
fl = MyUtility.getLatLong(fls);
}
if (tls.length() > 2) {
tl = MyUtility.getLatLong(tls);
}
if (fl != null && tl == null) {
MapHandler.getMapHandler().centerPointOnMap(fl, 0, 0, 0);
Destination.getDestination().setStartPoint(fl);
addFromMarker(fl);
}
if (fl == null && tl != null) {
MapHandler.getMapHandler().centerPointOnMap(tl, 0, 0, 0);
Destination.getDestination().setEndPoint(tl);
addToMarker(tl);
}
if (fl != null && tl != null) {
addFromMarker(fl);
addToMarker(tl);
Destination.getDestination().setStartPoint(fl);
Destination.getDestination().setEndPoint(tl);
activeNavigator();
}
if (fl == null && tl == null) {
Toast.makeText(activity, "Check your input (use coordinates)!\nExample:\nuse degrees: 63° 25′ 47″ N, 10° 23′ 36″ " + "E\nor use digital: 63.429722, 10.393333", Toast.LENGTH_LONG).show();
}
}
use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.
the class MapActivity method onStop.
@Override
protected void onStop() {
super.onStop();
if (mCurrentLocation != null) {
GeoPoint geoPoint = mapView.map().getMapPosition().getGeoPoint();
Variable.getVariable().setLastLocation(geoPoint);
// log("last browsed location : "+mapView.getModel().mapViewPosition
// .getMapPosition().latLong);
}
if (mapView != null)
Variable.getVariable().setLastZoomLevel(mapView.map().getMapPosition().getZoomLevel());
Variable.getVariable().saveVariables();
}
use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.
the class MapHandler method setStartEndPoint.
/**
* Set start or end Point-Marker.
* @param p The Point to set, or null.
* @param isStart True for startpoint false for endpoint.
* @param recalculate True to calculate path, when booth points are set.
* @return Whether the path will be recalculated. *
*/
public boolean setStartEndPoint(GeoPoint p, boolean isStart, boolean recalculate) {
boolean result = false;
int icon = R.drawable.ic_location_end_24dp;
boolean refreshBooth = false;
if (startMarker != null && endMarker != null && p != null) {
refreshBooth = true;
}
if (isStart) {
startMarker = p;
icon = R.drawable.ic_location_start_24dp;
} else {
endMarker = p;
}
// remove routing layers
if ((startMarker == null || endMarker == null) || refreshBooth) {
if (pathLayer != null) {
pathLayer.clearPath();
}
itemizedLayer.removeAllItems();
}
if (refreshBooth) {
itemizedLayer.addItem(createMarkerItem(startMarker, R.drawable.ic_location_start_24dp, 0.5f, 1.0f));
itemizedLayer.addItem(createMarkerItem(endMarker, R.drawable.ic_location_end_24dp, 0.5f, 1.0f));
} else if (p != null) {
itemizedLayer.addItem(createMarkerItem(p, icon, 0.5f, 1.0f));
}
if (startMarker != null && endMarker != null && recalculate) {
recalcPath();
result = true;
}
mapView.map().updateMap(true);
return result;
}
use of org.oscim.core.GeoPoint in project PocketMaps by junjunguo.
the class MapHandler method updatePathLayer.
private PathLayer updatePathLayer(PathLayer ref, PointList pointList, int color, int strokeWidth) {
if (ref == null) {
ref = createPathLayer(color, strokeWidth);
mapView.map().layers().add(ref);
}
List<GeoPoint> geoPoints = new ArrayList<>();
// TODO: Search for a more efficient way
for (int i = 0; i < pointList.getSize(); i++) geoPoints.add(new GeoPoint(pointList.getLatitude(i), pointList.getLongitude(i)));
ref.setPoints(geoPoints);
return ref;
}
Aggregations