Kyle
Kyle

Reputation: 4376

How to create Vector from vertices

Is there any way to create a Vector object from a list of vertices? Basically what I'm trying to do is be able to draw a polygon on the map, save the vertices of that polygon in persistent storage and re-draw it later. I am able to save the bounds of the polygon and redraw the Vector using these, but then all I get is a box around the polygon. I'm open to other ideas besides storing a list of vertices as well, this just seemed like the best way to do it.

Upvotes: 0

Views: 79

Answers (1)

Christophe Roussy
Christophe Roussy

Reputation: 17059

You want the vector layer features.

var features = yourVectorLayer.features;

You may then use GeoJSON to serialize the features using write.

To deserialize them use read.

Upvotes: 1

Related Questions