-
Notifications
You must be signed in to change notification settings - Fork 75
Set mapview options
Nutiteq edited this page Apr 29, 2014
·
7 revisions
Here are some optional, but useful additional configurations.
- Alter MapView configuration to get smoother map manipulation experience
// use more threads for tile loading. Helps a lot with multi-core devices
// optimal number of threads may be different on different devices
mapView.getOptions().setRasterTaskPoolSize(4);
// preload map tiles outside current view. Makes map panning faster, with cost of extra bandwidth usage
mapView.getOptions().setPreloading(true);
// repeating world view if you are panning out of map to east or west. Usually important for most general zooms only.
mapView.getOptions().setSeamlessHorizontalPan(true);
// blending animation for tile replacement
mapView.getOptions().setTileFading(true);
// pan/scroll map dynamically
mapView.getOptions().setKineticPanning(true);
// enable doubleclick gesture for zoom in
mapView.getOptions().setDoubleClickZoomIn(true);
// enable two-finger touch gesture to zoom out
mapView.getOptions().setDualClickZoomOut(true);
- Define bitmaps for sky view and map background
// set sky bitmap - optional, default - white
mapView.getOptions().setSkyDrawMode(Options.DRAW_BITMAP);
mapView.getOptions().setSkyOffset(4.86f);
// see sample image for good size ideas
mapView.getOptions().setSkyBitmap(
UnscaledBitmapLoader.decodeResource(getResources(),
R.drawable.sky_small));
// Map background, visible if no map tiles loaded - optional, default - white
mapView.getOptions().setBackgroundPlaneDrawMode(Options.DRAW_BITMAP);
mapView.getOptions().setBackgroundPlaneBitmap(
UnscaledBitmapLoader.decodeResource(getResources(),
R.drawable.background_plane));
mapView.getOptions().setClearColor(Color.WHITE);
- Configure caching to make later data loading much faster.
// configure texture caching. Following are usually good values
mapView.getOptions().setTextureMemoryCacheSize(40 * 1024 * 1024);
mapView.getOptions().setCompressedMemoryCacheSize(8 * 1024 * 1024);
// turn on persistent caching for particular layer, it is off by default
mapLayer.setPersistentCaching(true);
// define online map persistent caching
mapView.getOptions().setPersistentCachePath(
this.getDatabasePath("mapcache").getPath());
// set persistent raster cache limit to 100MB. Use any value you feel appropriate
mapView.getOptions().setPersistentCacheSize(100 * 1024 * 1024);
- Define initial map view coordinates. Here is perspective (2.5D) view.
// Location: San Francisco
// NB! it must be in base layer projection (EPSG3857), so we convert it from lat and long
mapView.setFocusPoint(mapView.getLayers().getBaseLayer().getProjection().fromWgs84(-122.41666666667f, 37.76666666666f));
// rotation - 0 = north-up
mapView.setMapRotation(0f);
// zoom - 0 = world, like on most web maps
mapView.setZoom(7.0f);
// tilt means perspective view. Default is 90 degrees for "normal" 2D map view, minimum allowed is 30 degrees.
mapView.setTilt(35.0f);