Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geom field value should not be modified when deserializing its content #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

@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