@mapbox/vector-tile - npm

文章推薦指數: 80 %
投票人數:10人

@mapbox/vector-tile. 1.3.1 • Public • Published 4 years ago. Readme · Explore BETA · 1 Dependency · 154 Dependents · 6 Versions ... @mapbox/vector-tile1.3.1 • Public • Published4yearsagoReadmeExploreBETA1Dependency154Dependents6Versionsvector-tile ThislibraryreadsMapboxVectorTilesandallowsaccesstothelayersandfeatures. Example var VectorTile = require('@mapbox/vector-tile').VectorTile;var Protobuf = require('pbf'); var tile = new VectorTile(new Protobuf(data)); // Contains a map of all layerstile.layers; var landuse = tile.layers.landuse; // Amount of features in this layerlanduse.length; // Returns the first featurelanduse.feature(0); Vectortilescontainedinserialtiles-spec aregzip-encoded,soacompleteexampleofparsingthemwiththenative zlibmodulewouldbe: var VectorTile = require('vector-tile').VectorTile;var Protobuf = require('pbf');var zlib = require('zlib'); zlib.gunzip(data, function(err, buffer) {    var tile = new VectorTile(new Protobuf(buffer));}); Depends Node.jsv0.10.xorv0.8.x Install Toinstall: npminstall@mapbox/vector-tile APIReference VectorTile Anobjectthatparsesvectortiledataandmakesitreadable. Constructor newVectorTile(protobuf[,end])— parsesthevectortiledatacontainedinthegivenProtobufobject, savingresultinglayersinthecreatedobjectasalayersproperty.Optionallyacceptsendindex. Properties layers(Object)—anobjectcontainingparsedlayersintheformof{:,...}, whereeachlayerisaVectorTileLayerobject. VectorTileLayer Anobjectthatcontainsthedataforasinglevectortilelayer. Properties version(Number,default:1) name(String)—layername extent(Number,default:4096)—tileextentsize length(Number)—numberoffeaturesinthelayer Methods feature(i)—getafeature(VectorTileFeature)bythegivenindexfromthelayer. VectorTileFeature Anobjectthatcontainsthedataforasinglefeature. Properties type(Number)—typeofthefeature(alsoseeVectorTileFeature.types) extent(Number)—featureextentsize id(Number)—featureidentifier,ifpresent properties(Object)—objectliteralwithfeatureproperties Methods loadGeometry()—parsesfeaturegeometryandreturnsanarrayof Pointarrays(witheachpointhavingxandyproperties) bbox()—calculatesandreturnstheboundingboxofthefeatureintheform[x1,y1,x2,y2] toGeoJSON(x,y,z)—returnsaGeoJSONrepresentationofthefeature.(x,y,andzrefertothecontainingtile'sindex.) KeywordsnoneInstallnpmi@mapbox/vector-tileRepositoryGitgithub.com/mapbox/vector-tile-jsHomepagegithub.com/mapbox/vector-tile-js#readmeDownloadsWeeklyDownloads508,410Version1.3.1LicenseBSD-3-ClauseUnpackedSize262kBTotalFiles30Lastpublish4yearsagoCollaboratorsTryonRunKitReportmalware



請為這篇文章評分?