com.google.android.gms.maps.model.TileOverlayOptions Java Examples
The following examples show how to use
com.google.android.gms.maps.model.TileOverlayOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GoogleMapsMapAdapter.java From ground-android with Apache License 2.0 | 6 votes |
private void addTileOverlay(String filePath) { File mbtilesFile = new File(context.getFilesDir(), filePath); if (!mbtilesFile.exists()) { Timber.i("mbtiles file %s does not exist", mbtilesFile.getAbsolutePath()); return; } try { MapBoxOfflineTileProvider tileProvider = new MapBoxOfflineTileProvider(mbtilesFile); tileProviders.onNext(tileProvider); map.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider)); } catch (Exception e) { Timber.e(e, "Couldn't initialize tile provider for mbtiles file %s", mbtilesFile); } }
Example #2
Source File: MapFragment.java From mage-android with Apache License 2.0 | 6 votes |
/** * 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); }
Example #3
Source File: HeatmapsDemoActivity.java From android-maps-utils with Apache License 2.0 | 6 votes |
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { String dataset = parent.getItemAtPosition(pos).toString(); TextView attribution = findViewById(R.id.attribution); // Check if need to instantiate (avoid setData etc twice) if (mProvider == null) { mProvider = new HeatmapTileProvider.Builder().data( mLists.get(getString(R.string.police_stations)).getData()).build(); mOverlay = getMap().addTileOverlay(new TileOverlayOptions().tileProvider(mProvider)); // Render links attribution.setMovementMethod(LinkMovementMethod.getInstance()); } else { mProvider.setData(mLists.get(dataset).getData()); mOverlay.clearTileCache(); } // Update attribution attribution.setText(Html.fromHtml(String.format(getString(R.string.attrib_format), mLists.get(dataset).getUrl()))); }
Example #4
Source File: GoogleMapControllerImpl.java From Companion-For-PUBG-Android with MIT License | 5 votes |
/** * Will overlay the current {@link GoogleMap} with tiles for PUBG. */ private void setUpMap() { final TileOverlayOptions overlayOptions = new TileOverlayOptions(); overlayOptions.tileProvider(new PUBGTileProvider()); this.googleMap.setMaxZoomPreference(5); this.googleMap.setMapType(GoogleMap.MAP_TYPE_NONE); this.googleMap.addTileOverlay(overlayOptions); this.googleMap.getUiSettings().setMapToolbarEnabled(false); }
Example #5
Source File: MapFragment.java From mage-android with Apache License 2.0 | 5 votes |
private void addURLCacheOverlay(Map<String, CacheOverlay> enabledCacheOverlays, URLCacheOverlay urlCacheOverlay){ // Retrieve the cache overlay if it already exists (and remove from cache overlays) CacheOverlay cacheOverlay = cacheOverlays.remove(urlCacheOverlay.getCacheName()); if(cacheOverlay == null){ // Create a new tile provider and add to the map TileProvider tileProvider = null; boolean isTransparent = false; if(urlCacheOverlay.getFormat().equalsIgnoreCase("xyz")) { tileProvider = new XYZTileProvider(256, 256, urlCacheOverlay); }else if(urlCacheOverlay.getFormat().equalsIgnoreCase("tms")){ tileProvider = new TMSTileProvider(256, 256, urlCacheOverlay); }else { tileProvider = new WMSTileProvider(256, 256, urlCacheOverlay); WMSCacheOverlay wms = (WMSCacheOverlay)urlCacheOverlay; isTransparent = Boolean.parseBoolean(wms.getWmsTransparent()); } TileOverlayOptions overlayOptions = createTileOverlayOptions(tileProvider); if(urlCacheOverlay.isBase()) { overlayOptions.zIndex(-4); } else if(!isTransparent) { overlayOptions.zIndex(-3); } else{ overlayOptions.zIndex(-2); } // Set the tile overlay in the cache overlay TileOverlay tileOverlay = map.addTileOverlay(overlayOptions); urlCacheOverlay.setTileOverlay(tileOverlay); cacheOverlay = urlCacheOverlay; } // Add the cache overlay to the enabled cache overlays enabledCacheOverlays.put(cacheOverlay.getCacheName(), cacheOverlay); }
Example #6
Source File: MapFragment.java From mage-android with Apache License 2.0 | 5 votes |
/** * 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; }
Example #7
Source File: HeatMapActivity.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
@Override protected void initMapSettings() { ArrayList<LatLng> locations = generateLocations(); mProvider = new HeatmapTileProvider.Builder().data( locations ).build(); mProvider.setRadius( HeatmapTileProvider.DEFAULT_RADIUS ); mGoogleMap.addTileOverlay(new TileOverlayOptions().tileProvider(mProvider)); }
Example #8
Source File: TileProviderAndProjectionDemo.java From android-maps-utils with Apache License 2.0 | 5 votes |
@Override protected void startDemo(boolean isRestore) { PointTileOverlay pto = new PointTileOverlay(); pto.addPoint(new LatLng(0, 0)); pto.addPoint(new LatLng(21, -10)); getMap().addTileOverlay(new TileOverlayOptions().tileProvider(pto)); }
Example #9
Source File: MapFragment.java From mage-android with Apache License 2.0 | 4 votes |
/** * Add the GeoPackage Tile Table Cache Overlay * @param enabledCacheOverlays * @param tileTableCacheOverlay * @param geoPackage * @param linkedToFeatures */ private void addGeoPackageTileCacheOverlay(Map<String, CacheOverlay> enabledCacheOverlays, GeoPackageTileTableCacheOverlay tileTableCacheOverlay, GeoPackage geoPackage, boolean linkedToFeatures){ // Retrieve the cache overlay if it already exists (and remove from cache overlays) CacheOverlay cacheOverlay = cacheOverlays.remove(tileTableCacheOverlay.getCacheName()); if(cacheOverlay != null){ // If the existing cache overlay is being replaced, create a new cache overlay if(tileTableCacheOverlay.getParent().isAdded()){ cacheOverlay = null; } } if(cacheOverlay == null){ // Create a new GeoPackage tile provider and add to the map TileDao tileDao = geoPackage.getTileDao(tileTableCacheOverlay.getName()); TileTableScaling tileTableScaling = new TileTableScaling(geoPackage, tileDao); TileScaling tileScaling = tileTableScaling.get(); BoundedOverlay overlay = GeoPackageOverlayFactory .getBoundedOverlay(tileDao, getResources().getDisplayMetrics().density, tileScaling); TileOverlayOptions overlayOptions = null; if(linkedToFeatures){ overlayOptions = createFeatureTileOverlayOptions(overlay); }else { overlayOptions = createTileOverlayOptions(overlay); } TileOverlay tileOverlay = map.addTileOverlay(overlayOptions); tileTableCacheOverlay.setTileOverlay(tileOverlay); // Check for linked feature tables tileTableCacheOverlay.clearFeatureOverlayQueries(); FeatureTileTableLinker linker = new FeatureTileTableLinker(geoPackage); List<FeatureDao> featureDaos = linker.getFeatureDaosForTileTable(tileDao.getTableName()); for(FeatureDao featureDao: featureDaos){ // Create the feature tiles FeatureTiles featureTiles = new DefaultFeatureTiles(getActivity(), geoPackage, featureDao, getResources().getDisplayMetrics().density); // Add the feature overlay query FeatureOverlayQuery featureOverlayQuery = new FeatureOverlayQuery(getActivity(), overlay, featureTiles); tileTableCacheOverlay.addFeatureOverlayQuery(featureOverlayQuery); } cacheOverlay = tileTableCacheOverlay; } // Add the cache overlay to the enabled cache overlays enabledCacheOverlays.put(cacheOverlay.getCacheName(), cacheOverlay); }
Example #10
Source File: MapFragment.java From mage-android with Apache License 2.0 | 4 votes |
/** * Add the GeoPackage Feature Table Cache Overlay * @param enabledCacheOverlays * @param featureTableCacheOverlay * @param geoPackage */ private void addGeoPackageFeatureCacheOverlay(Map<String, CacheOverlay> enabledCacheOverlays, GeoPackageFeatureTableCacheOverlay featureTableCacheOverlay, GeoPackage geoPackage){ // Retrieve the cache overlay if it already exists (and remove from cache overlays) CacheOverlay cacheOverlay = cacheOverlays.remove(featureTableCacheOverlay.getCacheName()); if(cacheOverlay != null){ // If the existing cache overlay is being replaced, create a new cache overlay if(featureTableCacheOverlay.getParent().isAdded()){ cacheOverlay = null; } for(GeoPackageTileTableCacheOverlay linkedTileTable: featureTableCacheOverlay.getLinkedTileTables()){ cacheOverlays.remove(linkedTileTable.getCacheName()); } } if(cacheOverlay == null) { // Add the features to the map FeatureDao featureDao = geoPackage.getFeatureDao(featureTableCacheOverlay.getName()); // If indexed, add as a tile overlay if(featureTableCacheOverlay.isIndexed()){ FeatureTiles featureTiles = new DefaultFeatureTiles(getActivity(), geoPackage, featureDao, getResources().getDisplayMetrics().density); Integer maxFeaturesPerTile = null; if(featureDao.getGeometryType() == GeometryType.POINT){ maxFeaturesPerTile = getResources().getInteger(R.integer.geopackage_feature_tiles_max_points_per_tile); }else{ maxFeaturesPerTile = getResources().getInteger(R.integer.geopackage_feature_tiles_max_features_per_tile); } featureTiles.setMaxFeaturesPerTile(maxFeaturesPerTile); NumberFeaturesTile numberFeaturesTile = new NumberFeaturesTile(getActivity()); // Adjust the max features number tile draw paint attributes here as needed to // change how tiles are drawn when more than the max features exist in a tile featureTiles.setMaxFeaturesTileDraw(numberFeaturesTile); // Adjust the feature tiles draw paint attributes here as needed to change how // features are drawn on tiles FeatureOverlay featureOverlay = new FeatureOverlay(featureTiles); featureOverlay.setMinZoom(featureTableCacheOverlay.getMinZoom()); // Get the tile linked overlay BoundedOverlay overlay = GeoPackageOverlayFactory.getLinkedFeatureOverlay(featureOverlay, geoPackage); FeatureOverlayQuery featureOverlayQuery = new FeatureOverlayQuery(getActivity(), overlay, featureTiles); featureTableCacheOverlay.setFeatureOverlayQuery(featureOverlayQuery); TileOverlayOptions overlayOptions = createFeatureTileOverlayOptions(overlay); TileOverlay tileOverlay = map.addTileOverlay(overlayOptions); featureTableCacheOverlay.setTileOverlay(tileOverlay); } // Not indexed, add the features to the map else { int maxFeaturesPerTable = 0; if(featureDao.getGeometryType() == GeometryType.POINT){ maxFeaturesPerTable = getResources().getInteger(R.integer.geopackage_features_max_points_per_table); }else{ maxFeaturesPerTable = getResources().getInteger(R.integer.geopackage_features_max_features_per_table); } Projection projection = featureDao.getProjection(); GoogleMapShapeConverter shapeConverter = new GoogleMapShapeConverter(projection); FeatureCursor featureCursor = featureDao.queryForAll(); try { final int totalCount = featureCursor.getCount(); int count = 0; while (featureCursor.moveToNext()) { try { FeatureRow featureRow = featureCursor.getRow(); GeoPackageGeometryData geometryData = featureRow.getGeometry(); if (geometryData != null && !geometryData.isEmpty()) { Geometry geometry = geometryData.getGeometry(); if (geometry != null) { GoogleMapShape shape = shapeConverter.toShape(geometry); // Set the Shape Marker, PolylineOptions, and PolygonOptions here if needed to change color and style featureTableCacheOverlay.addShapeToMap(featureRow.getId(), shape, map); if (++count >= maxFeaturesPerTable) { if (count < totalCount) { Toast.makeText(getActivity().getApplicationContext(), featureTableCacheOverlay.getCacheName() + "- added " + count + " of " + totalCount, Toast.LENGTH_LONG).show(); } break; } } } }catch(Exception e){ Log.e(LOG_NAME, "Failed to display feature. GeoPackage: " + geoPackage.getName() + ", Table: " + featureDao.getTableName() + ", Row: " + featureCursor.getPosition(), e); } } } finally { featureCursor.close(); } } cacheOverlay = featureTableCacheOverlay; } // Add the cache overlay to the enabled cache overlays enabledCacheOverlays.put(cacheOverlay.getCacheName(), cacheOverlay); }
Example #11
Source File: TileCoordinateDemoActivity.java From android-samples with Apache License 2.0 | 4 votes |
@Override public void onMapReady(GoogleMap map) { TileProvider coordTileProvider = new CoordTileProvider(this.getApplicationContext()); map.addTileOverlay(new TileOverlayOptions().tileProvider(coordTileProvider)); }
Example #12
Source File: GoogleMapImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 4 votes |
@Override public ITileOverlayDelegate addTileOverlay(TileOverlayOptions options) throws RemoteException { Log.d(TAG, "not yet usable: addTileOverlay"); return new TileOverlayImpl(); // TODO }
Example #13
Source File: MapFragment.java From mage-android with Apache License 2.0 | 2 votes |
/** * 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); }
Example #14
Source File: MapFragment.java From mage-android with Apache License 2.0 | 2 votes |
/** * Create Tile Overlay Options with the default z index for tile layers * @param tileProvider * @return */ private TileOverlayOptions createTileOverlayOptions(TileProvider tileProvider){ return createTileOverlayOptions(tileProvider, -2); }