[OpenLayers-Users] Error when parsing array with OpenLayers and Protocol.HTTP()

Ezequiel Gonzalez Rial gonrial at gmail.com
Fri Aug 22 11:47:58 PDT 2014


Hi,

If you are generating this information, check this part:

> {
>    "origin": "2013P00109",
>    "type": "LJ",
>    *"naf": "5610A",*
> },
>

the final comma in the naf line shouldn't be there.

Regards,
Ezequiel


2014-08-22 15:35 GMT-03:00 harko33 <xhanrot at gmail.com>:

> I'm trying to send a JSON file to my Node.js app via Protocol.HTTP. The
> file
> is correctly sent, but I can't access to an array. Here is the relevant
> code
> :
>
> Client side
>
>     (...)
>         var vectorProtocol = new OpenLayers.Protocol.HTTP({
>                         url: '/getcoords',
>                         format: vectorFormat,
>                         readWithPOST: true,
>                         params: {
>                             "code_company": "8501",
>                             "data_company": [
>                                 {
>                                     "origin": "2013P00109",
>                                     "type": "LJ",
>                                     "naf": "5610A",
>                                 },
>                                 {
>                                     "origin": "2013P00110",
>                                     "type": "FJ",
>                                     "naf": "5481"
>                                 }
>                             ]
>                         }
>                     });
>     (...)
>
> Server side, I try to build an array with only the "origin" field of my
> array "data_company":
>
>     function getCoords(params, callback) {
>           var arrOrigin = params.data_company.map(function(d) {
>              return d.origin;
>           });
>           (...)
>     }
>
> And I get this error :
>
> > TypeError: Object [object Object] has no method "map"
>
> It seems that my "data_company" is not recognized as an array but as an
> object. I tried to JSON.parse(params) before but I get another error :
>
> > SyntaxError: Unexpected token o
>
> Anyway, I'm stuck. Do you have any clue to help me to solve this ?
>
> Thanks
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/Error-when-parsing-array-with-OpenLayers-and-Protocol-HTTP-tp5157904.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20140822/9bab61cd/attachment.html>


More information about the Users mailing list