0.0.11 • Published 7 months ago

ly_leaflet_vue3 v0.0.11

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

ly_leaflet_vue3

安装依赖

npm i ly_leaflet_vue3 -S

在main.js 引用

import LyMap from 'ly_leaflet_vue3'

app.use(LyMap)
<template>
	<Map target="地图dom id" crs="坐标系" tianToken="天地图token" center="[维度, 经度]" zoom="默认放大等级" options="{}地图配置项" />
</template>	

image-20231010095030407

参数说明

参数说明默认值
target地图dom id'LyMap'
crs坐标系'EPSG4490'
tianToken天地图token
center默认地图中心29.038014380717993, 119.69593384554005
zoom默认放大等级10
options地图配置{}

crs

EPSG4490、EPSG4326、EPSG3857、EPSG3395、EPSG900913、EPSG4547、CRS3006

飞线

使用方式

import lyLeaflet from 'ly_leaflet_vue3'

const { LineMigrationControl } = lyLeaflet

const lineMigrationControl = new LineMigrationControl(lyMap)
const lineMigration1 = lineMigrationControl.add(
    [
        {
            labels: ['开始', '结束'],
            from: [119.69593384554005, 29.538014380717993],
            to: [119.69593384554005, 28.538014380717993],
            color: 'rgba(101,169,249, 1)',
            value: '2'
        }
    ],
    {
        line: {
            width: 1,
            order: false,
            icon: {
                type: 'arrow',
                imgUrl: '',
                size: 20
            }
        },
        ring: {
            left: 1,
            top: 1
        }
    },
	123321
) // 返回lineMigration对象
// lineMigration对象有show、hide、play、pause方法
// show——显示
// hide——隐藏
// play——开启动画
// pause——暂停动画

npm.io

参数说明

LineMigrationControl
参数说明是否必填默认值
mapleaflet地图/Object
lineMigrationControl.add——添加飞线
参数说明是否必填默认值
data飞线数据,lineMigrationData, lineMigrationData, ...,参数说明详见lineMigrationData说明
options飞线点和线配置,详见lineMigrationOptions说明
code飞线唯一编码/String
onAdd添加图层时调用的方法
onRemove删除图层时调用的方法
lineMigrationData
// 例子
[
	{
		labels: ['开始', '结束'],
		from: [119.69593384554005, 29.538014380717993],
		to: [119.69593384554005, 28.538014380717993],
		color: 'rgba(101,169,249, 1)',
		value: ''
	}
]
参数说明是否必填默认值
labels起点label, 终点label
from起点经纬度lng, lat
to终点经纬度lng, lat
color起始/结束点的颜色
value飞线值,会显示在飞线的tooltip中
lineMigrationOptions
{
	marker: {
		radius: [5, 10],
		pulse: {
			left: 0,
			top: 0
		},
		textVisible: true
	},
	line: {
		width: 1,
		order: false,
		icon: {
			type: 'arrow',
			imgUrl: '',
			size: 20
		}
	}
}
参数说明是否必填默认值
marker点的样式Object
marker.radiusmin, max会根据lineMigrationData.value来决定marker的大小5, 10
marker.pulsemarker的光圈动画是否启动/Booleantrue
marker.textVisiblemarker的label是否显示false
line飞线样式Object
line.width飞线宽度1
line.order飞线扫描是否按顺序进行false
line.icon飞线头部的的样式Object
line.icon.type类型枚举——'circle', 'arrow', 'img'circle
line.icon.imgUrl当type是img时,图片的路径
line.icon.sizeicon大小20
lineMigrationControl.clear——删除所有的飞线
lineMigrationControl.removeByCode——根据code删除对应的飞线
lineMigrationControl.destroy——摧毁所有图层

高亮Marker

使用方法

import lyLeaflet from 'ly_leaflet_vue3'
const { HighlightMarkerControl } = lyLeaflet

const highlightMarkerControl = new HighlightMarkerControl(mapRef.value.lyMap)
highlightMarkerControl.add([29.13014380717993, 119.69593384554005], {}, '12323221', 'label文本')
highlightMarkerControl.add([29.038014380717993, 119.69593384554005], {
		color: '#fe1500',
		apertureColor: '-webkit-radial-gradient(rgba(254, 21, 0, 100), rgba(254, 21, 0, 0) 70%)',
		apertureRadius: 30,
		iconAnchor: [2, 10] // marker 偏移
	}, '1232221', 'label2文本')

npm.io

参数说明

HighlightMarkerControl
参数说明是否必填默认值
mapleaflet地图/Object
highlightMarkerControl.add——返回marker对象
参数说明是否必填默认值
latlng添加点的经纬度
options点的配置见highlightMarkerOptions
code点的唯一值
tooltipLabelmarker的tooltip的label
tooltipOptionsmarker的tooltip的配置{ permanent: true }
onAddmarker添加时候的回调
onRemovemarker删除时候的回调
highlightMarkerOptions
{
	color: '#FED300FF', // marker 颜色
	apertureColor: '-webkit-radial-gradient(rgba(254, 211, 0, 1), rgba(255, 223, 67, 0) 70%)', // 扩散光圈颜色
	apertureRadius: 36, // 扩散光圈大小
	iconSize: [20, 20], // marker 大小
	iconAnchor: [10, 10] // marker 偏移
}
highlightMarkerControl.clear——删除所有的点
highlightMarkerControl.removeByCode——根据code删除对应的点
highlightMarkerControl.destroy——摧毁所有图层

点聚合MarkerCluster

使用方法

import lyLeaflet from 'ly_leaflet_vue3'
const { MarkerClusterControl } = lyLeaflet

 const MyCustomMarker = L.icon({
		iconAnchor: new L.Point(12, 12),
		iconSize: new L.Point(24, 24),
		iconUrl: positionPng
	})
const markerClusterControl = new MarkerClusterControl(mapRef.value.lyMap, {})
markerClusterControl.add([29.13014380717993, 119.69593384554005], { icon: MyCustomMarker }, 0)
markerClusterControl.add([29.23014380717993, 119.59593384554005], { icon: MyCustomMarker }, 1)
markerClusterControl.add([29.33014380717993, 119.49593384554005], { icon: MyCustomMarker }, 2)
markerClusterControl.add([29.43014380717993, 119.69593384554005], { icon: MyCustomMarker }, 3)
markerClusterControl.add([29.53014380717993, 119.59593384554005], { icon: MyCustomMarker }, 4)
markerClusterControl.add([29.63014380717993, 119.79593384554005], { icon: MyCustomMarker }, 5)
markerClusterControl.add([29.03014380717993, 119.69593384554005], { icon: MyCustomMarker }, 6)
markerClusterControl.add([28.13014380717993, 119.69593384554005], { icon: MyCustomMarker }, 7)
markerClusterControl.add([28.43014380717993, 120.69593384554005], { icon: MyCustomMarker }, 8)
markerClusterControl.add([28.63014380717993, 118.69593384554005], { icon: MyCustomMarker }, 9)
markerClusterControl.add([28.83014380717993, 119.29593384554005], { icon: MyCustomMarker }, 10)

npm.io

参数说明

MarkerClusterControl
参数说明是否必填默认值
mapleaflet地图/Object
clusterOptions点聚合相关配置
clusterOptions默认值及说明
const defaultOptions = {
	showCoverageOnHover: true, // 当鼠标经过一个聚合点时,会显示其包含的标记围成的范围。
	zoomToBoundsOnClick: true, // 当点击一个聚合点时,会快捷缩放至一个其对应范围适合显示的zoom级别
	spiderfyOnMaxZoom: true, // 当在最大缩放级别点击一个聚合点时,插件会将其蜘蛛化,以便能看到其包含的所有标记
	removeOutsideVisibleBounds: true, // 如果聚合点及标记处于你的显示区域外,则出于性能考虑将其从地图上移除
	animate: true // 当地图缩放或显示蜘蛛化的过程中,平滑的拆分/合并聚合点的子项。如果 L.DomUtil.TRANSITION为false,则该选项的值不会产生任何影响
	// animateAddingMarkers: false, // 如果设置为true (animate 选项也需要设置为true),在MarkerClusterGroup被添加到地图上之后,如果将单个标记添加到MarkerClusterGroup中,则也会添加动画并聚合。默认是false,因为这样会获得更好的性能表现。不支持使用 addLayers 批量添加标记, 只支持通过 addLayer单个添加标记
	// disableClusteringAtZoom: false, // 如果设置true,在指定缩放级别以及更高级别,标记将不会被聚合。默认是false。
	// maxClusterRadius: 80, // 一个聚合点的最大影响半径(单位为像素px),默认值是80。减小这个值,将可能会产生更多数值小的聚合点 。也可以定义一个函数,根据当前地图的缩放等级,返回一个单位为像素的聚合点最大影响半径。
	// polygonOptions: null, // 这个选项通过创建一个多边形L.Polygon(points, options) ,来显示一个聚合点的边界。默认为空,则leaflet会使用 默认路径选项.
	// singleMarkerMode: false, // 如果设置为true,所有的标记的图标将会被覆盖,并且为同一尺寸。(标注: 标记本身不会被聚合点的实例对象替换,仅仅是图标被覆盖,因此,他们仍然对正常的事件有反应,选项 disableClusteringAtZoom并不能恢复他们之前的图标。 (查阅 issue#391).)
	// spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }, // 允许自定义 PolylineOptions 来改变蜘蛛腿的样式, 默认样式是 { weight: 1.5, color: '#222', opacity: 0.5 }.
	// spiderfyDistanceMultiplier: 1 // 从1开始增加,以此增加蜘蛛化的标记距离中心点的距离。如果使用较大的标记图标,请使用这个选项。默认值为1。
	// iconCreateFunction: function () {}, // 可定义一个函数去创建聚合点的图标
	// spiderfyShapePositions: false, // 可定义一个函数去覆盖蜘蛛化图形的位置信息。
	// clusterPane: false // 聚合点的图标将被添加到指定图层,默认则是添加到leaflet地图的标记所在图层
}
markerClusterControl.add——返回marker对象
参数说明是否必填默认值
latlng添加点的经纬度
optionsleaflet marker点的配置见leaflet marker相关配置
code点的唯一值
markerClusterControl.addBatchMarkers——批量添加点
参数说明是否必填默认值
latlngArr经纬度数组
optionsleaflet marker点的配置见leaflet marker相关配置
latlngArr
Array [{ latlng: [], code: '' }]
// 例:
[
    {
        latlng: [29.13014380717993, 119.69593384554005],
        code: 1
    },
    {
        latlng: [29.33014380717993, 119.79593384554005],
        code: 2
    }
    
]
markerClusterControl.refreshClusters——刷新聚合点相关参数可参考https://blog.csdn.net/SuiFengDieWu/article/details/125886094 中的说明
markerClusterControl.clear——删除所有的点
markerClusterControl.removeByCode——根据code删除对应的点
markerClusterControl.destroy——摧毁所有图层
0.0.11

7 months ago

0.0.10

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago

0.0.0

7 months ago