123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- /**
- * [ONEMAP.M.footer]
- * @return {[object]}
- */
- define([
- 'html!templates/footer',
- 'css!styles/footer'
- ], function (tplLayout) {
- var status = {
- curTimeModel: 'six', //six 六进制 ten 十进制
- curZoingNum: 3 //分度带
- }
- var modValue = {
- hms: true,
- curLatlngType: 'dfm',
- beforeLocationMouseMove: true,
- }
- function init() {
- setLayout();
- layoutResize();
- bindEvent();
- subscribe();
- // getUserLocation();
- };
- function setLayout() {
- $(tplLayout).appendTo($("#footer .cover-content"));
- $('#copyright').html(onemapUrlConfig.systemCopy);
- $('#footer .contact.power').html(onemapUrlConfig.powerWords);
- if (onemapUrlConfig.contactNum) {
- var nums = onemapUrlConfig.contactNum;
- var contactDom = '';
- if (nums.length == 1) {
- contactDom = '<a href="javascript:;">' + nums[0] + '</a>';
- } else {
- for (var i = 0; i < nums.length; i++) {
- if (i != nums.length - 1) {
- contactDom += '<a href="javascript:;">' + nums[i] + '</a>,';
- } else {
- contactDom += '<a href="javascript:;">' + nums[i] + '</a>';
- }
- }
- }
- $("#footer .contact .phoneNum").html(contactDom);
- }
- layoutResize();
- $(window).resize(function () {
- layoutResize();
- });
- updateViewHeight(map23DData.view.zoom);
- $(".leaflet-control-scale-line").appendTo($("#footer .footer-content .scale"));
- if (map23DData.display.map2D) {
- $('#footer').removeClass('class3d');
- } else {
- $('#footer').addClass('class3d');
- }
- if (!ONEMAP.D.isLoad) {
- $('#footer .feedback').remove();
- }
- }
- function layoutResize() {
- var curWindowWeight = $(window).width();
- if (curWindowWeight < 1250) {
- $("#footer").addClass('min');
- } else {
- $("#footer").removeClass('min');
- }
- }
- function changeLtlngShowStyle() {
- if (status.curTimeModel === 'six') {
- $("#footer #pointInfoToTen").show();
- $("#footer #pointInfoToSix").hide();
- status.curTimeModel = 'ten';
- } else {
- $("#footer #pointInfoToTen").hide();
- $("#footer #pointInfoToSix").show();
- status.curTimeModel = 'six';
- }
- }
- function bindEvent() {
- $(".data-share-link").attr("href", onemapUrlConfig.shareUrl);
- $(".kf-center").attr("href", onemapUrlConfig.devCenterUrl);
- $(".olCommu").attr("href", onemapUrlConfig.olCommuUrl);
- $(".hoverShow").hover(function () {
- $(".phoneNum").toggle();
- })
- $("#pointInfoToTen .changeType").bind('click', function () {
- $("#changeLatlng").toggle();
- })
- $("#changeLatlng .latlng_list li").bind('click', function () {
- var mid = $(this).attr('mid');
- if (modValue.curLatlngType != mid) {
- $("#pointInfoToTen .changeType").html($(this).html());
- $("#changeLatlng").toggle();
- modValue.curLatlngType = mid;
- if (modValue.curLatlngType == "tgoos") {
- status.curZoingNum = 3;
- map23DControl.curZoingNum = 3;
- } else if (modValue.curLatlngType == "sgoos") {
- status.curZoingNum = 6;
- map23DControl.curZoingNum = 6;
- }
- ONEMAP.C.publisher.publish(status.curZoingNum, 'daihao');
- coordinateExport();
- }
- })
- //定位
- $('#footer .iplocation').bind('click', function () {
- getUserLocation();
- })
- };
- function change23D(options) {
- if (options == '2d') {
- $('#footer').removeClass('class3d');
- } else {
- $('#footer').addClass('class3d');
- }
- }
- function updateViewHeight(zoom) {
- if (map23DData.display.map3D) {
- //var distance = map23DData.view.distance;
- $("#footer .viewHeight .curheight").html(zoom.toFixed(0) + '米');
- $("#footer .viewHeight").show();
- $("#footer .viewZoom").hide();
- }
- if (map23DData.display.map2D) {
- $("#footer .viewZoom .curzoom").html(zoom);
- $("#footer .viewHeight").hide();
- $("#footer .viewZoom").show();
- }
- }
- function updateLatlng(options) {
- // if (!options.lng || !options.lat) {
- // options = modValue.curLatlng;
- // }
- if (options && options.lng && options.lat) {
- modValue.curLatlng = options;
- } else {
- options = modValue.curLatlng;
- }
- //经纬度显示
- lat = options.lat;
- lng = options.lng;
- var obj = {
- lng: lng,
- lat: lat
- }
- coordinateExport(obj)
- }
- function upsz() {
- // if (!modValue.beforeLocationMouseMove)
- // return;
- //经纬度显示
- lat = map2DViewer.map.getCenter().lat.toFixed(6);
- lng = map2DViewer.map.getCenter().lng.toFixed(6);
- modValue.curLatlng = {
- lng: lng,
- lat: lat
- }
- var obj = {
- lng: lng,
- lat: lat
- }
- coordinateExport(obj)
- }
- function coordinateExport(obj) {
- var latlng = null;
- if (obj) {
- latlng = new L.latLng(obj.lat, obj.lng)
- $('#pointInfoToTen .goosXY').data("lng", obj.lng)
- $('#pointInfoToTen .goosXY').data("lat", obj.lat)
- } else {
- latlng = new L.latLng($('#pointInfoToTen .goosXY').data("lat"), $('#pointInfoToTen .goosXY').data("lng"))
- }
- var zoom = map23DData.view.zoom;
- if (modValue.curLatlngType == 'dfm') {
- var nLatlng = L.Util.formatHMS(latlng);
- } else if (modValue.curLatlngType == 'df') {
- var nLatlng = L.Util.formatHM(latlng);
- } else if (modValue.curLatlngType == 'd') {
- if (lng > 180) {
- lng = (lng % 180) - 180;
- } else if (lng < -180) {
- lng = 180 + (lng % 180);
- }
- lng = lng.toFixed(6);
- lat = lat.toFixed(6);
- if (lat < 0) {
- nLat = 'S' + lat * -1;
- } else {
- nLat = 'N' + lat;
- }
- if (lng < 0) {
- nLng = 'W' + lng * -1;
- } else {
- nLng = 'E' + lng;
- }
- var nLatlng = {
- lng: nLng,
- lat: nLat
- };
- } else if (modValue.curLatlngType == 'tgoos' || modValue.curLatlngType == 'sgoos') {
- var goosLatlong = GaussUtil.fromLatLon(latlng.lat, latlng.lng, status.curZoingNum)
- }
- if (modValue.curLatlngType == 'tgoos' || modValue.curLatlngType == 'sgoos') {
- $('#pointInfoToTen .goosXY').empty().append('带号:' + goosLatlong.zoneNum + ' X:' + goosLatlong.x.toFixed(4) + ' Y:' + goosLatlong.y.toFixed(4));
- } else {
- $('#pointInfoToTen .goosXY').empty().append('经度:' + nLatlng.lng + ' 纬度:' + nLatlng.lat);
- }
- }
- function bian(e) {
- if (e == "1") {
- ONEMAP.C.publisher.unSubscribe(updateLatlng, 'mousemove23D');
- ONEMAP.C.publisher.subscribe(upsz, 'map2DMoveIng');
- } else {
- ONEMAP.C.publisher.unSubscribe(upsz, 'map2DMoveIng');
- ONEMAP.C.publisher.subscribe(updateLatlng, 'mousemove23D');
- }
- }
- function removeMouseMove() {
- ONEMAP.C.publisher.unSubscribe(updateLatlng, 'mousemove23D');
- ONEMAP.C.publisher.unSubscribe(upsz, 'map2DMoveIng');
- }
- function coordinateChage(obj) {
- coordinateExport(obj);
- }
- //三维回调
- function updateLatlng3D(msg, options) {
- var position = map3DViewer.screenToLatLng(options.x, options.y)
- updateLatlng({
- lng: position.lng,
- lat: position.lat
- });
- }
- //三维回调
- function updataDEMHeight3D(msg, options) {
- // var position = map3DViewer.screenToLatLng(options.x, options.y)
- // updateLatlng({
- // lng: position.lng,
- // lat: position.lat
- // });
- //经纬度显示
- var lat = options.infos.lat;
- //var nlat = map23DControl.formatDegree(lat);
- var lng = options.infos.lng;
- //var nlng = map23DControl.formatDegree(lng);
- var alt = options.infos.alt;
- var zoom = map3DViewer.getZoomFrom3DZoom(alt);
- updataDEMHeight(lat, lng, zoom);
- $("#footer .viewHeight .curheight").html(alt.toFixed(0) + '米');
- }
- //获取当前位置
- // 52定位
- function getUserLocation_() {
- $.ajax({
- url: onemapUrlConfig.getUserLocation,
- type: 'get',
- dataType: 'json',
- })
- .done(function (data) {
- map23DControl.setView({
- center: {
- lat: data.latitude,
- lng: data.longitude
- },
- zoom: 12
- })
- })
- .fail(function () {
- console.log("error");
- })
- .always(function () {
- console.log("complete");
- });
- }
- // qq定位
- function getUserLocation() {
- var geolocation = new qq.maps.Geolocation("RUZBZ-7KZCU-CUMVO-4F62L-BOSHJ-EHFVC", "yiqing");
- var options = {
- timeout: 8000
- };
- function showPosition(position) {
- position = qqmapTowgs84(position.lng, position.lat)
- ONEMAP.D.globalSettingData.baseMap2D.center.lat = position.lat
- ONEMAP.D.globalSettingData.baseMap2D.center.lng = position.lng
- setTimeout(function () {
- map23DControl.setView({
- center: {
- lat: ONEMAP.D.globalSettingData.baseMap2D.center.lat,
- lng: ONEMAP.D.globalSettingData.baseMap2D.center.lng
- },
- zoom: 12
- })
- }, 1000);
- };
- function showErr() {
- $.ajax({
- type: "get",
- dataType: 'json',
- url: onemapUrlConfig.getQQLocationUrl + '/ws/location/v1/ip',
- data: {
- key: 'RUZBZ-7KZCU-CUMVO-4F62L-BOSHJ-EHFVC'
- },
- success: function (data) {
- var location = data.result.location
- position = qqmapTowgs84(location.lng, location.lat)
- ONEMAP.D.globalSettingData.baseMap2D.center.lat = position.lat
- ONEMAP.D.globalSettingData.baseMap2D.center.lng = position.lng
- setTimeout(function () {
- map23DControl.setView({
- center: {
- lat: ONEMAP.D.globalSettingData.baseMap2D.center.lat,
- lng: ONEMAP.D.globalSettingData.baseMap2D.center.lng
- },
- zoom: 12
- })
- }, 1000);
- }
- })
- };
- //获取位置信息
- geolocation.getLocation(showPosition, showErr, options);
- }
- /**
- * 注册订阅
- * @type {Function}
- * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type');
- * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange');
- */
- function subscribe() {
- ONEMAP.C.publisher.subscribe(change23D, 'change23D');
- ONEMAP.C.publisher.subscribe(updateViewHeight, 'mapChange23D');
- ONEMAP.C.publisher.subscribe(updateLatlng, 'mousemove23D');
- ONEMAP.C.publisher.subscribe(bian, 'jingzhi');
- ONEMAP.C.publisher.subscribe(coordinateChage, 'coordinateChage');
- //3D
- PubSub.subscribe('map3D.mouseMove', updateLatlng3D);
- }
- return ONEMAP.M.footer = {
- init: init,
- removeMouseMove: removeMouseMove,
- coordinateChage: coordinateChage
- };
- })
|