Use JSON format for parsing JSON.

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.
This commit is contained in:
Tim Schaub
2012-02-25 20:18:23 -07:00
parent e6f0aa08e5
commit c18f6a23be

View File

@@ -6,6 +6,7 @@
/**
* @requires OpenLayers/Tile.js
* @requires OpenLayers/Format/JSON.js
*/
/**
@@ -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
@@ -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);
}
},