/** * [ONEMAP.M.toolShiZi] * @return {[object]} */ define(['html!templates/tools/toolShiZi', 'css!styles/user' ],function(tplLayout){ var status = { userContentShow:false, shiZi:false } function init(){ unSubscribe(); subscribe(); bindEvents(); setLayout(); }; function setLayout(){ if(!status.shiZi){ $(tplLayout).appendTo($("#wrapper")); status.shiZi = true; } if($(".tools-shiZi").hasClass("cur")){ remove({ modName: "cleanMap" }); } else{ if(map23DData.display.map3D){ $("#shiZi").addClass("active") } $(".tools-shiZi").addClass("cur"); addPolyLine() ONEMAP.C.publisher.publish('1', 'jingzhi'); } }; function addPolyLine(){ var Arr = [ [map2DViewer.map.getCenter().lat,-360], [map2DViewer.map.getCenter().lat,360] ] var Brr = [ [-90,map2DViewer.map.getCenter().lng], [90,map2DViewer.map.getCenter().lng] ] var a = L.polyline(Arr,{color: '#04cfed', weight: 2, opacity: 1}).addTo(map2DViewer.map); ONEMAP.D.Szguid = a._leaflet_id; var b = L.polyline(Brr,{color: '#04cfed', weight: 2, opacity: 1}).addTo(map2DViewer.map); ONEMAP.D.Szguid2 = b._leaflet_id; } function updateLatlng(){ var Arr = [ [map2DViewer.map.getCenter().lat,-360], [map2DViewer.map.getCenter().lat,360] ] var Brr = [ [-90,map2DViewer.map.getCenter().lng], [90,map2DViewer.map.getCenter().lng] ] map2DViewer.map._layers[ONEMAP.D.Szguid].setLatLngs(Arr) map2DViewer.map._layers[ONEMAP.D.Szguid2].setLatLngs(Brr) } function remove(options){ if(options.modName == "cleanMap"){ $(".tools-shiZi").removeClass("cur"); $("#shiZi").removeClass("active") if(map2DViewer.map._layers[ONEMAP.D.Szguid]){ map2DViewer.map.removeLayer(map2DViewer.map._layers[ONEMAP.D.Szguid]); map2DViewer.map.removeLayer(map2DViewer.map._layers[ONEMAP.D.Szguid2]); } unSubscribe() ONEMAP.C.publisher.publish('0', 'jingzhi'); } } function fullMap(option){ // if(option){ // $("#userContent").fadeOut('slow') // }else{ // $("#userContent").fadeIn('slow') // } } function change23D(options){ // if($(".tools-shiZi").hasClass("cur")){ // } else{ remove({ modName: "cleanMap" }); $(".tools-shiZi").removeClass("cur") $("#shiZi").removeClass("active") // } // if(options == '2d'){ // $('#userContent').removeClass('class3d'); // }else{ // $('#userContent').addClass('class3d'); // } } function subscribe(){ // ONEMAP.C.publisher.subscribe(closeLeft, 'layout::closeLeft'); ONEMAP.C.publisher.subscribe(change23D,'change23D'); ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap'); ONEMAP.C.publisher.subscribe(remove, 'tools:active'); ONEMAP.C.publisher.subscribe(updateLatlng, 'map2DMoveIng'); // ONEMAP.C.publisher.subscribe(updateLatlng, 'map2DMoveEnd'); }; function unSubscribe(){ ONEMAP.C.publisher.unSubscribe(remove, 'tools:active'); ONEMAP.C.publisher.unSubscribe(updateLatlng, 'map2DMoveIng'); } function bindEvents(){ }; return ONEMAP.M.toolShiZi = { init:init } })