I'm perplexed as to why tail_path is not drawing the line (can't see anything on the map) but the alert seems to be returning the correct data.

var path_travelled = new Array();
var path = json_coords.path_data;
for (i in path)
    var lat = path[i].LINE_LAT;
    var long = path[i].LINE_LONG;
    path_travelled.push(new OpenLayers.Geometry.Point(long, lat));
var tail_path = new OpenLayers.Geometry.LineString(path_travelled);

The alert for the path_travelled variable returns this (it adds a new POINT every time you click the OK button):

enter image description here

I'm using vectors.addFeatures (I have another variable I also use here but doesn't apply to this question so just removed it to avoid confusion).

Any input on the matter is appreciated.

  • what is the coordinate system of your map? You might find your line somewhere near 0,0 – tomfumb Oct 21 '13 at 19:13
  • EPSG4326/WGS84. When I hard code a line in it works just fine (don't see anything around 0,0). So definitely don't think the projection is the issue. More the way the data is being passed in. Everything looks good though is the thing... – Nubtacular Oct 21 '13 at 20:39
  • do you have an example of how you're hard-coding it? – tomfumb Oct 21 '13 at 20:51
  • Yes of course: codeshare.io/dTcf4 – Nubtacular Oct 21 '13 at 20:57
  • 1
    the only definite difference I see is that your question's example is missing new OpenLayers.Feature.Vector. Also, I'm not sure how the Point object's toString function works in alert(path_travelled) but it seems like the two examples are plotting in different parts of the world (in your question the positive ordinate is first, in your codeshare it's second). Are you sure it's not just appearing somewhere you don't expect? – tomfumb Oct 21 '13 at 21:11

Your Answer

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

Browse other questions tagged or ask your own question.