如何在OSM(开放地图街道)的Android studio中绘制直线(多段线)?
我想在OSM的两点之间划一条线,但我找不到任何对我有帮助的东西。类似谷歌地图中的多段线如何在OSM(开放地图街道)的Android studio中绘制直线(多段线)?,android,openstreetmap,osmdroid,Android,Openstreetmap,Osmdroid,我想在OSM的两点之间划一条线,但我找不到任何对我有帮助的东西。类似谷歌地图中的多段线 public class MainActivity extends Activity { private MapView mMapView; private MapController mMapController; public TextView textView; public String longitude; public String l
public class MainActivity extends Activity {
private MapView mMapView;
private MapController mMapController;
public TextView textView;
public String longitude;
public String latitude;
public Drawable marker;
private ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay;
ArrayList<OverlayItem> overlayItemArray;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.osm_main);
mMapView = (MapView) findViewById(mapview);
textView = (TextView) findViewById(R.id.textView);
mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
mMapView.setBuiltInZoomControls(true);
mMapController = (MapController) mMapView.getController();
mMapController.setZoom(16);
Double latE6 = (52.507621 )* 1E6;
Double lngE6 = (13.407334 )* 1E6;
GeoPoint gPt = new GeoPoint(latE6.intValue(), lngE6.intValue());
mMapController.setCenter(gPt);
}
}
公共类MainActivity扩展活动{
私人地图视图;
专用地图控制器mMapController;
公共文本视图文本视图;
公共字符串经度;
公共字符串纬度;
公共可牵引标记;
私人项目法令覆盖另一项法令覆盖;
ArrayList overlayItemArray;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.osm_main);
mMapView=(MapView)findViewById(MapView);
textView=(textView)findViewById(R.id.textView);
mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
mMapView.setBuiltInZoomControls(真);
mMapController=(MapController)mMapView.getController();
mMapController.setZoom(16);
双晚6=(52.507621)*1E6;
双lngE6=(13.407334)*1E6;
GeoPoint gPt=新的GeoPoint(latE6.intValue(),lngE6.intValue());
mMapController.setCenter(gPt);
}
}
我将此代码放在这行后面的onCreate中:
mMapController.setCenter(gPt)
注意:在你的观点之后使用d。好吧。。。只需使用osmdroid多段线
GeoPoint gPt0 = new GeoPoint(52.507621d, 13.407334d);
GeoPoint gPt1 = new GeoPoint(52.527621d, 13.427334d);
Polyline line = new Polyline(this);
line .addPoint(gPt0);
line .addPoint(gPt1);
mMapView.getOverlays().add(line);
如何删除多段线上的最后一点?。在多段线类中,我们在osmdroid多段线类上有addpoint方法,但没有remove point方法。。
GeoPoint gPt0 = new GeoPoint(52.507621d, 13.407334d);
GeoPoint gPt1 = new GeoPoint(52.527621d, 13.427334d);
Polyline line = new Polyline(this);
line .addPoint(gPt0);
line .addPoint(gPt1);
mMapView.getOverlays().add(line);