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

jxgs-map

v1.0.0

Published

``` npm install jxgs-map ```

Downloads

1

Readme

安装

npm install jxgs-map

使用

main文件引入

import MapView from 'jxgs-map'
import 'jxgs-map/lib/jxgs-map.css'
Vue.use(MapView)

组件调用

<!-- onSelectClick:选中某元素回调函数 -->
<map-view ref="mapview" :config="config" @onSelectClick="onSelectClick" >
  
  <!-- 导入弹窗模块 -->
  <div slot="overlays"> 
    <div id="clickOpen">点我~~~</div>
  </div>
</map-view>

初始化

 data() {
    
    return {
      config: {
         // chinaWhite 高速白底 chinaBlue 高速蓝底 默认'chinaBlue'
        layerName: 'chinaBlue', 
        center: [115.8, 28.7], // 中心坐标 默认[115.8, 28.7] 江西中心坐标
        zoom: 10, // 缩放
        minZoom: 7, 
        maxZoom: 21,
        projection: 'EPSG:4326' // 坐标系
      },
      rootMap: null, // 
    }
  },
 mounted() {
    // 获取地图工具对象
    this.rootMap = this.$refs.mapview.rootMap; 
    
 }

点、线、面图层渲染

方法1 导入GeoJson文件

const config =  {
    url: './data/geoMap.json',// 来源
    style, // 样式 格式参考Style 样式参考
    selectStyle, // 选中后样式
    layerName: 'geometryQuery', // 图层名称
  }
 this.rootMap.addArcgisLayer(config);

方法2 数据渲染

const mapDataConfig =  {
    features: [
       {
        // 属性
        attributes: {
          callbackParams: {},
          }
        },
        // 空间坐标 2中方式皆可
        //方式1
        // geometry: 'POINT(116.08307760642404 28.70426990703425)',
        // 方式2 点 1维数组 线 2维数组 面 3维数组
        geometry: [116.08307760642404,28.70426990703425],
        // 类型 Point: 点 ,LineString 线 Polygon:面
        geometryType: 'Point', 
        },
        style: {} // 样式 可选
        selectStyle, // 选中后样式 可选
    ],
    style, // 样式
    selectStyle, // 选中后样式
    layerName: 'geometryQuery', // 图层名称
    center: 7 // 是否设置该图层为中心图层 参数值为缩放参数
  }
 this.rootMap.addArcgisLayer(mapDataConfig);

热力图图层

// 热力图图层
 const heatConfig = {
      layerName: 'heatMap1', // 图层名称
      features: [
        {
          attributes: {
            callback,
            callbackParams: {},
            id: 1,
          },
          geometry: 'POINT(116.08307760642404 28.70426990703425)',
          geometryType: 'Point',
        },
      ],
      // url: './data/heatMap.json',// geoJson文件导入
      gradient: ['#00f', '#0ff', '#0f0', '#ff0', '#f00'],	//设置梯度颜色值
      opacity: 1,				//设置透明度,范围0~1,默认1
      blur: 4,				//设置模糊大小,单位px,默认15
      radius: 3,				//设置半径大小,单位px,默认8
      shadow: 150,			//设置阴影大小,单位px,默认250
      visible: true			//设置是否可见,默认true
    }
    this.rootMap.addHeatMapLayer(heatConfig);

轨迹动画图层


    const aniMapDataConfig = {
      features: [
      // 方案1 固定路线轨迹
        {
          geometry: [
            [116.07763476530948, 28.65668910573156],
            [116.0754191943188, 28.644162529255752],
            [116.07242406498187, 28.631695874686592],
            [116.06769304178104, 28.62523611202581],
            [116.06657943012551, 28.61659679189305],
            [116.06639015538764, 28.609170460200044],
            [116.06797674257635, 28.599729967572355],
            [116.0714042152619, 28.589595044949437],
            [116.07159029013975, 28.578071534022293],
            [116.07274900170891, 28.56947994010334],
            [116.0728660079105, 28.556099544379357],
            [116.07492243114712, 28.5465690934233],
            [116.07783098313982, 28.53873680213302],
            [116.07823332025407, 28.53180276588264],
            [116.07945445928063, 28.524109970376045],
            [116.07681626527076, 28.51613489288]],
          attributes: {},
        },
        // 方案2 起止点轨迹
        {
          to: [118.36176535728272, 29.716182043981643],
          from: [116.07681626527076, 28.51613489288],
           attributes: {},
        },
        
      ],
      speed: 16, // 速度
      animating: false,
      style: {
        stroke: { width: 1.5, color: 'rgba(228, 228, 54,0.7)' },
        icon: {
          src: require('/public/img/car.png'),
          scale: 1, // 缩放
        }
      },
      selectStyle: {
        stroke: { width: 2, color: '#ff0000' },
        fill: { color: '#ff0000' }
      },
      layerName:'aniLayer' // 图层名称
    }
    this.rootMap.addAnimationLayer(aniMapDataConfig);

交互事件

选中某元素回调

方案1 @onSelectClick 全局回调
方案2 单个元素配置
 const callback = (p: any) => {
    }
features: [
          {
            name: 'carMove',
            attributes: {
              callbackParams: {},
              callback, // 元素回调
            },
            geometry: ...

弹出层

this.rootMap.addOverlay(id,config)

// 参考
<div slot="overlays">
    <div id="clickOpen">点我~~~</div>
</div>
 const config =   {
id: 'clickOpen',
offset: [0, -25], // 偏移
position: p.mapBrowserEvent.coordinate, // 坐标
autoPan: true,
autoPanMargin: 100,
positioning: 'top-right'
}
this.rootMap.addOverlay('clickOpen',config)
const position = [115.88218961004041,28.64971213329288]
this.rootMap.setOverlayPosition('clickOpen',position) // 修改某弹出层坐标

关闭弹出层

this.rootMap.closeOverlay(id)

移除弹出层

this.rootMap.unOverlay(id)

移除图层

this.rootMap.removeArcgisLayer(layerName)

移除全部图层

this.rootMap.removeLayerAll()

暂停动画

 this.rootMap.unAnimation(layerName)

开启测量

 this.rootMap.addMeasure()

关闭测量

 this.rootMap.unMeasure()

style样式参考

  • style 样式
    • stroke 边样式
    • icon 图片 只支持Point
    • circle 圆形 只支持Point
    • fill 面样式
style: {
 stroke: { width: 4, color: '#ffff00' }, // 样式
 icon: {
   src: require('/public/img/icons/icon_shoufeizhan.png'),
   // anchor: [0.5, 1],
   scale: 0.7, // 缩放
 },
 circle: {
   radius: 20, // 直径
   color: '#ffff00', // 颜色
 },
 text: {
   text: '线', // 文本
 },
 fill: { color: 'rgba(255,255,255,0.3)' }
},

Address

openlayers-olStyle 说明文档

https://openlayers.org/en/v6.15.1/apidoc/module-ol_style_Style-Style.html