I need to draw routes from one point to another with the latitud
and longitud
of those points on a map with the library mapsforge or if there is another one that please tell me. Greetings
I need to draw routes from one point to another with the latitud
and longitud
of those points on a map with the library mapsforge or if there is another one that please tell me. Greetings
If you work with Android, you can use Google Maps, and you can use the PolylineOptions class to create the route between two points, for example:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_google_map);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
//Dibuja marcadores.
LatLng berlin = new LatLng(52.5243700 , 13.4105300);
mMap.addMarker(new MarkerOptions().position(berlin).title("Berlin!"));
mMap.addMarker(new MarkerOptions().position(new LatLng(53.5105300, 14.50)).title("my home!"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(berlin));
//Dibuja trayectoria.
PolylineOptions line=
new PolylineOptions().add(new LatLng(52.5243700,13.4105300),
new LatLng(52.5405300, 13.90),
new LatLng(53.1405300, 14.11),
new LatLng(53.5105300, 14.50))
.width(5).color(Color.RED);
mMap.addPolyline(line);
}
Two markers and the points of the trajectory are defined, which will be shown on the map in this way: