use of org.osmdroid.views.overlay.MapEventsOverlay in project collect by opendatakit.
the class GeoShapeOsmMapActivity method overlayPointPathListener.
private void overlayPointPathListener() {
overlayEvents = new MapEventsOverlay(receive);
polyline = new Polyline();
polyline.setColor(Color.RED);
Paint paint = polyline.getPaint();
paint.setStrokeWidth(stroke_width);
map.getOverlays().add(polyline);
map.getOverlays().add(overlayEvents);
map.invalidate();
}
use of org.osmdroid.views.overlay.MapEventsOverlay in project OpenBikeSharing by bparmentier.
the class MapActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
getActionBar().setDisplayHomeAsUpEnabled(true);
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
stationsDataSource = new StationsDataSource(this);
ArrayList<Station> stations = stationsDataSource.getStations();
map = (MapView) findViewById(R.id.mapView);
stationMarkerInfoWindow = new StationMarkerInfoWindow(R.layout.bonuspack_bubble, map);
/* handling map events */
MapEventsOverlay mapEventsOverlay = new MapEventsOverlay(this, this);
map.getOverlays().add(0, mapEventsOverlay);
/* markers list */
GridMarkerClusterer stationsMarkers = new GridMarkerClusterer();
Drawable clusterIconD = getResources().getDrawable(R.drawable.marker_cluster);
Bitmap clusterIcon = ((BitmapDrawable) clusterIconD).getBitmap();
map.getOverlays().add(stationsMarkers);
stationsMarkers.setIcon(clusterIcon);
stationsMarkers.setGridSize(100);
for (final Station station : stations) {
stationsMarkers.add(createStationMarker(station));
}
map.invalidate();
map.setMultiTouchControls(true);
map.setBuiltInZoomControls(true);
map.setMinZoomLevel(3);
/* map tile source */
String mapLayer = settings.getString(PREF_KEY_MAP_LAYER, "");
switch(mapLayer) {
case MAP_LAYER_MAPNIK:
map.setTileSource(TileSourceFactory.MAPNIK);
break;
case MAP_LAYER_CYCLEMAP:
map.setTileSource(TileSourceFactory.CYCLEMAP);
break;
case MAP_LAYER_OSMPUBLICTRANSPORT:
map.setTileSource(TileSourceFactory.PUBLIC_TRANSPORT);
break;
default:
map.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
break;
}
GpsMyLocationProvider imlp = new GpsMyLocationProvider(this.getBaseContext());
imlp.setLocationUpdateMinDistance(1000);
imlp.setLocationUpdateMinTime(60000);
map.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
myLocationOverlay = new MyLocationNewOverlay(imlp, this.map);
myLocationOverlay.enableMyLocation();
map.getOverlays().add(this.myLocationOverlay);
mapController = map.getController();
if (savedInstanceState != null) {
mapController.setZoom(savedInstanceState.getInt(MAP_CURRENT_ZOOM_KEY));
mapController.setCenter(new GeoPoint(savedInstanceState.getDouble(MAP_CENTER_LAT_KEY), savedInstanceState.getDouble(MAP_CENTER_LON_KEY)));
} else {
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
Location userLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (userLocation != null) {
mapController.setZoom(16);
mapController.animateTo(new GeoPoint(userLocation));
} else {
double bikeNetworkLatitude = Double.longBitsToDouble(settings.getLong(PREF_KEY_NETWORK_LATITUDE, 0));
double bikeNetworkLongitude = Double.longBitsToDouble(settings.getLong(PREF_KEY_NETWORK_LONGITUDE, 0));
mapController.setZoom(13);
mapController.setCenter(new GeoPoint(bikeNetworkLatitude, bikeNetworkLongitude));
Toast.makeText(this, R.string.location_not_found, Toast.LENGTH_LONG).show();
}
}
}
use of org.osmdroid.views.overlay.MapEventsOverlay in project collect by opendatakit.
the class GeoPointOsmMapActivity method overlayMyLocationLayers.
private void overlayMyLocationLayers() {
map.getOverlays().add(myLocationOverlay);
if (draggable && !readOnly) {
if (marker != null) {
marker.setOnMarkerDragListener(this);
marker.setDraggable(true);
}
MapEventsOverlay overlayEvents = new MapEventsOverlay(this);
map.getOverlays().add(overlayEvents);
}
myLocationOverlay.setEnabled(true);
myLocationOverlay.enableMyLocation();
}
use of org.osmdroid.views.overlay.MapEventsOverlay in project collect by opendatakit.
the class OsmDroidMapFragment method addAttributionAndMapEventsOverlays.
private void addAttributionAndMapEventsOverlays() {
map.getOverlays().add(new AttributionOverlay(getContext()));
map.getOverlays().add(new MapEventsOverlay(this));
}
Aggregations