start: add tilegridlayer to menu

This commit is contained in:
Hannes Janetzek 2014-05-24 23:07:47 +02:00
parent 4ddf9dcf39
commit c0369236d2
3 changed files with 24 additions and 0 deletions

View File

@ -27,4 +27,11 @@
</item>
</group>
<item
android:id="@+id/gridlayer"
android:showAsAction="never"
android:checkable="true"
android:title="@string/menu_gridlayer">
</item>
</menu>

View File

@ -15,5 +15,6 @@
<string name="styler_mode_area">Area</string>
<string name="styler_mode_outline">Outline</string>
<string name="styler_controls_toggle">Controls</string>
<string name="menu_gridlayer">Gridlayer</string>
</resources>

View File

@ -20,6 +20,7 @@ import org.oscim.android.MapActivity;
import org.oscim.android.MapView;
import org.oscim.android.cache.TileCache;
import org.oscim.core.MapPosition;
import org.oscim.layers.TileGridLayer;
import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.theme.VtmThemes;
import org.oscim.tiling.TileSource;
@ -36,6 +37,7 @@ public class BaseMapActivity extends MapActivity {
MapView mMapView;
VectorTileLayer mBaseLayer;
TileSource mTileSource;
TileGridLayer mGridLayer;
private TileCache mCache;
@ -105,6 +107,20 @@ public class BaseMapActivity extends MapActivity {
mMap.setTheme(VtmThemes.NEWTRON);
item.setChecked(true);
return true;
case R.id.gridlayer:
if (item.isChecked()) {
item.setChecked(false);
mMap.layers().remove(mGridLayer);
} else {
item.setChecked(true);
if (mGridLayer == null)
mGridLayer = new TileGridLayer(mMap);
mMap.layers().add(mGridLayer);
}
mMap.updateMap(true);
return true;
}
return false;