openlayers 3 - feature convert to geoJSON string failed -
i got geometry featureoverlay,and create feature geometry, when setid , setgeometryname feature ,i failed writefeature , bug ?
var poly = featureoverlay.getfeatures().item(0); if (poly != null) { var feature = new ol.feature({ geometry: poly }); feature.setid('bd355df3fd916d30'); feature.setgeometryname('test'); var extent = [0, 0, 749, 638]; var projection = new ol.proj.projection({ code: 'xkcd-image', units: 'pixels', extent: extent }); var geojson = new ol.format.geojson({ defaultdataprojection: projection }); //this success var geojsontext = geojson.writefeature(poly, { featureprojection: projection, dataprojection: projection }); //this failed var geojsontext = geojson.writefeature(feature, { featureprojection: projection, dataprojection: projection }); } uncaught typeerror: converting circular structure json l.qd @ openlayers?v=ygwtoeagf-vdycn0ewoqeiy8jyarvcdftraysewzwri1:501 stopinteraction @ testedit?id=8b0d3745a6c1b46b:447 onclick @ testedit?id=8b0d3745a6c1b46b:230
it's problem.
feature.setid('bd355df3fd916d30'); feature.setgeometryname('test');
modified fixed :
feature.setid('bd355df3fd916d30'); feature.setproperties(['test']);
Comments
Post a Comment