/** * [ONEMAP.M.footer] * @return {[object]} */ define([ 'html!templates/topBar', 'css!styles/topBar' ], function (tplLayout) { //状态模式 var status = { mapModel: '2D' //地图浏览模式 }; function init() { setLayout(); bindEvent(); subscribe(); }; function setLayout() { $(tplLayout).appendTo($("#topBar .total-content")); //军综网关闭态势功能 if (map23DConfig.netType == 2) { $("#topBar .tools-taiShi").hide(); } if (!map23DConfig.jbDraw) { $("#spDraw").hide(); } //地图切换 require(['layoutDir/chooseBg'], function (chooseBg) { chooseBg.init(); }); $(".tools-contact .web a").html(onemapUrlConfig.companyWeb) $(".tools-contact .web a").attr('href', onemapUrlConfig.companyWeb) $(".tools-contact .tel span").html(onemapUrlConfig.companyTel) } function bindEvent() { //定位 $(".tools-toolJumpToLatlng").unbind('click').bind('click', function () { require(['modDir/tools/toolJumpToLatlng'], function (toolJumpToLatlng) { toolJumpToLatlng.init(); }); ONEMAP.C.publisher.publish("locate", "topBarEvent"); }) //23维切换 // $("#mapModelChange .bg").bind('click', function () { // if (status.mapModel === '2D') { // ONEMAP.M.sideNav.show3dMap(); // status.mapModel = '3D'; // $("#mapBaseLayerControl .choosemap .name-dem-control .tufu-control").hide(); // } else if (status.mapModel === '3D') { // ONEMAP.M.sideNav.show2dMap(); // status.mapModel = '2D'; // $("#mapBaseLayerControl .choosemap .name-dem-control .tufu-control").show(); // } // ONEMAP.C.publisher.publish("modalChange", "topBarEvent"); // }); //放大 $(".tools-zoomIn").unbind('click').bind("click", function () { var center = { lng: 0, lat: 0 } var zoom = 0 if (map23DData.synch) { if (map23DData.display.map2D) { var center = map2DViewer.map.getCenter() var zoom = map2DViewer.map.getZoom(); } else if (map23DData.display.map3D) { var center = map3DViewer.get3DViewCenter() var zoom = map3DViewer.getZoomFrom3DZoom(center.alt) } zoom = zoom + 1 if (zoom > map2DViewer.map.options.maxZoom) { zoom = map2DViewer.map.options.maxZoom } map23DControl.setView({ center: { lat: center.lat, lng: center.lng }, zoom: zoom }) } else { if (map23DData.display.map2D) { var center = map2DViewer.map.getCenter() var zoom = map2DViewer.map.getZoom(); map2DViewer.setView({ center: { lat: center.lat, lng: center.lng }, zoom: zoom + 1 }) } else if (map23DData.display.map3D) { var center = map3DViewer.get3DViewCenter() var zoom = map3DViewer.getZoomFrom3DZoom(center.alt) map3DViewer.setView({ center: { lat: center.lat, lng: center.lng }, zoom: zoom + 1 }) } } }); //缩小 $(".tools-zoomOut").unbind('click').bind("click", function () { var center = { lng: 0, lat: 0 } var zoom = 0 if (map23DData.synch) { if (map23DData.display.map2D) { var center = map2DViewer.map.getCenter() var zoom = map2DViewer.map.getZoom(); } else if (map23DData.display.map3D) { var center = map3DViewer.get3DViewCenter() var zoom = map3DViewer.getZoomFrom3DZoom(center.alt) } if (!zoom) { zoom = map2DViewer.map.options.minZoom + 1 } zoom = zoom - 1; if (zoom < map2DViewer.map.options.minZoom) { zoom = map2DViewer.map.options.minZoom } map23DControl.setView({ center: { lat: center.lat, lng: center.lng }, zoom: zoom }) } else { if (map23DData.display.map2D) { var center = map2DViewer.map.getCenter() var zoom = map2DViewer.map.getZoom(); map2DViewer.setView({ center: { lat: center.lat, lng: center.lng }, zoom: zoom - 1 }) } else if (map23DData.display.map3D) { var center = map3DViewer.get3DViewCenter() var zoom = map3DViewer.getZoomFrom3DZoom(center.alt) if (!zoom) { zoom = 0 } zoom = zoom - 1 if (zoom < 0) { zoom = 0 } map3DViewer.setView({ center: { lat: center.lat, lng: center.lng }, zoom: zoom }) } } }); //联系我们 $(".tools-contact").bind("mouseover", function () { $(".tools-contact .bg .p").show() }).on('mouseout', function () { $(".tools-contact .bg .p").hide() }).bind('click', function () { }) //开发者 $(".tools-developer").on("mouseover", function () { $(".tools-developer .bg .p").show() }).on('mouseout', function () { $(".tools-developer .bg .p").hide() }).on('click', function () { if (ONEMAP.D.user.guest) { ONEMAP.C.publisher.publish({ type: 'warning', message: '用户未登录,请登录后查看。' }, 'noteBar::add'); return } else { if (ONEMAP.D.user.roles.indexOf('developer') == -1) { ONEMAP.C.publisher.publish({ type: 'warning', message: '用户未认证为开发者,请到用户中心认证。' }, 'noteBar::add'); return } else { window.open(onemapUrlConfig.developerWeb) } } }) //工具 require(['layoutDir/toolsBar'], function (toolsBar) { toolsBar.init(); }); //全屏 $(".tools-fullScreen,#fullscreen .cover-content").unbind('click').bind('click', function () { require(['modDir/tools/toolFullScreen'], function (toolFullScreen) { toolFullScreen.init(); }); }); }; function fullMap(option) { if (option) { $("#topBar").fadeOut('slow') } else { $("#topBar").fadeIn('slow') } } function resetMap23dStatus(options) { if (map23DData.display.map2D) { status['mapModel'] = '2D'; } else { status['mapModel'] = '3D'; } } /** * 注册订阅 * @type {Function} * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type'); * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange'); */ function subscribe() { ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap'); ONEMAP.C.publisher.subscribe(resetMap23dStatus, 'change23D'); } return ONEMAP.M.topBar = { init: init }; })