123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- /**
- * [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
- };
- })
|