Search in sources :

Example 6 with TileOverlayOptions

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

the class TileCoordinateDemoActivity method onMapReady.

@Override
public void onMapReady(GoogleMap map) {
    TileProvider coordTileProvider = new CoordTileProvider(this.getApplicationContext());
    map.addTileOverlay(new TileOverlayOptions().tileProvider(coordTileProvider));
}
Also used : TileOverlayOptions(com.google.android.gms.maps.model.TileOverlayOptions) TileProvider(com.google.android.gms.maps.model.TileProvider)

Example 7 with TileOverlayOptions

use of com.google.android.gms.maps.model.TileOverlayOptions 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)

Example 8 with TileOverlayOptions

use of com.google.android.gms.maps.model.TileOverlayOptions in project android-maps-utils by googlemaps.

the class TileProviderAndProjectionDemo method startDemo.

@Override
protected void startDemo() {
    PointTileOverlay pto = new PointTileOverlay();
    pto.addPoint(new LatLng(0, 0));
    pto.addPoint(new LatLng(21, -10));
    getMap().addTileOverlay(new TileOverlayOptions().tileProvider(pto));
}
Also used : TileOverlayOptions(com.google.android.gms.maps.model.TileOverlayOptions) LatLng(com.google.android.gms.maps.model.LatLng)

Example 9 with TileOverlayOptions

use of com.google.android.gms.maps.model.TileOverlayOptions in project collect by opendatakit.

the class MapHelper method showLayersDialog.

public void showLayersDialog(final Context context) {
    AlertDialog.Builder layerDialod = new AlertDialog.Builder(context);
    layerDialod.setTitle(context.getString(R.string.select_offline_layer));
    layerDialod.setSingleChoiceItems(offilineOverlays, selectedLayer, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int item) {
            switch(item) {
                case 0:
                    if (googleMap != null) {
                        if (googleTileOverlay != null) {
                            googleTileOverlay.remove();
                        }
                    } else {
                        // OSM
                        if (osmTileOverlay != null) {
                            osmMap.getOverlays().remove(osmTileOverlay);
                            osmMap.invalidate();
                        }
                    }
                    selectedLayer = item;
                    break;
                default:
                    File[] spFiles = getFileFromSelectedItem(item);
                    if (spFiles.length == 0) {
                        break;
                    } else {
                        File spfile = spFiles[0];
                        if (isFileFormatSupported(spfile)) {
                            if (googleMap != null) {
                                try {
                                    // googleMap.clear();
                                    if (googleTileOverlay != null) {
                                        googleTileOverlay.remove();
                                    }
                                    TileOverlayOptions opts = new TileOverlayOptions();
                                    GoogleMapsMapBoxOfflineTileProvider provider = new GoogleMapsMapBoxOfflineTileProvider(spfile);
                                    opts.tileProvider(provider);
                                    googleTileOverlay = googleMap.addTileOverlay(opts);
                                } catch (Exception e) {
                                    break;
                                }
                            } else {
                                if (osmTileOverlay != null) {
                                    osmMap.getOverlays().remove(osmTileOverlay);
                                    osmMap.invalidate();
                                }
                                osmMap.invalidate();
                                OsmMBTileProvider mbprovider = new OsmMBTileProvider(iregisterReceiver, spfile);
                                osmTileOverlay = new TilesOverlay(mbprovider, context);
                                osmTileOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
                                osmMap.getOverlays().add(0, osmTileOverlay);
                                osmMap.invalidate();
                            }
                            selectedLayer = item;
                        } else {
                            ToastUtils.showLongToast(R.string.not_supported_offline_layer_format);
                        }
                    }
                    break;
            }
            dialog.dismiss();
        }
    });
    layerDialod.show();
}
Also used : AlertDialog(android.app.AlertDialog) TileOverlayOptions(com.google.android.gms.maps.model.TileOverlayOptions) DialogInterface(android.content.DialogInterface) TilesOverlay(org.osmdroid.views.overlay.TilesOverlay) File(java.io.File)

Example 10 with TileOverlayOptions

use of com.google.android.gms.maps.model.TileOverlayOptions in project collect by opendatakit.

the class GoogleMapFragment method loadReferenceOverlay.

/**
 * Updates the map to reflect the value of referenceLayerFile.
 */
private void loadReferenceOverlay() {
    if (referenceOverlay != null) {
        referenceOverlay.remove();
        referenceOverlay = null;
    }
    if (referenceLayerFile != null) {
        referenceOverlay = this.map.addTileOverlay(new TileOverlayOptions().tileProvider(new GoogleMapsMapBoxOfflineTileProvider(referenceLayerFile)));
        setLabelsVisibility("off");
    } else {
        setLabelsVisibility("on");
    }
}
Also used : TileOverlayOptions(com.google.android.gms.maps.model.TileOverlayOptions)

Aggregations

TileOverlayOptions (com.google.android.gms.maps.model.TileOverlayOptions)11 TileProvider (com.google.android.gms.maps.model.TileProvider)6 MalformedURLException (java.net.MalformedURLException)5 URL (java.net.URL)5 LatLng (com.google.android.gms.maps.model.LatLng)4 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 TileOverlay (com.google.android.gms.maps.model.TileOverlay)3 DialogInterface (android.content.DialogInterface)2 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 AlertDialog (android.app.AlertDialog)1 SharedPreferences (android.content.SharedPreferences)1