I would like to create an Activity, that show a map. When I tap a Button I save to a list a LatLng point. So I walking on a street, while I walk, I tap the button and I would like to show on a map my route. So I try to write this code but it non found:
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);
}
}
Can we help me?
Best reguards