【问题标题】:OSM android does not show map tileOSM android不显示地图图块
【发布时间】:2014-10-29 06:02:21
【问题描述】:

我已经使用 Open Street Map 实现了一个应用程序,并使用 OSM android 作为库。我以前工作得很好,但我最近运行了这个应用程序,它根本没有显示地图图块。我多次更改了磁贴提供程序,但都不起作用。

这是我的代码:

public class OsmMapActivity extends SherlockActivity {

protected MapView mapView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());

        initialiseMap();
    }

    protected void initialiseMap(){
        mapView = (MapView)findViewById(R.id.mapView);                        
        mapView.setTileSource(TileSourceFactory.MAPQUESTOSM); //Mapink and other providers do not work
        mapView.setMultiTouchControls(true);
    }
}

另外,OSM android 是否支持第三方提供商?我有自己的 OSM 平铺服务器,当我使用 Javascript 显示地图时它运行良好,但在 Android 代码中无法运行。

OnlineTileSourceBase tileSource = new XYTileSource("MyOSM", null, 1, 19, 256, ".png", new String[]{"http://tactile.myserver.com/osm_tiles"});
TileSourceFactory.addTileSource(tileSource);
mapView.setTileSource("MyOSM");

您的回答将不胜感激。谢谢。

编辑: 我正在使用 osmdroid-android-4.2.jar 安卓4.0.3

当我更仔细地观察它时,我可以在很短的时间内看到地图图块,然后另一个图层覆盖在它上面。我从地图中删除了除基础层之外的其他层,但没有任何改变。

【问题讨论】:

  • 尝试找出它尝试检索的 URL。然后检查它们是否有效并返回平铺图像。
  • 调试它对服务器的请求
  • 指定使用的 Android SDK 和 osmdroid 版本。
  • 您是否设置了清单权限?目标 api 设置在什么位置?

标签: android map openstreetmap osmdroid


【解决方案1】:
    MapController mapController;
    MapView map = (MapView) root.findViewById(R.id.map);
    map.setTileSource(TileSourceFactory.MAPQUESTOSM);
    map.setBuiltInZoomControls(true);
    map.setMultiTouchControls(true);
    mapController = map.getController();
    myLocationoverlay = new MyLocationNewOverlay(map);
    myLocationoverlay.setEnabled(true);
    map.getOverlays().add(myLocationoverlay);
    mapController.setZoom(9.5);
    GeoPoint startPoint = new GeoPoint(35.744198, 51.4285752);
    mapController.setCenter(startPoint);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-20
    • 1970-01-01
    • 1970-01-01
    • 2020-07-20
    • 2013-06-05
    • 1970-01-01
    • 1970-01-01
    • 2013-06-13
    相关资源
    最近更新 更多