Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/ActivityMap.java
Show All 27 Lines | |||||
import android.util.Log; | import android.util.Log; | ||||
import android.view.View; | import android.view.View; | ||||
import android.widget.ImageButton; | import android.widget.ImageButton; | ||||
import android.support.annotation.RequiresApi; | import android.support.annotation.RequiresApi; | ||||
import android.support.v7.app.AppCompatActivity; | import android.support.v7.app.AppCompatActivity; | ||||
import android.support.v7.preference.PreferenceManager; | import android.support.v7.preference.PreferenceManager; | ||||
import android.widget.Toast; | import android.widget.Toast; | ||||
import it.reyboz.bustorino.middleware.NextGenDB; | |||||
import org.osmdroid.api.IMapController; | import org.osmdroid.api.IMapController; | ||||
import org.osmdroid.config.Configuration; | import org.osmdroid.config.Configuration; | ||||
import org.osmdroid.events.DelayedMapListener; | import org.osmdroid.events.DelayedMapListener; | ||||
import org.osmdroid.events.MapListener; | import org.osmdroid.events.MapListener; | ||||
import org.osmdroid.events.ScrollEvent; | import org.osmdroid.events.ScrollEvent; | ||||
import org.osmdroid.events.ZoomEvent; | import org.osmdroid.events.ZoomEvent; | ||||
import org.osmdroid.tileprovider.tilesource.TileSourceFactory; | import org.osmdroid.tileprovider.tilesource.TileSourceFactory; | ||||
import org.osmdroid.util.BoundingBox; | import org.osmdroid.util.BoundingBox; | ||||
▲ Show 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | public void loadMarkers() { | ||||
// get the top, bottom, left and right screen's coordinate | // get the top, bottom, left and right screen's coordinate | ||||
BoundingBox bb = map.getBoundingBox(); | BoundingBox bb = map.getBoundingBox(); | ||||
double latFrom = bb.getLatSouth(); | double latFrom = bb.getLatSouth(); | ||||
double latTo = bb.getLatNorth(); | double latTo = bb.getLatNorth(); | ||||
double lngFrom = bb.getLonWest(); | double lngFrom = bb.getLonWest(); | ||||
double lngTo = bb.getLonEast(); | double lngTo = bb.getLonEast(); | ||||
// get the stops located in those coordinates | // get the stops located in those coordinates | ||||
/* | |||||
StopsDB stopsDB = new StopsDB(ctx); | StopsDB stopsDB = new StopsDB(ctx); | ||||
stopsDB.openIfNeeded(); | stopsDB.openIfNeeded(); | ||||
Stop[] stops = stopsDB.queryAllInsideMapView(latFrom, latTo, lngFrom, lngTo); | Stop[] stops = stopsDB.queryAllInsideMapView(latFrom, latTo, lngFrom, lngTo); | ||||
stopsDB.closeIfNeeded(); | stopsDB.closeIfNeeded(); | ||||
*/ | |||||
NextGenDB dbHelper = new NextGenDB(ctx); | |||||
Stop[] stops = dbHelper.queryAllInsideMapView(latFrom, latTo, lngFrom, lngTo); | |||||
// add new markers of those stops | // add new markers of those stops | ||||
for (Stop stop : stops) { | for (Stop stop : stops) { | ||||
if (shownStops.contains(stop.ID)){ | if (shownStops.contains(stop.ID)){ | ||||
continue; | continue; | ||||
} | } | ||||
try{ | try{ | ||||
stop.getLatitude(); | stop.getLatitude(); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | public class ActivityMap extends AppCompatActivity { | ||||
protected void onSaveInstanceState(Bundle outState) { | protected void onSaveInstanceState(Bundle outState) { | ||||
super.onSaveInstanceState(outState); | super.onSaveInstanceState(outState); | ||||
outState.putDouble(MAP_CURRENT_ZOOM_KEY, map.getZoomLevelDouble()); | outState.putDouble(MAP_CURRENT_ZOOM_KEY, map.getZoomLevelDouble()); | ||||
outState.putDouble(MAP_CENTER_LAT_KEY, map.getMapCenter().getLatitude()); | outState.putDouble(MAP_CENTER_LAT_KEY, map.getMapCenter().getLatitude()); | ||||
outState.putDouble(MAP_CENTER_LON_KEY, map.getMapCenter().getLongitude()); | outState.putDouble(MAP_CENTER_LON_KEY, map.getMapCenter().getLongitude()); | ||||
} | } | ||||
} | } | ||||
No newline at end of file | No newline at end of file |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register