경로 오버레이를 OSMDroid 맵에 추가하려고하는데 표시되지 않습니다. 내가 뭘 놓치고 있니?OSMDroid PathOverlay가 나타나지 않습니다.
업데이트 : 나는 그것이 타일 크기 함께 할 수있는 뭔가가 파악
. 타일을 256으로 설정하더라도 크기를 512로 설정합니다. 그렇지 않으면 맵이 너무 커서 고밀도 화면에서 읽을 수 없습니다. 크기를 256으로 변경하면 경로가 표시됩니다. 512로 다시 변경하면 표시되지 않습니다.
public class MainActivity extends Activity {
// set this to 256 for actual tile size, 512 to show larger and cause PathOverlay to not be displayed
int tileSize = 512;
private MapView mapView;
// area of offline tiles
double north = 40.739063;
double south = 40.708361;
double west = -73.967171;
double east = -73.936272;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// center of offline tiles
double centerlat = (double) ((north+south)/2);
double centerlon = (double) ((west+east)/2);
// copy tiles to sd location for offline map
putMapOnSD();
// create mapView and show layout
mapView = new MapView(this,tileSize);
final LinearLayout layout = new LinearLayout(this);
final LinearLayout.LayoutParams mapViewLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
layout.addView(mapView, mapViewLayoutParams);
setContentView(layout);
// set map to use offline tiles and display
mapView.setTileSource (new XYTileSource ("tiles", ResourceProxy.string.offline_mode, 13, 17, tileSize, ".png", "http://127.0.0.1"));
mapView.setUseDataConnection(false);
mapView.setClickable(false);
mapView.setMultiTouchControls(true);
mapView.setBuiltInZoomControls(false);
mapView.getController().setZoom(15);
mapView.getController().setCenter(new GeoPoint(centerlat,centerlon));
// show pathOverlay
PathOverlay pathOverlay = new PathOverlay(Color.RED, this);
pathOverlay.addPoint(new GeoPoint(centerlat,centerlon));
centerlat += 0.005;
pathOverlay.addPoint(new GeoPoint(centerlat,centerlon));
centerlon += 0.005;
pathOverlay.addPoint(new GeoPoint(centerlat,centerlon));
pathOverlay.getPaint().setStrokeWidth(10.0f);
mapView.getOverlays().add(pathOverlay);
// refresh map, is this needed?
mapView.invalidate();
}
// this copies the offline tiles to the proper location for OSMDroid to use them offline
private void putMapOnSD() {
// see GitHub for this
}
}
전체 프로젝트를 GitHub에서 가져옵니다. https://github.com/tomkincaid/PathExample
Cloudmade의 @ 2x 타일을 사용하여이 문제를 해결 했으므로 고밀도 화면에 512 픽셀 크기를 사용할 필요가 없었습니다. 누구든지 조사하고 싶어하지만 기본적인 문제는 여전히 존재합니다.
더 큰 타일 크기 couse 경로 오버레이가 사라지는 경우, 당신은 당신의 지역 좌표가 더 차이나 크기를 늘려야 할 수도 있습니다 :) ^^ – ismail