1

I drew a line between two points and would like to change the line styles but currently is not working as expected. Tried to add the style into the features. Am i missing something?

        var points = [ 
            new OpenLayers.Geometry.Point( lng, lat ).transform(epsg4326, projectTo),
            new OpenLayers.Geometry.Point( qlng, qlat  ).transform(epsg4326, projectTo)
        ];

        var styles = { 
          strokeColor: '#000000', 
          strokeOpacity: 2,
          strokeWidth: 10
        };

        feature = new OpenLayers.Feature.Vector(
                new OpenLayers.Geometry.LineString(points, null, styles)
        );

        vectorLayer.addFeatures(feature);

1 Answer 1

1

The style is a parameter of the feature, not the linestring

    feature = new OpenLayers.Feature.Vector(
            new OpenLayers.Geometry.LineString(points),
            null,
            styles
    );
1
  • I see. Thank you for the explanation and solution.
    – Mezzan
    Commented May 15, 2020 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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