void addTileProvider(int floor, File f) { if (!f.exists()) { return; } TileProvider provider; try { SVGTileProvider svgProvider = new SVGTileProvider(f, mDPI); if (mTileCache == null) { // Use the SVGTileProvider directly as the TileProvider without a cache provider = svgProvider; } else { // Wrap the SVGTileProvider ina a CachedTileProvider for caching on disk provider = new CachedTileProvider(Integer.toString(floor), svgProvider, mTileCache); } } catch (IOException e) { LogUtils.LOGD(TAG, "Could not create Tile Provider."); return; } TileOverlayOptions tileOverlay = new TileOverlayOptions() .tileProvider(provider).visible(false); mTileProviders.put(floor, provider); mTileOverlays.put(floor, mMap.addTileOverlay(tileOverlay)); }
@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, y, x); 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); }
/** * Add XYZ Directory tile cache overlay * @param enabledCacheOverlays * @param xyzDirectoryCacheOverlay */ private void addXYZDirectoryCacheOverlay(Map<String, CacheOverlay> enabledCacheOverlays, XYZDirectoryCacheOverlay xyzDirectoryCacheOverlay){ // Retrieve the cache overlay if it already exists (and remove from cache overlays) CacheOverlay cacheOverlay = cacheOverlays.remove(xyzDirectoryCacheOverlay.getCacheName()); if(cacheOverlay == null){ // Create a new tile provider and add to the map TileProvider tileProvider = new FileSystemTileProvider(256, 256, xyzDirectoryCacheOverlay.getDirectory().getAbsolutePath()); TileOverlayOptions overlayOptions = createTileOverlayOptions(tileProvider); // Set the tile overlay in the cache overlay TileOverlay tileOverlay = map.addTileOverlay(overlayOptions); xyzDirectoryCacheOverlay.setTileOverlay(tileOverlay); cacheOverlay = xyzDirectoryCacheOverlay; } // Add the cache overlay to the enabled cache overlays enabledCacheOverlays.put(cacheOverlay.getCacheName(), cacheOverlay); }
void addTileProvider(int floor, File f) { if (!f.exists()) { return; } TileProvider provider; try { SVGTileProvider svgProvider = new SVGTileProvider(f, mDPI); if (mTileCache == null) { // Use the SVGTileProvider directly as the TileProvider without a cache provider = svgProvider; } else { // Wrap the SVGTileProvider ina a CachedTileProvider for caching on disk provider = new CachedTileProvider(Integer.toString(floor), svgProvider, mTileCache); } } catch (IOException e) { LOGD(TAG, "Could not create Tile Provider."); return; } TileOverlayOptions tileOverlay = new TileOverlayOptions() .tileProvider(provider).visible(false); mTileProviders.put(floor, provider); mTileOverlays.put(floor, mMap.addTileOverlay(tileOverlay)); }
private void setUpMap() { mMap.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 = mMap.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider)); }
@Override public Tile getTile(int x, int y, int z) { // query the provider for a tile specified by x, y and z coordinates String[] projection = new String[]{TilesContract.COLUMN_TILE_DATA}; String selection = TilesContract.COLUMN_ZOOM_LEVEL + " = ? AND " + TilesContract.COLUMN_TILE_COLUMN + "= ? AND " + TilesContract.COLUMN_TILE_ROW + "= ?"; String[] selectionArgs = new String[]{String.valueOf(z), String.valueOf(x), String.valueOf((int) (Math.pow(2, z) - y - 1))}; // .mbtiles database use TSM coordinates // we need to switch to Google compatible coordinates // https://gist.github.com/tmcw/4954720 Cursor cursor = mContext.getContentResolver().query(Uri.parse(mContentProviderPath), projection, selection, selectionArgs, null); Tile tile = TileProvider.NO_TILE; if (cursor.moveToFirst()) tile = cursorToMapItem(cursor); // make sure to close the cursor cursor.close(); return tile; }
private void setUpMap() { mMap.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; } }; mMap.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider)); }
/** * Add an overlay to the map. * * @param id * Map place holder ID. * @param jsonTileOverlay * JSON serialized TileOverlay. */ @JavascriptInterface public void addTileOverlay(final String id, final String jsonTileOverlay) { final GoogleMap map = getGoogleMapSync(id); UIThreadExecutor.execute(postponeWhenMapIsInvisible(id, new Runnable() { @Override public void run() { try { TileOverlay tileOverlay = TileOverlay.fromJsonTileOverlay(new JSONObject(jsonTileOverlay)); TileProvider tileProvider = new UrlPatternTileProvider(tileOverlay.tileUrlPattern, tileOverlay.enableGrayscaleFilter); com.google.android.gms.maps.model.TileOverlay gTileOverlay = map.addTileOverlay(new TileOverlayOptions() .tileProvider(tileProvider) .zIndex(tileOverlay.zIndex)); tileOverlayById.put(tileOverlay.id, gTileOverlay); } catch (JSONException e) { exceptionListener.onException(false, e); } } })); }
/** * Clears the map and initialises all map variables that hold markers and overlays. */ private void clearMap() { if (mMap != null) { mMap.clear(); } // setup tile provider arrays mTileProviders = new TileProvider[NUM_FLOORS]; mTileOverlays = new TileOverlay[NUM_FLOORS]; mMarkers = new HashMap<String, MarkerModel>(); mMarkersFloor = new ArrayList<ArrayList<Marker>>(); // initialise floor marker lists for (int i = 0; i < NUM_FLOORS; i++) { mMarkersFloor.add(i, new ArrayList<Marker>()); } }
void addTileProvider(int floor, File f) { if (!f.exists()) { return; } TileProvider provider; try { provider = new SVGTileProvider(f, mDPI); } catch (IOException e) { LOGD(TAG, "Could not create Tile Provider."); e.printStackTrace(); return; } TileOverlayOptions tileOverlay = new TileOverlayOptions() .tileProvider(provider).visible(false); mTileProviders[floor] = provider; mTileOverlays[floor] = mMap.addTileOverlay(tileOverlay); }
@Override public Tile getTile(int x, int y, int zoom) { if (zoom > maxZoomLevel) { return TileProvider.NO_TILE; } final String tileUri = MapboxUtils.getMapTileURL(mapboxId, mapboxAccessToken, zoom, x, y); byte[] data = DatabaseState.getOfflineDatabaseHandlerForMapId(context, mapboxId).dataForURL(tileUri); if (data == null || data.length == 0) return TileProvider.NO_TILE; return new Tile(MapboxUtils.TILE_WIDTH, MapboxUtils.TILE_HEIGHT, data); }
/** * Create Tile Overlay Options for the Tile Provider using the z index * @param tileProvider * @param zIndex * @return */ private TileOverlayOptions createTileOverlayOptions(TileProvider tileProvider, int zIndex){ TileOverlayOptions overlayOptions = new TileOverlayOptions(); overlayOptions.tileProvider(tileProvider); overlayOptions.zIndex(zIndex); return overlayOptions; }
private void setUpMap() { TileProvider wmsTileProvider = TileProviderFactory.getOsgeoWmsTileProvider(); mMap.addTileOverlay(new TileOverlayOptions().tileProvider(wmsTileProvider)); // Because the demo WMS layer we are using is just a white background map, switch the base layer // to satellite so we can see the WMS overlay. mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); }
public TileProvider getTileProvider() { return real.getTileProvider(); }
protected TileProviderManager(TileProvider onlineTileProvider, TileProvider offlineTileProvider) { this.offlineTileProvider = offlineTileProvider; this.onlineTileProvider = onlineTileProvider; }
public TileProvider getOfflineTileProvider() { return offlineTileProvider; }
public TileProvider getOnlineTileProvider() { return onlineTileProvider; }
private void setUpMap() { TileProvider coordTileProvider = new CoordTileProvider(this.getApplicationContext()); mMap.addTileOverlay(new TileOverlayOptions().tileProvider(coordTileProvider)); }
/** * Create Tile Overlay Options for the Tile Provider using the z index * * @param tileProvider * @param zIndex * @return */ private TileOverlayOptions createTileOverlayOptions(TileProvider tileProvider, int zIndex) { TileOverlayOptions overlayOptions = new TileOverlayOptions(); overlayOptions.tileProvider(tileProvider); overlayOptions.zIndex(zIndex); return overlayOptions; }
/** * TileProvider that wraps another TileProvider and caches all Tiles in a DiskLruCache. * * <p>A {@link com.jakewharton.disklrucache.DiskLruCache} can be reused across multiple * instances. * The keyTag is used to annotate entries for this TileProvider, it is recommended to use a * unique * String for each instance to prevent collisions. * * <p>NOTE: The supplied {@link com.jakewharton.disklrucache.DiskLruCache} requires space for * 3 entries per cached object. * * @param keyTag identifier used to identify tiles for this CachedTileProvider instance * @param tileProvider tiles from this TileProvider will be cached. * @param cache the cache used to store tiles */ public CachedTileProvider(String keyTag, TileProvider tileProvider, DiskLruCache cache) { mKeyTag = keyTag; mTileProvider = tileProvider; mCache = cache; }
/** * Get a Tile Provider for the Tile DAO * * @param tileDao * @return */ public static TileProvider getTileProvider(TileDao tileDao) { return getBoundedOverlay(tileDao); }
/** * Create Feature Tile Overlay Options with the default z index for tile layers drawn from features * @param tileProvider * @return */ private TileOverlayOptions createFeatureTileOverlayOptions(TileProvider tileProvider){ return createTileOverlayOptions(tileProvider, -1); }
/** * Create Tile Overlay Options with the default z index for tile layers * @param tileProvider * @return */ private TileOverlayOptions createTileOverlayOptions(TileProvider tileProvider){ return createTileOverlayOptions(tileProvider, -2); }
/** * TileProvider that wraps another TileProvider and caches all Tiles in a DiskLruCache. * * <p>A {@link com.jakewharton.disklrucache.DiskLruCache} can be reused across multiple instances. * The keyTag is used to annotate entries for this TileProvider, it is recommended to use a unique * String for each instance to prevent collisions. * * <p>NOTE: The supplied {@link com.jakewharton.disklrucache.DiskLruCache} requires space for * 3 entries per cached object. * * @param keyTag identifier used to identify tiles for this CachedTileProvider instance * @param tileProvider tiles from this TileProvider will be cached. * @param cache the cache used to store tiles */ public CachedTileProvider(String keyTag, TileProvider tileProvider, DiskLruCache cache) { mKeyTag = keyTag; mTileProvider = tileProvider; mCache = cache; }