diff --git a/lib/vectortilefeature.js b/lib/vectortilefeature.js index 740c66e..f8cdfc2 100644 --- a/lib/vectortilefeature.js +++ b/lib/vectortilefeature.js @@ -155,7 +155,7 @@ VectorTileFeature.prototype.toGeoJSON = function(x, y, z) { type = 'MultiLineString'; } - return { + var result = { type: "Feature", geometry: { type: type, @@ -163,4 +163,10 @@ VectorTileFeature.prototype.toGeoJSON = function(x, y, z) { }, properties: this.properties }; + + if ('_id' in this) { + result.id = this._id; + } + + return result; }; diff --git a/test/parse.test.js b/test/parse.test.js index 6a697ed..66727fc 100644 --- a/test/parse.test.js +++ b/test/parse.test.js @@ -72,6 +72,7 @@ test('parsing vector tiles', function(t) { var point = tile.layers.poi_label.feature(11).toGeoJSON(8801, 5371, 14); t.deepEqual(point.type, 'Feature'); + t.deepEqual(point.id, 3000003150561); t.deepEqual(point.properties, { localrank: 1, maki: 'park',