Thursday, February 26, 2015

GWT-OpenLayers - Drawing an arc between two points

I would like to display an arc on a map that connects two points. Ultimately, I would like to achieve something like this with GWT-OpenLayers:


Does GWT-OpenLayers support arcs like this? I cannot get the Curve class to display anything on a map, and I cannot find a working Curve example online. The closest examples I can find only let the user click multiple points, which are then connected by joint line segments... I would like to create arcs (or pseudo-arcs via line segments) that do not depend on user mouse input.

Here's an example for how I assume you use the Curve class, it may be incorrect.

//Use of Curve object. Does not show anything on the map.
Point midPoint = //midpoint calculation
Point midPointWithYOffset = new Point(midPoint.getX(), midPoint.getY()+10.0);
points[0] = startPoint;
points[1] = midPointWithYOffset; //to get a curve rather than a straight line
points[2] = endPoint;
VectorFeature feature = new VectorFeature(new Curve(points));


This results in nothing displaying on the map. However, if I change "Curve" to "LineString" (and ONLY if `points[1] = midPoint //without Y offset`), a straight line appears on the map just fine.
  •  Using LineString: if I attempt to choose a point that is not directly on the shortest straight line between the startPoint and endPoint, nothing shows on the map.
  •  Using Curve: I haven't been able to get this to work at all.
//Use of LineString object that does show a straight line on the map
Point midPoint = //midpoint calculation
points[0] = startPoint;
points[1] = midPoint;
points[2] = endPoint;
VectorFeature feature = new VectorFeature(new LineString(points));

//Use of LineString object that does not show anything on the map.
Point midPoint = //midpoint calculation
Point midPointWithYOffset = new Point(midPoint.getX(), midPoint.getY()+10.0);
points[0] = startPoint;
points[1] = midPointWithYOffset; //to get a curve rather than a straight line
points[2] = endPoint;
VectorFeature feature = new VectorFeature(new LineString(points));


I would be grateful for any knowledge the users here have. Thank you very much.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment