implement auto zoom
presets git-svn-id: https://osmand.googlecode.com/svn/trunk@164 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
600747da08
commit
d9286a9c71
5 changed files with 64 additions and 38 deletions
|
@ -41,14 +41,6 @@ public class ToDoConstants {
|
|||
// DONE: Load transport routes in swing.
|
||||
// TODO: Create transport index, create transport activity
|
||||
|
||||
// 44. Introduce settings presets (car/bicycle/pedestrian/default) - show different icons for car (bigger), possibly change fonts, position
|
||||
// DONE : Introduce settings property in settings screen
|
||||
// TODO : check if all is correct, change visible icon over map for car
|
||||
|
||||
// 45. Autozoom feature (for car navigation)
|
||||
// DONE : settings preferences done
|
||||
// TODO : add to Map activity algorithm of auto zooming in setLocation method
|
||||
|
||||
// 36. Postcode search
|
||||
|
||||
// 37. Get rid of exit button (!). Think about when notification should go & how clear resources if it is necessary
|
||||
|
@ -70,7 +62,6 @@ public class ToDoConstants {
|
|||
// Introducing cache of file names that are on disk (creating new File() consumes a lot of memory)
|
||||
|
||||
|
||||
|
||||
// TODO swing
|
||||
// 4. Fix issues with big files (such as netherlands) - save memory (!)
|
||||
// Current result : for big file (1 - task 60-80% time, 90% memory)
|
||||
|
@ -79,6 +70,8 @@ public class ToDoConstants {
|
|||
// BUGS Swing
|
||||
|
||||
// DONE ANDROID :
|
||||
// 45. Autozoom feature (for car navigation)
|
||||
// 44. Introduce settings presets (car/bicycle/pedestrian/default) - show different icons for car (bigger), possibly change fonts, position
|
||||
// 20. Implement save track/route to gpx
|
||||
|
||||
// DONE SWING
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="search_settings">Search settings</string>
|
||||
<string name="osm_settings">Osm settings</string>
|
||||
<string name="osm_settings_descr">Specify osm settings: show bugs, osm login</string>
|
||||
<string name="monitor_preferences_descr">Specify monitor settings : save track</string>
|
||||
<string name="search_settings_descr">Specify search settings</string>
|
||||
<string name="map_preferences_descr">Specify map settings : rotation, poi filter</string>
|
||||
<string name="search_settings">Search</string>
|
||||
<string name="osm_settings">Osm</string>
|
||||
<string name="auto_zoom_map_descr">Auto zoom map according to the speed</string>
|
||||
<string name="auto_zoom_map">Auto zoom map</string>
|
||||
<string name="additional_settings">Additional settings</string>
|
||||
|
@ -12,7 +16,7 @@
|
|||
<string name="save_current_track">Save current track</string>
|
||||
<string name="save_track_interval_descr">Choose time interval to save track</string>
|
||||
<string name="save_track_interval">Save track interval</string>
|
||||
<string name="monitor_preferences">Monitoring settings</string>
|
||||
<string name="monitor_preferences">Monitoring</string>
|
||||
<string name="save_track_to_gpx_descrp">Tracks will be saved to track directory grouped by days</string>
|
||||
<string name="save_track_to_gpx">Save track to gpx</string>
|
||||
<string name="navigate_to">Navigate to</string>
|
||||
|
@ -51,7 +55,7 @@
|
|||
<string name="map_source">Map source</string>
|
||||
<string name="use_internet">Use internet</string>
|
||||
<string name="show_location">Show location</string>
|
||||
<string name="map_preferences">Map settings</string>
|
||||
<string name="map_preferences">Map</string>
|
||||
<string name="settings_activity">Settings</string>
|
||||
<string name="show_gps_coordinates_text">Show gps coordinates on map</string>
|
||||
<string name="use_internet_to_download_tile">Use internet to download missing tiles</string>
|
||||
|
|
|
@ -2,39 +2,32 @@
|
|||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory android:title="@string/app_settings">
|
||||
<ListPreference android:summary="@string/settings_preset_descr" android:title="@string/settings_preset" android:key="application_mode"></ListPreference>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
<PreferenceCategory android:title="@string/map_preferences">
|
||||
<PreferenceScreen android:title="@string/map_preferences" android:summary="@string/map_preferences_descr">
|
||||
<CheckBoxPreference android:key="use_internet_to_download_tiles" android:title="@string/use_internet" android:summary="@string/use_internet_to_download_tile"></CheckBoxPreference>
|
||||
<CheckBoxPreference android:key="show_poi_over_map" android:title="@string/show_poi_over_map" android:summary="@string/show_poi_over_map_description"></CheckBoxPreference>
|
||||
<ListPreference android:title="@string/map_tile_source" android:summary="@string/map_tile_source_descr" android:key="map_tile_sources"></ListPreference>
|
||||
|
||||
<PreferenceScreen android:title="@string/additional_settings">
|
||||
<CheckBoxPreference android:title="@string/auto_zoom_map" android:summary="@string/auto_zoom_map_descr" android:key="auto_zoom_map"></CheckBoxPreference>
|
||||
<CheckBoxPreference android:key="rotate_map_to_bearing" android:title="@string/rotate_map_to_bearing" android:summary="@string/rotate_map_to_bearing_descr"></CheckBoxPreference>
|
||||
<CheckBoxPreference android:key="show_view_angle" android:title="@string/show_view_angle" android:summary="@string/show_view_angle_descr"></CheckBoxPreference>
|
||||
<ListPreference android:key="position_on_map" android:title="@string/position_on_map" android:summary="@string/position_on_map_descr"></ListPreference>
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/search_settings">
|
||||
<PreferenceScreen android:title="@string/search_settings" android:summary="@string/search_settings_descr">
|
||||
<CheckBoxPreference android:summary="@string/use_english_names_descr" android:title="@string/use_english_names" android:key="use_english_names"></CheckBoxPreference>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceCategory android:title="@string/monitor_preferences">
|
||||
<PreferenceScreen android:title="@string/monitor_preferences" android:summary="@string/monitor_preferences_descr">
|
||||
<CheckBoxPreference android:summary="@string/save_track_to_gpx_descrp" android:title="@string/save_track_to_gpx" android:key="save_track_to_gpx"></CheckBoxPreference>
|
||||
<ListPreference android:summary="@string/save_track_interval_descr" android:title="@string/save_track_interval" android:key="save_track_interval"></ListPreference>
|
||||
<Preference android:summary="@string/save_current_track_descr" android:title="@string/save_current_track" android:key="save_current_track"></Preference>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceCategory android:title="@string/osm_settings">
|
||||
<PreferenceScreen android:title="@string/osm_settings" android:summary="@string/osm_settings_descr">
|
||||
<CheckBoxPreference android:key="show_osm_bugs" android:title="@string/show_osm_bugs" android:summary="@string/show_osm_bugs_descr"></CheckBoxPreference>
|
||||
<EditTextPreference android:title="@string/user_name" android:summary="@string/user_name_descr" android:key="user_name"></EditTextPreference>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -101,6 +101,8 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
|||
savingTrackHelper = new SavingTrackHelper(this);
|
||||
|
||||
|
||||
locationLayer.setAppMode(OsmandSettings.getApplicationMode(this));
|
||||
|
||||
LatLon pointToNavigate = OsmandSettings.getPointToNavigate(this);
|
||||
navigationLayer.setPointToNavigate(pointToNavigate);
|
||||
|
||||
|
@ -232,8 +234,19 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
|||
}
|
||||
}
|
||||
Log.d(LogUtil.TAG, "Location changed");
|
||||
// TODO delete
|
||||
if(locationLayer.getLastKnownLocation() != null){
|
||||
location.setSpeed(location.distanceTo(locationLayer.getLastKnownLocation()));
|
||||
}
|
||||
locationLayer.setLastKnownLocation(location);
|
||||
if (location != null) {
|
||||
if(OsmandSettings.isAutoZoomEnabled(this) && location.hasSpeed()){
|
||||
int z = defineZoomFromSpeed(location.getSpeed());
|
||||
if(mapView.getZoom() != z){
|
||||
mapView.setZoom(z);
|
||||
}
|
||||
|
||||
}
|
||||
if (isMapLinkedToLocation()) {
|
||||
if (location.hasBearing() && OsmandSettings.isRotateMapToBearing(this)) {
|
||||
mapView.setRotate(-location.getBearing());
|
||||
|
@ -251,6 +264,18 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat
|
|||
}
|
||||
}
|
||||
|
||||
public int defineZoomFromSpeed(float speed){
|
||||
speed *= 3.6;
|
||||
if(speed < 20){
|
||||
return 17;
|
||||
} else if(speed < 60){
|
||||
return 16;
|
||||
} else if(speed < 120){
|
||||
return 15;
|
||||
}
|
||||
return 14;
|
||||
}
|
||||
|
||||
public void navigateToPoint(LatLon point){
|
||||
if(point != null){
|
||||
OsmandSettings.setPointToNavigate(this, point.getLatitude(), point.getLongitude());
|
||||
|
|
|
@ -23,7 +23,7 @@ public class PointLocationLayer implements OsmandMapLayer {
|
|||
private Paint area;
|
||||
private Paint headingPaint;
|
||||
private Path pathForDirection;
|
||||
private ApplicationMode preset = ApplicationMode.DEFAULT;
|
||||
private ApplicationMode appMode = ApplicationMode.DEFAULT;
|
||||
|
||||
protected Location lastKnownLocation = null;
|
||||
|
||||
|
@ -77,7 +77,13 @@ public class PointLocationLayer implements OsmandMapLayer {
|
|||
int radius = MapUtils.getLengthXFromMeters(view.getZoom(), view.getLatitude(), view.getLongitude(), lastKnownLocation
|
||||
.getAccuracy(), view.getTileSize(), view.getWidth());
|
||||
|
||||
if(appMode == ApplicationMode.CAR){
|
||||
if(!lastKnownLocation.hasBearing()){
|
||||
canvas.drawCircle(locationX, locationY, RADIUS * 2.5f, location);
|
||||
}
|
||||
} else {
|
||||
canvas.drawCircle(locationX, locationY, RADIUS, location);
|
||||
}
|
||||
if (radius > RADIUS) {
|
||||
canvas.drawCircle(locationX, locationY, radius, area);
|
||||
}
|
||||
|
@ -103,8 +109,16 @@ public class PointLocationLayer implements OsmandMapLayer {
|
|||
pathForDirection.lineTo(0, 0);
|
||||
Matrix m = new Matrix();
|
||||
m.reset();
|
||||
if(appMode == ApplicationMode.CAR){
|
||||
m.postScale(2.5f, radiusBearing * 1.5f);
|
||||
m.postTranslate(0, -radiusBearing/2);
|
||||
} else if(appMode == ApplicationMode.BICYCLE){
|
||||
m.postScale(2f, radiusBearing);
|
||||
m.postTranslate(0, -radiusBearing/2);
|
||||
} else {
|
||||
m.postScale(1, radiusBearing * 0.5f);
|
||||
m.postTranslate(0, -radiusBearing);
|
||||
}
|
||||
m.postTranslate(locationX, locationY);
|
||||
m.postRotate(bearing, locationX, locationY);
|
||||
|
||||
|
@ -150,15 +164,12 @@ public class PointLocationLayer implements OsmandMapLayer {
|
|||
public void destroyLayer() {
|
||||
|
||||
}
|
||||
|
||||
public ApplicationMode getPreset() {
|
||||
return preset;
|
||||
public ApplicationMode getAppMode() {
|
||||
return appMode;
|
||||
}
|
||||
|
||||
public void setSettingsPreset(ApplicationMode preset) {
|
||||
this.preset = preset;
|
||||
public void setAppMode(ApplicationMode appMode) {
|
||||
this.appMode = appMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean drawInScreenPixels() {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue