Google Map API弯曲时使线条更平滑 [英] Google Map API making lines smoother when bending
本文介绍了Google Map API弯曲时使线条更平滑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Google Map API在我的应用程序中获取地图上的线条.我正在使用以下代码从数据库加载行的节点:
I am using Google Map API to get lines on the map in my application. I am loading the nodes of the lines from a database using following code:
// Add polyline "walks voda"
List<WalkLine> dbwalknodes = dbclass.queryWalksFromDatabase(this); // list of latlng
for (int i = 0; i < dbwalknodes.size() - 1 ; i++) {
WalkLine source = dbwalknodes.get(i);
WalkLine destination = dbwalknodes.get(i+1);
Polyline line = mMap.addPolyline(new PolylineOptions()
.add(new LatLng(source.getLat(), source.getLon()),
new LatLng(destination.getLat(), destination.getLon()))
.width(16)
.color(Color.parseColor("#1b9e77"))
.geodesic(true));
line.setZIndex(1000);
}
您是否知道如何使弯曲时的线条比在波纹管上更平滑?有可能吗?
Do you have any idea how to create the lines smoother while it bends than on the picture bellow? Is it possible?
https://www. dropbox.com/s/6waic988mj90kdk/2014-10-22%2012.48.04.png?dl=0
推荐答案
您不应为每两个点创建一条多段线,它应该是具有多个点的连接多段线,如下所示:
You should not create a polyline for each two points, it should be a connected polyline with mulitple points, something like this:
public void drawRoute(List<LatLng> location) {
polylineOptions = new PolylineOptions().width(MAPS_PATH_WIDTH).color(routeColor).addAll(location);
polyLine = map.addPolyline(destinationRoutePolyLineOptions);
polyLine.setPoints(location);
}
这将使它更加平滑.
这篇关于Google Map API弯曲时使线条更平滑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文