3

I would like to draw a line between few GPS coordination. I tried to use OpenLayers.Geometry.LineString for that, but it uses a OpenLayers.Geometry.Point. Is there any function in OpenLayers that converts GPS coordination (latlon) to Geometry.Point? Or maybe I'm doing this wrong and shouldn't use lineString for drawing a line between latlon points?

7

These commands first create an array of points that is then used to create a line:

var points = new Array(
    new OpenLayers.Geometry.Point(lon1, lat1),
    new OpenLayers.Geometry.Point(lon2, lat2)
);
var line = new OpenLayers.Geometry.LineString(points);
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.