vueでgeobufを使用する

2つのライブラリgeobufとpbfをインストールする必要があります

cnpm i -S geobuf pbf

導入する

import geobuf from 'geobuf';
import Pbf from 'pbf';

使用する:

    let geojson_multiPolygon = {
      type: 'Feature',
      properties: {},
      geometry: {
        type: 'MultiPolygon',
        coordinates: [
          [
            [
              [109.2041015625, 30.088107753367257],
              [115.02685546875, 30.088107753367257],
              [115.02685546875, 32.7872745269555],
              [109.2041015625, 32.7872745269555],
              [109.2041015625, 30.088107753367257]
            ]
          ],
          [
            [
              [112.9833984375, 26.82407078047018],
              [116.69677734375, 26.82407078047018],
              [116.69677734375, 29.036960648558267],
              [112.9833984375, 29.036960648558267],
              [112.9833984375, 26.82407078047018]
            ]
          ]
        ]
      }
    };
    let a = geobuf.encode(geojson_multiPolygon, new Pbf());
    console.log('序列化:', a);

    let b = geobuf.decode(new Pbf(a));
    console.log('反序列化:', b);

 

おすすめ

転載: blog.csdn.net/qq_40323256/article/details/123995919