123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- define(['html!templates/heighterControl_mini',
- 'css!styles/heighterControl_mini'
- ],
- function(tplayout) {
- /**
- * [modValue description]
- * 数据存储
- * @type {[type]}
- */
- var modValue = {
- curLayerModel: null,
- curAddLayer: {},
- appendToMyLayer: null,
- shijingGroup: null
- };
- /**
- * 状态存储
- */
- var status = {
- initialized: false
- };
- /**
- * 模块初始化
- */
- function init() {
- if (!status.initialized) {
- status.initialized = true;
- setLayout();
- subscribe();
- bindEvents();
- }
- }
- /**
- * [setLayout description]
- * 加载布局0
- */
- function setLayout() {
- $(tplayout).appendTo($("#wrapper"));
- //添加路网实景控件
- modValue.leadorStreetViewControl = new L.Control.LeadorStreetView();
- modValue.leadorStreetViewControl.addTo(map2DViewer.map);
- };
- function change23D(options) {
- if (options == '2d') {
- $('#heighterSlider').removeClass('class3d');
- $("#leadorStreetViewModal .popup_html").removeClass('TD');
- } else {
- $('#heighterSlider').addClass('class3d');
- $("#leadorStreetViewModal .popup_html").addClass('TD');
- }
- }
- /**
- * 加载监听事件
- */
- function subscribe() {
- ONEMAP.C.publisher.subscribe(change23D, 'change23D');
- ONEMAP.C.publisher.subscribe(function(zoom) {
- if (zoom < 11) {
- jumpToLiveaction('clear');
- $("#heighterSlider").hide();
- } else if(onemapUrlConfig.leadorSwitch){
- $("#heighterSlider").show();
- }
- }, 'mapChange23D');
- ONEMAP.C.publisher.subscribe(function(options) {
- if (modValue.leadorStreetViewControl) {
- modValue.leadorStreetViewControl.updateMarker3D(options.latlng);
- }
- }, 'map3DclickNew')
- };
- /**
- * 加载点击事件
- */
- function bindEvents() {
- $("#heighterSlider .heighterslider-content .heighterslider-li").bind('click', function() {
- if ($(this).hasClass('active')) {
- $("#heighterSlider .heighterslider-content .heighterslider-li").removeClass('active');
- var mid = 'clear';
- } else {
- var mid = $(this).attr('mid');
- $("#heighterSlider .heighterslider-content .heighterslider-li").removeClass('active');
- $(this).addClass('active');
- }
- jumpToStallite(mid); //19
- jumpToIonosphere(mid); //18
- jumpToClouds(mid);
- jumpToImage(mid);
- jumpToModel(mid);
- jumpToLiveaction(mid);
- })
- $("#menu .liveaction").off("click").on("click", function() {
- var mid;
- if ($(this).hasClass('active')) {
- $(this).removeClass('active');
- mid = 'clear';
- } else {
- mid = $(this).attr('mid');
- $(this).addClass('active');
- }
- jumpToLiveaction(mid);
- })
- };
- function jumpToStallite(mid) {
- if (mid == 'stallite') {
- if (modValue.curLayerModel != 'stallite') {
- setViewer(1);
- ONEMAP.C.publisher.publish('3D', 'layout::mapStyle');
- modValue.curLayerModel = 'stallite';
- if (ONEMAP.M.taiShiMap) { ONEMAP.M.taiShiMap.removeAllLayers() }
- require(['modDir/weixing/daohang'], function(daohang) {
- daohang.init($(this));
- });
- }
- } else {
- if (ONEMAP.M.daohang) {
- ONEMAP.M.daohang.cleanmap();
- modValue.curLayerModel = null;
- }
- }
- };
- function jumpToIonosphere(mid) {
- if (mid == 'ionosphere') {
- if (modValue.curLayerModel != 'ionosphere') {
- setViewer(2);
- modValue.curLayerModel = 'ionosphere';
- }
- } else {
- modValue.curLayerModel = null;
- }
- };
- function jumpToClouds(mid) {
- if (mid == 'clouds') {
- if (modValue.curLayerModel != 'clouds') {
- setViewer(4);
- modValue.curLayerModel = 'clouds';
- }
- } else {
- modValue.curLayerModel = null;
- }
- };
- function jumpToImage(mid) {
- if (mid == 'image') {
- ONEMAP.C.publisher.publish('showGH', 'layout::mapStyle');
- } else {
- modValue.curLayerModel = null;
- }
- };
- function jumpToModel(mid) {
- if (mid == 'model') {
- if (modValue.curLayerModel != 'model') {
- modValue.curLayerModel = 'model';
- ONEMAP.C.publisher.publish('3D', 'layout::mapStyle');
- ONEMAP.C.publisher.publish('add', '3DModelControl');
- }
- } else {
- ONEMAP.C.publisher.publish('remove', '3DModelControl');
- modValue.curLayerModel = null;
- }
- };
- function jumpToLiveaction(mid) {
- if (mid == 'liveaction') {
- $("#leadorStreetViewControl #leadorStreetViewWrap").dragmove($("#leadorStreetViewControl"));
- if (modValue.curLayerModel != 'liveaction') {
- map23DControl.setView({
- center: {
- lat: 39.91302,
- lng: 116.4166
- },
- zoom: 13
- })
- modValue.curLayerModel = 'liveaction';
- if (!modValue.shijingGroup) {
- modValue.shijingGroup = map23DControl.group({
- action: 'add'
- })
- }
- if (!modValue.appendToMyLayer) {
- var options = {
- action: "add",
- DOM: {
- name: '实景',
- type: "group",
- guid: modValue.shijingGroup
- }
- }
- modValue.appendToMyLayer = ONEMAP.M.myLayers.myLayerControl(options);
- ONEMAP.C.publisher.subscribe(controlMyLayer, modValue.appendToMyLayer);
- }
- modValue.leadorStreetViewControl.addShijing();
- if (map23DData.display.map2D){
- $("#leadorStreetViewModal .popup_html").removeClass('TD');
- }else{
- $("#leadorStreetViewModal .popup_html").addClass('TD');
- }
- $("#leadorStreetViewModal .popup-ct").dragmove($("#leadorStreetViewModal"));
- } else {
- jumpToLiveaction('clear')
- }
- } else {
- $("#heighterSlider .heighterslider-content .liveaction").removeClass('active');
- if (modValue.leadorStreetViewControl) {
- modValue.leadorStreetViewControl.controlShijing();
- modValue.curLayerModel = null;
- var options = {
- action: "remove",
- DOMid: modValue.appendToMyLayer
- }
- ONEMAP.M.myLayers.myLayerControl(options);
- ONEMAP.C.publisher.unSubscribe(controlMyLayer, modValue.appendToMyLayer);
- modValue.appendToMyLayer = false;
- modValue.shijingGroup = false;
- }
- }
- };
- function clearOtherLayer() {
- $("#heighterSlider .heighterslider-content .liveaction").removeClass('active');
- modValue.leadorStreetViewControl.controlShijing();
- modValue.curLayerModel = null;
- if (modValue.shijingGroup) {
- map23DControl.group({
- action: 'remove',
- guid: modValue.shijingGroup
- })
- modValue.shijingGroup = false;
- }
- }
- function controlMyLayer(options) {
- switch (options.action) {
- case 'remove':
- removeMyLayer();
- break;
- case 'opacity':
- setGropOpacity(options);
- break;
- case 'up':
- case 'down':
- setGroupZIndex(options);
- break;
- }
- };
- function setGroupZIndex(options){
- }
- function removeMyLayer() {
- jumpToLiveaction('clear');
- };
- function setGropOpacity(options) {
- options = options.options;
- if (options.opacity == 1) {
- map23DControl.group({
- action: 'show',
- guid: modValue.shijingGroup
- })
- $("#leadorStreetViewModal").show();
- modValue.leadorStreetViewControl.controlMyLayer('show');
- } else if (options.opacity == 0) {
- map23DControl.group({
- action: 'hide',
- guid: modValue.shijingGroup
- })
- $("#leadorStreetViewModal").hide();
- modValue.leadorStreetViewControl.controlMyLayer('hide');
- }
- }
- function setViewer(zoom) {
- map23DControl.setView({
- zoom: zoom,
- heading: 0, //摄像机平面角度 正北为0
- tilt: 0, //摄像机倾斜角
- })
- }
- /**
- * [layoutResize description]
- * 重置布局
- * @return {[type]} [description]
- */
- function layoutResize() {
- }
- return ONEMAP.M.heighterControl = {
- init: init,
- modValue: modValue
- }
- })
|