diff --git a/lib/OpenLayers/Tile/UTFGrid.js b/lib/OpenLayers/Tile/UTFGrid.js index ab057e276f..1dc66454d0 100644 --- a/lib/OpenLayers/Tile/UTFGrid.js +++ b/lib/OpenLayers/Tile/UTFGrid.js @@ -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); } },