123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- define(function() {
- /**
- * 状态值
- * @type {Boolean}
- * @default false
- * @private
- */
- var status = {
- initialized: false, //是否初始化
- veiwHeightType: null
- };
- /**
- * 模块数据 用于数据存储和外部调用
- * @type {Object}
- * 数据存放
- */
- var modValue = {
- };
- /**
- * 三维高度测量初始化
- */
- function init() {
- if (!status.initialized) {
- subscribe();
- status.initialized = true;
- }
- ONEMAP.C.publisher.publish({
- modName: 'toolTSFX'
- }, 'tools:active');
- };
- /**
- * 注册监听事件
- */
- function subscribe() {
- ONEMAP.C.publisher.subscribe(remove, 'tools:active');
- ONEMAP.C.publisher.subscribe(removeEvent, 'change23D');
- ONEMAP.C.publisher.subscribe(removetoolTSFX, 'cleanMap');
- };
- function removeEvent(){
- if (map23DData.show3DAlert) {
- locaSpaceMap.Globe.Action = 0; //使鼠标动作返回普通浏览状态
- locaSpaceMap.Refresh();
- }
- remove2DEvent();
- }
- function mousemove23D(options) {
- var screen = options.e.containerPoint;
- $(".mouseTip").css({
- left: screen.x + 10,
- top: screen.y + 10
- })
- }
- function mapClick(options) {
- //添加起始点
- if (!modValue.arryCoor) {
- var guid = map2DViewer.marker({
- action: 'add',
- groupId: modValue.group,
- geojson: {
- "properties": {
- title: '',
- iconUrl: map23DConfig.map23DAssetsUrl + '/images/layout/marker/r3.png',
- iconSize: [10, 24],
- iconAnchor: [5, 24],
- },
- "geometry": {
- "coordinates": [options.lng, options.lat]
- }
- }
- })
- $(".mouseTip").html('点击地图添加目标点')
- modValue.arryCoor = {
- first: [options.lng, options.lat],
- scend: null
- }
- } else {
- var guid = map2DViewer.marker({
- action: 'add',
- groupId: modValue.group,
- geojson: {
- "properties": {
- title: '',
- iconUrl: map23DConfig.map23DAssetsUrl + '/images/layout/marker/y3.png',
- iconSize: [10, 24],
- iconAnchor: [5, 24],
- },
- "geometry": {
- "coordinates": [options.lng, options.lat]
- }
- }
- })
- modValue.arryCoor.scend = [options.lng, options.lat];
- getTSData();
- remove2DEvent();
- modValue.arryCoor = null;
- }
- }
- function getTSData() {
- var coods = [modValue.arryCoor.first[0].toFixed(5),modValue.arryCoor.first[1].toFixed(5),modValue.arryCoor.scend[0].toFixed(5),modValue.arryCoor.scend[1].toFixed(5)]
- $.ajax({
- type: 'get',
- dataType: 'json',
- url: onemapUrlConfig.elevationDataUrl + '/v2.0/geoprocessing/sightline',
- data: {
- lng1: coods[0],
- lat1: coods[1],
- lng2: coods[2],
- lat2: coods[3],
- height: 3
- },
- success: function(data) {
- $.each(data.features, function(i, t) {
- map2DViewer.polyline({
- action: 'add',
- groupId: modValue.group,
- geojson: {
- "type": "Feature",
- "properties": {
- title: '',
- color: t.properties.color,
- weight: 3,
- opacity: 1,
- },
- "geometry": {
- "coordinates": t.geometry.coordinates
- }
- }
- })
- })
- },
- error: function(errorData) {
- ONEMAP.V.loading.loaded();
- }
- })
- }
- function remove2DEvent() {
- $(".tools-TSFX").removeClass('cur');
- ONEMAP.C.publisher.unSubscribe(mapClick, 'mapClick2D');
- ONEMAP.C.publisher.unSubscribe(mousemove23D, 'mousemove23D');
- $(".mouseTip").remove();
- }
- /**
- * 通视分析加载或移除
- */
- function remove(options) {
- if (options.modName != 'toolTSFX') {
- if(options.modName == 'cleanMap'){
- removetoolTSFX();
- }
- $(".tools-TSFX").removeClass('cur');
- remove2DEvent();
- //removetoolTSFX();
- } else {
- if ($(".tools-TSFX").hasClass('cur')) {
- $(".tools-TSFX").removeClass('cur');
- removetoolTSFX();
- } else {
- $(".tools-TSFX").addClass('cur');
- addtoolTSFX();
- }
- }
- }
- /**
- *移除通视分析
- */
- function removetoolTSFX() {
- if (map23DData.show3DAlert) {
- locaSpaceMap.Globe.Action = 0; //使鼠标动作返回普通浏览状态
- locaSpaceMap.Refresh();
- }
- modValue.arryCoor = null;
- if(modValue.group){
- map23DControl.group({
- action: 'remove',
- guid:modValue.group,
- })
- modValue.group = false;
- }
- remove2DEvent();
- };
- /**
- * 加载通视分析
- */
- function addtoolTSFX() {
- if (!modValue.group) {
- modValue.group = map23DControl.group({
- action: 'add'
- })
- }
- if (map23DData.show3DAlert) {
- locaSpaceMap.Globe.Action = 15;
- locaSpaceMap.Refresh();
- }
- $(".mouseTip").remove();
- $('<p class="mouseTip">点击地图添加起点</p>').appendTo($("#map2DWrap"));
- ONEMAP.C.publisher.subscribe(mapClick, 'mapClick2D');
- ONEMAP.C.publisher.subscribe(mousemove23D, 'mousemove23D');
- };
- return ONEMAP.M.toolTSFX = {
- init: init
- }
- })
|