我使用 gwt-openlayers
。
我仍然没有找到如何显示路线。
是否可以使用 gwt-openlayers
显示路线?
最佳答案
我设法显示了路线:
KML:KML 坐标作为字符串
6.646280,49.753730,0.000000 6.646020,49.753230,0.000000 6.645650,49.752700,0.000000 ...
在这种情况下。
Vector routeLayer = new Vector("route");
List<Point> pointList = new ArrayList<Point>();
Projection defaultProj = new Projection(DEFAULT_PROJECTION);
// DEFAULT_PROJECTION = "EPSG:4326"
Projection mapProj = new Projection(mapWidget.getMap().getProjection());
for (String coord : KML.split(" "))
{
String[] xyz = coord.split(",");
if (xyz.length == 3)
{
Point point = new Point(Double.parseDouble(xyz[0]), Double.parseDouble(xyz[1]));
// lon,lat
point.transform(defaultProj, mapProj);
pointList.add(point);
}
}
LineString geometry = new LineString(pointList.toArray(new Point[pointList.size()]));
Style style = new Style();
style.setStrokeColor("#0033ff");
style.setStrokeWidth(5);
routeLayer.addFeature(new VectorFeature(geometry, style));
mapWidget.getMap().addLayer(routeLayer);
关于java - gwt-openlayers - 显示路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9616826/