12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090 |
- /**
- * [ONEMAP.M.toolDraw]
- * @return {[object]}
- */
- define([
- 'html!templates/tools/toolDraw_new',
- 'modDir/service/addressSearch',
- 'css!styles/tools/toolDraw_new'
- ],
- function (tplLayout, addressSearchF) {
- var modValue = {
- label: false,
- // Create an empty GeoJSON collection
- collection: {
- "type": "FeatureCollection",
- "features": []
- },
- globalGuid: '',
- closeSave: false,
- showhideAll: true,
- drawModel: '',
- tipText: '',
- drawGroup: [],
- sdPicker: 'polyline', //手动选择样式
- drawLayerGuids: [], //图形guid存储
- textGuids: [], //文字guid存储
- styleGuid: '',
- textPosition: {}, //文字位置
- ajaxData: {}, //保存&导出内容
- lastGuid: '',
- hdGuid: [],
- clostat: true, //弹窗关闭状态
- tdPoints: {}, //三维点集合
- tdshowData: {
- polyArr: [],
- lineArr: [],
- pointArr: []
- },
- tdian: {},
- tdline: {},
- tdpoly: {},
- tdcircle: {},
- drawType:null
- };
- ONEMAP.D.transArr = {};
- ONEMAP.showhideAll = true;
- var status = {
- initialized: false //是否初始化
- };
- var map3 = map2DViewer.map;
- function init(type) {
- if (!status.initialized) {
- setLayout();
- bindEvent();
- //取消订阅
- unSubscribe();
- //添加订阅
- subscribe();
- status.initialized = true;
- }
- modValue.drawType = type;
- ONEMAP.C.publisher.publish({
- modName: 'toolDraw'
- }, 'toolsd:active');
- $(".draw-polyline-latlngs-picker").css("top", "180px");
- $(".draw-polyline-latlngs-picker h4").dragmove($(".draw-polyline-latlngs-picker"))
- $(".draw-polyline-latlngs-picker h4 span").bind("click", function () {
- $(".draw-polyline-latlngs-picker").hide();
- $(".tsAct li.sd").removeClass('active')
- })
- }
- function isIE() { //ie?
- if (!!window.ActiveXObject || "ActiveXObject" in window) {
- return true;
- } else {
- return false;
- }
- }
- function setLayout() {
- $(tplLayout).appendTo($("#wrapper"));
- if (!ONEMAP.D.isLoad) {
- $("#xingmutishi").addClass('active');
- $("#xingmutishi .close").bind("click", function () {
- $("#xingmutishi").removeClass('active')
- })
- // ONEMAP.C.publisher.publish({ type: 'warning', message: '请先登录以便保存' }, 'noteBar::add');
- }
- if (map23DData.display.map2D) {
- $(".tsAct li.import .importFile").show();
- } else {
- $(".tsAct li.import .importFile").hide();
- }
- $("#topBar .total-content .tools-tool23Dchange").bind("click", function () {
- if (map23DData.display.map2D) {
- change23D('2d')
- } else {
- change23D('3d')
- }
- })
- if (!isIE()) {
- // $(".tsTX").dragmove($(".toolBF"));
- // $(".toolBF").css("top","330px");
- } else {
- // $(".toolBF").css("top","370px");
- }
- }
- //删除当前图形、存储、弹窗
- ONEMAP.C.delPoly = function (id) {
- if (map3._layers[id] == undefined) {
- $("#" + id).remove();
- } else {
- if (map3._layers[id].saveStatu) {
- var ajaxData = {
- _id: map3._layers[id].saveId
- };
- $.ajax({
- type: "GET",
- dataType: 'json',
- url: onemapUrlConfig.userCenterUrl + '/draw/del',
- data: ajaxData,
- success: function (data) {
- ONEMAP.V.loading.loaded();
- if (data.code == 4) {
- ONEMAP.T.noPermission('favorite');
- }
- if (data.code == 3) {
- ONEMAP.T.logout('favorite');
- }
- if (data.success) {
- ONEMAP.C.publisher.publish({
- type: 'success',
- message: '已删除'
- }, 'noteBar::add');
- if (ONEMAP.M.hasOwnProperty('userDraw')) {
- ONEMAP.M.userDraw.getFavData();
- }
- } else {
- ONEMAP.C.publisher.publish({
- type: 'error',
- message: '删除失败'
- }, 'noteBar::add');
- }
- },
- error: function (errorData) {
- ONEMAP.V.loading.loaded();
- }
- });
- }
- map3._layers[id].remove();
- var index = modValue.drawLayerGuids.indexOf(id);
- if (index > -1) {
- modValue.drawLayerGuids.splice(index, 1);
- }
- }
- // 文字清除
- $(".leaflet-marker-icon." + id).remove();
- // 三维点清除
- var aaa = $("#" + id + " h4 .bt").attr("tdm");
- delPoint(aaa);
- delete modValue.tdPoints[aaa];
- deltdCircle(modValue.tdcircle[id]);
- delete modValue.tdcircle[id];
- deltdline(modValue.tdline[id]);
- delete modValue.tdline[id];
- deltdpoly(modValue.tdpoly[id]);
- delete modValue.tdpoly[id];
- // 节点清除
- $("#" + id).remove();
- }
- function setStyle(id) {
- var setObj = {};
- setObj = map3._layers[id];
- var guid = modValue.styleGuid;
- $("." + guid + " .yanse span").off("click").on("click", function () {
- yanse = $(this).attr("class");
- switch (yanse) {
- case "black":
- yanse = "#000";
- break;
- case "blue":
- yanse = "#00f";
- break;
- case "gray":
- yanse = "#828282";
- break;
- case "green":
- yanse = "#007C00";
- break;
- case "orange":
- yanse = "#FF9E02";
- break;
- case "red":
- yanse = "#FE1D23";
- break;
- case "white":
- yanse = "#fff";
- break;
- case "yellow":
- yanse = "#FFFD00";
- break;
- }
- var polyguid = $(this).parents().filter(".pubPop").attr("id");
- map3._layers[polyguid].setStyle({
- "color": yanse
- })
- setStyle(polyguid)
- if (modValue.drawModel == "polygon" || modValue.drawModel == "rectangle") {
- var coods = [];
- for (var j = 0; j < setObj._latlngs[0].length; j++) {
- coods.push([setObj._latlngs[0][j].lng, setObj._latlngs[0][j].lat]);
- }
- coods.push([setObj._latlngs[0][0].lng, setObj._latlngs[0][0].lat]);
- deltdpoly(modValue.tdpoly[id]);
- delete modValue.tdpoly[id];
- var sid = add3DPoly(coods, yanse);
- modValue.tdpoly[id] = sid;
- }
- if (modValue.drawModel == "polyline") {
- var coods = [];
- for (var j = 0; j < setObj._latlngs.length; j++) {
- coods.push([setObj._latlngs[j].lng, setObj._latlngs[j].lat]);
- }
- deltdline(modValue.tdline[id]);
- delete modValue.tdline[id];
- var sid = add3DLine(coods, yanse);
- modValue.tdline[id] = sid;
- }
- if (modValue.drawModel == "circle") {
- var coods = [setObj._latlng.lng, setObj._latlng.lat];
- deltdCircle(modValue.tdcircle[id]);
- delete modValue.tdcircle[id];
- var sid = add3DCircle(coods, setObj._mRadius, yanse);
- modValue.tdcircle[id] = sid;
- }
- // map3.removeLayer(polyguid)
- // ONEMAP.M.userDraw.delFav(polyguid)
- // saveSingle(polyguid);
- })
- }
- ONEMAP.C.setPop = function (guid) {
- ////console.log(guid)
- if (typeof (guid) == "string" || typeof (guid) == "number") {
- modValue.styleGuid = guid;
- } else {
- modValue.styleGuid = guid.id;
- }
- if ($("." + modValue.styleGuid).hasClass("active")) {
- $("." + modValue.styleGuid).removeClass("active")
- } else {
- $("." + modValue.styleGuid).addClass("active")
- }
- }
-
- function deltdline(guid) {
- map3DViewer.polyline({
- action: 'remove',
- guid: guid
- })
- }
- //删除线
- function delPolyline(guid) {
- map3DViewer.polyline({
- action: 'remove',
- guid: guid
- })
- }
-
- //添加3D线段
- function add3DLine(coordinates, color) {
- var GDguid = map3DViewer.polyline({
- action: 'add',
- geojson: {
- "properties": {
- altitudeMode: 0,
- color: color || '#0e74d1',
- weight: 2,
- opacity: 1
- },
- "geometry": {
- "coordinates": coordinates
- }
- }
- })
- return GDguid;
- }
- //修改3D线段
- function updateLine(id, coordinates,color) {
- // var cl = '#0e74d1';
- // if(color){cl = color}
- var GDguid = map3DViewer.polyline({
- action: 'update',
- geojson: {
- "properties": {
- altitudeMode: 0,
- color: color||'#0e74d1',
- weight: 2,
- opacity: 1
- },
- "geometry": {
- "coordinates": coordinates
- }
- },
- guid: id
- })
- return GDguid;
- }
-
-
- //添加点
- function addPoint(title, coordinates, tdurl, color) {
- var ibg = onemapUrlConfig.siteUrl + '/scripts/vendor/leaflet/draw_new/images/marker-icon.png';
- if (tdurl) {
- ibg = tdurl
- }
- var guid = map3DViewer.marker({
- action: 'add',
- // groupId:modValue.markersGroupGuid,
- geojson: {
- "type": "Feature",
- "properties": {
- title: title,
- iconUrl: ibg,
- icon3DUrl: ibg,
- // iconSize: pointStyle.iconSize || '20',
- iconSize: [18, 26],
- // iconAnchor: pointStyle.iconAnchor || [0,0],
- iconAnchor: [0, 0],
- popupAnchor: [0, -30],
- altitlude: 1,
- altitudeMode: 0,
- popupContent: 'afsaf',
- titleColor: color || '#f00000',
- titleFontSize: 20
- },
- "geometry": {
- "type": "Point",
- "coordinates": coordinates
- }
- }
- })
- return guid;
- }
- //更新点
- function updatePoint(title, guid, pointBg, color) {
- var bg = onemapUrlConfig.siteUrl + '/scripts/vendor/leaflet/draw_new/images/marker-icon.png';
- if (pointBg) {
- bg = pointBg
- };
- map3DViewer.marker({
- action: 'update',
- geojson: {
- "properties": {
- title: title,
- iconUrl: bg,
- icon3DUrl: bg,
- titleColor: color || '#f00',
- // titleFontSize: styleInfo.fontSize
- }
- },
- guid: guid
- })
- }
- function updatePointS(title, guid) {
- map3DViewer.marker({
- action: 'update',
- geojson: {
- "properties": {
- title: title
- }
- },
- guid: guid
- })
- }
- //删除点
- function delPoint(guid) {
- map3DViewer.marker({
- action: 'remove',
- guid: guid
- })
- }
- // 获取文字点击位置
- function bindGloCli() {
- document.onclick = function (ev) {
- var oEvent = ev || event;
- var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
- var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
- modValue.textPosition.left = oEvent.clientX + 'px';
- modValue.textPosition.top = oEvent.clientY + 'px';
- }
- }
- // 提示文字
- function moveTip(model) {
- $("#drawTipText").show();
- switch (model) {
- case "point":
- modValue.tipText = '左键点击绘制点标注';
- bindGloCli();
- break;
- case "label":
- modValue.tipText = '左键点击绘制文本标注';
- bindGloCli();
- break;
- case "polyline":
- modValue.tipText = '左键点击绘制路线';
- bindGloCli();
- break;
- case "polygon":
- modValue.tipText = '左键点击绘制面标注';
- bindGloCli();
- break;
- case "rectangle":
- modValue.tipText = '左键点击绘制矩形';
- bindGloCli();
- break;
- case "circle":
- modValue.tipText = '左键点击绘制圆';
- bindGloCli();
- break;
- }
- $("#drawTipText").text(modValue.tipText)
- document.onmousemove = function (ev) {
- var oEvent = ev || event;
- var oDiv = document.getElementById('drawTipText');
- var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
- var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
- oDiv.style.left = oEvent.clientX + scrollLeft + 'px';
- oDiv.style.top = oEvent.clientY + scrollTop + 'px';
- }
- }
- function bindEvent() {
- map3.pm.addControls({
- drawMarker: true,
- drawPolygon: false,
- editPolygon: false,
- drawPolyline: true,
- deleteLayer: false,
- editMode: true,
- toggleEdit: true
- });
- map3.on('pm:drawstart', function (e) {
- var layer = e.workingLayer;
- layer.on('pm:vertexadded', function (e) {
- switch (modValue.drawModel) {
- case "polyline":
- modValue.tipText = '左键双击结束绘制';
- break;
- case "polygon":
- modValue.tipText = '左键点击绘制面标注;点击第一个点完成绘画';
- break;
- case "rectangle":
- modValue.tipText = '左键点击完成绘制';
- break;
- case "circle":
- modValue.tipText = '左键点击完成绘制';
- break;
- }
- $("#drawTipText").text(modValue.tipText)
- });
- layer.on('pm:snapdrag', function (e) {
- // ////console.log(e)
- switch (modValue.drawModel) {
- case "polyline":
- modValue.tipText = '左键双击结束绘制';
- break;
- case "polygon":
- modValue.tipText = '左键点击绘制面标注;点击第一个点完成绘画';
- break;
- case "rectangle":
- modValue.tipText = '左键点击完成绘制';
- break;
- case "circle":
- modValue.tipText = '左键点击完成绘制';
- break;
- }
- $("#drawTipText").text(modValue.tipText)
- });
- });
- // 图形创建后编辑及绑定弹窗
- map3.on('pm:create', function (e) {
- modValue.lastGuid = "";
- bindEdit(e);
- $('#toolsBar .tools-painting').removeClass('cur');
- });
- //移除当前图形选择
- function rmDom(shape) {
- switch (shape) {
- case 4:
- $('.tsTX .polygon').removeClass('active');
- break;
- case 3:
- $('.tsTX .polyline').removeClass('active');
- break;
- case 5:
- $('.tsTX .rectangle').removeClass('active');
- break;
- case 6:
- $('.tsTX .circle').removeClass('active');
- break;
- case 1:
- $('.tsTX .point').removeClass('active');
- break;
- }
- }
- $(".pubPop button.del").bind("click", function () {
- // delPoint(guid);
- // delete modValue.tdPoints[shortGu];
- //console.log("shanchu")
- })
- // 图形绘制
- $(".tsTX li").on("click", function () {
- if (map23DData.display.map2D) {
- $(".tsTX li").not(this).removeClass('active')
- if ($(this).hasClass('active')) {
- $(this).removeClass('active')
- } else {
- $(this).addClass('active')
- $(".tsAct li").removeClass("active");
- $(".draw-polyline-latlngs-picker").hide();
- }
- if ($(this).hasClass("label")) {
- modValue.label = true;
- } else {
- modValue.label = false;
- }
- moveTip($(this).attr("layer"));
- modValue.drawModel = $(this).attr("layer");
- } else if ($(this).hasClass("point")) {
- $(".tsTX li").not(this).removeClass('active')
- if ($(this).hasClass('active')) {
- $(this).removeClass('active')
- } else {
- $(this).addClass('active')
- $(".tsAct li").removeClass("active");
- $(".draw-polyline-latlngs-picker").hide();
- }
- } else {
- alert("三维暂只支持点标注")
- }
- })
-
- /**
- * 下载文件
- */
- var downloadTextFile = function (mobileCode) {
- var v = IEVersion();
- if (v == 'ie' || v == 'Edge') {
- var fileObj = new Blob([mobileCode], {
- type: 'json/application'
- });
- // ////console.log(fileObj);
- window.navigator.msSaveBlob(fileObj, '标注' + getdate() + '.json');
- } else if (v == '-1') {
- var file = new File([mobileCode], '标注' + getdate() + '.json', {
- type: "text/plain;charset=utf-8"
- });
- saveAs(file);
- }
- setTimeout(function () {
- $(".tsAct li.export").removeClass('active')
- }, 200)
- }
-
- //判断是否是IE浏览器,包括Edge浏览器
- function IEVersion() {
- var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
- var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE浏览器
- var isEdge = userAgent.indexOf("Windows NT 6.1; Trident/7.0;") > -1 && !isIE; //判断是否IE的Edge浏览器
- if (isIE) {
- return "ie";
- } else if (isEdge) {
- return "Edge";
- } else {
- return "-1"; //非IE
- }
- }
- var adName = '';
- $("#userDrawAddName").on("change", function () {
- adName = $("#userDrawAddName").val();
- })
- $("#userDrawAddModal .form .sure").bind("click", function () {
- saveDraw(adName + ";" + getdate(), 'all', 'add', false, getdate());
- $("#userDrawAddModal").hide();
- })
- $("#userDrawAddModal .close").bind("click", function () {
- $("#userDrawAddModal").hide();
- })
-
- }
- //获取点位位置信息
- function getPointName(earthLatlng, callback) {
- var addressSearch = new addressSearchF();
- var region = addressSearch.getAddressInfo({
- // zoom: map2DViewer.map.getZoom(),
- zoom: map23DData.view.zoom,
- latLng: [earthLatlng.lat, earthLatlng.lng]
- }, function (data) {
- var data = data.data;
- callback(data.region);
- });
- }
- function popact(guid, type) {
- $(".pubPop").children().not(".pubPop_2").not(".ppfooter").bind("click", function () {
- $(".pubPop_2." + guid).removeClass("active");
- })
- $(".pubPop").children().not(".intro").bind("click", function () {
- $(".popTips").remove();
- })
- $("#" + guid + " .point").unbind("click").bind("click", function () {
- if ($(".pubPop_2." + guid).hasClass("active")) {
- $(".pubPop_2." + guid).removeClass("active")
- } else {
- $(".pubPop_2." + guid).addClass("active");
- }
- })
- $("#" + guid + " h4").dragmove($("#" + guid));
- setTimeout(function () {
- $("#" + guid + " .close").one("click", function () {
- if (modValue.clostat) {
- $("#" + guid).removeClass("active");
- $(".pubPop_2." + guid).removeClass("active");
- $(".popTips").remove();
- saveSingle(guid);
- }
- if (modValue.lastGuid) {
- $("#" + guid).attr('id', modValue.lastGuid);
- }
- })
- }, 200)
- $("#" + guid + " .lineStyle").unbind("click").bind("click", function () {
- setStyle(guid)
- })
- }
- function layerActs(e) {
- var id = e.target._leaflet_id;
- if (e.target.shape == "Marker") {
- var lat = e.latlng.lat;
- var lng = e.latlng.lng;
- $("#" + id + " .ppfooter input").eq(0).val(lat);
- $("#" + id + " .ppfooter input").eq(1).val(lng);
- pTle = "点标注";
- $("#" + id + " h4 .bt").text(pTle);
- getPointName(e.latlng, function (addr) {
- pTle = addr;
- $("#" + id + " h4 .bt").text(addr);
- });
- }
- if ($("#" + id).hasClass("active")) {
- $("#" + id).removeClass("active")
- modValue.clostat = true;
- } else {
- $("#" + id).addClass("active")
- modValue.clostat = false;
- setTimeout(function () {
- modValue.clostat = true;
- }, 400)
- $("#" + id + " .close").unbind("click").bind("click", function () {
- if (modValue.clostat) {
- $("#" + id).removeClass("active");
- $(".pubPop_2." + id).removeClass("active");
- $(".popTips").remove();
- saveSingle(id);
- }
- if (modValue.lastGuid) {
- $("#" + id).attr('id', modValue.lastGuid);
- }
- })
- }
- }
- // 设置文字样式
- function setTxt(lat, lng, guid, type, txtContent, tcolor) {
- var myIcon = L.divIcon({
- html: txtContent,
- className: guid,
- iconSize: 30
- });
- modValue.hdGuid.push(guid);
- modValue.labelCss = {};
- modValue.labelCss = L.marker([lat, lng], {
- icon: myIcon
- }).addTo(map3);
- modValue.labelCss.shape = 'Marker';
- var txtStyle = {
- width: 145,
- font: 28,
- color: '#00f'
- }
- if (type == 'point') {
- txtStyle.width = 200;
- txtStyle.font = 20;
- txtStyle.color = '#f00';
- txtStyle.shadow = '0';
- $(".leaflet-marker-icon." + guid).css({
- 'margin-left': 15 + 'px',
- 'margin-top': -70 + 'px',
- 'text-shadow': 0
- })
- modValue.textGuids.push(guid)
- } else if (type == 'label') {
- $(".leaflet-marker-icon." + guid).css({
- "text-shadow": 1 + "px " + 0 + "px " + 0 + "px #fff"
- })
- $("#" + guid + " .close").unbind("click").bind("click", function () {
- $("#" + guid).removeClass("active");
- $(".pubPop_2." + guid).removeClass("active");
- saveSingle(modValue.labelCss._leaflet_id, guid);
- })
- $(".leaflet-marker-icon." + guid).unbind("click").bind("click", function () {
- if ($("#" + guid).hasClass("active")) {
- $("#" + guid).removeClass("active")
- } else {
- $("#" + guid).addClass("active")
- $("#" + guid + " .close").unbind("click")
- setTimeout(function () {
- $("#" + guid + " .close").unbind("click").bind("click", function () {
- $("#" + guid).removeClass("active");
- $(".pubPop_2." + guid).removeClass("active");
- saveSingle(modValue.labelCss._leaflet_id, guid);
- })
- }, 300)
- }
- })
- }
- modValue.labelCss.options = {
- Oclass: guid,
- Ofz: txtStyle.font,
- Oc: txtStyle.color,
- Off: '黑体',
- txt: txtContent
- }
- map3._layers[modValue.labelCss._leaflet_id].saveStatu = true;
- $(".leaflet-marker-icon." + guid).css({ //设置文字样式
- "width": txtStyle.width + "px",
- "height": "auto",
- "font-size": txtStyle.font + "px",
- "color": txtStyle.color,
- "font-family": "黑体",
- "word-break": "break-all"
- })
- }
- // 切换时更新三维数据
- function up3DrawData() {
- var data = map2DViewer.map._layers;
- $.each(data, function (key, dl) {
-
- if (dl.shape == 'Line') {
- var coods = [];
- for (var j = 0; j < dl._latlngs.length; j++) {
- coods.push([dl._latlngs[j].lng, dl._latlngs[j].lat]);
- }
- updateLine(modValue.tdline[dl._leaflet_id], coods,dl.options.color);
- }
- });
- // return JSON.stringify(data);
- }
- function bindEdit(e) {
- modValue.closeSave = true;
- $(".tsTX li").not(".point").not(".label").removeClass('active')
- // //console.log(e);
- $(".leaflet-popup-tip-container").hide();
- var layer = e.layer || e;
- var shape = e.shape;
- var tdpoint = ''; //三维点guid
- modValue.drawLayerGuids.push(layer._leaflet_id);
- var guid = layer._leaflet_id;
- modValue.globalGuid = guid;
- // //console.log(layer._leaflet_id);
- layer.on('pm:dragend', function (item) {
- console.log(item);
- layer._latlngs = item.target._latlngs;
- });
- map3._layers[guid].shape = shape;
- map3._layers[guid].saveStatu = false;
- var lat, lng;
- var pTle, type;
- if (modValue.label == false) {
- switch (shape) {
- case "Poly":
- pTle = "面标注";
- type = 4;
- $("#drawTipText").hide();
- // 同时添加三维面
- var coods = [];
- for (var j = 0; j < layer._latlngs[0].length; j++) {
- coods.push([layer._latlngs[0][j].lng, layer._latlngs[0][j].lat]);
- }
- var tdguid = add3DPoly(coods);
- modValue.tdpoly[guid] = tdguid;
- break;
- case "Line":
- pTle = "绘制路线";
- type = 3;
- $("#drawTipText").hide();
- // 同时添加三维线段
- var coods = [];
- for (var j = 0; j < layer._latlngs.length; j++) {
- coods.push([layer._latlngs[j].lng, layer._latlngs[j].lat]);
- }
- var tdguid = add3DLine(coods);
- modValue.tdline[guid] = tdguid;
- break;
- case "Rectangle":
- pTle = "矩形";
- type = 5;
- $("#drawTipText").hide();
- // 同时添加三维面
- var coods = [];
- for (var j = 0; j < layer._latlngs[0].length; j++) {
- coods.push([layer._latlngs[0][j].lng, layer._latlngs[0][j].lat]);
- }
- var tdguid = add3DPoly(coods);
- modValue.tdpoly[guid] = tdguid;
- break;
- case "Circle":
- pTle = "圆";
- type = 6;
- $("#drawTipText").hide();
- // 同时添加三维圆
- var coods = [layer._latlng.lng, layer._latlng.lat];
- var tdguid = add3DCircle(coods, layer._mRadius);
- modValue.tdcircle[guid] = tdguid;
- break;
- case "Marker":
- lat = e.marker._latlng.lat || e._latlng.lat;
- lng = e.marker._latlng.lng || e._latlng.lng;
- pTle = "点标注";
- getPointName(e.marker._latlng, function (addr) {
- pTle = addr;
- $("#" + guid + " h4 .bt").text(addr);
- // setTxt(lat,lng,guid,'point',pTle);
- setTxt(lat, lng, guid, 'point', '');
- // 添加三维标注点
- var rs = [lng, lat];
- tdpoint = addPoint(addr, rs);
- modValue.tdian[guid] = tdpoint;
- $("#" + guid + " h4 .bt").attr("tdm", tdpoint);
- // $(".leaflet-marker-icon."+guid).text(pTle);
- });
- type = 1;
- break;
- }
- layer.addEventListener('click', function (e) {
- layerActs(e);
- layer.pm.toggleEdit();
- });
-
- //定制dom
- var popStyle = '';
- if (modValue.drawModel == "point") {
- var popTop = '<div class="pubPop" id="' + guid + '">' +
- '<h4 class=""><span class="bt">' + pTle + '</span><span class="close">×</span></h4>' +
- '<div class="title">标注名称</div>' +
- '<div><input type="text" class="zhuji"></div>' +
- '<div class="intro"><span>附加说明</span>' +
- '<div class="tips">' +
- '<img src="images/tools/new/link.png" alt="链接文本" class="tplink">' +
- '<img src="images/tools/new/img.png" alt="链接图片" class="tpimg">' +
- '<img src="images/tools/new/video.png" alt="链接视频" class="tpvideo">' +
- '</div></div>' +
- '<textarea class="draw-latlngs-textarea"></textarea>';
- var imgUrl = onemapUrlConfig.siteUrl + "/images/tools/new/grayPoint.png";
- popFooter = '<div class="ppfooter bg">' +
- '<img src=' + imgUrl + ' class="yuanbg">' +
- '<input type="text" value="' + layer._latlng.lat + '" class="weizhi">' +
- '<input type="text" value="' + layer._latlng.lng + '" class="weizhi">' +
- '<button class="del" onclick="ONEMAP.C.delPoly(' + guid + ');"></button>' +
- '<button class="point"></button>' +
- '</div>';
- popStyle = '<div class="pubPop_2 style pointSty ' + guid + '">' +
- '<div>图标</div><div class="marker-build-list icon-list">' +
- '<span><img tid="1" src="' + map23DConfig.map23DAssetsUrl + '/images/layout/marker/r1.png"></span>' +
- '<span><img tid="2" src="' + map23DConfig.map23DAssetsUrl + '/images/layout/marker/r2.png"></span>' +
- '<span><img tid="5" src="' + map23DConfig.map23DAssetsUrl + '/images/layout/marker/b1.png"></span>' +
- '<span><img tid="6" src="' + map23DConfig.map23DAssetsUrl + '/images/layout/marker/b2.png"></span>' +
- '<span><img tid="9" src="' + map23DConfig.map23DAssetsUrl + '/images/layout/marker/y1.png"></span>' +
- '<span><img tid="10" src="' + map23DConfig.map23DAssetsUrl + '/images/layout/marker/y2.png"></span>' +
- '</div></div>';
- } else {
- //默认dom
- var popTop = '<div class="pubPop" id="' + guid + '">' +
- '<h4 class=""><span class="bt">' + pTle + '</span><span class="close">×</span></h4>' +
- '<div class="title">路线名称</div>' +
- '<div><input type="text" class="zhuji"></div>' +
- '<div class="intro"><span>附加说明</span>' +
- '<div class="tips">' +
- '<img src="images/tools/new/link.png" alt="链接文本" class="tplink">' +
- '<img src="images/tools/new/img.png" alt="链接图片" class="tpimg">' +
- '<img src="images/tools/new/video.png" alt="链接视频" class="tpvideo">' +
- '</div></div>' +
- '<textarea class="draw-latlngs-textarea"></textarea>';
- popFooter = '<div class="ppfooter">' +
- '<button class="del" onclick="ONEMAP.C.delPoly(' + guid + ')"></button>' +
- '<button class="lineStyle" onclick="ONEMAP.C.setPop(' + String(guid) + ');"></button>' +
- '</div>';
- popStyle = '<div class="pubPop_2 style ' + guid + '">' +
- '<div class="lineColor">线条颜色</div><div class="yanse xt">' +
- '<span class="blue"></span><span class="green"></span>' +
- '<span class="red"></span><span class="orange"></span>' +
- '<span class="yellow"></span><span class="gray"></span>' +
- '<span class="white"></span><span class="black"></span>' +
- '</div></div>';
- }
- var pop = popTop + popFooter + popStyle + '</div>';
- //绑定弹窗
- $("body").append($(pop));
- if (modValue.drawModel == "point") {
- setTimeout(function () {
- $("#" + guid).css({
- "left": modValue.textPosition.left,
- "top": modValue.textPosition.top
- })
- $(".tsTX li.point").click();
- $("#" + guid).addClass("active");
- popact(guid, 'point')
- }, 200)
- // } else if(modValue.drawModel == "circle"){
- } else {
- setTimeout(function () {
- $("#" + guid).css({
- "left": modValue.textPosition.left,
- "top": modValue.textPosition.top
- })
- $("#" + guid).addClass("active");
- popact(guid)
- }, 200)
- }
- // var b = layer.bindPopup(pop).openPopup();
- //样式设置
- map3._layers[guid].lastLayer = {};
- map3._layers[guid].styleStatu = 0;
- //附加说明链接控制
- var poplink = '<div class="pubPop_link popTips" layer="' + guid + '">' +
- '<div class="bt">链接快捷编辑</div>' +
- '<div class="wenzi">链接文字</div>' +
- '<div><input type="text" placeholder="请输入文字..." class="wz"></div>' +
- '<div class="wenzi">链接地址</div>' +
- '<div><input type="text" placeholder="url链接" class="link"><span class="shengcheng">生成</span></div>' +
- '</div>';
- var popimg = '<div class="pubPop_img popTips" layer="' + guid + '">' +
- '<div class="bt">图像快捷编辑</div><div class="wenzi">图像链接</div>' +
- '<div><input type="text" placeholder="url链接" class="link"><span class="shengcheng">生成</span></div>' +
- '</div>';
- var popvideo = '<div class="pubPop_video popTips" layer="' + guid + '">' +
- '<div class="bt">视频快捷编辑</div><div class="wenzi">视频链接</div>' +
- '<div><input type="text" placeholder="url链接" class="link"><span class="shengcheng">生成</span></div>' +
- '</div>';
- var apStatu = 0;
- $("#" + guid + " .intro .tips img.tplink").bind("click", function () {
- if (apStatu != 1) {
- apStatu = 1;
- $("#" + guid + " .popTips").remove();
- $("#" + guid).append($(poplink));
- var pTxt, pLink;
- $("#" + guid + " .pubPop_link div input.link").on("change", function () {
- pLink = $("#" + guid + " .pubPop_link div input.link").val();
- })
- $("#" + guid + " .pubPop_link div input.wz").on("change", function () {
- pTxt = $("#" + guid + " .pubPop_link div input.wz").val();
- })
- $("#" + guid + " .pubPop_link div .shengcheng").bind("click", function () {
- if (pTxt == undefined) {
- pTxt = '链接'
- }
- var a = '<a href="' + pLink + '">' + pTxt + '</a>';
- var v = $("#" + guid + " textarea").val();
- $("#" + guid + " textarea").val(v + a);
- map3._layers[guid].tip = v + a;
- $("#" + guid + " .pubPop_link").remove();
- apStatu = 0;
- })
- } else if (apStatu == 1) {
- $("#" + guid + " .pubPop_link").remove();
- apStatu = 0;
- }
- })
- $("#" + guid + " .intro .tips img.tpimg").unbind("click").bind("click", function () {
- if (apStatu != 2) {
- apStatu = 2;
- $(".popTips").remove();
- $("#" + guid).append($(popimg));
- var pTxt, pLink;
- $(".pubPop_img div input.link").on("change", function () {
- pLink = $(".pubPop_img div input.link").val();
- })
- $(".pubPop_img div .shengcheng").bind("click", function () {
- var a = '<img src="' + pLink + '" alt="图片链接">';
- var v = $("#" + guid + " textarea").val();
- $("#" + guid + " textarea").val(v + a);
- map3._layers[guid].tip = v + a;
- $(".pubPop_img").remove();
- apStatu = 0;
- })
- } else if (apStatu == 2) {
- $(".pubPop_img").remove();
- apStatu = 0;
- }
- })
- $("#" + guid + " .intro .tips img.tpvideo").unbind("click").bind("click", function () {
- if (apStatu != 3) {
- apStatu = 3;
- $(".popTips").remove();
- $("#" + guid).append($(popvideo));
- var pTxt, pLink;
- $(".pubPop_video div input.link").on("change", function () {
- pLink = $(".pubPop_video div input.link").val();
- })
- $(".pubPop_video div .shengcheng").bind("click", function () {
- var a = '<video controls="" autoplay="" name="media"><source src="' + pLink + '" type="video/mp4"></video>';
- var v = $("#" + guid + " textarea").val();
- $("#" + guid + " textarea").val(v + a);
- map3._layers[guid].tip = v + a;
- $(".pubPop_video").remove();
- apStatu = 0;
- })
- } else if (apStatu == 3) {
- $(".pubPop_video").remove();
- apStatu = 0;
- }
- })
- $("#" + guid + " .zhuji").bind("input propertychange", function (event) {
- var viewName = this.value;
- $(".leaflet-marker-icon." + guid).text(viewName)
- map3._layers[guid].zhuji = viewName;
- });
- $("#" + guid + " textarea").bind("input propertychange", function (event) {
- map3._layers[guid].tip = this.value;
- });
- //位置修改
- $("#" + guid + " .ppfooter .yuanbg").bind('click', function (event) {
- // if (event.keyCode == "13") {
- //回车执行跳转
- console.log("ttasdf")
- var wz1 = JSON.parse($("#" + guid + " .ppfooter .weizhi").eq(0).val());
- var wz2 = JSON.parse($("#" + guid + " .ppfooter .weizhi").eq(1).val());
- map2DViewer.map._layers[guid].setLatLng({
- lat: wz1,
- lng: wz2
- });
- var nm = $(".leaflet-marker-icon." + guid).text();
- $(".leaflet-marker-icon." + guid).remove();
- getPointName({
- lat: wz1,
- lng: wz2
- }, function (addr) {
- $("#" + guid + " h4 .bt").text(addr);
- })
- setTxt(wz1, wz2, guid, 'point', nm);
- map23DControl.setView({
- center: {
- lat: wz1,
- lng: wz2
- },
- zoom: map2DViewer.map.getZoom()
- })
- // }
- });
- $("#" + guid + " .ppfooter .weizhi").bind('keydown', function (event) {
- if (event.keyCode == "13") {
- return false;
- }
- })
- if (modValue.drawModel == "point") {
- // 使用用户自己的图标
- var eqIcon;
- // var eqIcon = map23DConfig.map23DAssetsUrl+'/images/layout/marker/roadsign_type_1_m.png';
- var LeafIcon = L.Icon.extend({
- options: {
- iconSize: [25, 41],
- iconAnchor: [12, 41]
- }
- });
- $(".pubPop_2." + guid + " .icon-list span img").unbind("click").bind("click", function () {
- var tid = $(this).attr("tid");
- switch (tid) {
- case "1":
- eqIcon = map23DConfig.map23DAssetsUrl + '/images/layout/marker/r1.png';
- break;
- case "2":
- eqIcon = map23DConfig.map23DAssetsUrl + '/images/layout/marker/r2.png';
- break;
- case "5":
- eqIcon = map23DConfig.map23DAssetsUrl + '/images/layout/marker/b1.png';
- break;
- case "6":
- eqIcon = map23DConfig.map23DAssetsUrl + '/images/layout/marker/b2.png';
- break;
- case "9":
- eqIcon = map23DConfig.map23DAssetsUrl + '/images/layout/marker/y1.png';
- break;
- case "10":
- eqIcon = map23DConfig.map23DAssetsUrl + '/images/layout/marker/y2.png';
- break;
- }
- // ////console.log(eqIcon);
- $(".pubPop_2." + guid + " .icon-list span").removeClass("select");
- $(this).parent().addClass("select")
- var greenIcon = new LeafIcon({
- iconUrl: eqIcon
- });
- layer.setIcon(greenIcon)
- })
- }
- } else if (modValue.drawModel == "label") {
- var lat = e.marker._latlng.lat || e._latlng.lat;
- var lng = e.marker._latlng.lng || e._latlng.lng;
- var labelTitle = '文本注记';
- getPointName(e.marker._latlng, function (addr) {
- labelTitle = addr;
- $("#" + guid + " h4 .bt").text(addr);
- });
- modValue.textGuids.push(guid);
- var popLabel = '<div class="pubPop" id="' + guid + '"><h4 class=""><span class="bt">' + labelTitle + '</span><span class="close">×</span></h4>' +
- '<div class="title">注记文本</div>' +
- '<div><input type="text" class="zhuji" value="新文本"></div>' +
- '<div class="ppfooter">' +
- '<button class="del"></button>' +
- '<button class="txt"></button>' +
- '</div><div class="pubPop_2 ' + guid + '">' +
- '<div class="fontWeight">文字大小</div>' +
- '<div><select class="daxiao">' +
- '<option>大</option><option>中</option><option>小</option>' +
- '</select></div>' +
- '<div class="fontStyle">文字样式</div>' +
- '<div><select class="yangshi">' +
- '<option>黑体</option><option>微软雅黑</option><option>宋体</option>' +
- '</select></div>' +
- '<div class="fontColor">文字颜色</div>' +
- '<div class="yanse zt">' +
- '<span layer="ys1"></span><span layer="ys2"></span>' +
- '<span layer="ys3"></span><span layer="ys4"></span>' +
- '<span layer="ys5"></span><span layer="ys6"></span>' +
- '<span layer="ys7"></span><span layer="ys8"></span>' +
- '</div></div></div>';
- var myIcon = L.divIcon({
- html: "新文本",
- className: guid,
- iconSize: 30
- });
- modValue.hdGuid.push(guid);
- modValue.labelCss = {};
- modValue.labelCss = L.marker([lat, lng], {
- icon: myIcon
- }).addTo(map3);
- modValue.labelCss.shape = 'Label';
- modValue.labelCss.options = {
- Oclass: guid,
- Ofz: 28,
- Oc: '#00f',
- Off: '黑体',
- txt: '新文本'
- }
- map3._layers[modValue.labelCss._leaflet_id].saveStatu = false;
- $(".leaflet-marker-icon." + guid).css({ //设置文字样式
- "width": 145 + "px",
- "height": "auto",
- "font-size": 28 + "px",
- "color": "#00f",
- "text-shadow": 1 + "px " + 0 + "px " + 0 + "px #fff",
- "font-family": "黑体",
- "word-break": "break-all"
- })
- //绑定弹窗
- $("body").append($(popLabel));
- setTimeout(function () {
- $("#" + guid).addClass("active");
- $("#" + guid).css({
- "left": modValue.textPosition.left,
- "top": modValue.textPosition.top
- })
- $(".tsTX li.label").click();
- }, 200)
- var rs = [lng, lat];
- var tdlabel = "新文本";
- var color = "#00f";
- var ibg = '../../scripts/vendor/leaflet/draw_new/images/marker-icon.png';
- // setTxt(lat,lng,guid,'label','新文本');//添加二维文本
- map3._layers[guid].shape = 'Label';
- var tdguid = addPoint(tdlabel, rs, ibg, '#00f'); // 添加三维文本
- modValue.tdian[guid] = tdguid;
- $(".pubPop").children().not(".pubPop_2").not(".ppfooter").unbind("click").bind("click", function () {
- $(".pubPop_2." + guid).removeClass("active");
- })
- $(".pubPop").children().not(".intro").bind("click", function () {
- $(".popTips").remove();
- })
- $("#" + guid + " h4").dragmove($("#" + guid));
- // var b = layer.bindPopup(popLabel).openPopup();
- $("#" + guid + " button.del").bind("click", function () {
- // ////console.log("del")
- $("#" + guid).remove();
- $(".leaflet-marker-icon." + guid).remove();
- map3._layers[guid].remove();
- })
- $("#" + guid + " .close").one("click", function () {
- $("#" + guid).removeClass("active");
- $(".pubPop_2." + guid).removeClass("active");
- saveSingle(modValue.labelCss._leaflet_id, guid);
- })
- $(".leaflet-marker-icon." + guid).unbind("click").bind("click", function () {
- $("#" + guid).addClass('active');
- setTimeout(function () {
- $("#" + guid + " .close").one("click", function () {
- $("#" + guid).removeClass("active");
- $(".pubPop_2." + guid).removeClass("active");
- saveSingle(modValue.labelCss._leaflet_id, guid);
- })
- }, 250)
- })
- $("#" + guid + " .zhuji").bind("input propertychange", function (event) {
- tdlabel = this.value;
- $(".leaflet-marker-icon." + guid).text(tdlabel);
- map3._layers[guid].zhuji = tdlabel;
- modValue.labelCss.options.txt = tdlabel;
-
- });
- $("#" + guid + " button.txt").bind("click", function () {
- if ($(".pubPop_2." + guid).hasClass("active")) {
- $(".pubPop_2." + guid).removeClass("active")
- } else {
- $(".pubPop_2." + guid).addClass("active")
- }
- })
- //文本样式设置
- var daxiao = 28,
- ziti = 'Microsoft yahei',
- yanse = '#000';
- $("#" + guid + " .daxiao").on("change", function () {
- if ($(this).val() == '大') {
- daxiao = 28;
- } else if ($(this).val() == '中') {
- daxiao = 20;
- } else if ($(this).val() == '小') {
- daxiao = 12;
- }
- $(".leaflet-marker-icon." + guid).css("font-size", daxiao + "px");
- // map3._layers[guid].options.Ofz = daxiao;
- modValue.labelCss.options.Ofz = daxiao;
- })
- $("#" + guid + " .yangshi").on("change", function () {
- ziti = $(this).val();
- if ($(this).val() == '微软雅黑') {
- ziti = 'Microsoft yahei';
- }
- $(".leaflet-marker-icon." + guid).css("font-family", ziti);
- // map3._layers[guid].options.Off = ziti;
- modValue.labelCss.options.Off = ziti;
- })
- $("#" + guid + " .yanse span").on("click", function () {
- yanse = $(this).attr("layer");
- var sd = "fff";
- switch (yanse) {
- case "ys8":
- yanse = "#000";
- break;
- case "ys1":
- yanse = "#00f";
- break;
- case "ys6":
- yanse = "#828282";
- break;
- case "ys2":
- yanse = "#007C00";
- break;
- case "ys4":
- yanse = "#FF9E02";
- sd = "000";
- break;
- case "ys3":
- yanse = "#FE1D23";
- break;
- case "ys7":
- yanse = "#fff";
- sd = "000";
- break;
- case "ys5":
- yanse = "#FFFD00";
- sd = "000";
- break;
- }
- $(".leaflet-marker-icon." + guid).css({
- "color": yanse,
- "text-shadow": 1 + "px " + 0 + "px " + 0 + "px #" + sd
- });
- // map3._layers[guid].options.Oc = yanse;
- modValue.labelCss.options.Oc = yanse;
- $("#" + guid + " .yanse span").not(this).removeClass("active");
- $(this).addClass("active");
- })
- }
- }
- // 删除旧的页面标注
- function cleanOld() {
- // 清除旧的三维数据
- var oldtd = modValue.tdshowData;
- $.each(oldtd.polyArr, function (key, dl) {
- delPolygon(dl);
- var index = oldtd.polyArr.indexOf(dl);
- if (index > -1) {
- oldtd.polyArr.splice(index, 1);
- }
- })
- $.each(oldtd.lineArr, function (key, dl) {
- delPolyline(dl);
- var index = oldtd.lineArr.indexOf(dl);
- if (index > -1) {
- oldtd.lineArr.splice(index, 1);
- }
- })
- $.each(oldtd.pointArr, function (key, dl) {
- delPoint(dl);
- var index = oldtd.pointArr.indexOf(dl);
- if (index > -1) {
- oldtd.pointArr.splice(index, 1);
- }
- })
- }
- // 展示当前页
- function showDraw(data) {
- var tuxingData = JSON.parse(data.draw_data);
- var layer;
- var Did = data._id;
- $(".leaflet-marker-icon." + Did).remove();
- $("#" + Did).remove();
- if (data.name.indexOf(";") > -1) {
- var darr = data.name.split(";");
- data.name = darr[0];
- data.tip = darr[2];
- }
- ////console.log(tuxing);
- var tuxing = [];
- var LeafIcon = L.Icon.extend({
- options: {
- iconSize: [25, 41],
- iconAnchor: [12, 41]
- }
- });
- if (tuxingData.shape) {
- tuxing.push(tuxingData);
- } else {
- tuxing = tuxingData;
- }
- // $("#userContent .userInfo .moreLink .linkList li.myBh").show();
- for (var i = 0; i < tuxing.length; i++) {
- if (tuxing[i].shape == 'Poly') {
- if (!tuxing[i].zhuji) {
- tuxing[i].zhuji = data.name;
- }
- layer = L.polygon(tuxing[i].LatLngs, tuxing[i].options).addTo(map3);
- layer.shape = 'Poly';
- // 同时添加三维面
- var coods = [];
- for (var j = 0; j < tuxing[i].LatLngs[0].length; j++) {
- coods.push([tuxing[i].LatLngs[0][j].lng, tuxing[i].LatLngs[0][j].lat]);
- }
- coods.push([tuxing[i].LatLngs[0][0].lng, tuxing[i].LatLngs[0][0].lat]);
- var polyid;
- if (tuxing[i].options.color) {
- polyid = add3DPoly(coods, tuxing[i].options.color);
- } else {
- polyid = add3DPoly(coods);
- }
- modValue.tdpoly[layer._leaflet_id] = polyid;
- // modValue.tdshowData.polyArr.push(polyid);
- }
- if (tuxing[i].shape == 'Line') {
- if (!tuxing[i].zhuji) {
- tuxing[i].zhuji = data.name;
- }
- layer = L.polyline(tuxing[i].LatLngs, tuxing[i].options).addTo(map3);
- layer.shape = 'Line';
- // 同时添加三维线段
- var coods = [];
- for (var j = 0; j < tuxing[i].LatLngs.length; j++) {
- coods.push([tuxing[i].LatLngs[j].lng, tuxing[i].LatLngs[j].lat]);
- }
- var lineid;
- if (tuxing[i].options.color) {
- lineid = add3DLine(coods, tuxing[i].options.color);
- } else {
- lineid = add3DLine(coods);
- }
- modValue.tdline[layer._leaflet_id] = lineid;
- // modValue.tdshowData.lineArr.push(lineid);
- }
- if (tuxing[i].shape == 'Rectangle') {
- if (!tuxing[i].zhuji) {
- tuxing[i].zhuji = data.name;
- }
- layer = L.polygon(tuxing[i].LatLngs, tuxing[i].options).addTo(map3);
- layer.shape = 'Rectangle';
- // 同时添加三维面
- var coods = [];
- for (var j = 0; j < tuxing[i].LatLngs[0].length; j++) {
- coods.push([tuxing[i].LatLngs[0][j].lng, tuxing[i].LatLngs[0][j].lat]);
- }
- coods.push([tuxing[i].LatLngs[0][0].lng, tuxing[i].LatLngs[0][0].lat]);
- var polyid;
- if (tuxing[i].options.color) {
- polyid = add3DPoly(coods, tuxing[i].options.color);
- } else {
- polyid = add3DPoly(coods);
- }
- modValue.tdpoly[layer._leaflet_id] = polyid;
- // modValue.tdshowData.polyArr.push(polyid);
- }
- if (tuxing[i].shape == 'Marker') {
- if (!tuxing[i].zhuji) {
- tuxing[i].zhuji = data.name;
- }
- if (tuxing[i].options.icon) {
- var xinOp = {};
- xinOp.draggable = tuxing[i].options.draggable;
- xinOp.opacity = tuxing[i].options.opacity;
- layer = L.marker(tuxing[i].LatLngs, xinOp).addTo(map3);
- var eqIcon = tuxing[i].options.icon.options.iconUrl;
- var greenIcon = new LeafIcon({
- iconUrl: eqIcon
- });
- layer.setIcon(greenIcon)
- } else {
- layer = L.marker(tuxing[i].LatLngs, tuxing[i].options).addTo(map3);
- }
- layer.shape = 'Marker';
- // 同时添加文本注记
- var myIcon = L.divIcon({
- html: tuxing[i].zhuji || data.name,
- className: Did,
- iconSize: 30
- });
- var atxt = L.marker([tuxing[i].LatLngs.lat, tuxing[i].LatLngs.lng], {
- icon: myIcon
- }).addTo(map3);
- $(".leaflet-marker-icon." + Did).css({ //设置文字样式
- "width": 200 + "px",
- "height": "auto",
- "font-size": 20 + "px",
- "color": '#f00',
- "word-break": "break-all",
- 'margin-left': 15 + 'px',
- 'margin-top': -70 + 'px',
- })
- $(".leaflet-marker-icon." + Did).prev().addClass(Did.toString()); //Marker添加class
- modValue.textGuids.push(Did);
- // 同时添加三维数据
- var rs = [tuxing[i].LatLngs.lng, tuxing[i].LatLngs.lat]
- var guid = '';
- if (tuxing[i].options.icon) {
- var eqIcon = tuxing[i].options.icon.options.iconUrl;
- guid = addPoint(tuxing[i].zhuji || data.name, rs, eqIcon);
- modValue.tdian[layer._leaflet_id] = guid;
- } else {
- guid = addPoint(tuxing[i].zhuji || data.name, rs)
- modValue.tdian[layer._leaflet_id] = guid;
- }
- //展示后的三维数据存储到tdPoints中
- var os = {};
- os.lng = tuxing[i].LatLngs.lng;
- os.lat = tuxing[i].LatLngs.lat;
- var tdm = {
- guid: guid,
- shape: 'Marker',
- LatLngs: os,
- options: '',
- zhuji: tuxing[i].zhuji || data.name,
- tip: data.tip || '',
- erid: Did
- };
- ONEMAP.D.transArr[Did] = guid;
- modValue.tdPoints[guid] = tdm;
- // 展示中存储
- // modValue.tdshowData.pointArr.push(guid);
- }
- if (tuxing[i].shape == 'Label') {
- var myIcon = L.divIcon({
- html: data.name || tuxing[i].options.txt,
- className: tuxing[i].options.Oclass,
- iconSize: 30
- });
- // layer = L.marker(tuxing[i].LatLngs, { icon: myIcon }).addTo(map3);
- if (tuxing[i].options.Oclass) {
- layer = L.marker(tuxing[i].LatLngs, {
- icon: myIcon
- }).addTo(map3);
- } else {
- layer = {};
- }
- $(".leaflet-marker-icon." + tuxing[i].options.Oclass).css({ //设置文字样式
- "width": 145 + "px",
- "height": "auto",
- "font-size": tuxing[i].options.Ofz + "px",
- "color": tuxing[i].options.Oc,
- "text-shadow": 1 + "px " + 0 + "px " + 0 + "px #fff",
- "font-family": tuxing[i].options.Off,
- "word-break": "break-all",
- "opacity": 1
- })
- $(".leaflet-marker-icon." + tuxing[i].options.Oclass).addClass(Did.toString());
- layer.shape = 'Label';
- tuxing[i].zhuji = data.name || tuxing[i].options.txt;
- // 同时添加三维数据
- var rs = [tuxing[i].LatLngs.lng, tuxing[i].LatLngs.lat]
- var guid = '';
- var ibg = '../../scripts/vendor/leaflet/draw_new/images/marker-icon.png';
- // if(tuxing[i].options.icon){
- // var eqIcon = tuxing[i].options.icon.options.iconUrl;
- // guid = addPoint(tuxing[i].zhuji||data.name,rs,eqIcon);
- // modValue.tdian[atxt._leaflet_id] = guid;
- // } else{
- guid = addPoint(tuxing[i].zhuji || data.name, rs, ibg, tuxing[i].options.Oc || '#00f')
- modValue.tdian[layer._leaflet_id] = guid;
- // }
- }
- if (tuxing[i].shape == 'Circle') {
- if (!tuxing[i].zhuji) {
- tuxing[i].zhuji = data.name;
- }
- var cl = '#3388ff'
- if (tuxing[i].options.color) {
- cl = tuxing[i].options.color
- }
- layer = new L.Circle(tuxing[i].LatLngs, tuxing[i].options.radius, {
- color: cl, //颜色
- fillColor: tuxing[i].options.fillColor || cl,
- fillOpacity: tuxing[i].options.fillOpacity || 0.5, //透明度
- }).addTo(map3);
- layer.shape = 'Circle';
- // 添加三维圆
- var rs = [tuxing[i].LatLngs.lng, tuxing[i].LatLngs.lat]
- var guid = add3DCircle(rs, tuxing[i].options.radius, cl);
- modValue.tdcircle[layer._leaflet_id] = guid;
- }
- // Did = 'd_'+(Did+i);
- // Did = Did+i;
- ////console.log(layer);
- if (layer != undefined) {
- modValue.drawLayerGuids.push(layer._leaflet_id);
- }
- var label = '';
- if ((tuxing[i].zhuji || tuxing[i].tip) && tuxing[i].options.opacity != 0.0001) {
- if (tuxing[i].tip == undefined || tuxing[i].tip == 'undefined' || typeof (tuxing[i].tip) == undefined) {
- tuxing[i].tip = '';
- }
- if (tuxing[i].zhuji == undefined || tuxing[i].zhuji == 'undefined' || typeof (tuxing[i].zhuji) == undefined) {
- tuxing[i].zhuji = '';
- }
- if (data.tip) {
- tuxing[i].tip = data.tip;
- }
- label = '<div class="pubPop pubPopRe ' + layer._leaflet_id + '" id="' + Did + '">' +
- '<h4 class=""><span class="bt">' + data.name + '</span><span class="close">×</span><span class="del"></span></h4>' +
- '<div class="title">注记文本<button class="cgEdit">修改</button></div>' +
- '<div><input type="text" class="zhuji" value="' + tuxing[i].zhuji + '" readonly="readonly"></div>' +
- '<div class="intro"><span>附加说明</span></div>' +
- '<textarea class="draw-latlngs-textarea">' + tuxing[i].tip + '</textarea>' +
- '<div class="yingXiang">' + tuxing[i].tip + '</div></div>';
- $(label).appendTo($("#wrapper"))
- var lingid;
- layer.addEventListener('click', function (e) {
- //console.log(e);
- lingid = e.target._leaflet_id;
- $("." + lingid).css({
- "left": e.containerPoint.x + 30 + "px",
- "top": e.containerPoint.y + 30 + "px"
- });
- if ($("." + lingid).hasClass("xianshi")) {
- $("." + lingid).removeClass("xianshi");
- } else {
- $("." + lingid).addClass("xianshi")
- modValue.cln = false;
- $("#" + Did + " .close").unbind("click").bind("click", function () {
- if (modValue.cln) {
- // if(map3._layers[layer._leaflet_id]){map3._layers[layer._leaflet_id].remove();}
- $("#" + Did).removeClass("xianshi");
- }
- })
- setTimeout(function () {
- modValue.cln = true;
- }, 250)
- }
- })
- //列表弹窗拖拽
- $("#" + Did + " h4").dragmove($("#" + Did));
- // $("#"+Did).show();
- map3._layers[layer._leaflet_id].zhuji = $("#" + Did + " .zhuji").val();
- map3._layers[layer._leaflet_id].tip = $("#" + Did + " .draw-latlngs-textarea").val()
- $("#" + Did + " .zhuji").bind("input propertychange", function (event) {
- map3._layers[layer._leaflet_id].zhuji = this.value;
- data.name = this.value;
- });
- //删除
- $("#" + Did + ".pubPop h4 .del").bind("click", function () {
- $("#" + Did).remove();
- // 三维删除
- delPoint(modValue.tdian[layer._leaflet_id]);
- delete modValue.tdian[layer._leaflet_id];
- deltdCircle(modValue.tdcircle[layer._leaflet_id]);
- delete modValue.tdcircle[layer._leaflet_id];
- deltdline(modValue.tdline[layer._leaflet_id]);
- delete modValue.tdline[layer._leaflet_id];
- deltdpoly(modValue.tdpoly[layer._leaflet_id]);
- delete modValue.tdpoly[layer._leaflet_id];
- // 二维删除
- map3.removeLayer(map3._layers[layer._leaflet_id]);
- $(".leaflet-marker-icon." + Did).remove();
- // 收藏删除
- ONEMAP.M.userDraw.delFav(Did);
- // $("#usdFavor #userFavList dt."+Did).find(".del").click();
- })
- // $("#"+Did+" .tName").bind("input propertychange",function(event){
- // data.name = this.value;
- // });
- $("#" + Did + " .draw-latlngs-textarea").bind("input propertychange", function (event) {
- map3._layers[layer._leaflet_id].tip = this.value;
- data.tip = this.value;
- });
- $("#" + Did + " .cgEdit").bind("click", function () {
- if ($(this).hasClass('cur')) {
- //无update,change方法
- // saveDraw(data.name,'all','update',Did);
- updateDraw(Did, data.name + ";" + getdate() + ";" + data.tip);
- $("#" + Did + " .bt").text(data.name);
- $(".leaflet-marker-icon." + Did).text(data.name);
- //信息已修改
- // map3._layers[layer._leaflet_id].remove();
- // $("#"+Did).remove();
- $("#" + Did).removeClass("xianshi");
- } else {
- $("#" + Did + " .zhuji").removeAttr("readonly");
- $("#" + Did + " .draw-latlngs-textarea").show();
- // $("#"+Did+" .tName").show();
- $("#" + Did + " .yingXiang").hide();
- $(this).text("完成");
- $(this).addClass('cur')
- }
- });
- // setTimeout(function(){
- // $("#"+Did+" .close").unbind("click").bind("click",function(){
- // // if(map3._layers[layer._leaflet_id]){map3._layers[layer._leaflet_id].remove();}
- // $("#"+Did).removeClass("xianshi");
- // })
- // },250)
- }
- }
- // if(map23DData.display.map2D){
- // modValue.controlAll();
- // }
- // 用户中心删除
- $("#userFavList .sure").bind("click", function () {
- console.log("223423")
- // map3._layers[layer._leaflet_id].remove();
- // $("#"+Did).remove();
- // $("."+tuxing[i].options.Oclass).remove();
- })
- }
- //更新数据
- function updateDraw(guid, name) {
- var options = {};
- options._id = guid;
- options.name = name;
- $.ajax({
- type: "get",
- dataType: 'json',
- url: onemapUrlConfig.userCenterUrl + '/draw/update',
- data: options,
- success: function (data) {
- console.log(data);
- ONEMAP.M.userDraw.getFavData();
- }
- })
- }
- //保存数据
- function saveDraw(name, quantity, action, guid, infoName) {
- //构造数据
- modValue.ajaxData.name = name;
- modValue.ajaxData.center_lon = map2DViewer.map.getCenter()['lng'];
- modValue.ajaxData.center_lat = map2DViewer.map.getCenter()['lat'];
- modValue.ajaxData.initial_zoom = map2DViewer.map.getZoom();
- modValue.ajaxData.map_type = 1;
- if (quantity == 'all') {
- modValue.ajaxData.draw_data = jsonDrawData();
- } else {
- modValue.ajaxData.draw_data = createSingleData(quantity);
- }
- // if(action == 'update'){
- // modValue.ajaxData._id = guid;
- // }
- modValue.ajaxData.info = 'newdraw;' + infoName || 'newdraw'; //其他信息
- // if(info){
- // modValue.ajaxData.info = info;
- // }
- ////console.log(modValue.ajaxData)
- ONEMAP.V.loading.load();
- $.ajax({
- type: "post",
- dataType: 'json',
- url: onemapUrlConfig.userCenterUrl + '/draw/' + action,
- data: modValue.ajaxData,
- success: function (data) {
- //console.log(data)
- ONEMAP.V.loading.loaded();
- if (data.code == 4) {
- ONEMAP.T.noPermission('favorite');
- }
- if (data.code == 3) {
- ONEMAP.T.logout('favorite');
- }
- if (data.success) {
- ONEMAP.C.publisher.publish({
- type: 'success',
- message: '保存成功,可在“用户中心-我的收藏-绘制路线”中打开'
- }, 'noteBar::add');
- if (ONEMAP.M.hasOwnProperty('userDraw')) {
- //ONEMAP.M.userDraw.isFavDataChange = true;
- ONEMAP.M.userDraw.getFavData();
- }
- if (guid) {
- map3._layers[guid].saveId = data.id;
- }
- } else if (data.msg == '标绘名已存在') {
- ONEMAP.C.publisher.publish({
- type: 'warning',
- message: '名称重复,请填写注记文本'
- }, 'noteBar::add');
- }
- },
- error: function (errorData) {
- ONEMAP.V.loading.loaded();
- }
- });
- }
- //创建单个绘制数据
- function createSingleData(dl) {
- var dlItem = {
- shape: dl.shape,
- options: dl.options,
- zhuji: dl.zhuji,
- tip: dl.tip
- }
- if (dl._latlngs && dl.options.fillOpacity != 1) {
- dlItem.LatLngs = dl._latlngs;
- }
- if (dl._latlng) {
- dlItem.LatLngs = dl._latlng;
- }
- //console.log(JSON.stringify(dlItem));
- return JSON.stringify(dlItem);
- }
- function getdate() {
- var now = new Date(),
- y = now.getFullYear(),
- m = now.getMonth() + 1,
- d = now.getDate();
- return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 8);
- }
- //保存单个绘制
- function saveSingle(id, delId) {
- // if(modValue.drawModel=='label'||modValue.drawModel=='point'){
- var info = $("#" + id + " h4 .bt").text() + " " + getdate();
- var name = '未命名标注';
- var sName = name + ";" + getdate();
- var zj = $("#" + id + " .zhuji").val();
- if (zj != "") {
- sName = zj + ";" + getdate();
- }
- var sst;
- if (map3._layers[id] != undefined) {
- sst = map3._layers[id].saveStatu;
- if (map3._layers[id].shape == "Label") {
- info = $("#" + delId + " h4 .bt").text() + " " + getdate();
- }
- } else {
- sst = false
- }
- if (id != undefined && id != 'undefined' && typeof (id) != undefined && (!isNaN(id)) && sst == false && map3._layers[id] != undefined) {
- // if(id!=undefined&&id!='undefined'&&typeof(id)!=undefined&&(!isNaN(id))&&map3._layers[id]!=undefined){
- // if(modValue.drawModel=='label'||modValue.drawModel=='point'||id==modValue.globalGuid&&modValue.closeSave){
- var zt = '';
- if (modValue.drawModel == 'label') {
- var zt = map3._layers[id].options.txt;
- sName = zt + ";" + getdate();
- } else {
- if (map3._layers[id]._latlngs) {
- // map3._layers[id].setStyle({"color":"#00f"})
- }
- if (map3._layers[id]._latlng) {
- // map3._layers[id].setOpacity(1);
- }
- }
- //console.log("保存标注");
- //console.log(map3._layers[id]);
- // saveDraw(sName,map3._layers[id],'add',id,showName);
- if (zt != undefined && map3._layers[id].options.opacity != 0.0001) {
- saveDraw(sName, map3._layers[id], 'add', id, info);
- // saveDraw(sName,'all','add');
- map3._layers[id].saveStatu = true;
- modValue.closeSave = false;
- }
- }
- // }
- }
- //获取上一个标注id
- function getLastId(e) {
- // if(!modValue.labelCss){
- $(".pubPop .close").click();
- var pop = $(".pubPop");
- var length = pop.length;
- var id = parseInt(pop.eq(length - 1).attr("id"));
- if (id > 0) {
- saveSingle(id);
- }
- // } else{
- // $(".pubPop .close").click();
- // }
- }
- /**
- * 解析DrawGroup图层信息并返回JSON串
- * @returns {*}
- * @private
- */
- function jsonDrawData() {
- var data = [];
- // if(map23DData.display.map2D){
- $.each(map3._layers, function (key, dl) {
- if (dl._latlngs) {
- if (dl.options.fillOpacity != 1) {
- var dlItem = {
- shape: dl.shape,
- LatLngs: dl._latlngs,
- options: dl.options,
- zhuji: dl.zhuji,
- tip: dl.tip
- }
- data.push(dlItem);
- }
- }
- if (dl._latlng) {
- if (map3._layers[dl._leaflet_id].saveStatu == false) {
- var dlItem = {
- shape: dl.shape,
- LatLngs: dl._latlng,
- options: dl.options,
- zhuji: dl.zhuji,
- tip: dl.tip
- }
- data.push(dlItem);
- }
- }
- });
- // }
- // else{
- // // alert(3333)
- // $.each(modValue.tdPoints,function(key,dl){
- // var dlItem = {
- // shape: dl.shape,
- // LatLngs: dl.LatLngs,
- // options: dl.options,
- // zhuji: dl.zhuji,
- // tip: dl.tip
- // }
- // data.push(dlItem);
- // })
- // }
- return JSON.stringify(data);
- }
- function change23D(options) {
- if (options == '2d') {
- $(".tsAct li.import .importFile").show();
- } else {
- $(".tsAct li.import .importFile").hide();
- up3DrawData()
- }
- }
- /**
- * 模块移除
- * @return {[type]} [description]
- */
- function remove(options) {
- $(".pubPop,.tdPop").remove();
- ONEMAP.showhideAll = true; //全部显隐
- if (!$("#userContent .userInfo .moreLink .linkList li.myBh").hasClass("uFavo")) {
- $("#userContent .userInfo .moreLink .linkList li.myBh").addClass("uFavo");
- }
- // modValue.tdPoints = {};
- // $("#userContent .userInfo .moreLink .linkList li.myBh").hide();
- if (options.modName != "toolDraw") {
- $('#toolsBar .tools-painting').removeClass('cur');
- ONEMAP.C.publisher.publish({
- modName: 'mapfish::hide'
- }, 'mapfish');
- map3.pm.disableDraw('Line');
- } else {
- if ($('#toolsBar .tools-painting').hasClass('cur')) {
- $('#toolsBar .tools-painting').removeClass('cur');
- ONEMAP.C.publisher.publish({
- modName: 'mapfish::hide'
- }, 'mapfish');
- map3.pm.disableDraw('Line');
- } else {
- // $('#toolsBar .tools-painting').addClass('cur');
- // $(".toolBF").show();
- }
- }
- if (options.modName == "bh") {
- $('#toolsBar .tools-painting').addClass('cur');
- }
- map3.pm.disableDraw('Marker');
- map3.pm.disableDraw('Line');
- map3.pm.disableDraw('Poly');
- map3.pm.disableDraw('Rectangle');
- map3.pm.disableDraw('Circle');
- $(".tsTX li").removeClass("active");
- $("#drawTipText").text("").hide();
- var guids = modValue.drawLayerGuids;
- for (var i = 0; i < guids.length; i++) {
- if (map3._layers[guids[i]]) {
- var type = map3._layers[guids[i]].shape
- map3.removeLayer(map3._layers[guids[i]]);
- switch (type) {
- case "Poly":
- case "Rectangle":
- deltdpoly(modValue.tdpoly[guids[i]])
- break;
- case "Line":
- deltdline(modValue.tdline[guids[i]])
- break;
- case "Label":
- delPoint(modValue.tdian[guids[i]])
- break;
- case "Circle":
- deltdCircle(modValue.tdcircle[guids[i]])
- break;
- default:
- break;
- }
- }
- }
- modValue.drawLayerGuids = [];
- var tG = modValue.textGuids;
- for (var i = 0; i < tG.length; i++) {
- $("." + tG[i]).remove();
- // map3.removeLayer(map3._layers[tG[i]]);
- }
- modValue.textGuids = [];
- $.each(modValue.tdPoints, function (key, dl) {
- delPoint(key);
- delete modValue.tdPoints[key];
- })
- }
- function otherTool(e) {
- if (e.modName != "toolDraw") {
- if (e.modName == 'cleanMap') {
- remove({
- modName: 'toolDraw'
- });
- }
- }else {
- if(modValue.drawType == 'Line'){
- if($('#toolsBar .tools-marker').hasClass('cur')){
- map3.pm.disableDraw('Marker');
- $('#toolsBar .tools-marker').removeClass('cur');
- }
- if($('#toolsBar .tools-painting').hasClass('cur')){
- map3.pm.disableDraw('Line');
- $("#drawTipText").hide();
- $('#toolsBar .tools-painting').removeClass('cur');
- }else{
- moveTip('polyline');
- map3.pm.enableDraw('Line');
- modValue.drawModel = 'polyline';
- $('#toolsBar .tools-painting').addClass('cur');
- }
- }
- if(modValue.drawType == 'Marker'){
- if($('#toolsBar .tools-painting').hasClass('cur')){
- map3.pm.disableDraw('Line');
- $('#toolsBar .tools-painting').removeClass('cur');
- }
- if($('#toolsBar .tools-marker').hasClass('cur')){
- map3.pm.disableDraw('Marker');
- $("#drawTipText").hide();
- $('#toolsBar .tools-marker').removeClass('cur');
- }else{
- moveTip('point');
- map3.pm.enableDraw('Marker');
- modValue.drawModel = 'point';
- $('#toolsBar .tools-marker').addClass('cur');
- }
- }
- }
- }
- /**
- * 注册订阅
- * @type {Function}
- * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
- * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
- */
- function subscribe() {
- ONEMAP.C.publisher.subscribe(change23D, 'change23D');
- ONEMAP.C.publisher.subscribe(remove,'cleanMap');
- ONEMAP.C.publisher.subscribe(otherTool, 'toolsd:active');
- ONEMAP.C.publisher.subscribe(otherTool, 'tools:active');
- ONEMAP.C.publisher.subscribe(getLastId, 'mapClick2D');
- }
- /**
- * 取消订阅
- * @type {Function}
- * 取消订阅:ONEMAP.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange');
- */
- function unSubscribe() {
- ONEMAP.C.publisher.unSubscribe(remove, 'cleanMap');
- ONEMAP.C.publisher.unSubscribe(otherTool, 'toolsd:active');
- ONEMAP.C.publisher.unSubscribe(otherTool, 'tools:active');
- }
- return ONEMAP.M.toolDraw = {
- init: init,
- showDraw: showDraw,
- remove: remove
- }
- });
|