altizure-plugin-shapefile

0.0.3 • Public • Published

altizure-plugin-shapefile

The Shapefile plugin for Altizure Javascript SDK.

example

Setup

  • Dependencies

    1. nodejs
    2. yarn
  • Setup

    1. Clone the repository

      git clone https://bitbucket.org/<YOUR_GIT>/altizure-plugin-shapefile/

    2. Install npm modules

      cd altizure-plugin-shapefile

      yarn

    3. Compile debug version

      yarn build

    4. Compile release version

      yarn release

Pre-Release

  • Coding style yarn lint

usage

This plugin needs altizure defined.

support shapefile type

  • Polygon
  • MultiPolygon
  • LineString
  • Point

in js

This plugin has to be used together with the altizure module. Make sure altizure is in your dependencies (or devDependencies) list in package.json file.

import {Sandbox} from 'altizure'
import {polygonsFromShp} from 'altizure-plugin-shapefile'

let options = {
  altizureApi:{
    key: your key here...
  }
}
let sandbox = new Sandbox('page-content', options)

let shpOptions = {
  shpPath: '../testdata/polygons_wgs84.shp',
  dbfPath: '../testdata/polygons_wgs84.dbf',
  encoding: 'GBK'   // if table info contains Chinese characters, please use GBK
}
let polygons
altizure.Shapefile.polygonsFromShp(shpOptions, sandbox, {
  top: 60,
  bottom: 0.2,
  color: 0xffffff * Math.random(),
  opacity: 0.2
}).then(function(res) {
  polygons = res
  console.log(polygons)
})

in html

Include altizure-sdk.min.js before this plugin.

<head>
  <script type="text/javascript" src="https://unpkg.com/altizure/release/altizure-sdk.min.js"></script>
  <script type="text/javascript" src="../../build/altizure-plugin-shapefile.min.js"></script>
</head>
<body>
  <div id="page-content" />
  <script>
    let options = {
      altizureApi:{
        key: your key here...
      }
    }
    let sandbox = new altizure.Sandbox('page-content', options)

    let shpOptions = {
      shpPath: '../testdata/polygons_wgs84.shp',
      dbfPath: '../testdata/polygons_wgs84.dbf',
      encoding: 'GBK'   // if table info contains Chinese characters, please use GBK
    }
    let polygons
    altizure.Shapefile.polygonsFromShp(shpOptions, sandbox, {
      top: 60,
      bottom: 0.2,
      color: 0xffffff * Math.random(),
      opacity: 0.2
    }).then(function(res) {
      polygons = res
      console.log(polygons)
    })
  </script>
</body>

Package Sidebar

Install

npm i altizure-plugin-shapefile

Weekly Downloads

0

Version

0.0.3

License

ISC

Unpacked Size

304 kB

Total Files

5

Last publish

Collaborators

  • jingbo