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

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 May 15 '20 at 23:55

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.