Search in sources :

Example 1 with MapEventsOverlay

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();
}
Also used : MapEventsOverlay(org.osmdroid.views.overlay.MapEventsOverlay) Polyline(org.osmdroid.views.overlay.Polyline) Paint(android.graphics.Paint)

Example 2 with MapEventsOverlay

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();
        }
    }
}
Also used : LocationManager(android.location.LocationManager) SharedPreferences(android.content.SharedPreferences) MapEventsOverlay(org.osmdroid.views.overlay.MapEventsOverlay) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) GpsMyLocationProvider(org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider) MyLocationNewOverlay(org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) View(android.view.View) MapView(org.osmdroid.views.MapView) Station(be.brunoparmentier.openbikesharing.app.models.Station) GeoPoint(org.osmdroid.util.GeoPoint) Bitmap(android.graphics.Bitmap) GridMarkerClusterer(org.osmdroid.bonuspack.clustering.GridMarkerClusterer) StationsDataSource(be.brunoparmentier.openbikesharing.app.db.StationsDataSource) Location(android.location.Location)

Example 3 with MapEventsOverlay

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();
}
Also used : MapEventsOverlay(org.osmdroid.views.overlay.MapEventsOverlay)

Example 4 with MapEventsOverlay

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));
}
Also used : MapEventsOverlay(org.osmdroid.views.overlay.MapEventsOverlay)

Aggregations

MapEventsOverlay (org.osmdroid.views.overlay.MapEventsOverlay)4 SharedPreferences (android.content.SharedPreferences)1 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Drawable (android.graphics.drawable.Drawable)1 Location (android.location.Location)1 LocationManager (android.location.LocationManager)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 StationsDataSource (be.brunoparmentier.openbikesharing.app.db.StationsDataSource)1 Station (be.brunoparmentier.openbikesharing.app.models.Station)1 GridMarkerClusterer (org.osmdroid.bonuspack.clustering.GridMarkerClusterer)1 GeoPoint (org.osmdroid.util.GeoPoint)1 MapView (org.osmdroid.views.MapView)1 Polyline (org.osmdroid.views.overlay.Polyline)1 GpsMyLocationProvider (org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider)1 MyLocationNewOverlay (org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay)1