截取显示的OpenStreetMap

时间:2017-09-06 11:26:56

标签: android openstreetmap osmdroid

我创建了一个独立的应用程序,使用OpenStreetMaps显示当前用户位置。这是我的主要活动:

我使用的是osmdroid 5.6.2

package com.example.re.osm;

public class MainActivity extends Activity {

    private LocationManager locationManager;
    private Location onlyOneLocation;
    private final int REQUEST_FINE_LOCATION = 1234;
    public GeoPoint startPoint;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Context ctx = getApplicationContext();

        if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)
            ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_FINE_LOCATION);


        Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));
        setContentView(R.layout.activity_main);

        final MapView map = (MapView) findViewById(R.id.map);
        map.setTileSource(TileSourceFactory.MAPNIK);
        map.setBuiltInZoomControls(true);
        map.setMultiTouchControls(true);

        final IMapController mapController = map.getController();
        mapController.setZoom(18);

        CurrentLocation.requestSingleUpdate(this,
                new CurrentLocation.LocationCallback() {

                    @Override public void onNewLocationAvailable(GPSCoordinates location) {
                        Log.d("Location", "my location is " + location.latitude + " : " + location.longitude);
                        startPoint = new GeoPoint(location.latitude, location.longitude);

                        // My Location Overlay
                        Marker marker=new Marker(map);
                        marker.setPosition(startPoint);
                        marker.setTitle("Your Location");
                        marker.showInfoWindow();
                        map.getOverlays().add(marker);
                        map.invalidate();
                        //This geopoint is currently static and shows a single location everytime the app is executed
                        mapController.setCenter(startPoint);
                    }
                });



    }
}

我需要截取地图的截图并显示它。知道我该怎么办?

由于

0 个答案:

没有答案