123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- define(function() {
- /**
- * 状态值
- * @type {Boolean}
- * @default false
- * @private
- */
- var status = {
- initialized: false, //是否初始化
- veiwHeightType: null
- };
- /**
- * 模块数据 用于数据存储和外部调用
- * @type {Object}
- * 数据存放
- */
- var modValue = {
- drawId: []
- };
- /**
- * 可是分析初始化
- */
- function init() {
- if (!status.initialized) {
- subscribe();
- status.initialized = true;
- }
- ONEMAP.C.publisher.publish({
- modName: 'toolKSFX'
- }, 'tools:active');
- };
- /**
- * 注册监听事件
- */
- function subscribe() {
- ONEMAP.C.publisher.subscribe(remove, 'tools:active');
- ONEMAP.C.publisher.subscribe(removetoolKSFX, 'cleanMap');
- ONEMAP.C.publisher.subscribe(removeEvent, 'change23D');
- };
- function removeEvent() {
- if (map23DData.show3DAlert) {
- locaSpaceMap.Globe.Action = 0; //使鼠标动作返回普通浏览状态
- locaSpaceMap.Refresh();
- }
- $('#coverHeightKSFX').hide();
- closeCircleControl();
- }
- /**
- * 通视分析加载或移除
- */
- function remove(options) {
- if (options.modName != 'toolKSFX') {
- if (options.modName == 'cleanMap') {
- removetoolKSFX();
- }
- $(".tools-KSFX").removeClass('cur');
- } else {
- if ($(".tools-KSFX").hasClass('cur')) {
- $(".tools-KSFX").removeClass('cur');
- removetoolKSFX();
- } else {
- $(".tools-KSFX").addClass('cur');
- addtoolKSFX();
- }
- }
- }
- /**
- *移除通视分析
- */
- function removetoolKSFX() {
- if (map23DData.show3DAlert) {
- locaSpaceMap.Globe.Action = 0; //使鼠标动作返回普通浏览状态
- locaSpaceMap.Refresh();
- }
- if (modValue.group) {
- map23DControl.group({
- action: 'remove',
- guid: modValue.group,
- })
- modValue.group = false;
- }
- $('#coverHeightKSFX').hide();
- closeCircleControl();
- };
- /**
- * 加载通视分析
- */
- function addtoolKSFX() {
- $('#coverHeightKSFX').show();
- $('#coverHeightKSFX .cancel').unbind('click').bind('click', function() {
- $('#coverHeightKSFX').hide();
- $(".tools-KSFX").removeClass('cur');
- removetoolKSFX();
- });
- $('#coverHeightKSFX .sure').unbind('click').bind('click', function() {
- if (!modValue.group) {
- modValue.group = map23DControl.group({
- action: 'add'
- })
- }
- var height = parseInt($('#coverHeightKSFX .input').val());
- modValue.viewHeight = height;
- if (height > 0 && height < 1000) {
- $('#coverHeightKSFX').hide();
- if (map23DData.show3DAlert) {
- locaSpaceMap.Globe.CenterHeightOfViewshedAnalysis = height;
- locaSpaceMap.Globe.Action = 13;
- locaSpaceMap.Refresh();
- }
- openCircleControl();
- $(".tools-KSFX").removeClass('cur');
- } else {
- alert('请输入大于0小于1000的高度值');
- }
- });
- };
- function closeCircleControl() {
- //map2DViewer.drawCircleResult = function(){}
- map2DViewer.removeCircle();
- }
- function openCircleControl() {
- map2DViewer.drawCircleResult = function(data) {
- if (data.radius > 10000) {
- alert('半径过大,建议小于10000米')
- } else {
- modValue.radius = data.radius;
- modValue.coordinates = data.startpoint;
- var guid = map2DViewer.marker({
- action: 'add',
- groupId: modValue.group,
- geojson: {
- "properties": {
- title: '',
- iconUrl: map23DConfig.map23DAssetsUrl + '/images/layout/marker/b3.png',
- iconSize: [10, 24],
- iconAnchor: [5, 24],
- },
- "geometry": {
- "coordinates": [modValue.coordinates[1], modValue.coordinates[0]]
- }
- }
- })
- showKSY();
- }
- }
- map2DViewer.drawCircle();
- }
- function showKSY() {
- var coods = [modValue.coordinates[1].toFixed(5),modValue.coordinates[0].toFixed(5)]
- $.ajax({
- type: 'get',
- dataType: 'json',
- url: onemapUrlConfig.elevationDataUrl + '/v2.0/geoprocessing/viewshed',
- data: {
- lng: coods[0],
- lat: coods[1],
- radius: modValue.radius,
-
- height: modValue.viewHeight
- },
- success: function(data) {
- $.each(data.features, function(i, t) {
- var guid = map2DViewer.polygon({
- action: 'add',
- groupId: modValue.group,
- geojson: {
- "properties": {
- title: '测试polygon',
- color: '#00ffcc',
- weight: 1,
- fillColor: '#00ffcc',
- opacity: 0.7,
- fillOpacity: 0.7,
- popupContent: ''
- },
- "geometry": {
- "type": "Polygon",
- "coordinates": t.geometry.coordinates
- }
- }
- })
- })
- closeCircleControl();
- },
- error: function(errorData) {
- ONEMAP.V.loading.loaded();
- }
- })
- }
- return ONEMAP.M.toolKSFX = {
- init: init
- }
- })
|