2

I'm trying to create a viewModel for my application and the data is typically populated by a call to a database. I can retrieve the coordinates and convert this to geometry which can be displayed on a map but I would like to bind these two together so that if a feature is modified (say points are added or removed) the information is relayed back to the viewModel for updating to the database.

The main difficulty I've encountered is that I can't set properties on the individual vertices of a linestring so trying to get the ID of an individual vertex and then finding the corresponding id on the VM isn't an option.

Alternatively I can try to get the index of the item in the two respective arrays and use an array method but that just seems entirely hit-and-miss. I've been considering utilising KnockoutJS in order to implement some rudimentary binding but I'm wondering if there isn't something baked in to OL3 by way of the ol.Observable class.

More importantly, if I wished to show rich data for each point such as elevation, name, etc., how could this possibly be attached to the geometry point itself? I've encountered a jsFiddle where each vertex of a linestring is actually a clone of a Point object and moving one will be reflected in the other but it seems like it will take an enormous amount of effort for me to re-engineer how my drawing interactions work. Can anyone enlighten me as to how this might be achieved?

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.