Skip to content

Commit

Permalink
Use JSON format for parsing JSON.
Browse files Browse the repository at this point in the history
To get IE7 support, the OpenLayers.Format.JSON parser should be used.  This leverages the native JSON.parse method where available.  It does add extra weight to UTFGrid builds.  However, as of this commit date, we lose large portions of US govt agencies when we exclude IE7.
  • Loading branch information
tschaub committed Feb 26, 2012
1 parent e6f0aa0 commit c18f6a2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/OpenLayers/Tile/UTFGrid.js
Expand Up @@ -6,6 +6,7 @@

/**
* @requires OpenLayers/Tile.js
* @requires OpenLayers/Format/JSON.js
*/

/**
Expand Down Expand Up @@ -37,6 +38,14 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
* Stores the parsed JSON tile data structure.
*/
json: null,

/**
* Property: format
* {OpenLayers.Format.JSON}
* Parser instance used to parse JSON for cross browser support. The native
* JSON.parse method will be used where available (all except IE<8).
*/
format: null,

/**
* Constructor: OpenLayers.Tile.UTFGrid
Expand Down Expand Up @@ -114,8 +123,10 @@ OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {
*/
parseData: function(req) {
if (req.status == 200) {
var text = req.responseText;
this.json = JSON.parse(text);
if (!this.format) {
this.format = new OpenLayers.Format.JSON();
}
this.json = this.format.read(req.responseText);
}
},

Expand Down

0 comments on commit c18f6a2

Please sign in to comment.