npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hansotech/supjt-suw-wsir-picc-jssdk

v0.3.2

Published

Supjt-FOR-PICC-JSSDK

Downloads

1

Readme

Demo

http://demo-gis-picc-jssdk.hanso.tech/

SDK

引用

import { useMapFun } from '@supjt/suw-wsir-picc-jssdk'

初始化

const map = /* Mapbox 实例*/

const { setMap } = useMapFun();


setMap({map, backend, draw});

/**
 * 初始化
 * @param {object} option - 选项
 * @param {mapboxgl.Map} option.map - 地图实例
 * @param {string} option.backend - 瓦片服务端地址
 * @param {MapboxDraw} option.draw - MapboxDraw绘图实例
 */
setMap({map : mapboxgl.Map, backend:string, draw: MapboxDraw}){}

加载矢量数据

const { addVectorLayer } = useMapFun()

  /**
   * 添加地块图层
   * @param {'underwrite' | 'compensate'} type - 加载类型,承保或者理赔
   * @param {string} path - 矢量地块路径
   * @param {object} style - 地块样式
   * @param {{paint: mapboxgl.FillPaint, layout: mapboxgl.FillLayout}} style.fill - 地块填充样式
   * @param {{paint: mapboxgl.LinePaint, layout: mapboxgl.LineLayout}} style.line - 地块轮廓样式
   * @param {(fs: GeoJSON.Feature) => void} callback - 地块点击的回调事件
   * @return {{ fill: string;  line:string}} ids - 填充和轮廓图层id
   * @example
   * addVectorLayer(
   * 'underwrite',
   * 'vector/insure:2022:5101',
   * {fill: { paint: { 'fill-color': '#c00', 'fill-opacity': .5 } },},
   * (feature: {properties}) => {console.log(properties)})
   */
  function addVectorLayer(
    type: "underwrite" | "compensate",
    path: string,
    style: VectorStyle | null = {},
    callback: (fs: GeoJSON.Feature) => void
  ): { fill: string; line: string } {}

卸载矢量数据

const { removeVectorLayer } = useMapFun()

  /**
   * 移除地块图层
   * @param {'underwrite' | 'compensate'} type - 加载类型,承保或者理赔
   * @param {string} path - 矢量路径
   */
  function removeVectorLayer(type: "underwrite" | "compensate", path: string) {}

过滤矢量数据

const { setVectorFilter } = useMapFun()

  /**
   * 对矢量地块进行过滤
   * @param {'underwrite' | 'compensate'} type - 加载类型,承保或者理赔
   * @param {string} path - 矢量路径
   * @param {{ [prop: string]: Array<string | number> | string | number } } filter - 过滤条件对象,key为需要过滤的属性字符串,value为满足过滤属性的枚举值,或者单个字符串/数值类型,字符串以%结尾可进行头部匹配,可组合过滤
   * @example
   * setVectorFilter('underwrite', {QX: ['绵阳市', '江油市']})
   * setVectorFilter('underwrite', {szqk: '开%'})
   */
  function setVectorFilter(
    type: "underwrite" | "compensate",
    path: string,
    filter: { [prop: string]: Array<string | number> | string | number }
  ) {}

绘制/框选

const { drawPolygon } = useMapFun()

  /**
   * 框选/绘制多边形,注意,请在使用此函数未取消时,禁用与此无关的绘图操作,避免冲突。
   * @param {string} path - 理赔的矢量路径
   * @param {(geometry: GeoJSON.Geometry, list: { [prop: string]: any }[]) => void} callback - 绘制好之后得回调,返回绘制的几何、与理赔相交的土块要素,面积字段存在properties里面,字段key为'_area',注意:返回要素会有重复元素,需要自行根据唯一值合并并累加面积值
   */
  function drawPolygon(
    path: string,
    callback: (
      geometry: GeoJSON.Geometry,
      list: { [prop: string]: any }[]
    ) => void
  ) {}

取消/重置/移除框选

const { cancelDraw } = useMapFun()

  /**
   * 取消/重置/移除绘图
   */
  function cancelDraw() {}

添加栅格图层

const { addRasterLayer } = useMapFun()

  /**
   *
   * @param {'underwrite' | 'compensate'} type - 加载类型,承保或者理赔
   * @param { 'image' | 'aerial'} layer - 图层类型,高精度影像,或者航拍图
   * @param { string } area - 表示加载某个市区的卫星图
   * @return { string } id - 图层id
   * @example
   * addRasterLayer('underwrite', 'image', 'raster/sat2022:z5101')
   */
  function addRasterLayer(
    type: "underwrite" | "compensate",
    layer: "image" | "aerial",
    area: string
  ): string {}

移除栅格图层

const { removeRasterLayer } = useMapFun()

  /**
   *
   * @param type  {'underwrite' | 'compensate'} type - 加载类型,承保或者理赔
   * @param { 'image' | 'aerial'} layer - 图层类型,全球谷歌底图,高精度影像,或者航拍图
   * @param { string } area - 表示加载某个市区的卫星图
   */
  function removeRasterLayer(
    type: "underwrite" | "compensate",
    layer: "image" | "aerial",
    area: string
  ) {}

外部函数-手动设置地块样式

利用地图实例,根据mapboxgl官方文档,通过加载地块函数返回的id,自行设置样式即可

  map.setPaintProperty(vectorCompensateFillId, 'fill-color', '#00c')
  map.setPaintProperty(vectorCompensateLineId, 'line-color', '#cc0')

外部函数-回显框选图层

利用地图实例,根据mapboxgl官方文档,通过绘制函数返回的几何,自行加载图层即可

  map.addLayer({
    id: 'renderPolygon',
    type: 'fill',
    paint: {
      "fill-color": '#c6c',
      'fill-opacity': .7
    },
    source: {
      type: 'geojson',
      data: currentDrawFeature
    }
  })