Closed Montago closed 8 years ago
I've made a polygon editing tool using Google Maps api, JSTS and Wicket
JSTS allows me to cut (difference) and add (union) parts to a polygon shown on Google Maps.
BUT... there's a weird problem !!
if the first polygon i show, is a WKT:POLYGON - then i'm not allowed to render a WKT:MULTIPOLYGON afterwords !!
on the other hand, if the first polygon i show is a WKT:MULTIPOLYGON, then i can freely add / remove WKT:POLYGONs and WKT:MULTIPOLYGONs
i've copied most of the code from the demo: http://arthur-e.github.io/Wicket/sandbox-gmaps3.html
var mapIt = function (wktpoly) { var wkt = wktpoly; var obj = wkt.toObject(map.defaults); if (Wkt.isArray(obj)) { obj.forEach(function (o) { if (!Wkt.isArray(o)) { o.setMap(map); features.push(o); } }); } else { obj.setMap(map); features.push(obj); } return obj; };
var mapIt = function (wktpoly) { var wkt = wktpoly; var obj = wkt.toObject(map.defaults); if (Wkt.isArray(obj)) { obj.forEach(function (o) { if (!Wkt.isArray(o)) { o.setMap(map); features.push(o); } }); } else { obj.setMap(map); features.push(obj); }
return obj; };
and Wicket instances is made this way:
var polygon = (new Wkt.Wkt()).read("MULTIPOLYGON(((12.343662987509497 55.55056767251673,12.343662987509497 55.80130975155818,12.504501342773438 55.80130975155818,12.504501342773438 55.795877445664104,12.504501342773438 55.785454243141885,12.506561279296875 55.774642049830206,12.509994506835938 55.75919085473824,12.514114379882812 55.74953074789918,12.5189208984375 55.74102787471819,12.525787353515625 55.73213652597944,12.533340454101562 55.72401656896143,12.541580200195312 55.71628170645908,12.544759065339964 55.714132762561235,12.5408935546875 55.71086639119249,12.536773681640625 55.70777158827011,12.53265380859375 55.702355093270924,12.53265380859375 55.697711785689854,12.53265380859375 55.691519850785426,12.53265380859375 55.68610110318786,12.534027099609375 55.6799073292233,12.535400390625 55.67448697232047,12.536773681640625 55.669840354308725,12.536973031290898 55.66961549462442,12.536773681640625 55.66945311123117,12.530593872070312 55.66325670077184,12.5244140625 55.65628456619121,12.5189208984375 55.650086070637734,12.512741088867188 55.64001142229069,12.508621215820312 55.632647540285284,12.504501342773438 55.62450690239057,12.49969482421875 55.616364573379,12.495574951171875 55.60860840190929,12.492141723632812 55.60085069621599,12.489395141601562 55.593867449197575,12.486648559570312 55.58688295920994,12.484588623046875 55.58067348009016,12.484588623046875 55.57446301869603,12.484588623046875 55.56902805913944,12.484588623046875 55.563592347410776,12.4859619140625 55.55737918433739,12.488021850585938 55.5534954584537,12.489903963062195 55.55056767251673,12.343662987509497 55.55056767251673)),((12.587048140645559 55.65512242302239,12.59033203125 55.65512242302239,12.59307861328125 55.65512242302239,12.61505126953125 55.655897188968034,12.616424560546875 55.655897188968034,12.62054443359375 55.65667193958129,12.624664306640625 55.65822139481129,12.63153076171875 55.6597707887137,12.635650634765625 55.66286939254093,12.638397216796875 55.66674230238031,12.64251708984375 55.672163732295054,12.64251708984375 55.67293816096562,12.654190063476562 55.669840354308725,12.667922973632812 55.667516838357216,12.68096923828125 55.66596775107334,12.6947021484375 55.66519318443606,12.707748413085938 55.664805895368524,12.721481323242188 55.66519318443606,12.737274169921875 55.667129572285006,12.753067016601562 55.66906586432124,12.770919799804688 55.67371257430738,12.786712646484375 55.6791330385063,12.78739550263763 55.6793832806291,12.78739550263763 55.55056767251673,12.551947872976596 55.55056767251673,12.553939819335938 55.55582574004364,12.555313110351562 55.56242745417594,12.557373046875 55.57058098147687,12.560806274414062 55.57950909340291,12.564926147460938 55.59037535958225,12.567672729492188 55.60085069621599,12.57659912109375 55.62838360752494,12.578659057617188 55.63574829088387,12.580718994140625 55.64194905593519,12.586212158203125 55.65241062146783,12.587048140645559 55.65512242302239)))")
...
IT SEEMS that the global Wkt object is acting like a singleton, keeping some data / settings / stuff for too long !
the source i use are:
http://arthur-e.github.io/Wicket/wicket-gmap3.js http://arthur-e.github.io/Wicket/wicket.js
I've made a polygon editing tool using Google Maps api, JSTS and Wicket
JSTS allows me to cut (difference) and add (union) parts to a polygon shown on Google Maps.
BUT... there's a weird problem !!
if the first polygon i show, is a WKT:POLYGON - then i'm not allowed to render a WKT:MULTIPOLYGON afterwords !!
on the other hand, if the first polygon i show is a WKT:MULTIPOLYGON, then i can freely add / remove WKT:POLYGONs and WKT:MULTIPOLYGONs
i've copied most of the code from the demo: http://arthur-e.github.io/Wicket/sandbox-gmaps3.html
and Wicket instances is made this way:
var polygon = (new Wkt.Wkt()).read("MULTIPOLYGON(((12.343662987509497 55.55056767251673,12.343662987509497 55.80130975155818,12.504501342773438 55.80130975155818,12.504501342773438 55.795877445664104,12.504501342773438 55.785454243141885,12.506561279296875 55.774642049830206,12.509994506835938 55.75919085473824,12.514114379882812 55.74953074789918,12.5189208984375 55.74102787471819,12.525787353515625 55.73213652597944,12.533340454101562 55.72401656896143,12.541580200195312 55.71628170645908,12.544759065339964 55.714132762561235,12.5408935546875 55.71086639119249,12.536773681640625 55.70777158827011,12.53265380859375 55.702355093270924,12.53265380859375 55.697711785689854,12.53265380859375 55.691519850785426,12.53265380859375 55.68610110318786,12.534027099609375 55.6799073292233,12.535400390625 55.67448697232047,12.536773681640625 55.669840354308725,12.536973031290898 55.66961549462442,12.536773681640625 55.66945311123117,12.530593872070312 55.66325670077184,12.5244140625 55.65628456619121,12.5189208984375 55.650086070637734,12.512741088867188 55.64001142229069,12.508621215820312 55.632647540285284,12.504501342773438 55.62450690239057,12.49969482421875 55.616364573379,12.495574951171875 55.60860840190929,12.492141723632812 55.60085069621599,12.489395141601562 55.593867449197575,12.486648559570312 55.58688295920994,12.484588623046875 55.58067348009016,12.484588623046875 55.57446301869603,12.484588623046875 55.56902805913944,12.484588623046875 55.563592347410776,12.4859619140625 55.55737918433739,12.488021850585938 55.5534954584537,12.489903963062195 55.55056767251673,12.343662987509497 55.55056767251673)),((12.587048140645559 55.65512242302239,12.59033203125 55.65512242302239,12.59307861328125 55.65512242302239,12.61505126953125 55.655897188968034,12.616424560546875 55.655897188968034,12.62054443359375 55.65667193958129,12.624664306640625 55.65822139481129,12.63153076171875 55.6597707887137,12.635650634765625 55.66286939254093,12.638397216796875 55.66674230238031,12.64251708984375 55.672163732295054,12.64251708984375 55.67293816096562,12.654190063476562 55.669840354308725,12.667922973632812 55.667516838357216,12.68096923828125 55.66596775107334,12.6947021484375 55.66519318443606,12.707748413085938 55.664805895368524,12.721481323242188 55.66519318443606,12.737274169921875 55.667129572285006,12.753067016601562 55.66906586432124,12.770919799804688 55.67371257430738,12.786712646484375 55.6791330385063,12.78739550263763 55.6793832806291,12.78739550263763 55.55056767251673,12.551947872976596 55.55056767251673,12.553939819335938 55.55582574004364,12.555313110351562 55.56242745417594,12.557373046875 55.57058098147687,12.560806274414062 55.57950909340291,12.564926147460938 55.59037535958225,12.567672729492188 55.60085069621599,12.57659912109375 55.62838360752494,12.578659057617188 55.63574829088387,12.580718994140625 55.64194905593519,12.586212158203125 55.65241062146783,12.587048140645559 55.65512242302239)))")
...
IT SEEMS that the global Wkt object is acting like a singleton, keeping some data / settings / stuff for too long !
the source i use are:
http://arthur-e.github.io/Wicket/wicket-gmap3.js http://arthur-e.github.io/Wicket/wicket.js