Search in sources :

Example 6 with TileProvider

use of com.google.android.gms.maps.model.TileProvider in project android-samples by googlemaps.

the class TileOverlayDemoActivity method onMapReady.

@Override
public void onMapReady(GoogleMap map) {
    map.setMapType(GoogleMap.MAP_TYPE_NONE);
    TileProvider tileProvider = new UrlTileProvider(256, 256) {

        @Override
        public synchronized URL getTileUrl(int x, int y, int zoom) {
            // The moon tile coordinate system is reversed.  This is not normal.
            int reversedY = (1 << zoom) - y - 1;
            String s = String.format(Locale.US, MOON_MAP_URL_FORMAT, zoom, x, reversedY);
            URL url = null;
            try {
                url = new URL(s);
            } catch (MalformedURLException e) {
                throw new AssertionError(e);
            }
            return url;
        }
    };
    mMoonTiles = map.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));
    mTransparencyBar.setOnSeekBarChangeListener(this);
}
Also used : MalformedURLException(java.net.MalformedURLException) TileOverlayOptions(com.google.android.gms.maps.model.TileOverlayOptions) UrlTileProvider(com.google.android.gms.maps.model.UrlTileProvider) UrlTileProvider(com.google.android.gms.maps.model.UrlTileProvider) TileProvider(com.google.android.gms.maps.model.TileProvider) URL(java.net.URL)

Aggregations

TileOverlayOptions (com.google.android.gms.maps.model.TileOverlayOptions)6 TileProvider (com.google.android.gms.maps.model.TileProvider)6 MalformedURLException (java.net.MalformedURLException)5 URL (java.net.URL)5 UrlTileProvider (com.google.android.gms.maps.model.UrlTileProvider)4 Intent (android.content.Intent)3 GoogleMap (com.google.android.gms.maps.GoogleMap)3 OnMapReadyCallback (com.google.android.gms.maps.OnMapReadyCallback)3 LatLng (com.google.android.gms.maps.model.LatLng)3 TileOverlay (com.google.android.gms.maps.model.TileOverlay)3 ActionBar (android.support.v7.app.ActionBar)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 CameraPosition (com.google.android.gms.maps.model.CameraPosition)2 JSONObject (org.json.JSONObject)2 DialogInterface (android.content.DialogInterface)1 SharedPreferences (android.content.SharedPreferences)1 Point (android.graphics.Point)1