我使用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 tile服务器,当我使用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罐安卓4.0.3
当我更仔细地看它时,我可以在很短的时间内看到地图瓷砖,然后另一层覆盖在上面。我从地图上删除了除基本层之外的其他层,但没有任何变化。
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);