Skip to content

Conversation

gutard
Copy link
Collaborator

@gutard gutard commented Oct 8, 2020

@Zhigal you change the value of the input field when deserializing:

        this.formfield.value = JSON.stringify(JSON.parse(value));

This is a problem for me. My code does not work anymore with this change. Could you explain the rationale behind your fix ? Why de-re-serialize, why modify de DOM ?

Are you OK with this PR ?

@Gagaro
Copy link
Member

Gagaro commented Oct 12, 2020

Relevant PRs:

#291
#294

@Gagaro Gagaro force-pushed the master branch 17 times, most recently from 96ea661 to 854ac59 Compare November 30, 2020 11:08
@Gagaro Gagaro force-pushed the master branch 2 times, most recently from f6487c7 to 0376c15 Compare May 17, 2021 08:32
@Zhigal
Copy link
Contributor

Zhigal commented Sep 13, 2021

@gutard, I'm really sorry for breaking your code.
But the rationale behind those changes is that this allows to keep input field syncronized with the geometry on a map with the set number of decimal places. I need this because varying precision was adding unpredictable error in my app.
Your changes do not make any sence to me since input field will have varying presicion and unpredictable number of decimal places.

We may do something like this:

if (value === 0) {
     var _value = JSON.stringify(JSON.parse(value));
     return L.GeoJSON.geometryToLayer(JSON.parse(_value));
} else {
     this.formfield.value = JSON.stringify(JSON.parse(value));
     return L.GeoJSON.geometryToLayer(JSON.parse(value));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants