如何像在osmdroid中一样在mapsforge中设置边界框,以及如何将文本放在pathLayer的上方或下方?
在osmdroid中,我通常调用setScrollableAreaLimit()方法,但是在mapsforge中,mapView中没有这样的方法。我该如何做到这一点?
另外,如何在PathLayer之下或之上添加TextOverlay
//Bounding Box
maxScrollableLimit = new BoundingBox(14.7882,121.1421,14.3469,120.8990);
...
private PathLayer createPathLayerFirst(PathWrapper response) {
Style style = Style.builder()
.generalization(Style.GENERALIZATION_SMALL)
.strokeColor(0x9900cc33)
.strokeWidth(4 * getResources().getDisplayMetrics().density)
.build();
PathLayer pathLayer = new PathLayer(mapView.map(), style);
List<GeoPoint> geoPoints = new ArrayList<>();
PointList pointList = response.getPoints();
for (int i = 0; i < pointList.getSize(); i++)
geoPoints.add(new GeoPoint(pointList.getLatitude(i), pointList.getLongitude(i)));
pathLayer.setPoints(geoPoints);
return pathLayer;
}发布于 2017-01-27 22:13:59
从您提供的代码中,根本不清楚您是否查看了mapsforge docs。先这样做,然后再返回到我的答案。
要设置地图限制,请将以下代码添加到onStart()方法中:
mapView.getModel().mapViewPosition.setMapLimit(this.getBoundingBox());在同一个类中,准备好以下方法:
private BoundingBox getBoundingBox() {
final double MINLAT = Double.valueOf(res.getString(R.string.mapminlat));
final double MINLON = Double.valueOf(res.getString(R.string.mapminlon));
final double MAXLAT = Double.valueOf(res.getString(R.string.mapmaxlat));
final double MAXLON = Double.valueOf(res.getString(R.string.mapmaxlon));
return new BoundingBox(MINLAT, MINLON, MAXLAT, MAXLON);
}要将图层添加到地图视图,请执行以下操作:
mapView.getLayerManager().getLayers().add(layer);有关创建层的信息,请参阅文档。请特别查看一下examples;也许LabelLayer就是您要找的。
https://stackoverflow.com/questions/41873669
复制相似问题