Socket
Socket
Sign inDemoInstall

@karpojs/vue-tmap

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

6

dist/components/map.d.ts

@@ -185,3 +185,3 @@ /// <reference types="@map-component/tmap-types" />

getZoom: () => number;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "ready"[], "ready", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
version: {

@@ -304,3 +304,5 @@ type: StringConstructor;

};
}>>, {
}>> & {
onReady?: ((...args: any[]) => any) | undefined;
}, {
version: string;

@@ -307,0 +309,0 @@ mapKey: string;

@@ -127,3 +127,4 @@ import { defineComponent, ref, onMounted, onUnmounted, watch, provide, h, inject, toRaw, computed } from "vue";

},
setup(props) {
emits: ["ready"],
setup(props, { emit }) {
const el = ref(null);

@@ -192,2 +193,3 @@ const map = ref(null);

map.value = mapIns;
emit("ready", mapIns);
}

@@ -1018,2 +1020,8 @@ });

);
watch(
() => props.modelValue,
(geometries2) => {
polygon == null ? void 0 : polygon.updateGeometries(geometries2);
}
);
onUnmounted(() => {

@@ -1039,63 +1047,2 @@ polygon.setMap(null);

});
var GeometryEditor = defineComponent({
name: "tmap-geometry-editor",
props: {
selectedStyleId: {
type: String,
default: "selected"
}
},
setup(props) {
const map = inject("map");
const geometry = inject("geometry");
if (!map || !geometry) {
return {};
}
const editor = new TMap.tools.GeometryEditor({
map: toRaw(map.value),
overlayList: [
{
overlay: geometry,
id: geometry.id,
selectedStyleId: props.selectedStyleId
}
],
actionMode: TMap.tools.constants.EDITOR_ACTION.INTERACT,
activeOverlayId: geometry.id,
selectable: true,
snappable: true
});
editor.on("active_changed", (e) => {
console.log("active_changed", e);
});
editor.on("select", (e) => {
console.log("select", e);
});
editor.on("draw_complete", (e) => {
console.log("draw_complete", e);
});
editor.on("adjust_complete", (e) => {
console.log("adjust_complete", e);
});
editor.on("delete_complete", (e) => {
console.log("delete_complete", e);
});
editor.on("split_complete", (e) => {
console.log("split_complete", e);
});
editor.on("union_complete", (e) => {
console.log("union_complete", e);
});
editor.on("split_fail", (e) => {
console.log("split_fail", e);
});
editor.on("union_fail", (e) => {
console.log("union_fail", e);
});
return {};
},
render() {
return null;
}
});
const getLatLng = (latlngData) => {

@@ -1192,3 +1139,2 @@ return new TMap.LatLng(latlngData.lat, latlngData.lng);

PolygonEditor,
GeometryEditor,
DOMOverlay

@@ -1195,0 +1141,0 @@ ];

@@ -1,1 +0,1 @@

(function(u,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(u=typeof globalThis!="undefined"?globalThis:u||self,o(u["vue-tmap"]={},u.vue))})(this,function(u,o){"use strict";function x(e,n,a){const l=["visualization","tools","geometry",...a||[]];return new Promise(i=>{if(window.TMap){i(window.TMap);return}window.tmapCallback=function(){i(window.TMap)},window.__POWERED_BY_QIANKUN__&&top&&(top.tmapCallback=function(){i(TMap)});const r=document.createElement("script");r.type="text/javascript",r.src=`https://map.qq.com/api/gljs?v=${e}&key=${n}&libraries=${l.join(",")}&callback=tmapCallback`,document.body.appendChild(r)})}function f(e,n,a,l){if(!a){e.removeControl(n);return}const i=e.getControl(n),{position:r,className:t}=a;l[r]&&i.setPosition(l[r]),i.setClassName(t)}var b=o.defineComponent({name:"tmap-map",props:{version:{type:String,default:"1.exp"},mapKey:{type:String,default:""},libraries:{type:Array,default:()=>[]},class:{type:String,default:""},style:{type:Object,default:()=>({})},center:{type:Object,default:()=>({lat:40.040452,lng:116.273486})},zoom:{type:Number,default:17},minZoom:{type:Number,default:3},maxZoom:{type:Number,default:20},rotation:{type:Number,default:0},pitch:{type:Number,default:0},scale:{type:Number,default:1},offset:{type:Object,default:()=>({x:0,y:0})},draggable:{type:Boolean,default:!0},scrollable:{type:Boolean,default:!0},doubleClickZoom:{type:Boolean,default:!0},boundary:{type:Object,default:null},mapStyleId:{type:String},baseMap:{type:Object},viewMode:{type:String,default:"3D"},control:{type:Object,default:()=>({scale:{},zoom:{},rotation:{}})},events:{type:Object,default:()=>({})}},setup(e){const n=o.ref(null),a=o.ref(null);let l,i;const r=[];return Object.keys(e.events).forEach(t=>{r.push(t)}),o.onMounted(async()=>{await x(e.version,e.mapKey,e.libraries),i={topLeft:TMap.constants.CONTROL_POSITION.TOP_LEFT,topCenter:TMap.constants.CONTROL_POSITION.TOP_CENTER,topRight:TMap.constants.CONTROL_POSITION.TOP_RIGHT,centerLeft:TMap.constants.CONTROL_POSITION.CENTER_LEFT,center:TMap.constants.CONTROL_POSITION.CENTER,centerRight:TMap.constants.CONTROL_POSITION.CENTER_RIGHT,bottomLeft:TMap.constants.CONTROL_POSITION.BOTTOM_LEFT,bottomCenter:TMap.constants.CONTROL_POSITION.BOTTOM_CENTER,bottomRight:TMap.constants.CONTROL_POSITION.BOTTOM_RIGHT};const t=new TMap.LatLng(e.center.lat,e.center.lng);n.value&&(l=new TMap.Map(n.value,{center:t,zoom:e.zoom,minZoom:e.minZoom,maxZoom:e.maxZoom,rotation:e.rotation,pitch:e.pitch,scale:e.scale,offset:e.offset,draggable:e.draggable,scrollable:e.scrollable,doubleClickZoom:e.doubleClickZoom,boundary:e.boundary,mapStyleId:e.mapStyleId,baseMap:e.baseMap,viewMode:e.viewMode,showControl:!0}),f(l,TMap.constants.DEFAULT_CONTROL_ID.SCALE,e.control.scale,i),f(l,TMap.constants.DEFAULT_CONTROL_ID.ZOOM,e.control.zoom,i),f(l,TMap.constants.DEFAULT_CONTROL_ID.ROTATION,e.control.rotation,i),r.forEach(s=>{l.on(s,e.events[s])}),a.value=l)}),o.onUnmounted(()=>{l&&(r.forEach(t=>{l.off(t,e.events[t])}),l.destroy())}),o.watch(()=>[e.center,e.zoom,e.rotation,e.pitch],([t,s,d,c])=>{l&&l.easeTo({center:new TMap.LatLng(t.lat,t.lng),zoom:s,rotation:d,pitch:c},{duration:500})}),o.watch(()=>e.scale,t=>l&&l.setScale(t)),o.watch(()=>e.offset,t=>l&&l.setOffset(t)),o.watch(()=>e.draggable,t=>l&&l.setDraggable(t)),o.watch(()=>e.scrollable,t=>l&&l.setScrollable(t)),o.watch(()=>e.doubleClickZoom,t=>l&&l.setDoubleClickZoom(t)),o.watch(()=>e.boundary,t=>l&&l.setBoundary(t)),o.watch(()=>e.control,t=>{f(l,TMap.constants.DEFAULT_CONTROL_ID.SCALE,t.scale,i),f(l,TMap.constants.DEFAULT_CONTROL_ID.ZOOM,t.zoom,i),f(l,TMap.constants.DEFAULT_CONTROL_ID.ROTATION,t.rotation,i)}),o.provide("map",a),{map:a,el:n,getCenter:()=>l==null?void 0:l.getCenter(),getZoom:()=>l==null?void 0:l.getZoom()}},render(){return o.h("div",{class:this.class,style:{...this.style,height:"100%",width:"100%"},ref:"el"},this.$slots.default&&this.map?this.$slots.default():[])}});function p(e,n,a){const l=[],i=[];Object.keys(n).forEach(r=>{if(r.indexOf("on")===0){const t=r[2].toLowerCase()+r.slice(3);l.push(t),i.push(a.bind(null,t))}}),l.forEach((r,t)=>{e.on(r,i[t])}),o.onUnmounted(()=>{l.forEach((r,t)=>{e.off(r,i[t])})})}function m(e,n){const a=e.getLayer(n);a&&a.setMap(null);const l=e.getLayer(`${n}_border_line`);l&&l.setMap(null);const i=e.getLayer(`${n}_border`);i&&i.setMap(null)}function h(e){const n={};return Object.keys(e).forEach(a=>{n[a]=new TMap.MarkerStyle(e[a])}),n}function M(e){return e.map(n=>({...n,position:new TMap.LatLng(n.position.lat,n.position.lng)}))}var w=o.defineComponent({name:"tmap-multi-marker",props:{id:{type:String,default:"default"},styles:{type:Object,required:!0},geometries:{type:Array,required:!0}},setup(e,{attrs:n,emit:a}){const l=o.inject("map");if(!l)return{};const i=o.toRaw(l.value);m(i,e.id);const r=new TMap.MultiMarker({id:e.id,map:i,styles:h(e.styles),geometries:M(e.geometries)});return p(r,n,a),o.watch(()=>e.styles,t=>{r.setStyles(h(t))}),o.watch(()=>e.geometries,t=>{r.setGeometries(M(t))}),o.onUnmounted(()=>{r.setMap(null)}),{getStyles:r.getStyles,moveAlong:r.moveAlong.bind(r),stopMove:r.stopMove.bind(r),pauseMove:r.pauseMove.bind(r),resumeMove:r.resumeMove.bind(r),on:r.on.bind(r)}},render(){return null}}),C=o.defineComponent({name:"tmap-marker-cluster",props:{id:{type:String,default:"default"},enableDefaultStyle:{type:Boolean,default:!0},minimumClusterSize:{type:Number,default:2},geometries:{type:Array,required:!0},zoomOnClick:{type:Boolean,default:!0},gridSize:{type:Number,default:60},averageCenter:{type:Boolean,default:!1},maxZoom:{type:Number,default:20}},setup(e){const n=o.inject("map");if(!n)return{};const a=new TMap.MarkerCluster({id:e.id,map:o.toRaw(n.value),enableDefaultStyle:e.enableDefaultStyle,minimumClusterSize:e.minimumClusterSize,geometries:M(e.geometries),zoomOnClick:e.zoomOnClick,gridSize:e.gridSize,averageCenter:e.averageCenter,maxZoom:e.maxZoom});return o.watch(()=>e.geometries,l=>{a.setGeometries(M(l))}),{}},render(){return null}});function I(e){const n={};return Object.keys(e).forEach(a=>{n[a]=new TMap.PolylineStyle(e[a])}),n}function S(e){return e.map(n=>({...n,paths:n.paths.map(a=>new TMap.LatLng(a.lat,a.lng))}))}var _=o.defineComponent({name:"tmap-multi-polyline",props:{id:{type:String,default:"default"},zIndex:{type:Number,default:1},styles:{type:Object,required:!0},geometries:{type:Array,required:!0}},setup(e,{attrs:n,emit:a}){const l=o.inject("map");if(!l)return{};const i=o.toRaw(l.value);m(i,e.id);const r=new TMap.MultiPolyline({id:e.id,map:i,zIndex:e.zIndex,styles:I(e.styles),geometries:S(e.geometries)});return p(r,n,a),o.watch(()=>e.zIndex,t=>{r.setZIndex(t)}),o.watch(()=>e.styles,t=>{r.setStyles(I(t))}),o.watch(()=>e.geometries,t=>{r.setGeometries(S(t))}),o.onUnmounted(()=>{r.setMap(null)}),{}},render(){return null}});function q(e,n){return e.reduce((a,l)=>{const i=l[n];return a[i]=l,a},{})}function G(e,n){var a,l;if(e.id!==n.id||e.styleId!==n.styleId||e.rank!==n.rank)return!1;if(e.paths.length===n.paths.length){if(JSON.stringify(e.paths)!==JSON.stringify(n.paths))return!1}else return!1;if(e.properties!==void 0&&n.properties!==void 0){const i=Object.keys(e.properties||{}),r=Object.keys(n.properties||{});if(i.length!==r.length)return!1;for(let t=i.length-1;t>=0;t-=1){const s=i[t];if(((a=e.properties)==null?void 0:a[s])!==((l=n.properties)==null?void 0:l[s]))return!1}}else if(e.properties!==n.properties)return!1;return!0}function O(e){const n={};return Object.keys(e).forEach(a=>{n[a]=new TMap.PolygonStyle(e[a])}),n}function T(e){return e.map(n=>({...n,paths:n.paths.map(a=>new TMap.LatLng(a.lat,a.lng))}))}var L=o.defineComponent({name:"tmap-multi-polygon",props:{id:{type:String,default:"default"},zIndex:{type:Number,default:1},styles:{type:Object,required:!0},geometries:{type:Array,required:!0}},setup(e,{attrs:n,emit:a}){const l=o.inject("map");if(!l)return{};const i=o.toRaw(l.value);let r=e.geometries;m(i,e.id);const t=new TMap.MultiPolygon({id:e.id,map:i,zIndex:e.zIndex,styles:O(e.styles),geometries:T(r)});return p(t,n,a),o.watch(()=>e.zIndex,s=>{t.setZIndex(s)}),o.watch(()=>e.styles,s=>{t.setStyles(O(s))}),o.watch(()=>e.geometries,s=>{const d=q(r,"id"),c=new Set(Object.keys(d)),g=[];s.forEach(y=>{d[y.id]?(c.delete(y.id),G(d[y.id],y)||g.push(y)):g.push(y)}),r=s,c.size>0&&t.remove([...c]),g.length>0&&t.updateGeometries(T(s))}),o.provide("geometry",t),o.onUnmounted(()=>{t.setMap(null)}),{}},render(){return this.$slots.default?this.$slots.default():null}});function N(e){const n={};return Object.keys(e).forEach(a=>{n[a]=new TMap.LabelStyle(e[a])}),n}var R=o.defineComponent({name:"tmap-multi-label",props:{id:{type:String,default:"default"},styles:{type:Object,required:!0},geometries:{type:Array,required:!0},enableCollision:{type:Boolean,required:!1,default:!1}},setup(e,{attrs:n,emit:a}){const l=o.inject("map");if(!l)return{};const i=o.toRaw(l.value);m(i,e.id);const r=s=>s.map(d=>({...d,position:new TMap.LatLng(d.position.lat,d.position.lng)})),t=new TMap.MultiLabel({id:e.id,map:o.toRaw(l.value),styles:N(e.styles),geometries:r(e.geometries),enableCollision:e.enableCollision});return p(t,n,a),o.watch(()=>e.styles,s=>{t.setStyles(N(s))}),o.watch(()=>e.geometries,s=>{t.setGeometries(r(s))}),o.onUnmounted(()=>{t.setMap(null)}),{}},render(){return null}});function E(e){const n={};return Object.keys(e).forEach(a=>{n[a]=new TMap.CircleStyle(e[a])}),n}var j=o.defineComponent({name:"tmap-multi-circle",props:{id:{type:String,default:"default"},zIndex:{type:Number,default:1},styles:{type:Object,required:!0},geometries:{type:Array,required:!0}},setup(e,{attrs:n,emit:a}){const l=o.inject("map");if(!l)return{};const i=o.toRaw(l.value);m(i,e.id);const r=s=>s.map(d=>({...d,center:new TMap.LatLng(d.center.lat,d.center.lng)})),t=new TMap.MultiCircle({id:e.id,map:i,styles:E(e.styles),geometries:r(e.geometries),zIndex:1});return p(t,n,a),o.watch(()=>e.zIndex,s=>{t.setZIndex(s)}),o.watch(()=>e.styles,s=>{t.setStyles(E(s))}),o.watch(()=>e.geometries,s=>{t.setGeometries(r(s))}),o.onUnmounted(()=>{t.setMap(null)}),{}},render(){return null}});const k=e=>new TMap.LatLng(e.lat,e.lng);var A=o.defineComponent({name:"tmap-info-window",props:{id:{type:String,default:"default"},visible:{type:Boolean,required:!0},position:{type:Object,required:!0},content:{type:String,required:!0},zIndex:{type:Number,required:!1,default:0},offset:{type:Object,required:!1,default:()=>({x:0,y:0})},enableCustom:{type:Boolean,required:!1,default:!1}},emits:["close-click"],setup(e,{emit:n}){const a=o.inject("map");if(!a)return{};const l=o.toRaw(a.value);m(l,e.id);const i=k(e.position),r=new TMap.InfoWindow({map:o.toRaw(a.value),position:i,content:e.content,zIndex:e.zIndex,offset:e.offset,enableCustom:e.enableCustom});return r.on("closeclick",()=>{n("close-click")}),o.watch(()=>e.visible,t=>{t?r.open():r.close()}),o.watch(()=>e.content,t=>{r.setContent(t)}),o.watch(()=>e.position,t=>{r.setPosition(k(t))}),o.onUnmounted(()=>{r.destroy()}),{}},render(){return null}}),z=o.defineComponent({name:"tmap-polygon-editor",props:{id:{type:String,default:"default"},zIndex:{type:Number,default:2},snappable:{type:Boolean,default:!0},drawingStyleId:{type:String,default:"drawing"},selectedStyleId:{type:String,default:"selected"},styles:{type:Object,required:!0},modelValue:{type:Array,required:!0},actionMode:{type:Number}},emits:["update:modelValue","select","error"],setup(e,{emit:n}){const a=o.inject("map");if(!a)return{};const l=o.toRaw(a.value);m(l,e.id);const i=T(e.modelValue),r=new TMap.MultiPolygon({id:e.id,map:l,zIndex:e.zIndex,styles:O(e.styles),geometries:i}),t=new TMap.tools.GeometryEditor({map:l,overlayList:[{overlay:r,id:e.id,drawingStyleId:e.drawingStyleId,selectedStyleId:e.selectedStyleId}],actionMode:e.actionMode===1?TMap.tools.constants.EDITOR_ACTION.INTERACT:TMap.tools.constants.EDITOR_ACTION.DRAW,activeOverlayId:e.id,selectable:!0,snappable:e.snappable});return t.on("select",()=>{n("select",t.getSelectedList())}),t.on("draw_complete",s=>{n("update:modelValue",[...e.modelValue,s])}),t.on("adjust_complete",s=>{for(let d=e.modelValue.length-1;d>=0;d-=1)if(e.modelValue[d].id===s.id){Object.assign(e.modelValue[d],s),n("update:modelValue",[...e.modelValue]);break}}),t.on("delete_complete",s=>{const d=s.map(c=>c.id);n("update:modelValue",e.modelValue.filter(c=>d.indexOf(c.id)===-1)),n("select",t.getSelectedList())}),t.on("split_complete",s=>{const d=t.getActiveOverlay();n("update:modelValue",[...d.overlay.getGeometries(),...s]),n("select",t.getSelectedList())}),t.on("union_complete",s=>{const d=t.getActiveOverlay();n("update:modelValue",[...d.overlay.getGeometries(),s]),n("select",t.getSelectedList())}),t.on("split_fail",s=>{n("error",s)}),t.on("union_fail",s=>{n("error",s)}),o.watch(()=>e.actionMode,s=>{const d=s===1?TMap.tools.constants.EDITOR_ACTION.INTERACT:TMap.tools.constants.EDITOR_ACTION.DRAW;t.setActionMode(d)}),o.onUnmounted(()=>{r.setMap(null);try{t.destroy()}catch{}}),{select:t.select.bind(t),stop:t.stop.bind(t),split:t.split.bind(t),union:t.union.bind(t),delete:t.delete.bind(t),destroy:t.destroy.bind(t)}},render(){return null}}),Z=o.defineComponent({name:"tmap-geometry-editor",props:{selectedStyleId:{type:String,default:"selected"}},setup(e){const n=o.inject("map"),a=o.inject("geometry");if(!n||!a)return{};const l=new TMap.tools.GeometryEditor({map:o.toRaw(n.value),overlayList:[{overlay:a,id:a.id,selectedStyleId:e.selectedStyleId}],actionMode:TMap.tools.constants.EDITOR_ACTION.INTERACT,activeOverlayId:a.id,selectable:!0,snappable:!0});return l.on("active_changed",i=>{console.log("active_changed",i)}),l.on("select",i=>{console.log("select",i)}),l.on("draw_complete",i=>{console.log("draw_complete",i)}),l.on("adjust_complete",i=>{console.log("adjust_complete",i)}),l.on("delete_complete",i=>{console.log("delete_complete",i)}),l.on("split_complete",i=>{console.log("split_complete",i)}),l.on("union_complete",i=>{console.log("union_complete",i)}),l.on("split_fail",i=>{console.log("split_fail",i)}),l.on("union_fail",i=>{console.log("union_fail",i)}),{}},render(){return null}});const D=e=>new TMap.LatLng(e.lat,e.lng);var P=o.defineComponent({name:"tmap-dom-overlay",props:{id:{type:String,default:"default"},position:{type:Object,required:!0},offset:{type:Array,required:!1,default:()=>[0,0]}},setup(e,{slots:n}){const a=o.inject("map");if(!a)return{};const l=o.toRaw(a.value);m(l,e.id);const i=o.ref(document.createElement("div")),r=o.computed(()=>D(D(e.position)));class t extends TMap.DOMOverlay{constructor(c){super(c),this.map=c.map,this.onInit(c)}onInit(c){this.ele=c.ele}createDOM(){return this.ele}updateDOM(){const c=this.map.projectToContainer(r.value),g=`${c.getX()-this.ele.clientWidth/2+e.offset[0]}px`,y=`${c.getY()-this.ele.clientHeight/2+e.offset[1]}px`;this.ele.setAttribute("style",`top: ${y}; left: ${g}; position: absolute;`)}onDestroy(){this.ele.innerHTML=""}}let s;return o.onMounted(()=>{s=new t({map:a.value,ele:i.value})}),o.watch(()=>e.position,()=>{s.updateDOM()}),o.onUnmounted(()=>{s.onDestroy()}),()=>o.h("span",{ref:i},n.default?n.default():[])}});const $=[b,w,C,L,_,R,j,A,z,Z,P],B=e=>{$.forEach(n=>{e.component(n.name,n)})};u.DOMOverlay=P,u.InfoWindow=A,u.MarkerCluster=C,u.MultiCircle=j,u.MultiLabel=R,u.MultiMarker=w,u.MultiPolygon=L,u.MultiPolyline=_,u.PolygonEditor=z,u.TMap=b,u.default=B,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(u,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(u=typeof globalThis!="undefined"?globalThis:u||self,n(u["vue-tmap"]={},u.vue))})(this,function(u,n){"use strict";function x(e,a,r){const s=["visualization","tools","geometry",...r||[]];return new Promise(l=>{if(window.TMap){l(window.TMap);return}window.tmapCallback=function(){l(window.TMap)},window.__POWERED_BY_QIANKUN__&&top&&(top.tmapCallback=function(){l(TMap)});const i=document.createElement("script");i.type="text/javascript",i.src=`https://map.qq.com/api/gljs?v=${e}&key=${a}&libraries=${s.join(",")}&callback=tmapCallback`,document.body.appendChild(i)})}function g(e,a,r,s){if(!r){e.removeControl(a);return}const l=e.getControl(a),{position:i,className:t}=r;s[i]&&l.setPosition(s[i]),l.setClassName(t)}var b=n.defineComponent({name:"tmap-map",props:{version:{type:String,default:"1.exp"},mapKey:{type:String,default:""},libraries:{type:Array,default:()=>[]},class:{type:String,default:""},style:{type:Object,default:()=>({})},center:{type:Object,default:()=>({lat:40.040452,lng:116.273486})},zoom:{type:Number,default:17},minZoom:{type:Number,default:3},maxZoom:{type:Number,default:20},rotation:{type:Number,default:0},pitch:{type:Number,default:0},scale:{type:Number,default:1},offset:{type:Object,default:()=>({x:0,y:0})},draggable:{type:Boolean,default:!0},scrollable:{type:Boolean,default:!0},doubleClickZoom:{type:Boolean,default:!0},boundary:{type:Object,default:null},mapStyleId:{type:String},baseMap:{type:Object},viewMode:{type:String,default:"3D"},control:{type:Object,default:()=>({scale:{},zoom:{},rotation:{}})},events:{type:Object,default:()=>({})}},emits:["ready"],setup(e,{emit:a}){const r=n.ref(null),s=n.ref(null);let l,i;const t=[];return Object.keys(e.events).forEach(o=>{t.push(o)}),n.onMounted(async()=>{await x(e.version,e.mapKey,e.libraries),i={topLeft:TMap.constants.CONTROL_POSITION.TOP_LEFT,topCenter:TMap.constants.CONTROL_POSITION.TOP_CENTER,topRight:TMap.constants.CONTROL_POSITION.TOP_RIGHT,centerLeft:TMap.constants.CONTROL_POSITION.CENTER_LEFT,center:TMap.constants.CONTROL_POSITION.CENTER,centerRight:TMap.constants.CONTROL_POSITION.CENTER_RIGHT,bottomLeft:TMap.constants.CONTROL_POSITION.BOTTOM_LEFT,bottomCenter:TMap.constants.CONTROL_POSITION.BOTTOM_CENTER,bottomRight:TMap.constants.CONTROL_POSITION.BOTTOM_RIGHT};const o=new TMap.LatLng(e.center.lat,e.center.lng);r.value&&(l=new TMap.Map(r.value,{center:o,zoom:e.zoom,minZoom:e.minZoom,maxZoom:e.maxZoom,rotation:e.rotation,pitch:e.pitch,scale:e.scale,offset:e.offset,draggable:e.draggable,scrollable:e.scrollable,doubleClickZoom:e.doubleClickZoom,boundary:e.boundary,mapStyleId:e.mapStyleId,baseMap:e.baseMap,viewMode:e.viewMode,showControl:!0}),g(l,TMap.constants.DEFAULT_CONTROL_ID.SCALE,e.control.scale,i),g(l,TMap.constants.DEFAULT_CONTROL_ID.ZOOM,e.control.zoom,i),g(l,TMap.constants.DEFAULT_CONTROL_ID.ROTATION,e.control.rotation,i),t.forEach(d=>{l.on(d,e.events[d])}),s.value=l,a("ready",l))}),n.onUnmounted(()=>{l&&(t.forEach(o=>{l.off(o,e.events[o])}),l.destroy())}),n.watch(()=>[e.center,e.zoom,e.rotation,e.pitch],([o,d,c,f])=>{l&&l.easeTo({center:new TMap.LatLng(o.lat,o.lng),zoom:d,rotation:c,pitch:f},{duration:500})}),n.watch(()=>e.scale,o=>l&&l.setScale(o)),n.watch(()=>e.offset,o=>l&&l.setOffset(o)),n.watch(()=>e.draggable,o=>l&&l.setDraggable(o)),n.watch(()=>e.scrollable,o=>l&&l.setScrollable(o)),n.watch(()=>e.doubleClickZoom,o=>l&&l.setDoubleClickZoom(o)),n.watch(()=>e.boundary,o=>l&&l.setBoundary(o)),n.watch(()=>e.control,o=>{g(l,TMap.constants.DEFAULT_CONTROL_ID.SCALE,o.scale,i),g(l,TMap.constants.DEFAULT_CONTROL_ID.ZOOM,o.zoom,i),g(l,TMap.constants.DEFAULT_CONTROL_ID.ROTATION,o.rotation,i)}),n.provide("map",s),{map:s,el:r,getCenter:()=>l==null?void 0:l.getCenter(),getZoom:()=>l==null?void 0:l.getZoom()}},render(){return n.h("div",{class:this.class,style:{...this.style,height:"100%",width:"100%"},ref:"el"},this.$slots.default&&this.map?this.$slots.default():[])}});function p(e,a,r){const s=[],l=[];Object.keys(a).forEach(i=>{if(i.indexOf("on")===0){const t=i[2].toLowerCase()+i.slice(3);s.push(t),l.push(r.bind(null,t))}}),s.forEach((i,t)=>{e.on(i,l[t])}),n.onUnmounted(()=>{s.forEach((i,t)=>{e.off(i,l[t])})})}function m(e,a){const r=e.getLayer(a);r&&r.setMap(null);const s=e.getLayer(`${a}_border_line`);s&&s.setMap(null);const l=e.getLayer(`${a}_border`);l&&l.setMap(null)}function h(e){const a={};return Object.keys(e).forEach(r=>{a[r]=new TMap.MarkerStyle(e[r])}),a}function M(e){return e.map(a=>({...a,position:new TMap.LatLng(a.position.lat,a.position.lng)}))}var w=n.defineComponent({name:"tmap-multi-marker",props:{id:{type:String,default:"default"},styles:{type:Object,required:!0},geometries:{type:Array,required:!0}},setup(e,{attrs:a,emit:r}){const s=n.inject("map");if(!s)return{};const l=n.toRaw(s.value);m(l,e.id);const i=new TMap.MultiMarker({id:e.id,map:l,styles:h(e.styles),geometries:M(e.geometries)});return p(i,a,r),n.watch(()=>e.styles,t=>{i.setStyles(h(t))}),n.watch(()=>e.geometries,t=>{i.setGeometries(M(t))}),n.onUnmounted(()=>{i.setMap(null)}),{getStyles:i.getStyles,moveAlong:i.moveAlong.bind(i),stopMove:i.stopMove.bind(i),pauseMove:i.pauseMove.bind(i),resumeMove:i.resumeMove.bind(i),on:i.on.bind(i)}},render(){return null}}),C=n.defineComponent({name:"tmap-marker-cluster",props:{id:{type:String,default:"default"},enableDefaultStyle:{type:Boolean,default:!0},minimumClusterSize:{type:Number,default:2},geometries:{type:Array,required:!0},zoomOnClick:{type:Boolean,default:!0},gridSize:{type:Number,default:60},averageCenter:{type:Boolean,default:!1},maxZoom:{type:Number,default:20}},setup(e){const a=n.inject("map");if(!a)return{};const r=new TMap.MarkerCluster({id:e.id,map:n.toRaw(a.value),enableDefaultStyle:e.enableDefaultStyle,minimumClusterSize:e.minimumClusterSize,geometries:M(e.geometries),zoomOnClick:e.zoomOnClick,gridSize:e.gridSize,averageCenter:e.averageCenter,maxZoom:e.maxZoom});return n.watch(()=>e.geometries,s=>{r.setGeometries(M(s))}),{}},render(){return null}});function I(e){const a={};return Object.keys(e).forEach(r=>{a[r]=new TMap.PolylineStyle(e[r])}),a}function S(e){return e.map(a=>({...a,paths:a.paths.map(r=>new TMap.LatLng(r.lat,r.lng))}))}var L=n.defineComponent({name:"tmap-multi-polyline",props:{id:{type:String,default:"default"},zIndex:{type:Number,default:1},styles:{type:Object,required:!0},geometries:{type:Array,required:!0}},setup(e,{attrs:a,emit:r}){const s=n.inject("map");if(!s)return{};const l=n.toRaw(s.value);m(l,e.id);const i=new TMap.MultiPolyline({id:e.id,map:l,zIndex:e.zIndex,styles:I(e.styles),geometries:S(e.geometries)});return p(i,a,r),n.watch(()=>e.zIndex,t=>{i.setZIndex(t)}),n.watch(()=>e.styles,t=>{i.setStyles(I(t))}),n.watch(()=>e.geometries,t=>{i.setGeometries(S(t))}),n.onUnmounted(()=>{i.setMap(null)}),{}},render(){return null}});function q(e,a){return e.reduce((r,s)=>{const l=s[a];return r[l]=s,r},{})}function G(e,a){var r,s;if(e.id!==a.id||e.styleId!==a.styleId||e.rank!==a.rank)return!1;if(e.paths.length===a.paths.length){if(JSON.stringify(e.paths)!==JSON.stringify(a.paths))return!1}else return!1;if(e.properties!==void 0&&a.properties!==void 0){const l=Object.keys(e.properties||{}),i=Object.keys(a.properties||{});if(l.length!==i.length)return!1;for(let t=l.length-1;t>=0;t-=1){const o=l[t];if(((r=e.properties)==null?void 0:r[o])!==((s=a.properties)==null?void 0:s[o]))return!1}}else if(e.properties!==a.properties)return!1;return!0}function O(e){const a={};return Object.keys(e).forEach(r=>{a[r]=new TMap.PolygonStyle(e[r])}),a}function T(e){return e.map(a=>({...a,paths:a.paths.map(r=>new TMap.LatLng(r.lat,r.lng))}))}var N=n.defineComponent({name:"tmap-multi-polygon",props:{id:{type:String,default:"default"},zIndex:{type:Number,default:1},styles:{type:Object,required:!0},geometries:{type:Array,required:!0}},setup(e,{attrs:a,emit:r}){const s=n.inject("map");if(!s)return{};const l=n.toRaw(s.value);let i=e.geometries;m(l,e.id);const t=new TMap.MultiPolygon({id:e.id,map:l,zIndex:e.zIndex,styles:O(e.styles),geometries:T(i)});return p(t,a,r),n.watch(()=>e.zIndex,o=>{t.setZIndex(o)}),n.watch(()=>e.styles,o=>{t.setStyles(O(o))}),n.watch(()=>e.geometries,o=>{const d=q(i,"id"),c=new Set(Object.keys(d)),f=[];o.forEach(y=>{d[y.id]?(c.delete(y.id),G(d[y.id],y)||f.push(y)):f.push(y)}),i=o,c.size>0&&t.remove([...c]),f.length>0&&t.updateGeometries(T(o))}),n.provide("geometry",t),n.onUnmounted(()=>{t.setMap(null)}),{}},render(){return this.$slots.default?this.$slots.default():null}});function R(e){const a={};return Object.keys(e).forEach(r=>{a[r]=new TMap.LabelStyle(e[r])}),a}var _=n.defineComponent({name:"tmap-multi-label",props:{id:{type:String,default:"default"},styles:{type:Object,required:!0},geometries:{type:Array,required:!0},enableCollision:{type:Boolean,required:!1,default:!1}},setup(e,{attrs:a,emit:r}){const s=n.inject("map");if(!s)return{};const l=n.toRaw(s.value);m(l,e.id);const i=o=>o.map(d=>({...d,position:new TMap.LatLng(d.position.lat,d.position.lng)})),t=new TMap.MultiLabel({id:e.id,map:n.toRaw(s.value),styles:R(e.styles),geometries:i(e.geometries),enableCollision:e.enableCollision});return p(t,a,r),n.watch(()=>e.styles,o=>{t.setStyles(R(o))}),n.watch(()=>e.geometries,o=>{t.setGeometries(i(o))}),n.onUnmounted(()=>{t.setMap(null)}),{}},render(){return null}});function E(e){const a={};return Object.keys(e).forEach(r=>{a[r]=new TMap.CircleStyle(e[r])}),a}var j=n.defineComponent({name:"tmap-multi-circle",props:{id:{type:String,default:"default"},zIndex:{type:Number,default:1},styles:{type:Object,required:!0},geometries:{type:Array,required:!0}},setup(e,{attrs:a,emit:r}){const s=n.inject("map");if(!s)return{};const l=n.toRaw(s.value);m(l,e.id);const i=o=>o.map(d=>({...d,center:new TMap.LatLng(d.center.lat,d.center.lng)})),t=new TMap.MultiCircle({id:e.id,map:l,styles:E(e.styles),geometries:i(e.geometries),zIndex:1});return p(t,a,r),n.watch(()=>e.zIndex,o=>{t.setZIndex(o)}),n.watch(()=>e.styles,o=>{t.setStyles(E(o))}),n.watch(()=>e.geometries,o=>{t.setGeometries(i(o))}),n.onUnmounted(()=>{t.setMap(null)}),{}},render(){return null}});const k=e=>new TMap.LatLng(e.lat,e.lng);var z=n.defineComponent({name:"tmap-info-window",props:{id:{type:String,default:"default"},visible:{type:Boolean,required:!0},position:{type:Object,required:!0},content:{type:String,required:!0},zIndex:{type:Number,required:!1,default:0},offset:{type:Object,required:!1,default:()=>({x:0,y:0})},enableCustom:{type:Boolean,required:!1,default:!1}},emits:["close-click"],setup(e,{emit:a}){const r=n.inject("map");if(!r)return{};const s=n.toRaw(r.value);m(s,e.id);const l=k(e.position),i=new TMap.InfoWindow({map:n.toRaw(r.value),position:l,content:e.content,zIndex:e.zIndex,offset:e.offset,enableCustom:e.enableCustom});return i.on("closeclick",()=>{a("close-click")}),n.watch(()=>e.visible,t=>{t?i.open():i.close()}),n.watch(()=>e.content,t=>{i.setContent(t)}),n.watch(()=>e.position,t=>{i.setPosition(k(t))}),n.onUnmounted(()=>{i.destroy()}),{}},render(){return null}}),A=n.defineComponent({name:"tmap-polygon-editor",props:{id:{type:String,default:"default"},zIndex:{type:Number,default:2},snappable:{type:Boolean,default:!0},drawingStyleId:{type:String,default:"drawing"},selectedStyleId:{type:String,default:"selected"},styles:{type:Object,required:!0},modelValue:{type:Array,required:!0},actionMode:{type:Number}},emits:["update:modelValue","select","error"],setup(e,{emit:a}){const r=n.inject("map");if(!r)return{};const s=n.toRaw(r.value);m(s,e.id);const l=T(e.modelValue),i=new TMap.MultiPolygon({id:e.id,map:s,zIndex:e.zIndex,styles:O(e.styles),geometries:l}),t=new TMap.tools.GeometryEditor({map:s,overlayList:[{overlay:i,id:e.id,drawingStyleId:e.drawingStyleId,selectedStyleId:e.selectedStyleId}],actionMode:e.actionMode===1?TMap.tools.constants.EDITOR_ACTION.INTERACT:TMap.tools.constants.EDITOR_ACTION.DRAW,activeOverlayId:e.id,selectable:!0,snappable:e.snappable});return t.on("select",()=>{a("select",t.getSelectedList())}),t.on("draw_complete",o=>{a("update:modelValue",[...e.modelValue,o])}),t.on("adjust_complete",o=>{for(let d=e.modelValue.length-1;d>=0;d-=1)if(e.modelValue[d].id===o.id){Object.assign(e.modelValue[d],o),a("update:modelValue",[...e.modelValue]);break}}),t.on("delete_complete",o=>{const d=o.map(c=>c.id);a("update:modelValue",e.modelValue.filter(c=>d.indexOf(c.id)===-1)),a("select",t.getSelectedList())}),t.on("split_complete",o=>{const d=t.getActiveOverlay();a("update:modelValue",[...d.overlay.getGeometries(),...o]),a("select",t.getSelectedList())}),t.on("union_complete",o=>{const d=t.getActiveOverlay();a("update:modelValue",[...d.overlay.getGeometries(),o]),a("select",t.getSelectedList())}),t.on("split_fail",o=>{a("error",o)}),t.on("union_fail",o=>{a("error",o)}),n.watch(()=>e.actionMode,o=>{const d=o===1?TMap.tools.constants.EDITOR_ACTION.INTERACT:TMap.tools.constants.EDITOR_ACTION.DRAW;t.setActionMode(d)}),n.watch(()=>e.modelValue,o=>{i==null||i.updateGeometries(o)}),n.onUnmounted(()=>{i.setMap(null);try{t.destroy()}catch{}}),{select:t.select.bind(t),stop:t.stop.bind(t),split:t.split.bind(t),union:t.union.bind(t),delete:t.delete.bind(t),destroy:t.destroy.bind(t)}},render(){return null}});const D=e=>new TMap.LatLng(e.lat,e.lng);var P=n.defineComponent({name:"tmap-dom-overlay",props:{id:{type:String,default:"default"},position:{type:Object,required:!0},offset:{type:Array,required:!1,default:()=>[0,0]}},setup(e,{slots:a}){const r=n.inject("map");if(!r)return{};const s=n.toRaw(r.value);m(s,e.id);const l=n.ref(document.createElement("div")),i=n.computed(()=>D(D(e.position)));class t extends TMap.DOMOverlay{constructor(c){super(c),this.map=c.map,this.onInit(c)}onInit(c){this.ele=c.ele}createDOM(){return this.ele}updateDOM(){const c=this.map.projectToContainer(i.value),f=`${c.getX()-this.ele.clientWidth/2+e.offset[0]}px`,y=`${c.getY()-this.ele.clientHeight/2+e.offset[1]}px`;this.ele.setAttribute("style",`top: ${y}; left: ${f}; position: absolute;`)}onDestroy(){this.ele.innerHTML=""}}let o;return n.onMounted(()=>{o=new t({map:r.value,ele:l.value})}),n.watch(()=>e.position,()=>{o.updateDOM()}),n.onUnmounted(()=>{o.onDestroy()}),()=>n.h("span",{ref:l},a.default?a.default():[])}});const Z=[b,w,C,N,L,_,j,z,A,P],$=e=>{Z.forEach(a=>{e.component(a.name,a)})};u.DOMOverlay=P,u.InfoWindow=z,u.MarkerCluster=C,u.MultiCircle=j,u.MultiLabel=_,u.MultiMarker=w,u.MultiPolygon=N,u.MultiPolyline=L,u.PolygonEditor=A,u.TMap=b,u.default=$,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
{
"name": "@karpojs/vue-tmap",
"version": "1.0.2",
"version": "1.0.3",
"description": "基于腾讯地图 JavaScript API GL、TypeScript 封装适用于 Vue3 的高性能地图组件库",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc