You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { PropType } from "vue-demi";
import { uuid } from "../../utils";
import { DefineEmits, DefineProps } from "../../types";
import { LoadConfig } from "../../use";
export const NATIVE_PROPS = {
/** EPSG:900913(墨卡托投影)EPSG:4326(大地平面投影) */
projection: { type: String, default: "EPSG:900913" },
/** 地图允许展示的最小级别 */
minZoom: { type: Number, default: 1 },
/** 地图允许展示的最大级别 */
maxZoom: { type: Number, default: 18 },
/** 地图的初始化中心点 */
center: { type: Array as unknown as PropType<VT.LngLat>, default: () => [0, 0] },
/** 地图的初始化级别 */
zoom: { type: Number, default: 1 }
};
export const EXTRA_PROPS = {
/** 启用地图拖拽,默认启用 */
drag: { type: Boolean, default: true },
/** 启用滚轮放大缩小,默认启用 */
scrollWheelZoom: { type: Boolean, default: true },
/** 启用双击放大,默认启用 */
doubleClickZoom: { type: Boolean, default: true },
/** 启用键盘操作,默认启用 */
keyboard: { type: Boolean, default: true },
/** 启用地图惯性拖拽,默认启用 */
inertia: { type: Boolean, default: true },
/** 启用连续缩放效果,默认启用 */
continuousZoom: { type: Boolean, default: true },
/** 启用双指操作缩放,默认启用 */
pinchToZoom: { type: Boolean, default: true },
/** 启用自动适应容器尺寸变化,默认启用 */
autoResize: { type: Boolean, default: true },
/** 当这个选项被设置后地图被限制在给定的地理边界内当用户平移将地图拖动到视图以外的范围时会出现弹回的效果并且也不允许缩小视图到给定范围以外的区域这取决于地图的尺寸。使用setMaxBounds方法可以动态地设置这种约束 */
maxBounds: { type: Array as unknown as PropType<VT.Bounds> },
/** 根据提供的坐标点数组设置地图视野,调整后的视野会保证包含提供的坐标点 */
viewport: { type: Array as PropType<VT.LngLat[]> },
/** 地图样式原天地图api的style分别为blackindigo */
mapStyle: { type: String as PropType<"black" | "indigo"> },
/** 地图容器id */
mid: { type: String, default: () => uuid() },
/** 控件 */
controls: { type: Array as PropType<(VT.ControlName | VT.ControlOptions)[]>, default: () => [] },
/** 加载Api的配置 */
loadConfig: { type: Object as PropType<LoadConfig> }
};
export const NATIVE_EVENTS: T.MapEvents = {
click: () => true,
dblclick: () => true,
contextmenu: () => true,
mousemove: () => true,
mouseover: () => true,
mouseout: () => true,
movestart: () => true,
move: () => true,
moveend: () => true,
zoomstart: () => true,
zoomend: () => true,
addoverlay: () => true,
removeoverlay: () => true,
addcontrol: () => true,
removecontrol: () => true,
clearoverlays: () => true,
dragstart: () => true,
drag: () => true,
dragend: () => true,
layeradd: () => true,
layerremove: () => true,
load: () => true,
resize: () => true,
levels: () => true,
touchstart: () => true,
touchmove: () => true,
touchend: () => true,
longpress: () => true
};
export const EXTRA_EVENTS = {
/** 地图初始化 */
init: (e: T.Map) => e instanceof T.Map,
/** 鹰眼视图控件的开合状态变化时触发事件 */
viewchange: (e: T.ControlOverviewMapEvent) => true
};
export const PROPS = { ...NATIVE_PROPS, ...EXTRA_PROPS };
export const EVENTS = { ...NATIVE_EVENTS, ...EXTRA_EVENTS };
export type Props = DefineProps<typeof PROPS>;
export type Emit = DefineEmits<typeof EVENTS>;