@@ -28,9 +28,7 @@ Take the example data below:
28
28
29
29
Convert it to GeoJSON:
30
30
31
- GeoJSON.parse(data, {Point: [ 'lat', 'lng'] }, function(geojson){
32
- console.log(JSON.stringify(geojson));
33
- });
31
+ GeoJSON.parse(data, {Point: [ 'lat', 'lng'] });
34
32
35
33
{
36
34
"type": "FeatureCollection",
@@ -61,9 +59,7 @@ Convert it to GeoJSON:
61
59
62
60
Convert the example data to GeoJSON, and only include the ` name ` attribute in ` properties ` for each feature.
63
61
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'] });
67
63
68
64
{
69
65
"type": "FeatureCollection",
@@ -84,33 +80,6 @@ Convert the example data to GeoJSON, and only include the `name` attribute in `p
84
80
]
85
81
}
86
82
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
- }
114
83
115
84
The ` parse ` method can handle data with different geometry types. Consider the following sample data:
116
85
@@ -136,9 +105,7 @@ The `parse` method can handle data with different geometry types. Consider the f
136
105
137
106
For each geometry type, specify which attribute contains the geometric data
138
107
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'});
142
109
143
110
{
144
111
"type": "FeatureCollection",
@@ -188,9 +155,7 @@ You can also specify default settings if you will be parsing mutliple datasets w
188
155
189
156
GeoJSON.defaults = {Point: ['x', 'y'], include: ['name']};
190
157
191
- GeoJSON.parse(data1, {}, function(geojson){
192
- console.log(JSON.stringify(geojson));
193
- });
158
+ GeoJSON.parse(data1, {});
194
159
195
160
{
196
161
"type": "FeatureCollection",
@@ -208,9 +173,7 @@ You can also specify default settings if you will be parsing mutliple datasets w
208
173
]
209
174
}
210
175
211
- GeoJSON.parse(data2, {}, function(geojson){
212
- console.log(geojson.js)
213
- });
176
+ GeoJSON.parse(data2, {});
214
177
215
178
{
216
179
"type": "FeatureCollection",
@@ -228,7 +191,7 @@ You can also specify default settings if you will be parsing mutliple datasets w
228
191
]
229
192
}
230
193
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.
232
195
233
196
GeoJSON.parse(data, {Point: ['lat', 'lng']}, function(geojson){
234
197
console.log(JSON.stringify(geojson));
@@ -290,9 +253,6 @@ You can add arbitrary properties to features using the `extra` param. The value
290
253
"opacity": 0.65
291
254
}
292
255
}
293
- },
294
- function(geojson){
295
- console.log(JSON.stringify(geojson));
296
256
});
297
257
298
258
{
@@ -315,7 +275,7 @@ You can add arbitrary properties to features using the `extra` param. The value
315
275
316
276
#### extraGlobal
317
277
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.
319
279
320
280
GeoJSON.parse(data, {
321
281
Point: ['lat', 'lng'],
@@ -324,8 +284,6 @@ You can also add dataset properties using the `extraGlobal` param. The value for
324
284
'records': data.length,
325
285
'summary': 'A few example points'
326
286
}
327
- }, function(geojson){
328
- console.log(geojson);
329
287
});
330
288
331
289
{
0 commit comments