123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- /**
- * [ONEMAP.M.pcLayout]
- * @return {[object]}
- */
- define([
- 'html!templates/layout',
- 'css!styles/layout',
- 'layoutDir/noteBar',
- 'css!styles/popupHtml.css'
- ], function(tplLayout) {
- /**
- * pc端界面布局 模块
- * @exports ONEMAP.M.pcLayout
- * @type {Object}
- */
- //布局完成后加载地图和侧栏内容,如果url传来参数,将解析参数加载相应的模块
- /**
- * 界面样式数值变量
- * @type {Object}
- */
- var styles = {
- //头部高度
- headerHeight: 61,
- //工具栏高度
- toolbarHeight: 30,
- //地图视窗宽
- mapWidth: null,
- //地图视窗高
- mapHeight: null,
- //侧栏宽度
- sideBarWidth: 270,
- //侧栏高度
- sideBarHeight: '100%',
- };
- /**
- * 模块状态,用于存储模块的状态 例如:收起,关闭
- * @type {Object}
- */
- var status = {
- showSideBar: false,
- showFullMap: false
- }
- /**
- * 加载布局 初始化
- * 先加载 CSS,html,html事件,地图,地图控件
- * @type {Function}
- * @returns {*}
- */
- function init() {
- setLayout();
- $(window).resize(function() {
- layoutResize();
- });
- subscribe();
- bindEvent();
- };
- /**
- * 设置布局
- * @return {[type]} [description]
- */
- function setLayout() {
- // $("body").html("");
- // console.log(tplLayout);
- $('body').append(tplLayout);
- $("#openSTSideContent").appendTo($("#map2DWrap"));
- //设置系统标题,logo,版权信息
- document.title = onemapUrlConfig.systemName;
-
- // require(['layoutDir/header'], function(header) {
- // header.init();
- // });
- require(['layoutDir/sideNav'], function(sideNav) {
- sideNav.init();
- require(['modDir/mapHolder'], function(mapHolder) {
- mapHolder.init();
-
- require(['layoutDir/topBar'], function(topBar) {
- topBar.init();
- });
- require(['layoutDir/footer'], function(footer) {
- footer.init();
- });
- });
- });
- require(['layoutDir/sideBar'], function(sideBar) {
- sideBar.init();
- });
- require(['layoutDir/menu'], function(menu) {
- menu.init();
- });
-
- require(['layoutDir/layerController'], function(layerController) {
- layerController.init();
- });
-
- };
- function layoutResize() {
-
- };
- function bindEvent(){
- $("#openSTSideContent").bind('click',function(){
- if(status.showSideBar){
- ONEMAP.C.publisher.publish('handHide','layout::sideBar');
- }else{
- ONEMAP.C.publisher.publish('handShow','layout::sideBar');
- }
- })
- //全屏
- $(".tools-fullScreen").unbind('click').bind('click',function(){
- require(['modDir/tools/toolFullScreen'], function(toolFullScreen) {
- toolFullScreen.init();
- });
- });
- }
-
- /**
- * 设置侧栏显示状态
- * @param {[type]} options [description]
- * 显示: ONEMAP.C.publisher.publish('show','layout::sideBar');
- * 隐藏: ONEMAP.C.publisher.publish('show','layout::sideBar');
- */
- function SideBarStatusControl(options){
- if(options == 'show' || options == 'handShow'){
- if(!status.showSideBar){
- $('#wrapper').animate({
- right: 310},
- 300, function() {
- ONEMAP.C.publisher.publish({},'layout::resize');
- sideBarBtn("show");
- });
- status.showSideBar = true;
- ONEMAP.C.publisher.publish('sideBarStatus', 'sideBarStatus');
- }
- }else {
- if(status.showSideBar){
- sideBarBtn("hide");
- $('#wrapper').animate({
- right: 0},
- 300, function() {
- ONEMAP.C.publisher.publish({},'layout::resize');
- });
- status.showSideBar = false;
- ONEMAP.C.publisher.publish('sideBarStatus', 'sideBarStatus');
- }
- }
- }
- function setSideBarStatus(options){
- if(options == "handHide" || options == "handShow"){
- SideBarStatusControl(options)
- }else{
- if($('.abtn-mini-side-bar').hasClass('close')){
- return false;
- }else{
- SideBarStatusControl(options);
- }
- }
- };
- //侧栏控制按钮
- function sideBarBtn(options){
- if(options === "show"){
- $("#openSTSideContent img").attr("src",onemapUrlConfig.siteUrl+"/images/layout/close3dSideIcon.png");
- $("#openSTSideContent").css("right","410px");
- }else{
- $("#openSTSideContent img").attr("src",onemapUrlConfig.siteUrl+"/images/layout/open3dSideIcon.png");
- $("#openSTSideContent").css("right","0px");
- }
- }
- /**
- * 设置全屏显示状态
- * @param {[type]} options [description]
- * 全屏: ONEMAP.C.publisher.publish(true,'layout::fullMap');
- * 取消全屏: ONEMAP.C.publisher.publish(false,'layout::fullMap');
- */
- function setFullMapStatus(options){
- if(options == true){
- status.showFullMap = true;
- ONEMAP.C.publisher.publish({},'layout::resize');
- $("#menu").animate({
- left:-340
- }, 500)
- $('#header').animate({
- top: -61},
- 500, function() {});
- $('#footer').animate({
- bottom: -30},
- 500, function() {});
- $('#topBar').animate({
- right: -45},
- 500, function() {});
- $('#menu').animate({
- right: -310},
- 500, function() {});
- $('#sideNav').hide();
- }else {
- status.showFullMap = false;
- ONEMAP.C.publisher.publish({},'layout::resize');
- $("#menu").animate({
- left: 0
- }, 400)
- $('#header').animate({
- top: 0},
- 500, function() {});
- $('#footer').animate({
- bottom: 0},
- 500, function() {});
- $('#topBar').animate({
- right: 0},
- 500, function() {});
- $('#menu').animate({
- right: 0},
- 500, function() {});
- $('#sideNav').show();
- }
- }
-
- function controlShijing(data){
- if(data.zoom<11){
- $(".abtn-show-shijing").hide();
- }else{
- $(".abtn-show-shijing").show();
- }
- }
- /**
- * 注册监听
- * @type {Function}
- */
- function subscribe() {
- ONEMAP.C.publisher.subscribe(setSideBarStatus,'layout::sideBar');
- ONEMAP.C.publisher.subscribe(setFullMapStatus,'layout::fullMap');
- };
- return ONEMAP.M.pcLayout = {
- init: init,
- styles:styles,
- status:status
- };
- });
|