Skip to content

Commit

Permalink
pass GeoJSON in stringified form
Browse files Browse the repository at this point in the history
This is a reapplication of #2001 without changing the API, and serves
as the middle ground for improving `setData` performance as discussed
in #1504.
  • Loading branch information
mourner committed Mar 4, 2016
1 parent 07838e4 commit c634d8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion js/source/geojson_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ GeoJSONSource.prototype = util.inherit(Evented, /** @lends GeoJSONSource.prototy
data = urlResolve(window.location.href, data);
}
this.workerID = this.dispatcher.send('parse geojson', {
data: data,
data: typeof data === 'object' ? JSON.stringify(data) : data,
tileSize: this.tileSize,
source: this.id,
geojsonVtOptions: this.geojsonVtOptions,
Expand Down
6 changes: 3 additions & 3 deletions js/source/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ util.extend(Worker.prototype, {
// explicit origin or absolute path.
// ie: /foo/bar.json or http://example.com/bar.json
// but not ../foo/bar.json
if (typeof params.data === 'string') {
ajax.getJSON(params.data, indexData);
if (params.data.charAt(0) === '{') {
indexData(null, JSON.parse(params.data));
}
else indexData(null, params.data);
else ajax.getJSON(params.data, indexData);
},

'load geojson tile': function(params, callback) {
Expand Down

0 comments on commit c634d8c

Please sign in to comment.