Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 7 down vote accepted

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);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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