public static void setMapFile(MapsActivity context) { MapsForgeTilesProvider provider; try { provider = new MapsForgeTilesProvider( context.getApplication(), new File(mapFile), new File(themeFile)); } catch (Exception e) { mapFile = null; e.printStackTrace(); Toast.makeText(context, "無法開啟檔案", Toast.LENGTH_SHORT).show(); return; } TileOverlay lastTile = context.getMapsManager().getCurrentMapTile(); if (lastTile != null) lastTile.remove(); MapsManager manager = context.getMapsManager(); manager.setCurrentMapTile(manager.getCurrentMap().addTileOverlay( new TileOverlayOptions().tileProvider(provider))); manager.getCurrentMapTile().setZIndex(ZINDEX_BASEMAP); manager.getCurrentMap().setMapType(GoogleMap.MAP_TYPE_NONE); }
/** * Change the visibility of all Markers and TileOverlays for a floor. */ private void setFloorElementsVisible(int floor, boolean visible) { // Overlays final TileOverlay overlay = mTileOverlays.get(floor); if (overlay != null) { overlay.setVisible(visible); } // Markers final ArrayList<Marker> markers = mMarkersFloor.get(floor); if (markers != null) { for (Marker m : markers) { m.setVisible(visible); } } }
/** * Remove this tile layer * @param args * @param callbackContext * @throws JSONException */ protected void remove(JSONArray args, CallbackContext callbackContext) throws JSONException { String id = args.getString(1); TileOverlay tileOverlay = (TileOverlay)this.objects.get(id); if (tileOverlay == null) { this.sendNoResult(callbackContext); return; } tileOverlay.remove(); tileOverlay.clearTileCache(); id = id.replace("tile_", "tileProvider_"); this.objects.put(id, null); this.objects.remove(id); this.sendNoResult(callbackContext); }
/** * 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); }
/** * Change the visibility of all Markers and TileOverlays for a floor. * * @param floor * @param visible */ private void setFloorElementsVisible(int floor, boolean visible) { // Overlays final TileOverlay overlay = mTileOverlays.get(floor); if (overlay != null) { overlay.setVisible(visible); } // Markers final ArrayList<Marker> markers = mMarkersFloor.get(floor); if (markers != null) { for (Marker m : markers) { m.setVisible(visible); } } }
private void clearMap() { if (mMap != null) { for (int floor =0; floor < mMarkersFloor.size();floor++) { ArrayList<Marker> markers = mMarkersFloor.valueAt(floor); if (markers != null) { for (Marker marker : markers) { marker.setVisible(false); } } } for (int floor =0; floor < mTileOverlays.size();floor++) { TileOverlay overlay = mTileOverlays.valueAt(floor); if(overlay!=null) { overlay.setVisible(false); } } } }
public final TileOverlay addTileOverlay(TileOverlayOptions paramTileOverlayOptions) { try { f localf = this.Br.addTileOverlay(paramTileOverlayOptions); if (localf != null) { TileOverlay localTileOverlay = new TileOverlay(localf); return localTileOverlay; } return null; } catch (RemoteException localRemoteException) { throw new RuntimeRemoteException(localRemoteException); } }
/** * Creates check box for a given search term * * @param keyword the search terms associated with the check box */ private void makeCheckBox(final String keyword) { mCheckboxLayout.setVisibility(View.VISIBLE); // Make new checkbox CheckBox checkBox = new CheckBox(this); checkBox.setText(keyword); checkBox.setTextColor(HEATMAP_COLORS[mOverlaysRendered]); checkBox.setChecked(true); checkBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { CheckBox c = (CheckBox) view; // Text is the keyword TileOverlay overlay = mOverlays.get(keyword); if (overlay != null) { overlay.setVisible(c.isChecked()); } } }); mCheckboxLayout.addView(checkBox); }
/** * 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>()); } }
public static void pickOnlineTile(final Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("選擇線上底圖") .setItems(ONLINE_TILES, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { MapsManager manager = ((MapsActivity) context).getMapsManager(); GoogleMap map = manager.getCurrentMap(); TileOverlay lastTile = manager.getCurrentMapTile(); if (lastTile != null) lastTile.remove(); switch (which) { case 0: map.setMapType(MAP_TYPE_HYBRID); break; case 1: map.setMapType(MAP_TYPE_NORMAL); break; default: TileOverlay newTile = map.addTileOverlay( getTileSetting(URL_ONLINE_TILES[which].toString())); newTile.setZIndex(ZINDEX_BASEMAP); manager.setCurrentMapTile(newTile); map.setMapType(MAP_TYPE_NONE); } } }); builder.show(); }
public static void pickAdditionalTile(final Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("選擇疊加圖層") .setItems(ADDITION_TILES, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { MapsManager manager = ((MapsActivity) context).getMapsManager(); GoogleMap map = manager.getCurrentMap(); switch (which) { case 1: manager.addMapAddTiles(map.addTileOverlay( new TileOverlayOptions().tileProvider( new CoorTileProvider(context, Color.BLACK)))); break; case 2: manager.addMapAddTiles(map.addTileOverlay( new TileOverlayOptions().tileProvider( new CoorTileProvider(context, Color.WHITE)))); break; case 4: manager.clearCurrentMapAddTiles(); break; default: TileOverlay tileOverlay = map.addTileOverlay( getTileSetting(URL_ADDITIONAL_TILES[which].toString())); tileOverlay.setZIndex(ZINDEX_ADDTILE); manager.addMapAddTiles(tileOverlay); } } }); builder.show(); }
public void clearCurrentMapAddTiles() { List<TileOverlay> addTiles; if (currentMapCode == MAP_CODE_MAIN) addTiles = mMapAddTiles.first; else addTiles = mMapAddTiles.second; for (TileOverlay layer : addTiles) layer.remove(); addTiles.clear(); }
/** * Create tile overlay * * @param args * @param callbackContext * @throws JSONException */ @SuppressWarnings("unused") private void createTileOverlay(final JSONArray args, final CallbackContext callbackContext) throws JSONException { JSONObject opts = args.getJSONObject(1); int tileSize = opts.getInt("tileSize"); final String tileUrlFormat = opts.getString("tileUrlFormat"); double opacity = 1.0; if (opts.has("opacity")) { opacity = opts.getDouble("opacity"); } PluginTileProvider tileProvider = new PluginTileProvider(tileUrlFormat, opacity, tileSize); TileOverlayOptions options = new TileOverlayOptions(); options.tileProvider(tileProvider); if (opts.has("zIndex")) { options.zIndex((float)opts.getDouble("zIndex")); } if (opts.has("visible")) { options.visible(opts.getBoolean("visible")); } TileOverlay tileOverlay = this.map.addTileOverlay(options); String id = "tile_" + tileOverlay.getId(); this.objects.put(id, tileOverlay); this.objects.put(id.replace("tile_", "tileProvider_"), tileProvider); JSONObject result = new JSONObject(); result.put("hashCode", tileOverlay.hashCode()); result.put("id", id); callbackContext.success(result); }
/** * Clear cache * @param args * @param callbackContext * @throws JSONException */ protected void clearTileCache(JSONArray args, CallbackContext callbackContext) throws JSONException { String id = args.getString(1); TileOverlay tileOverlay = (TileOverlay)this.objects.get(id); tileOverlay.clearTileCache(); this.sendNoResult(callbackContext); }
private void loadOfflineData(int pos) { try { String extPath = Environment.getExternalStorageDirectory().getAbsolutePath(); String filepath = extPath + "/" + CommonFunctions.parentFolderName + "/" + CommonFunctions.dataFolderName + "/" + offlineSpatialData.get(pos).getFile_Name(); OfflineTileProvider provider = offlineSpatialData.get(pos).getProvider(); File mbtileFile = new File(filepath); TileOverlayOptions opts = new TileOverlayOptions(); if (provider == null) { // Create an instance of OfflineTileProvider. provider = new OfflineTileProvider(mbtileFile); offlineSpatialData.get(pos).setProvider(provider); } // Set the tile provider on the TileOverlayOptions. opts.tileProvider(provider); // Add the tile overlay to the map. TileOverlay overlay = googleMap.addTileOverlay(opts); offlineSpatialData.get(pos).setOverlay(overlay); // Sometime later when the map view is destroyed, close the provider. // This is important to prevent a leak of the backing SQLiteDatabase. provider.close(); } catch (Exception e) { cf.appLog("", e); //String msg = getResources().getString(R.string.unableToLoadOfflineData); //Toast.makeText(context,msg+": "+offlineSpatialData.get(pos).getAlias(), Toast.LENGTH_SHORT).show(); } }
private void loadOfflineData(int pos) { try { String extPath = Environment.getExternalStorageDirectory().getAbsolutePath(); String filepath = extPath + "/" + CommonFunctions.parentFolderName + "/" + CommonFunctions.dataFolderName + "/" + offlineSpatialData.get(pos).getFile_Name(); OfflineTileProvider provider = offlineSpatialData.get(pos).getProvider(); File mbtileFile = new File(filepath); TileOverlayOptions opts = new TileOverlayOptions(); if (provider == null) { // Create an instance of OfflineTileProvider. provider = new OfflineTileProvider(mbtileFile); offlineSpatialData.get(pos).setProvider(provider); } // Set the tile provider on the TileOverlayOptions. opts.tileProvider(provider); // Add the tile overlay to the map. TileOverlay overlay = googleMap.addTileOverlay(opts); offlineSpatialData.get(pos).setOverlay(overlay); // Sometime later when the map view is destroyed, close the provider. // This is important to prevent a leak of the backing SQLiteDatabase. provider.close(); } catch (Exception e) { cf.appLog("", e); String msg = getResources().getString(R.string.unableToLoadOfflineData); Toast.makeText(context, msg + ": " + offlineSpatialData.get(pos).getAlias(), Toast.LENGTH_SHORT).show(); } }
private void setupOfflineMapOverlay(GoogleMap map) { map.setMapType(GoogleMap.MAP_TYPE_NONE); TileOverlay tileOverlay = map.addTileOverlay(new TileOverlayOptions() .tileProvider(new LocalMapTileProvider())); tileOverlay.setZIndex(-1); tileOverlay.clearTileCache(); }
/** * Add a tile table to the map * * @param geoPackage * @param name * @param data */ private void addTileTable(GeoPackage geoPackage, String name, GeoPackageMapData data) { GeoPackageTableMapData tableData = new GeoPackageTableMapData(name, false); data.addTable(tableData); // Create a new GeoPackage tile provider and add to the map TileDao tileDao = geoPackage.getTileDao(name); BoundedOverlay geoPackageTileOverlay = GeoPackageOverlayFactory.getBoundedOverlay(tileDao); // Check for linked feature tables FeatureTileTableLinker linker = new FeatureTileTableLinker(geoPackage); List<FeatureDao> featureDaos = linker.getFeatureDaosForTileTable(tileDao.getTableName()); for (FeatureDao featureDao : featureDaos) { // Create the feature tiles FeatureTiles featureTiles = new DefaultFeatureTiles(context, featureDao); // Create an index manager FeatureIndexManager indexer = new FeatureIndexManager(context, geoPackage, featureDao); featureTiles.setIndexManager(indexer); // Add the feature overlay query FeatureOverlayQuery featureOverlayQuery = new FeatureOverlayQuery(context, geoPackageTileOverlay, featureTiles); tableData.addFeatureOverlayQuery(featureOverlayQuery); } // Set the tiles index to be -2 of it is behind features and tiles drawn from features int zIndex = -2; // If these tiles are linked to features, set the zIndex to -1 so they are placed before imagery tiles if (!featureDaos.isEmpty()) { zIndex = -1; } TileOverlayOptions overlayOptions = createTileOverlayOptions(geoPackageTileOverlay, zIndex); TileOverlay tileOverlay = map.addTileOverlay(overlayOptions); tableData.setTileOverlay(tileOverlay); }
public TileOverlayHolder(final TileOverlay tileOverlay, final MapOverlayType overlayType) { this.tileOverlay = tileOverlay; this.overlayType = overlayType; }
public TileOverlay getTileOverlay() { return tileOverlay; }
public TileOverlay getCurrentMapTile() { return mMapTiles.get(currentMapCode); }
public void setCurrentMapTile(TileOverlay tileOverlay) { mMapTiles.set(currentMapCode, tileOverlay); }
public void addMapAddTiles(TileOverlay layer) { if (currentMapCode == MAP_CODE_MAIN) mMapAddTiles.first.add(layer); else if (currentMapCode == MAP_CODE_SUB) mMapAddTiles.second.add(layer); }
@Override public final TileOverlay addTileOverlay(TileOverlayOptions options) { return map.addTileOverlay(options); }