geosdi / GWT-OpenLayers

GWT Wrapper for OpenLayers
47 stars 20 forks source link

Curve Class Doesn't Work? (Attempting arc between two points) #28

Open Glchriste opened 9 years ago

Glchriste commented 9 years ago

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:

Arc.js seems to do this well also: https://www.mapbox.com/mapbox.js/example/v1.0.0/arcjs/

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.

//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.