[OpenLayers-Trac] [OpenLayers] #3309: GeoJson Response by Protocol.HTTP Null

OpenLayers trac-20090302 at openlayers.org
Fri May 20 10:16:31 EDT 2011


#3309: GeoJson Response by Protocol.HTTP Null
---------------------------+------------------------------------------------
 Reporter:  blaviale       |       Owner:              
     Type:  bug            |      Status:  new         
 Priority:  blocker        |   Milestone:  2.10 Release
Component:  Protocol.HTTP  |     Version:  2.10        
 Keywords:                 |       State:              
---------------------------+------------------------------------------------
 Hi guys,
 I have problem with openlayers.protocol.http, when it parse the
 responseText

 My goal is just to get GeoJson objects from a web Service and to add them
 into my layer in using the protocol class.

 First I create my protocol on my layer

 {{{
 vectorLayerPark.protocol = new OpenLayers.Protocol.HTTP({
         url:'/parks',
         params :{
                 'format':'json'
         },
         format: new OpenLayers.Format.GeoJSON()
 });
 }}}


 after I call my read method and it return my GeoJson Object (Go to the
 bottom to see).

 For the moment all is find...


 The problem is that the req.features object return null.
 But, if I parse my req.priv.responseText object, all is good.
 It seems that the protocol object do not the parsing or not with the good
 parser.



 {{{
 vectorLayerPark.protocol.handleRead = function(req){

         jsonParser = new OpenLayers.Format.GeoJSON();

         json = jsonParser.read(req.priv.responseText);

         vectorLayerPark.addFeatures(req.features); // Is not good

         vectorLayerPark.addFeatures(json); // Is good

 };
 }}}



 Have a nice day... and thanks
 Benoit







 ----


 ### Response GeoJson ( from req.priv.responseText )

 {{{

 {"type": "FeatureCollection", "features": [{"geometry": {"type":
 "Polygon", "coordinates": [[[95125.0, 92250.0], [85875.0, 79500.0],
 [95875.0, 78500.0], [99125.0, 87500.0], [95125.0, 92250.0]]]}, "crs":
 {"type": "EPSG", "properties": {"code": 2169}}, "type": "Feature",
 "properties": {"name": "Nouveau Park", "id": 1661}}, {"geometry": {"type":
 "Polygon", "coordinates": [[[64375.0, 79250.0], [63375.0, 68500.0],
 [75125.0, 67000.0], [78875.0, 68750.0], [76375.0, 80000.0], [64375.0,
 79250.0]]]}, "crs": {"type": "EPSG", "properties": {"code": 2169}},
 "type": "Feature", "properties": {"name": "Nouveau Park", "id": 1662}},
 {"geometry": {"type": "Polygon", "coordinates": [[[66915.0, 125130.0],
 [66695.0, 125050.0], [66575.0, 124970.0], [66555.0, 124950.0], [66235.0,
 124750.0], [66015.0, 124610.0], [65975.0, 124570.0], [65395.0, 124190.0],
 [64755.0, 123710.0], [64695.0, 123650.0], [63875.0, 123010.0], [63815.0,
 122950.0], [63155.0, 122330.0], [62975.0, 122070.0], [62895.0, 121690.0],
 [62915.0, 121530.0], [63035.0, 121330.0], [63295.0, 121070.0], [63415.0,
 120990.0], [63535.0, 120910.0], [63635.0, 120850.0], [63655.0, 120830.0],
 [64115.0, 120610.0], [64155.0, 120610.0], [64715.0, 120490.0], [65035.0,
 120430.0], [65095.0, 120410.0], [66575.0, 120330.0], [67475.0, 120250.0],
 [67535.0, 120250.0], [68835.0, 120250.0], [69475.0, 120250.0], [69715.0,
 120250.0], [69755.0, 120250.0], [70215.0, 120250.0], [70915.0, 120250.0],
 [70975.0, 120250.0], [71695.0, 120250.0], [72495.0, 120290.0], [66915.0,
 125130.0]]]}, "crs": {"type": "EPSG", "properties": {"code": 2169}},
 "type": "Feature", "properties": {"name": "Nouveau Park", "id": 1663}},
 {"geometry": {"type": "Polygon", "coordinates": [[[71135.0, 125030.0],
 [71095.0, 125030.0], [70975.0, 124950.0], [70775.0, 124650.0], [70755.0,
 124610.0], [70715.0, 124390.0], [70755.0, 124050.0], [70775.0, 124030.0],
 [70955.0, 123830.0], [71255.0, 123650.0], [71295.0, 123630.0], [71575.0,
 123570.0], [71775.0, 123530.0], [71795.0, 123530.0], [72195.0, 123510.0],
 [72235.0, 123510.0], [72435.0, 123510.0], [72535.0, 123510.0], [72595.0,
 123510.0], [72675.0, 123590.0], [72695.0, 123650.0], [71135.0,
 125030.0]]]}, "crs": {"type": "EPSG", "properties": {"code": 2169}},
 "type": "Feature", "properties": {"name": "Nouveau Park", "id": 1664}},
 {"geometry": {"type": "Polygon", "coordinates": [[[63955.0, 125450.0],
 [63955.0, 125430.0], [63935.0, 125410.0], [63915.0, 125370.0], [63875.0,
 125310.0], [63855.0, 125270.0], [63815.0, 125230.0], [63775.0, 125170.0],
 [63755.0, 125150.0], [63735.0, 125130.0], [63955.0, 125450.0]]]}, "crs":
 {"type": "EPSG", "properties": {"code": 2169}}, "type": "Feature",
 "properties": {"name": "Nouveau Park", "id": 1665}}, {"geometry": {"type":
 "Polygon", "coordinates": [[[62275.0, 124670.0], [62255.0, 124670.0],
 [62215.0, 124670.0], [62155.0, 124670.0], [62135.0, 124670.0], [61955.0,
 124670.0], [61355.0, 124670.0], [61215.0, 124670.0], [61135.0, 124670.0],
 [62275.0, 124670.0]]]}, "crs": {"type": "EPSG", "properties": {"code":
 2169}}, "type": "Feature", "properties": {"name": "Nouveau Park", "id":
 1666}}, {"geometry": {"type": "Polygon", "coordinates": [[[60975.0,
 125450.0], [60995.0, 125450.0], [60975.0, 125450.0], [60975.0,
 125450.0]]]}, "crs": {"type": "EPSG", "properties": {"code": 2169}},
 "type": "Feature", "properties": {"name": "Nouveau Park", "id": 1667}},
 {"geometry": {"type": "Polygon", "coordinates": [[[59135.0, 123750.0],
 [59115.0, 123750.0], [59115.0, 123730.0], [59115.0, 123690.0], [59115.0,
 123630.0], [59115.0, 123570.0], [59115.0, 123510.0], [59115.0, 123470.0],
 [59115.0, 123450.0], [59115.0, 123370.0], [59115.0, 123310.0], [59135.0,
 123210.0], [59155.0, 123130.0], [59215.0, 123010.0], [59435.0, 122730.0],
 [59535.0, 122650.0], [59555.0, 122630.0], [59575.0, 122630.0], [59615.0,
 122590.0], [59655.0, 122570.0], [59695.0, 122570.0], [59735.0, 122570.0],
 [59815.0, 122570.0], [59875.0, 122570.0], [59935.0, 122570.0], [60055.0,
 122570.0], [60155.0, 122570.0], [60215.0, 122570.0], [60235.0, 122570.0],
 [60315.0, 122570.0], [60375.0, 122570.0], [60395.0, 122570.0], [60475.0,
 122610.0], [60615.0, 122610.0], [60655.0, 122610.0], [60775.0, 122610.0],
 [60855.0, 122610.0], [60875.0, 122630.0], [60995.0, 122650.0], [61055.0,
 122650.0], [61175.0, 122690.0], [61235.0, 122710.0], [61275.0, 122710.0],
 [61335.0, 122750.0], [61415.0, 122770.0], [61455.0, 122790.0], [61475.0,
 122790.0], [61555.0, 122830.0], [61615.0, 122830.0], [61655.0, 122870.0],
 [61675.0, 122870.0], [61715.0, 122890.0], [61775.0, 122910.0], [61795.0,
 122910.0], [61855.0, 122910.0], [61935.0, 122910.0], [61975.0, 122910.0],
 [62055.0, 122930.0], [62075.0, 122930.0], [62135.0, 122930.0], [62195.0,
 122930.0], [62255.0, 122930.0], [62295.0, 122930.0], [62315.0, 122930.0],
 [62355.0, 122930.0], [62395.0, 122930.0], [62455.0, 122910.0], [62475.0,
 122870.0], [62515.0, 122770.0], [62555.0, 122650.0], [62555.0, 122550.0],
 [62555.0, 122530.0], [62555.0, 122450.0], [62555.0, 122430.0], [62575.0,
 122330.0], [62575.0, 122310.0], [62575.0, 122230.0], [62575.0, 122170.0],
 [62575.0, 122150.0], [62575.0, 122130.0], [62535.0, 122090.0], [62515.0,
 122070.0], [62475.0, 122030.0], [62455.0, 122030.0], [62415.0, 122030.0],
 [62355.0, 122010.0], [62295.0, 122010.0], [62295.0, 121990.0], [62275.0,
 121990.0], [62255.0, 121990.0], [62255.0, 121970.0], [62235.0, 121950.0],
 [62175.0, 121930.0], [62135.0, 121890.0], [62115.0, 121890.0], [62055.0,
 121850.0], [62015.0, 121810.0], [62015.0, 121790.0], [61975.0, 121790.0],
 [61955.0, 121750.0], [61935.0, 121750.0], [61915.0, 121710.0], [61875.0,
 121670.0], [61815.0, 121610.0], [61775.0, 121590.0], [61715.0, 121530.0],
 [61635.0, 121470.0], [61615.0, 121470.0], [61515.0, 121410.0], [61475.0,
 121390.0], [61255.0, 121250.0], [61235.0, 121250.0], [61155.0, 121190.0],
 [61155.0, 121170.0], [61095.0, 121130.0], [60915.0, 121010.0], [60775.0,
 120890.0], [60675.0, 120850.0], [60675.0, 120830.0], [60575.0, 120790.0],
 [60515.0, 120750.0], [60435.0, 120710.0], [60355.0, 120670.0], [60275.0,
 120630.0], [60275.0, 120610.0], [60155.0, 120570.0], [60055.0, 120550.0],
 [59995.0, 120550.0], [59915.0, 120530.0], [59855.0, 120530.0], [59835.0,
 120530.0], [59815.0, 120530.0], [59795.0, 120530.0], [59775.0, 120530.0],
 [59755.0, 120530.0], [59735.0, 120530.0], [59695.0, 120530.0], [59675.0,
 120530.0], [59655.0, 120530.0], [59615.0, 120530.0], [59595.0, 120530.0],
 [59555.0, 120530.0], [58535.0, 120890.0], [58515.0, 120890.0], [58495.0,
 120890.0], [58435.0, 120890.0], [58375.0, 120910.0], [58275.0, 120930.0],
 [58235.0, 120930.0], [58215.0, 120930.0], [58195.0, 120930.0], [58175.0,
 120930.0], [58135.0, 120930.0], [58095.0, 120930.0], [57995.0, 120930.0],
 [57935.0, 120930.0], [57895.0, 120930.0], [57875.0, 120930.0], [57855.0,
 120930.0], [57835.0, 120930.0], [57815.0, 120930.0], [57795.0, 120930.0],
 [57775.0, 120930.0], [57775.0, 120950.0], [57755.0, 120950.0], [57735.0,
 120950.0], [57735.0, 120970.0], [57715.0, 120990.0], [57695.0, 121010.0],
 [57675.0, 121010.0], [57615.0, 121070.0], [57515.0, 121150.0], [57515.0,
 121170.0], [57475.0, 121190.0], [57415.0, 121250.0], [57415.0, 121270.0],
 [57395.0, 121310.0], [57355.0, 121390.0], [57315.0, 121410.0], [57315.0,
 121430.0], [57275.0, 121570.0], [57275.0, 121590.0], [57255.0, 121730.0],
 [57235.0, 121850.0], [57215.0, 121990.0], [57175.0, 122110.0], [57175.0,
 122170.0], [57175.0, 122210.0], [57175.0, 122230.0], [57175.0, 122370.0],
 [57175.0, 122410.0], [57175.0, 122430.0], [57195.0, 122470.0], [57195.0,
 122510.0], [57295.0, 122670.0], [57315.0, 122690.0], [57315.0, 122710.0],
 [57355.0, 122730.0], [57375.0, 122750.0], [57415.0, 122770.0], [57455.0,
 122830.0], [57475.0, 122850.0], [57515.0, 122910.0], [57535.0, 122970.0],
 [57555.0, 122990.0], [57575.0, 123090.0], [57575.0, 123110.0], [57595.0,
 123190.0], [57595.0, 123290.0], [57595.0, 123390.0], [57595.0, 123570.0],
 [57595.0, 123630.0], [57595.0, 123730.0], [57595.0, 123790.0], [57595.0,
 123830.0], [57595.0, 123850.0], [57595.0, 123890.0], [57595.0, 123990.0],
 [57595.0, 124070.0], [57595.0, 124130.0], [57595.0, 124170.0], [57595.0,
 124210.0], [57595.0, 124310.0], [57595.0, 124370.0], [57595.0, 124470.0],
 [57615.0, 124510.0], [57655.0, 124570.0], [57695.0, 124610.0], [57755.0,
 124630.0], [57875.0, 124710.0], [57975.0, 124750.0], [58175.0, 124890.0],
 [58235.0, 124950.0], [58255.0, 124950.0], [58295.0, 125030.0], [58315.0,
 125050.0], [58315.0, 125070.0], [58315.0, 125090.0], [58315.0, 125110.0],
 [58335.0, 125150.0], [58355.0, 125150.0], [58355.0, 125170.0], [58375.0,
 125190.0], [58375.0, 125210.0], [58395.0, 125230.0], [58415.0, 125250.0],
 [58435.0, 125270.0], [58455.0, 125310.0], [58475.0, 125330.0], [58495.0,
 125350.0], [58515.0, 125370.0], [58515.0, 125390.0], [58655.0, 125450.0],
 [59135.0, 123750.0]]]}, "crs": {"type": "EPSG", "properties": {"code":
 2169}}, "type": "Feature", "properties": {"name": "Nouveau Park", "id":
 1668}}, {"geometry": {"type": "Polygon", "coordinates": [[[59195.0,
 119690.0], [58435.0, 118650.0], [61455.0, 118350.0], [63695.0, 118430.0],
 [63895.0, 119610.0], [61535.0, 120350.0], [59195.0, 119690.0]]]}, "crs":
 {"type": "EPSG", "properties": {"code": 2169}}, "type": "Feature",
 "properties": {"name": "Nouveau Park", "id": 1669}}, {"geometry": {"type":
 "Polygon", "coordinates": [[[67489.656001924595, 105716.081308636],
 [69770.964192838597, 108695.74914982999], [74100.0, 107050.0], [77175.0,
 107733.33333333299], [80761.834986474307, 103548.69251578],
 [79347.8212290503, 102049.49720670401], [74800.0, 101000.0], [75350.0,
 103450.0], [73850.0, 103200.0], [73400.0, 105450.0], [72000.0, 104650.0],
 [67489.656001924595, 105716.081308636]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1676}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[72146.574973031296, 93096.817691477903],
 [71189.913590783006, 93400.149349263898], [77080.906480721897,
 99646.021328958203], [72146.574973031296, 93096.817691477903]]]}, "crs":
 {"type": "EPSG", "properties": {"code": 2169}}, "type": "Feature",
 "properties": {"name": "Nouveau Park", "id": 1660}}, {"geometry": {"type":
 "Polygon", "coordinates": [[[59625.0, 111500.0], [59875.0, 105500.0],
 [68875.0, 112750.0], [59625.0, 111500.0]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1672}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[55600.619612069, 100112.634698276], [55000.0, 99050.0],
 [51250.0, 99100.0], [52843.414120126501, 102661.749209694],
 [55600.619612069, 100112.634698276]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1673}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[52843.414120126501, 102661.749209694], [53800.0,
 104800.0], [57600.0, 103650.0], [55600.619612069, 100112.634698276],
 [52843.414120126501, 102661.749209694]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1674}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[69770.964192838597, 108695.74914982999], [72875.0,
 112750.0], [77175.0, 107733.33333333299], [74100.0, 107050.0],
 [69770.964192838597, 108695.74914982999]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1680}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[65227.607361963303, 102761.568799299],
 [67489.656001924595, 105716.081308636], [68994.186046511604,
 105360.465116279], [69800.0, 102650.0], [67500.0, 101950.0],
 [65227.607361963303, 102761.568799299]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1675}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[66443.814432989704, 99931.443298969098], [66900.0,
 101300.0], [64025.222479580603, 101191.10691210499], [65227.607361963303,
 102761.568799299], [67500.0, 101950.0], [69800.0, 102650.0],
 [68994.186046511604, 105360.465116279], [71595.461658841901,
 104745.61815336499], [71400.0, 100250.0], [69150.0, 100550.0],
 [66443.814432989704, 99931.443298969098]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1677}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[70543.937125748504, 98821.332335329294], [66050.0,
 98750.0], [66443.814432989704, 99931.443298969098], [69150.0, 100550.0],
 [71400.0, 100250.0], [71595.461658841901, 104745.61815336499], [72000.0,
 104650.0], [73400.0, 105450.0], [73850.0, 103200.0], [74781.858407079693,
 103355.30973451299], [71950.0, 100750.0], [73450.0, 100100.0],
 [70543.937125748504, 98821.332335329294]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1678}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[71189.913590783006, 93400.149349263898],
 [67140.7500645494, 94684.030467338001], [75500.0, 98900.0],
 [70543.937125748504, 98821.332335329294], [73450.0, 100100.0], [71950.0,
 100750.0], [74781.858407079693, 103355.30973451299], [75350.0, 103450.0],
 [74800.0, 101000.0], [79347.8212290503, 102049.49720670401],
 [71189.913590783006, 93400.149349263898]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1679}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[82006.7673378076, 102096.271439224], [86375.0, 97000.0],
 [84997.4959828602, 95228.923406534595], [79050.0, 97950.0],
 [82006.7673378076, 102096.271439224]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1671}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[83699.010791366905, 93559.442446043206], [81125.0,
 90250.0], [77789.879154078502, 91307.477341389706], [79700.0, 94300.0],
 [83699.010791366905, 93559.442446043206]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1681}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[78423.850766155898, 92300.699533644205],
 [77789.879154078502, 91307.477341389706], [72146.574973031296,
 93096.817691477903], [73459.134615384595, 94838.942307692298], [77650.0,
 95750.0], [77450.0, 94050.0], [76700.0, 93350.0], [78423.850766155898,
 92300.699533644205]]]}, "crs": {"type": "EPSG", "properties": {"code":
 2169}}, "type": "Feature", "properties": {"name": "Nouveau Park", "id":
 1682}}, {"geometry": {"type": "Polygon", "coordinates":
 [[[84230.952380952396, 94243.367346938801], [83699.010791366905,
 93559.442446043206], [79700.0, 94300.0], [79672.440944881906,
 94256.824146981598], [79150.0, 95650.0], [81050.0, 96000.0], [82100.0,
 94700.0], [84230.952380952396, 94243.367346938801]]]}, "crs": {"type":
 "EPSG", "properties": {"code": 2169}}, "type": "Feature", "properties":
 {"name": "Nouveau Park", "id": 1683}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[80761.834986474307, 103548.69251578], [82006.7673378076,
 102096.271439224], [79050.0, 97950.0], [84997.4959828602,
 95228.923406534595], [84230.952380952396, 94243.367346938801], [82100.0,
 94700.0], [81050.0, 96000.0], [79150.0, 95650.0], [79672.440944881906,
 94256.824146981598], [78423.850766155898, 92300.699533644205], [76700.0,
 93350.0], [77450.0, 94050.0], [77650.0, 95750.0], [73459.134615384595,
 94838.942307692298], [77080.906480721897, 99646.021328958203],
 [80761.834986474307, 103548.69251578]]]}, "crs": {"type": "EPSG",
 "properties": {"code": 2169}}, "type": "Feature", "properties": {"name":
 "Nouveau Park", "id": 1684}}, {"geometry": {"type": "Polygon",
 "coordinates": [[[65360.365853658601, 95248.542534205801], [60625.0,
 96750.0], [62485.217237725301, 99179.671494171693], [63400.0, 99200.0],
 [64350.0, 97300.0], [68950.0, 97700.0], [65360.365853658601,
 95248.542534205801]]]}, "crs": {"type": "EPSG", "properties": {"code":
 2169}}, "type": "Feature", "properties": {"name": "Nouveau Park", "id":
 1670}}, {"geometry": {"type": "Polygon", "coordinates":
 [[[67140.7500645494, 94684.030467338001], [65360.365853658601,
 95248.542534205801], [68950.0, 97700.0], [64350.0, 97300.0], [63400.0,
 99200.0], [62485.217237725301, 99179.671494171693], [64025.222479580603,
 101191.10691210499], [66900.0, 101300.0], [66050.0, 98750.0], [75500.0,
 98900.0], [67140.7500645494, 94684.030467338001]]]}, "crs": {"type":
 "EPSG", "properties": {"code": 2169}}, "type": "Feature", "properties":
 {"name": "Nouveau Park", "id": 1685}}]}




 }}}

-- 
Ticket URL: <http://trac.openlayers.org/ticket/3309>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list