Skip to content

Commit dac30a4

Browse files
author
Casey Thomas
committed
Clean up README
* Remove duplicate `extraGlobal` example * Prefer no callback style in examples. Refs #9
1 parent 64d9454 commit dac30a4

File tree

1 file changed

+7
-49
lines changed

1 file changed

+7
-49
lines changed

README.md

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ Take the example data below:
2828

2929
Convert it to GeoJSON:
3030

31-
GeoJSON.parse(data, {Point: ['lat', 'lng']}, function(geojson){
32-
console.log(JSON.stringify(geojson));
33-
});
31+
GeoJSON.parse(data, {Point: ['lat', 'lng']});
3432

3533
{
3634
"type": "FeatureCollection",
@@ -61,9 +59,7 @@ Convert it to GeoJSON:
6159

6260
Convert the example data to GeoJSON, and only include the `name` attribute in `properties` for each feature.
6361

64-
GeoJSON.parse(data, {Point: ['lat', 'lng'], include: ['name']}, function(geojson){
65-
console.log(JSON.stringify(geojson));
66-
});
62+
GeoJSON.parse(data, {Point: ['lat', 'lng'], include: ['name']});
6763

6864
{
6965
"type": "FeatureCollection",
@@ -84,33 +80,6 @@ Convert the example data to GeoJSON, and only include the `name` attribute in `p
8480
]
8581
}
8682

87-
Convert the example data to GeoJSON, and include some dataset attributes.
88-
89-
GeoJSON.parse(data, {Point: ['lat', 'lng'], attrs: {'Creator': 'Mr. Example', 'records': data.length, 'summary': 'A few example points'}}, function(geojson){
90-
console.log(geojson);
91-
});
92-
93-
{
94-
"type": "FeatureCollection",
95-
"features": [
96-
{ "type": "Feature",
97-
"geometry": {"type": "Point", "coordinates": [-75.343, 39.984]},
98-
"properties": {
99-
"name": "Location A"
100-
}
101-
},
102-
...
103-
{ "type": "Feature",
104-
"geometry": {"type": "Point", "coordinates": [ -75.534, 39.123]},
105-
"properties": {
106-
"name": "Location C"
107-
}
108-
}
109-
],
110-
"Creator": "Mr. Example",
111-
"records": 2,
112-
"summary": "A few example points"
113-
}
11483

11584
The `parse` method can handle data with different geometry types. Consider the following sample data:
11685

@@ -136,9 +105,7 @@ The `parse` method can handle data with different geometry types. Consider the f
136105

137106
For each geometry type, specify which attribute contains the geometric data
138107

139-
GeoJSON.parse(data2, {'Point': ['x', 'y'], 'LineString': 'line', 'Polygon': 'polygon'}, function(geojson){
140-
console.log(JSON.stringify(geojson));
141-
});
108+
GeoJSON.parse(data2, {'Point': ['x', 'y'], 'LineString': 'line', 'Polygon': 'polygon'});
142109

143110
{
144111
"type": "FeatureCollection",
@@ -188,9 +155,7 @@ You can also specify default settings if you will be parsing mutliple datasets w
188155

189156
GeoJSON.defaults = {Point: ['x', 'y'], include: ['name']};
190157

191-
GeoJSON.parse(data1, {}, function(geojson){
192-
console.log(JSON.stringify(geojson));
193-
});
158+
GeoJSON.parse(data1, {});
194159

195160
{
196161
"type": "FeatureCollection",
@@ -208,9 +173,7 @@ You can also specify default settings if you will be parsing mutliple datasets w
208173
]
209174
}
210175

211-
GeoJSON.parse(data2, {}, function(geojson){
212-
console.log(geojson.js)
213-
});
176+
GeoJSON.parse(data2, {});
214177

215178
{
216179
"type": "FeatureCollection",
@@ -228,7 +191,7 @@ You can also specify default settings if you will be parsing mutliple datasets w
228191
]
229192
}
230193

231-
If you specify a callback function, the GeoJSON output is set as the first parameter of the function
194+
You can specify a callback function as an option third parameter.
232195

233196
GeoJSON.parse(data, {Point: ['lat', 'lng']}, function(geojson){
234197
console.log(JSON.stringify(geojson));
@@ -290,9 +253,6 @@ You can add arbitrary properties to features using the `extra` param. The value
290253
"opacity": 0.65
291254
}
292255
}
293-
},
294-
function(geojson){
295-
console.log(JSON.stringify(geojson));
296256
});
297257

298258
{
@@ -315,7 +275,7 @@ You can add arbitrary properties to features using the `extra` param. The value
315275

316276
#### extraGlobal
317277

318-
You can also add dataset properties using the `extraGlobal` param. The value for `extraGlobal` must be an object. For example, see below:
278+
You can also add dataset properties using the `extraGlobal` param. The value for `extraGlobal` must be an object.
319279

320280
GeoJSON.parse(data, {
321281
Point: ['lat', 'lng'],
@@ -324,8 +284,6 @@ You can also add dataset properties using the `extraGlobal` param. The value for
324284
'records': data.length,
325285
'summary': 'A few example points'
326286
}
327-
}, function(geojson){
328-
console.log(geojson);
329287
});
330288

331289
{

0 commit comments

Comments
 (0)