jodit-pro
Version:
PRO Version of Jodit Editor
2 lines (1 loc) • 1.96 kB
JavaScript
var g=Object.defineProperty;var n=(o,e)=>g(o,"name",{value:e,configurable:!0});import{onChangeGeometries as p}from"./on-change-geometries.js";import{openPropsDialog as m}from"./open-props-dialog.js";import{updateStateAndGme as c}from"./update-state-and-gme.js";import{uniqueUid as s}from"jodit/esm/core/global.js";import{Icon as d}from"jodit/esm/core/ui/icon.js";import{arrayToPath as h}from"../../../helpers/helpers.js";function L(o,e){var a;const t=this.mapElements[e];if(t){if(t.state.type===o.type)return c.call(this,o,e);t.gme.setMap(null)}let r;switch(o.type){case"text":r=new google.maps.Marker({position:new google.maps.LatLng(o.coordinates[0],o.coordinates[1]),draggable:!0,title:o.text,map:this.map});break;case"marker":r=new google.maps.Marker({position:new google.maps.LatLng(o.coordinates[0],o.coordinates[1]),draggable:!0,label:o.showCaption?o.title:"",title:o.title,icon:o.icon?d.get(o.icon):void 0,map:this.map});break;case"polyline":case"polygon":{const l=h(o.coordinates);r=new google.maps[o.type==="polygon"?"Polygon":"Polyline"]({path:l,strokeColor:o.strokeColor,fillColor:o.fillColor,strokeWeight:o.strokeWeight,editable:!0,draggable:!0,map:this.map,fillOpacity:o.type==="polygon"?o.fillOpacity:1})}break;case"circle":r=new google.maps.Circle({center:new google.maps.LatLng(o.coordinates[0],o.coordinates[1]),radius:o.radius,strokeColor:o.strokeColor,fillColor:o.fillColor,strokeWeight:o.strokeWeight,editable:!0,draggable:!0,map:this.map,fillOpacity:(a=o.fillOpacity)!==null&&a!==void 0?a:1});break}const i={type:o.type,uid:s(),state:o,gme:r};"dragend radius_changed center_changed".split(" ").forEach(l=>r.addListener(l,()=>p.call(this,i,e))),(i.type==="polygon"||i.type==="polyline")&&"insert_at set_at remove_at".split(" ").forEach(l=>i.gme.getPath().addListener(l,()=>p.call(this,i,e))),r.addListener("click",()=>m.call(this,i,e)),this.mapElements[e]=i}n(L,"initOrUpdateElementFromState");export{L as initOrUpdateElementFromState};