I have a KML coordinate set file. I want to draw a path between two location points in the KML overlay.
Here, R.raw.railways contain my coordinates. And it has successfully import as a layer. Now I want to know how can I draw path line between rail1 and rail2 on the KML layer. No need to use google paths. As here, KML contain railway paths. so I need to draw on this railway path.
This is KML file; https://drive.google.com/open?id=1k0bu3VbxthF4snJQoE94qPgTZgfw59hi
Code:
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
KmlLayer layer = null;
try {
layer = new KmlLayer(mMap, R.raw.railways, getApplicationContext());
layer.addLayerToMap();
LatLng rail1 = new LatLng(6.814692, 79.866891);
LatLng rail2 = new LatLng(6.774442, 79.881984);
mMap.addMarker(new MarkerOptions().position(rail1));
mMap.addMarker(new MarkerOptions().position(rail2));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(rail2, 15));
////// code for drawing path between rail1 and rail2
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Here, R.raw.railways contain my coordinates. And it has successfully import as a layer. Now I want to know how can I draw path line between rail1 and rail2 on the KML layer. No need to use google paths. As here, KML contain railway paths. so I need to draw on this railway path.
This is KML file; https://drive.google.com/open?id=1k0bu3VbxthF4snJQoE94qPgTZgfw59hi