【发布时间】:2014-10-10 09:41:21
【问题描述】:
我想创建一个显示地图的活动。当我点击一个按钮时,我将一个 LatLng 点保存到列表中。所以我走在一条街上,当我走的时候,我点击按钮,我想在地图上显示我的路线。所以我尝试编写这段代码,但没有找到:
public void settaMappa(View view){
LocationResult locationResult = new LocationResult(){
@Override
public void gotLocation(Location location){
//Got the location!
System.out.println("ho avuto un segnale gps valido ");
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map2)).getMap();
if(listaPuntiTerreno == null)
listaPuntiTerreno = new ArrayList<LatLng>();
if (location != null)
{
LatLng latLong = new LatLng(location.getLatitude(), location.getLongitude());
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLong, 13));
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(location.getLatitude(), location.getLongitude())) // Sets the center of the map to location user
.zoom(17) // Sets the zoom
.bearing(90) // Sets the orientation of the camera to east
.tilt(40) // Sets the tilt of the camera to 30 degrees
.build(); // Creates a CameraPosition from the builder
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
listaPuntiTerreno.add(latLong);
disegnaTracciato();
}
}
};
MyLocation myLocation = new MyLocation();
myLocation.getLocation(this, locationResult);
}
public void disegnaTracciato(){
if(listaPuntiTerreno !=null &&
listaPuntiTerreno.size()>1){
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map2)).getMap();
PolylineOptions options = new PolylineOptions().width(5).color(Color.BLUE).geodesic(true);
for (int z = 0; z < listaPuntiTerreno.size(); z++) {
LatLng point = listaPuntiTerreno.get(z);
options.add(point);
}
Polyline line = mMap.addPolyline(options);
}
}
我们能帮帮我吗?
最好的后卫
【问题讨论】:
-
你的问题到底是什么?
-
想用您的特定路线为您当前的位置设置动画吗?
-
问题是这样的:当我输入地图 PolylineOptions 但我在地图上看不到规则时。
标签: android google-maps map