现在,我只是假设没有公共图书馆为我们做这件事,因此在解析我的KML文件中的数据后,我将使用Google的代码向地图添加折线和多边形。如果找到库,将更新此答案。
创建折线和多边形:
// Instantiates a new Polyline object and adds points to define a rectanglePolylineOptions rectOptions = new PolylineOptions() .add(new LatLng(37.35, -122.0)) .add(new LatLng(37.45, -122.0)) // North of the previous point, but at the same longitude .add(new LatLng(37.45, -122.2)) // Same latitude, and 30km to the west .add(new LatLng(37.35, -122.2)) // Same longitude, and 16km to the south .add(new LatLng(37.35, -122.0)); // Closes the polyline.// Set the rectangle's color to redrectOptions.color(Color.RED);// Get back the mutable PolylinePolyline polyline = myMap.addPolyline(rectOptions);



