OSMDROID在Android中显示带有折线的多个地图

编程入门 行业动态 更新时间:2024-10-19 17:37:24
本文介绍了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中显示带有折线的多个地图

本文发布于:2023-06-07 21:59:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/568523.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:折线   多个   地图   OSMDROID   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!