[1.6.x] Fixed #20998 -- Allow custom (de)serialization for GIS widgets

Thanks Mathieu Leplatre for the report and the initial patch.
Backport of 102f26c92 from master.