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.1 to 1.0.2

dist/components/geometry-editor.d.ts

62

dist/index.js

@@ -1036,2 +1036,63 @@ import { defineComponent, ref, onMounted, onUnmounted, watch, provide, h, inject, toRaw, computed } from "vue";

});
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) => {

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

PolygonEditor,
GeometryEditor,
DOMOverlay

@@ -1130,0 +1192,0 @@ ];

2

dist/index.umd.js

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

(function(u,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(u=typeof globalThis!="undefined"?globalThis:u||self,a(u["vue-tmap"]={},u.vue))})(this,function(u,a){"use strict";function x(e,n,i){const l=["visualization","tools","geometry",...i||[]];return new Promise(s=>{if(window.TMap){s(window.TMap);return}window.tmapCallback=function(){s(window.TMap)},window.__POWERED_BY_QIANKUN__&&top&&(top.tmapCallback=function(){s(TMap)});const o=document.createElement("script");o.type="text/javascript",o.src=`https://map.qq.com/api/gljs?v=${e}&key=${n}&libraries=${l.join(",")}&callback=tmapCallback`,document.body.appendChild(o)})}function f(e,n,i,l){if(!i){e.removeControl(n);return}const s=e.getControl(n),{position:o,className:t}=i;l[o]&&s.setPosition(l[o]),s.setClassName(t)}var b=a.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=a.ref(null),i=a.ref(null);let l,s;const o=[];return Object.keys(e.events).forEach(t=>{o.push(t)}),a.onMounted(async()=>{await x(e.version,e.mapKey,e.libraries),s={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,s),f(l,TMap.constants.DEFAULT_CONTROL_ID.ZOOM,e.control.zoom,s),f(l,TMap.constants.DEFAULT_CONTROL_ID.ROTATION,e.control.rotation,s),o.forEach(r=>{l.on(r,e.events[r])}),i.value=l)}),a.onUnmounted(()=>{l&&(o.forEach(t=>{l.off(t,e.events[t])}),l.destroy())}),a.watch(()=>[e.center,e.zoom,e.rotation,e.pitch],([t,r,d,c])=>{l&&l.easeTo({center:new TMap.LatLng(t.lat,t.lng),zoom:r,rotation:d,pitch:c},{duration:500})}),a.watch(()=>e.scale,t=>l&&l.setScale(t)),a.watch(()=>e.offset,t=>l&&l.setOffset(t)),a.watch(()=>e.draggable,t=>l&&l.setDraggable(t)),a.watch(()=>e.scrollable,t=>l&&l.setScrollable(t)),a.watch(()=>e.doubleClickZoom,t=>l&&l.setDoubleClickZoom(t)),a.watch(()=>e.boundary,t=>l&&l.setBoundary(t)),a.watch(()=>e.control,t=>{f(l,TMap.constants.DEFAULT_CONTROL_ID.SCALE,t.scale,s),f(l,TMap.constants.DEFAULT_CONTROL_ID.ZOOM,t.zoom,s),f(l,TMap.constants.DEFAULT_CONTROL_ID.ROTATION,t.rotation,s)}),a.provide("map",i),{map:i,el:n,getCenter:()=>l==null?void 0:l.getCenter(),getZoom:()=>l==null?void 0:l.getZoom()}},render(){return a.h("div",{class:this.class,style:{...this.style,height:"100%",width:"100%"},ref:"el"},this.$slots.default&&this.map?this.$slots.default():[])}});function g(e,n,i){const l=[],s=[];Object.keys(n).forEach(o=>{if(o.indexOf("on")===0){const t=o[2].toLowerCase()+o.slice(3);l.push(t),s.push(i.bind(null,t))}}),l.forEach((o,t)=>{e.on(o,s[t])}),a.onUnmounted(()=>{l.forEach((o,t)=>{e.off(o,s[t])})})}function m(e,n){const i=e.getLayer(n);i&&i.setMap(null);const l=e.getLayer(`${n}_border_line`);l&&l.setMap(null);const s=e.getLayer(`${n}_border`);s&&s.setMap(null)}function h(e){const n={};return Object.keys(e).forEach(i=>{n[i]=new TMap.MarkerStyle(e[i])}),n}function M(e){return e.map(n=>({...n,position:new TMap.LatLng(n.position.lat,n.position.lng)}))}var w=a.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:i}){const l=a.inject("map");if(!l)return{};const s=a.toRaw(l.value);m(s,e.id);const o=new TMap.MultiMarker({id:e.id,map:s,styles:h(e.styles),geometries:M(e.geometries)});return g(o,n,i),a.watch(()=>e.styles,t=>{o.setStyles(h(t))}),a.watch(()=>e.geometries,t=>{o.setGeometries(M(t))}),a.onUnmounted(()=>{o.setMap(null)}),{getStyles:o.getStyles,moveAlong:o.moveAlong.bind(o),stopMove:o.stopMove.bind(o),pauseMove:o.pauseMove.bind(o),resumeMove:o.resumeMove.bind(o),on:o.on.bind(o)}},render(){return null}}),C=a.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=a.inject("map");if(!n)return{};const i=new TMap.MarkerCluster({id:e.id,map:a.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 a.watch(()=>e.geometries,l=>{i.setGeometries(M(l))}),{}},render(){return null}});function I(e){const n={};return Object.keys(e).forEach(i=>{n[i]=new TMap.PolylineStyle(e[i])}),n}function S(e){return e.map(n=>({...n,paths:n.paths.map(i=>new TMap.LatLng(i.lat,i.lng))}))}var L=a.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:i}){const l=a.inject("map");if(!l)return{};const s=a.toRaw(l.value);m(s,e.id);const o=new TMap.MultiPolyline({id:e.id,map:s,zIndex:e.zIndex,styles:I(e.styles),geometries:S(e.geometries)});return g(o,n,i),a.watch(()=>e.zIndex,t=>{o.setZIndex(t)}),a.watch(()=>e.styles,t=>{o.setStyles(I(t))}),a.watch(()=>e.geometries,t=>{o.setGeometries(S(t))}),a.onUnmounted(()=>{o.setMap(null)}),{}},render(){return null}});function q(e,n){return e.reduce((i,l)=>{const s=l[n];return i[s]=l,i},{})}function Z(e,n){var i,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 s=Object.keys(e.properties||{}),o=Object.keys(n.properties||{});if(s.length!==o.length)return!1;for(let t=s.length-1;t>=0;t-=1){const r=s[t];if(((i=e.properties)==null?void 0:i[r])!==((l=n.properties)==null?void 0:l[r]))return!1}}else if(e.properties!==n.properties)return!1;return!0}function O(e){const n={};return Object.keys(e).forEach(i=>{n[i]=new TMap.PolygonStyle(e[i])}),n}function T(e){return e.map(n=>({...n,paths:n.paths.map(i=>new TMap.LatLng(i.lat,i.lng))}))}var N=a.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:i}){const l=a.inject("map");if(!l)return{};const s=a.toRaw(l.value);let o=e.geometries;m(s,e.id);const t=new TMap.MultiPolygon({id:e.id,map:s,zIndex:e.zIndex,styles:O(e.styles),geometries:T(o)});return g(t,n,i),a.watch(()=>e.zIndex,r=>{t.setZIndex(r)}),a.watch(()=>e.styles,r=>{t.setStyles(O(r))}),a.watch(()=>e.geometries,r=>{const d=q(o,"id"),c=new Set(Object.keys(d)),p=[];r.forEach(y=>{d[y.id]?(c.delete(y.id),Z(d[y.id],y)||p.push(y)):p.push(y)}),o=r,c.size>0&&t.remove([...c]),p.length>0&&t.updateGeometries(T(r))}),a.provide("geometry",t),a.onUnmounted(()=>{t.setMap(null)}),{}},render(){return this.$slots.default?this.$slots.default():null}});function R(e){const n={};return Object.keys(e).forEach(i=>{n[i]=new TMap.LabelStyle(e[i])}),n}var _=a.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:i}){const l=a.inject("map");if(!l)return{};const s=a.toRaw(l.value);m(s,e.id);const o=r=>r.map(d=>({...d,position:new TMap.LatLng(d.position.lat,d.position.lng)})),t=new TMap.MultiLabel({id:e.id,map:a.toRaw(l.value),styles:R(e.styles),geometries:o(e.geometries),enableCollision:e.enableCollision});return g(t,n,i),a.watch(()=>e.styles,r=>{t.setStyles(R(r))}),a.watch(()=>e.geometries,r=>{t.setGeometries(o(r))}),a.onUnmounted(()=>{t.setMap(null)}),{}},render(){return null}});function E(e){const n={};return Object.keys(e).forEach(i=>{n[i]=new TMap.CircleStyle(e[i])}),n}var j=a.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:i}){const l=a.inject("map");if(!l)return{};const s=a.toRaw(l.value);m(s,e.id);const o=r=>r.map(d=>({...d,center:new TMap.LatLng(d.center.lat,d.center.lng)})),t=new TMap.MultiCircle({id:e.id,map:s,styles:E(e.styles),geometries:o(e.geometries),zIndex:1});return g(t,n,i),a.watch(()=>e.zIndex,r=>{t.setZIndex(r)}),a.watch(()=>e.styles,r=>{t.setStyles(E(r))}),a.watch(()=>e.geometries,r=>{t.setGeometries(o(r))}),a.onUnmounted(()=>{t.setMap(null)}),{}},render(){return null}});const k=e=>new TMap.LatLng(e.lat,e.lng);var z=a.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 i=a.inject("map");if(!i)return{};const l=a.toRaw(i.value);m(l,e.id);const s=k(e.position),o=new TMap.InfoWindow({map:a.toRaw(i.value),position:s,content:e.content,zIndex:e.zIndex,offset:e.offset,enableCustom:e.enableCustom});return o.on("closeclick",()=>{n("close-click")}),a.watch(()=>e.visible,t=>{t?o.open():o.close()}),a.watch(()=>e.content,t=>{o.setContent(t)}),a.watch(()=>e.position,t=>{o.setPosition(k(t))}),a.onUnmounted(()=>{o.destroy()}),{}},render(){return null}}),A=a.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 i=a.inject("map");if(!i)return{};const l=a.toRaw(i.value);m(l,e.id);const s=T(e.modelValue),o=new TMap.MultiPolygon({id:e.id,map:l,zIndex:e.zIndex,styles:O(e.styles),geometries:s}),t=new TMap.tools.GeometryEditor({map:l,overlayList:[{overlay:o,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",r=>{n("update:modelValue",[...e.modelValue,r])}),t.on("adjust_complete",r=>{for(let d=e.modelValue.length-1;d>=0;d-=1)if(e.modelValue[d].id===r.id){Object.assign(e.modelValue[d],r),n("update:modelValue",[...e.modelValue]);break}}),t.on("delete_complete",r=>{const d=r.map(c=>c.id);n("update:modelValue",e.modelValue.filter(c=>d.indexOf(c.id)===-1)),n("select",t.getSelectedList())}),t.on("split_complete",r=>{const d=t.getActiveOverlay();n("update:modelValue",[...d.overlay.getGeometries(),...r]),n("select",t.getSelectedList())}),t.on("union_complete",r=>{const d=t.getActiveOverlay();n("update:modelValue",[...d.overlay.getGeometries(),r]),n("select",t.getSelectedList())}),t.on("split_fail",r=>{n("error",r)}),t.on("union_fail",r=>{n("error",r)}),a.watch(()=>e.actionMode,r=>{const d=r===1?TMap.tools.constants.EDITOR_ACTION.INTERACT:TMap.tools.constants.EDITOR_ACTION.DRAW;t.setActionMode(d)}),a.onUnmounted(()=>{o.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=a.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 i=a.inject("map");if(!i)return{};const l=a.toRaw(i.value);m(l,e.id);const s=a.ref(document.createElement("div")),o=a.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(o.value),p=`${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: ${p}; position: absolute;`)}onDestroy(){this.ele.innerHTML=""}}let r;return a.onMounted(()=>{r=new t({map:i.value,ele:s.value})}),a.watch(()=>e.position,()=>{r.updateDOM()}),a.onUnmounted(()=>{r.onDestroy()}),()=>a.h("span",{ref:s},n.default?n.default():[])}});const $=[b,w,C,N,L,_,j,z,A,P],G=e=>{$.forEach(n=>{e.component(n.name,n)})};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=G,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(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"}})});
{
"name": "@karpojs/vue-tmap",
"version": "1.0.1",
"version": "1.0.2",
"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