"Gabriel Vatin" <[email protected]> escribió:

Hi,

I think you can use the function JSON.stringify() from json2.js library that converts a JavaScript array to JSON :
https://github.com/douglascrockford/JSON-js

I've never tried it, I just found it, but I would be interested to know if it's ok ! :)

So you get your feature(s) with OpenLayers.Feature.Vector.features[] and pass it to the stringify funtion, that should work fine !

Gabriel

i try this

//-------------------------------------------------------------
var v = new OpenLayers.Layer.Vector(titulo, {
     styleMap : styleMapvlayer
});

v.events.register('featureselected', '',function(evt) {
                console.dir(typeof (evt.feature.layer.features));
                console.dir(JSON.stringify(evt.feature.layer.features));
                }
//---------------------------------------------------------------------
and my browser get crazy, and then try this


//----------------------------------------------------------------
var v = new OpenLayers.Layer.Vector(titulo, {
     styleMap : styleMapvlayer
});

v.events.register('featureselected', '',function(evt) {
                console.dir(typeof (evt.feature.layer.features[0]));
                console.dir(JSON.stringify(evt.feature.layer.features[0]));
                }

//----------------------------------------------------------------
and my firebug return this


//********************************
No hay objetos hijos

TypeError: cyclic object value
http://10.8.194.221/personal/assets/ge/scripts/funcGenerales.js
Line 315


//*********************************






On 14/11/2012 16:26, [email protected] wrote:
Hi people, exist the posibility of convert the data or attributes fields of "OpenLayers.Feature.Vector" to "json" cause i need it to work and i dont know a way to solve that, or retrieve the columns or fields value of the data or attributes fields, for example these is what i get with firebug

Object { cpopular="xcvx", empresa="vxcvxc", nombre="cvxcv",cantidad="xcvxcv",func="xcvxcv",ubicacion= "xcvxcv"}

cantidad "xcvxcv"
cpopular "xcvx"
empresa "vxcvxc"
func "xcvxcv"
nombre "cvxcv"
ubicacion "xcvxcv"


i need to convert it to json i means to this:

{ "cpopular":"xcvx", "empresa":"vxcvxc", "nombre":"cvxcv","cantidad":"xcvxcv","func":"xcvxcv","ubicacion": "xcvxcv"}

or get the fields in form of array to convert my self to json cause i cant get the column values i mean:

[cantidad,
cpopular,
empresa,
func,
nombre,
ubicacion]

thanks to all you

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


--

Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users




----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


--

Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to