本文介绍了OSMDROID在Android中显示带有折线的多个地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
启动我的android应用程序时,我看到了多条带有折线的地图.我怎么只显示一张地图?
MainActivity :
public class MainActivity extends AppCompatActivity { MapView map; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context ctx = getApplicationContext(); Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx)); setContentView(R.layout.activity_main); map = findViewById(R.id.mapViewMain); map.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE); map.setBuiltInZoomControls(true); map.setMultiTouchControls(true); } protected void onResume() { super.onResume(); map.onPause(); } protected void onPause() { super.onPause(); map.onPause(); } }布局 activity_main :
<LinearLayout xmlns:android="schemas.android/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <org.osmdroid.views.MapView android:id="@+id/mapViewMain" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>我只想在我的设备上看到一张地图.
I want to see only one map on my device.
推荐答案我用以下方法解决了这个问题:
I solved that with this:
MapView map = (MapView) findViewById(R.id.map); map.setScrollableAreaLimitDouble(new BoundingBox(85, 180, -85, -180)); map.setMaxZoomLevel(20.0); map.setMinZoomLevel(4.0); map.setHorizontalMapRepetitionEnabled(false); map.setVerticalMapRepetitionEnabled(false); map.setScrollableAreaLimitLatitude(MapView.getTileSystem().getMaxLatitude(), MapView.getTileSystem().getMinLatitude(), 0);更多推荐
OSMDROID在Android中显示带有折线的多个地图
发布评论