我用gwt-openlayers
.
我还没有找到如何显示路线。
是否可以显示路线gwt-openlayers
?
我用gwt-openlayers
.
我还没有找到如何显示路线。
是否可以显示路线gwt-openlayers
?
我设法展示了路线:
KML:
6.646280,49.753730,0.000000 6.646020,49.753230,0.000000 6.645650,49.752700,0.000000 ...
在这种情况下,KML 坐标为字符串。
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);
取决于您的路线格式,但如果您有 KML,请使用 GML 层。