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

vue-openlayers-d

v1.5.9

Published

地图辅助包

Downloads

26

Readme

openlayer + vue

效果展示

See 效果展示.jpg

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Lints and fixes files

npm run lint

Customize configuration

See Configuration Reference.

使用

<template>
  <div class="openlayer">
    <!--地图容器-->
    <div id="map" ref="rootmap">
      <!-- 弹出窗体 -->
      <MapPopup :position="mapPopupData.position" :title="mapPopupData.title" :offset="mapPopupData.offset" :mapShow="mapPopupData.show" @close="mapPopupClose" :className="'map-popup'"> 自定义弹出窗体的内 <slot> {{ popupText }} </MapPopup>
      <!-- 点标注,如果只想用文字标注label,可以把图片设置成一个像素的透明图片,如果只想用图标就label设置为null,单独的懒得封装了,-->
      <MapIconMark :position="mapIconData.position" :label="mapIconData.label" :icon='mapIconData.icon' :elementName="mapIconData.elementName" :className="mapIconData.className"></MapIconMark>
      <!-- 折线 -->
      <MapLineString :pointList="mapLineStringData.pointlist" :lineColor="mapLineStringData.lineColor" :lineWidth="mapLineStringData.lineWidth" :lineDash="mapLineStringData.lineDash" :elementName="mapLineStringData.elementName" :className="mapLineStringData.className"></MapLineString>
      <!-- 多边形 -->
      <MapPolygon :pointList="mapPolygonData.pointlist" :fillColor="mapPolygonData.fillColor" :lineColor="mapPolygonData.lineColor" :lineWidth="mapPolygonData.lineWidth" :lineDash="mapPolygonData.lineDash" :elementName="mapPolygonData.elementName" :className="mapPolygonData.className"></MapPolygon>
      <!-- 圆形 -->
      <MapCircle :position="mapCircleData.position" :radius="mapCircleData.radius" :fillColor="mapCircleData.fillColor" :lineColor="mapCircleData.lineColor" :lineWidth="mapCircleData.lineWidth" :lineDash="mapCircleData.lineDash" :elementName="mapCircleData.elementName" :className="mapCircleData.className"></MapCircle>
      <!-- 自定义覆盖物 -->
      <MapOverlay :position="mapOverlayData.position" :className="mapOverlayData.className"><div><img :src="mapOverlayData.img" alt=""></div></MapOverlay>
      <!-- 海量点 -->
      <MapPointCollection :pointList="mapPointCollectionData.pointlist" :distance="mapPointCollectionData.distance" :fillColor="mapPointCollectionData.fillColor" :fontColor="mapPointCollectionData.fontColor" :zIndex='mapPointCollectionData.zIndex' :offset="mapPointCollectionData.offset"></MapPointCollection>
      <!-- 循环使用的方法 -->
      <template v-for="(item,index) of pointlist">
        <MapIconMark :position="item" :icon='iconImg' :key="index" :label="'标记点' + String(index)"></MapIconMark>
      </template>
      <!-- 路径示例 -->
      <MapLineString :pointList="pointlist" :lineColor="'red'" :lineWidth="5" :lineDash="null" :elementName="'轨迹'" :className="'map-road'"></MapLineString>
    </div>
    <div class="click-center">{{clickCenter}}</div>
  </div>
</template>
<script>
import 'ol/ol.css'
import { Map, View } from 'ol'
import * as olControl from 'ol/control'
// 引入组件
import MapPopup from '@/components/MapPopup'
import MapIconMark from '@/components/MapIconMark'
import MapLineString from '@/components/MapLineString'
import MapPolygon from '@/components/MapPolygon'
import MapCircle from '@/components/MapCircle'
import MapOverlay from '@/components/MapOverlay'
import MapPointCollection from '@/components/MapPointCollection'
import mapconfig from '@/mapconfig'
export default {
  name:'openlayer',
  components: {
    // 引入组件
    MapPopup,
    MapIconMark,
    MapLineString,
    MapPolygon,
    MapCircle,
    MapOverlay,
    MapPointCollection
  },
  data() {
    return {
     // 地图初始化数据
     ...
    }
  }
}
</script>

点标注(MapIconMark)

<MapIconMark :position="mapIconData.position" :label="mapIconData.label" :icon='mapIconData.icon' :elementName="mapIconData.elementName" :className="mapIconData.className"></MapIconMark>
/**
* position // 标注点的位置 array [lng, lat]
* label // 标注点的标签 string | null , 非必须 ,默认 null,
* icon // 标注点的图标 string(url) | 如果只要标签名称就设置成一个像素的透明图标, 必须
* elmentName // 通过feature.get('name') 方法可以获得该叠加图层,非必须, 默认 'el-mapIconMark'
* className // 设置class名称, 非必须, 默认 'map-icon-mark'
* zIndex // 图层z轴高度, 非必须, 默认 800
*/

折线(MapLineString)

<MapLineString :pointList="mapLineStringData.pointlist" :lineColor="mapLineStringData.lineColor" :lineWidth="mapLineStringData.lineWidth" :lineDash="mapLineStringData.lineDash" :elementName="mapLineStringData.elementName" :className="mapLineStringData.className"></MapLineString>
/**
* pointList // 组成线的点列表数组 array [[lng, lat],...]
* lineColor // 线条颜色 String,非必须,默认为 '#409eff' 
* lineWidth // 线条宽度 Number,非必须,默认为 2
* lineDash // 虚线 Array[number], 是否使用虚线,默认为 null
* className // 图层的class String, 非必须, 默认 "map-line-string"
* zIndex // 图层z轴高度, 非必须, 默认 300
* elmentName // 通过feature.get('name') 方法可以获得该叠加图层
*/

多边形(MapPolygon)

<MapPolygon :pointList="mapPolygonData.pointlist" :fillColor="mapPolygonData.fillColor" :lineColor="mapPolygonData.lineColor" :lineWidth="mapPolygonData.lineWidth" :lineDash="mapPolygonData.lineDash" :elementName="mapPolygonData.elementName" :className="mapPolygonData.className"></MapPolygon>
/**
* pointList // 组成多边形的点列表数组 array [[lng, lat],...]
* fillColor // 多边形填充颜色,非必须,默认为 'rgba(0,0,0,0.8)'
* elementName // 多边形识别名称 String, 非必须,默认为 'el-mapPolygon'
* lineColor // 多边形线条颜色 String,非必须,默认为 '#409eff'
* lineWidth // 多边形线条宽度 Number,非必须,默认为 2
* lineDash // 多边形虚线 Array[number], 是否使用虚线 ,默认为 null
* className // 图层的class String, 非必须,默认为 'map-polygon'
*/

圆形(MapCircle)

 <MapCircle :position="mapCircleData.position" :radius="mapCircleData.radius" :fillColor="mapCircleData.fillColor" :lineColor="mapCircleData.lineColor" :lineWidth="mapCircleData.lineWidth" :lineDash="mapCircleData.lineDash" :elementName="mapCircleData.elementName" :className="mapCircleData.className"></MapCircle>
/**
* position // 圆中心点 Array, 必须
* radius // 圆半径 number ,默认为 100
* fillColor // 圆形填充颜色,非必须,默认为 'rgba(255,255,255,0.5)'
* elementName // 圆形识别名称 String, 非必须,默认为 'el-mapCircle'
* lineColor // 圆形线条颜色 String,非必须,默认为 '#409eff'
* lineWidth // 圆形线条宽度 Number,非必须,默认为 2
* lineDash // 圆形虚线 Array[number], 是否使用虚线 ,默认为 null
* className // 图层的class String, 非必须,默认为 'map-circle'
*/

自定义覆盖物(MapOverlay)

<MapOverlay :position="mapOverlayData.position" :className="mapOverlayData.className"><div><img :src="mapOverlayData.img" alt=""></div></MapOverlay>
/**
* position // 标注中心点 Array, 必须
* className // 设置自定义图层的class String ,非必须, 默认 'map-overlay'
* offset // 设置自定义图层的偏移量 Array[number] ,非必须,默认[0, 0]
*/

弹出窗体(MapPopup)

<MapPopup :position="mapPopupData.position" :title="mapPopupData.title" :offset="mapPopupData.offset" :mapShow="mapPopupData.show" @close="mapPopupClose" :className="'map-popup'">{{ popupText }}</MapPopup>
/**
* position // 弹窗中心点 Array[array], 必须
* title // 弹窗标题 String,非必须,默认为 ' '
* mapShow // 弹窗显隐 Boolean,必须,默认为 true
* offset // 弹窗偏移 Array[number],必须,默认为 [0, 0]
* className // 图层的class String,非必须,默认为 'map-popup'
* close() // 弹窗关闭事件
*/

海量点(MapPointCollection)

<MapPointCollection :pointList="mapPointCollectionData.pointlist" :distance="mapPointCollectionData.distance" :fillColor="mapPointCollectionData.fillColor" :fontColor="mapPointCollectionData.fontColor" :zIndex='mapPointCollectionData.zIndex' :offset="mapPointCollectionData.offset"></MapPointCollection>
/**
* pointlist // 组成多边形的点列表数组 array [[lng, lat],...]
* distance // 收起点的间距  number,必须,默认为 40
* zIndex // 图层z轴高度, 非必须, 默认 400
* offset // 文字偏移距离 [x,y], 非必须, 默认 [0,0]
* fontColor // 文字的颜色 string (色彩标识,支持rgba),默认'#fff'(如果去掉文字那么直接rgba透明度设置为0)
* fillColor // 文字的背景颜色 string(色彩标识,支持rgba),默认'#f00'(如果去不要背景颜色那么直接rgba透明度设置为0)
* bgImg // 设置背景图,如果设置了此那么文字背景可以不设置
*/