123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823 |
- /**
- * [ONEMAP.M.user]
- * @return {[object]}
- */
- define(['html!templates/user',
- 'css!styles/user',
- 'css!styles/tools/toolPublicPopup',
- 'modDir/tools/toolDraw_new'
- ], function (tplLayout) {
- /*****
- * 地理帮助脚本
- */
- const coordinate = {
- x_PI: (Math.PI * 3000.0) / 180.0,
- PI: Math.PI,
- ee: 0.00669342162296594323,
- a: 6378245.0,
- projs: {
- '01': 'wgs84', //84坐标
- '02': 'gcj02', //火星坐标
- '03': 'bd09', //百度坐标
- '04': 'utm4', //utm坐标
- '05': 'shcj', //城建坐标
- '06': 'meter', //米制单位
- '07': 'degree' // 度制单位
- },
- epsg: {
- //WGS 84 - WGS84 - World Geodetic System 1984, used in GPS
- '4326': '+proj=longlat +datum=WGS84 +no_defs',
- //WGS 84 / Pseudo-Mercator - Spherical Mercator, Google Maps, OpenStreetMap, Bing, ArcGIS, ESRI
- '3857':
- '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs',
- //CGCS2000 / 3-degree Gauss-Kruger zone 40
- '4528':
- '+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=GRS80 +units=m +no_defs'
- },
- bd09_to_gcj02: function (bd_lon, bd_lat) {
- var x = bd_lon - 0.0065
- var y = bd_lat - 0.006
- var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * this.x_PI)
- var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.x_PI)
- var gg_lng = z * Math.cos(theta)
- var gg_lat = z * Math.sin(theta)
- return [gg_lng, gg_lat]
- },
- gcj02_to_bd09: function (lng, lat) {
- var z =
- Math.Sqrt(lng * lng + lat * lat) + 0.00002 * Math.Sin(lat * this.x_PI)
- var theta = Math.Atan2(lat, lng) + 0.000003 * Math.Cos(lng * this.x_PI)
- var bd_lng = z * Math.Cos(theta) + 0.0065
- var bd_lat = z * Math.Sin(theta) + 0.006
- return [bd_lng, bd_lat]
- },
- wgs84_to_gcj02: function (lng, lat) {
- if (this.out_of_china(lng, lat)) {
- [lng, lat]
- } else {
- var dlat = this.transformlat(lng - 105.0, lat - 35.0)
- var dlng = this.transformlng(lng - 105.0, lat - 35.0)
- var radlat = (lat / 180.0) * this.PI
- var magic = Math.sin(radlat)
- magic = 1 - this.ee * magic * magic
- var sqrtmagic = Math.sqrt(magic)
- dlat =
- (dlat * 180.0) /
- (((this.a * (1 - this.ee)) / (magic * sqrtmagic)) * this.PI)
- dlng =
- (dlng * 180.0) / ((this.a / sqrtmagic) * Math.cos(radlat) * this.PI)
- var mglat = parseFloat(lat) + parseFloat(dlat)
- var mglng = parseFloat(lng) + parseFloat(dlng)
- return [mglng, mglat]
- }
- },
- gcj02_to_wgs84: function (lng, lat) {
- if (this.out_of_china(lng, lat)) {
- return [lng, lat]
- } else {
- var dlat = this.transformlat(lng - 105.0, lat - 35.0)
- var dlng = this.transformlng(lng - 105.0, lat - 35.0)
- var radlat = (lat / 180.0) * this.PI
- var magic = Math.sin(radlat)
- magic = 1 - this.ee * magic * magic
- var sqrtmagic = Math.sqrt(magic)
- dlat =
- (dlat * 180.0) /
- (((this.a * (1 - this.ee)) / (magic * sqrtmagic)) * this.PI)
- dlng =
- (dlng * 180.0) / ((this.a / sqrtmagic) * Math.cos(radlat) * this.PI)
- var mglat = lat + dlat
- var mglng = lng + dlng
- return [lng * 2 - mglng, lat * 2 - mglat]
- }
- },
- out_of_china: function (lng, lat) {
- // 纬度3.86~53.55,经度73.66~135.05
- return !(lng > 73.66 && lng < 135.05 && lat > 3.86 && lat < 53.55)
- },
- transformlat: function (lng, lat) {
- var ret =
- -100.0 +
- 2.0 * lng +
- 3.0 * lat +
- 0.2 * lat * lat +
- 0.1 * lng * lat +
- 0.2 * Math.sqrt(Math.abs(lng))
- ret +=
- ((20.0 * Math.sin(6.0 * lng * this.PI) +
- 20.0 * Math.sin(2.0 * lng * this.PI)) *
- 2.0) /
- 3.0
- ret +=
- ((20.0 * Math.sin(lat * this.PI) +
- 40.0 * Math.sin((lat / 3.0) * this.PI)) *
- 2.0) /
- 3.0
- ret +=
- ((160.0 * Math.sin((lat / 12.0) * this.PI) +
- 320 * Math.sin((lat * this.PI) / 30.0)) *
- 2.0) /
- 3.0
- return ret
- },
- transformlng: function (lng, lat) {
- var ret =
- 300.0 +
- lng +
- 2.0 * lat +
- 0.1 * lng * lng +
- 0.1 * lng * lat +
- 0.1 * Math.sqrt(Math.abs(lng))
- ret +=
- ((20.0 * Math.sin(6.0 * lng * this.PI) +
- 20.0 * Math.sin(2.0 * lng * this.PI)) *
- 2.0) /
- 3.0
- ret +=
- ((20.0 * Math.sin(lng * this.PI) +
- 40.0 * Math.sin((lng / 3.0) * this.PI)) *
- 2.0) /
- 3.0
- ret +=
- ((150.0 * Math.sin((lng / 12.0) * this.PI) +
- 300.0 * Math.sin((lng / 30.0) * this.PI)) *
- 2.0) /
- 3.0
- return ret
- },
- /// <summary>
- /// web墨卡托经纬度转米
- /// </summary>
- /// <param name="lng"></param>
- /// <param name="lat"></param>
- /// <returns></returns>
- degree_to_meter: function (lng, lat) {
- var x = (lng * 20037508.34) / 180
- var y = Math.log(Math.tan(((90 + lat) * this.PI) / 360)) / (this.PI / 180)
- y = (y * 20037508.34) / 180
- return [x, y]
- },
- //Web墨卡托转经纬度
- meter_to_degree: function (x, y) {
- var lon = (x / 20037508.34) * 180
- var lat = (y / 20037508.34) * 180
- lat =
- (180 / this.PI) *
- (2 * Math.atan(Math.exp((lat * this.PI) / 180)) - this.PI / 2)
- return [lon, lat]
- },
- /**
- * @description wgs84坐标转上海城建
- * @time 2020-09-02
- * @author zhb
- * @param {*} x
- * @param {*} y
- */
- wgs84_to_shcj: function (x, y) {
- let xy = []
- xy = this.shcj_get_UTM_from_WGS(x, y)
- return this.utm_to_shcj4(xy[0], xy[1])
- },
- utm_to_shcj4(x, y) {
- let DX, DY, T, K
- DX = -500199.29965
- DY = -3457078.805985
- T = 0.0000001755
- K = 1.0004000106
- return this.covert_by_four_parm(x, y, DX, DY, T, K)
- },
- shcj_get_UTM_from_WGS: function (lon, lat) {
- let a = 6378137
- let b = 6356752.3142451
- let f = (a - b) / a
- let eSquare = 2 * f - f * f
- let k0 = 0.9996
- let lonOrigin = 121.46714714
- let FN = 0
- // # 确保longtitude位于-180.00----179.9之间
- let lonTemp = lon + 180 - Math.floor((lon + 180) / 360) * 360 - 180
- let latRad = (lat * this.PI) / 180
- let lonRad = (lonTemp * this.PI) / 180
- let lonOriginRad = (lonOrigin * this.PI) / 180
- let e2Square = eSquare / (1 - eSquare)
- let V = a / Math.sqrt(1 - eSquare * Math.pow(Math.sin(latRad), 2))
- let T = Math.pow(Math.tan(latRad), 2)
- let C = e2Square * Math.pow(Math.cos(latRad), 2)
- let A = Math.cos(latRad) * (lonRad - lonOriginRad)
- let M =
- a *
- ((1 -
- eSquare / 4 -
- (3 * Math.pow(eSquare, 2)) / 64 -
- (5 * Math.pow(eSquare, 3)) / 256) *
- latRad -
- ((3 * eSquare) / 8 +
- (3 * Math.pow(eSquare, 2)) / 32 +
- (45 * Math.pow(eSquare, 3)) / 1024) *
- Math.sin(2 * latRad) +
- ((15 * Math.pow(eSquare, 2)) / 256 +
- (45 * Math.pow(eSquare, 3)) / 1024) *
- Math.sin(4 * latRad) -
- ((35 * Math.pow(eSquare, 3)) / 3072) * Math.sin(6 * latRad))
- // # x
- let UTMEasting =
- k0 *
- V *
- (A +
- ((1 - T + C) * Math.pow(A, 3)) / 6 +
- ((5 - 18 * T + Math.pow(T, 2) + 72 * C - 58 * e2Square) *
- Math.pow(A, 5)) /
- 120) +
- 500000.0
- // # y
- let UTMNorthing =
- k0 *
- (M +
- V *
- Math.tan(latRad) *
- (Math.pow(A, 2) / 2 +
- ((5 - T + 9 * C + 4 * Math.pow(C, 2)) * Math.pow(A, 4)) / 24 +
- ((61 - 58 * T + Math.pow(T, 2) + 600 * C - 330 * e2Square) *
- Math.pow(A, 6)) /
- 720))
- //# 南半球纬度起点为10000000.0m
- UTMNorthing += FN
- let xy = []
- xy[0] = UTMEasting
- xy[1] = UTMNorthing
- return xy
- },
- /**
- * @description 上海城建坐标转wgs84
- * @time 2020-09-02
- * @author zhb
- * @param {*} x
- * @param {*} y
- */
- shcj_to_wgs84: function (x, y) {
- let xy = []
- xy = this.shcj_to_utm4(x, y)
- return this.shcj_get_WGS_from_UTM(xy[0], xy[1])
- },
- shcj_to_utm4: function (x, y) {
- let DX, DY, T, K
- DX = 499999.90104
- DY = 3455696.403019
- T = -0.0000001755
- K = 0.999600149344
- return this.covert_by_four_parm(x, y, DX, DY, T, K)
- },
- //四参数公式
- covert_by_four_parm: function (x, y, dx, dy, a, k) {
- let px = 0
- let py = 0
- px = x * k * Math.cos(a) - y * k * Math.sin(a) + dx
- py = x * k * Math.sin(a) + y * k * Math.cos(a) + dy
- let xy = []
- xy[0] = px
- xy[1] = py
- return xy
- },
- shcj_get_WGS_from_UTM: function (x, y) {
- //WGS84
- let a = 6378137 //椭球体长半轴
- let b = 6356752.3142451 //椭球体短半轴
- // double a = 6378245 ;
- // double b =6356863.018773047300000000;
- x = 500000 - x
- let k0 = 0.9996
- let e = Math.sqrt(1 - Math.pow(b, 2) / Math.pow(a, 2))
- // # calculate the meridional arc
- let M = y / k0
- //# calculate footprint latitude
- let mu =
- M /
- (a *
- (1 -
- Math.pow(e, 2) / 4 -
- (3 * Math.pow(e, 4)) / 64 -
- (5 * Math.pow(e, 6)) / 256))
- let e1 =
- (1 - Math.pow(1 - Math.pow(e, 2), 1.0 / 2)) /
- (1 + Math.pow(1 - Math.pow(e, 2), 1.0 / 2))
- let J1 = (3 * e1) / 2 - (27 * Math.pow(e1, 3)) / 32
- let J2 = (21 * Math.pow(e1, 2)) / 16 - (55 * Math.pow(e1, 4)) / 32
- let J3 = (151 * Math.pow(e1, 3)) / 96
- let J4 = (1097 * Math.pow(e1, 4)) / 512
- let fp =
- mu +
- J1 * Math.sin(2 * mu) +
- J2 * Math.sin(4 * mu) +
- J3 * Math.sin(6 * mu) +
- J4 * Math.sin(8 * mu)
- // # Calculate Latitude and Longitude
- let e2 = Math.pow(e, 2) / (1 - Math.pow(e, 2))
- let C1 = e2 * Math.pow(Math.cos(fp), 2)
- let T1 = Math.pow(Math.tan(fp), 2)
- let R1 =
- (a * (1 - Math.pow(e, 2))) /
- Math.pow(1 - Math.pow(e * Math.sin(fp), 2), 3.0 / 2)
- //# This is the same as rho in the forward conversion formulas above, but calculated for fp instead of lat.
- let N1 = a / Math.pow(1 - Math.pow(e * Math.sin(fp), 2), 1.0 / 2)
- //# This is the same as nu in the forward conversion formulas above, but calculated for fp instead of lat.
- let D = x / (N1 * k0)
- let Q1 = (N1 * Math.tan(fp)) / R1
- let Q2 = Math.pow(D, 2) / 2
- let Q3 =
- ((5 + 3 * T1 + 10 * C1 - 4 * Math.pow(C1, 2) - 9 * e2) * Math.pow(D, 4)) /
- 24
- let Q4 =
- ((61 +
- 90 * T1 +
- 298 * C1 +
- 45 * Math.pow(T1, 2) -
- 3 * Math.pow(C1, 2) -
- 252 * e2) *
- Math.pow(D, 6)) /
- 720
- let lat = ((fp - Q1 * (Q2 - Q3 + Q4)) * 180) / this.PI
- // System.out.println("lat===="+Math.toRadians(fp - Q1*(Q2 - Q3 + Q4)));
- let Q5 = D
- let Q6 = ((1 + 2 * T1 + C1) * Math.pow(D, 3)) / 6
- let Q7 =
- ((5 -
- 2 * C1 +
- 28 * T1 -
- 3 * Math.pow(C1, 2) +
- 8 * e2 +
- 24 * Math.pow(T1, 2)) *
- Math.pow(D, 5)) /
- 120
- let lonmid = 121.46714714
- let lon = lonmid - (((Q5 - Q6 + Q7) / Math.cos(fp)) * 180) / this.PI
- //System.out.println("lon===="+(mMid - Math.toRadians((Q5 - Q6 + Q7)/Math.cos(fp))));
- // System.out.println(lat+","+lon);
- let xy = []
- xy[0] = lon
- xy[1] = lat
- return xy
- },
- wgs84_to_bd09: function (x, y) {
- let ll = this.wgs84_to_gcj02(x, y)
- ll = this.gcj02_to_bd09(ll[0], ll[1])
- return ll
- },
- bd09_to_wgs84: function (x, y) {
- let ll = this.bd09_to_gcj02(x, y)
- ll = this.gcj02_to_wgs84(ll[0], ll[1])
- return ll
- },
- gcj02_to_shcj: function (x, y) {
- let ll = this.gcj02_to_wgs84(x, y)
- ll = this.wgs84_to_shcj(ll[0], ll[1])
- return ll
- },
- shcj_to_gcj02: function (x, y) {
- let ll = this.shcj_to_wgs84(x, y)
- ll = this.wgs84_to_gcj02(ll[0], ll[1])
- return ll
- },
- /**
- * @description 坐标转换转换 01:84,02:高德,03.百度,04,UTM,05,上海城建,06:米制单位
- * @param {} from
- * @param {*} to
- * @param {*} xy
- * @time 2020-09-02
- * @author zhb
- */
- convert_proj_from_to: function (from, to, xy) {
- if (from === to) {
- return xy
- } else {
- let fromProj = this.projs[from]
- let toProj = this.projs[to]
- let targetMethod = `${fromProj}_to_${toProj}`
- return this[targetMethod](xy[0], xy[1])
- }
- }
- }
- var status = {
- userContentShow: false,
- netType: null,
- // showhideAll:true
- }
- function init() {
- setLayout();
- subscribe();
- bindEvents();
- };
- function setLayout() {
- // 获取地名地址token - 刘梦祥
- getAddrApiToken();
- // 渲染地名地址搜索框 - 刘梦祥
- setTimeout(function () {
- $("#addressSearch").show();
- showResultListBox(false, [], false);
- // 地名地址搜索框内容监听
- $("#addressSearch").on("change", function () {
- let searchValue = "";
- searchValue = $("#addressSearch").val();
- if (searchValue != "") {
- searchValueFun();
- } else {
- // 收起建议栏
- showResultListBox(false, [], false);
- }
- });
- //监听地名地址搜索结果View Close按钮
- $(".closeDiv").off("click").on("click", function () {
- showResultListBox(false, [], false);
- })
- }, 500);
- // $(tplLayout).appendTo($("#wrapper"));
- $(tplLayout).appendTo($("#userInfo"));
- //$('#userContent .userLink .cover-content').html(ONEMAP.D.user.name);
- //拖拽
- $(".userInfo .popup-ct").dragmove($('.userInfo'));
- if (ONEMAP.D.isLoad) {//判断是否登录,ture 登录
- return;
- var role_list = ONEMAP.D.user.roles;
- // 只有admin用户才有地图设置选项
- $.each(role_list, function (i, t) {
- switch (t) {
- case "admin":
- $('#userContent .userInfo .moreLink .linkList li.set').css("display", "inline-block");
- break;
- }
- })
- }
- if (map23DConfig.netType == 1) {
- $("#userInfo .check-button").html("离线");
- $("#userContent .lgfooter .check-button").animate({ "left": "40px" }, 200);
- status.netType = 1;
- } else {
- $("#userInfo .check-button").html("在线");
- $("#userContent .lgfooter .check-button").animate({ "left": "8px" }, 200);
- status.netType = 2;
- }
- if (ONEMAP.D.user.username != "map_super_user") {
- $('#userContent .userInfo .moreLink .linkList li.set').hide();
- }
- if (!map23DConfig.showSourceCenter) {
- $('#userContent .share').hide();
- }
- };
- // 获取地名地址token信息,并保存到LocalStorage中 - 刘梦祥
- function getAddrApiToken() {
- try {
- $.ajax({
- url: onemapUrlConfig.DMS_URL + '/dms/content/selectContentList',
- type: 'POST',
- headers: {
- token: localStorage.getItem("systemToken")
- },
- dataType: "json",
- data: {
- columnId: 1229,
- states: 0,
- pageSize: 10,
- page: 0
- },
- })
- .done(function (res) {
- if (res.content && res.content.data && res.content.data[0].c_content) {
- localStorage.setItem("Accesstoken", res.content.data[0].c_content);
- } else {
- ONEMAP.C.publisher.publish({
- type: 'warning',
- message: "用户尚未登录!"
- }, 'noteBar::add');
- }
- }).fail(function (error) {
- ONEMAP.C.publisher.publish({
- type: 'warning',
- message: error
- }, 'noteBar::add');
- console.error("getAddrApiToken", error);
- });
- } catch (error) {
- console.error("getAddrApiToken catch", error);
- }
- }
- // 地名地址搜索功能 - 刘梦祥
- function searchValueFun() {
- // 根据搜索条件进行搜索匹配
- try {
- let searchValue = $("#addressSearch").val();
- let params = {
- addr: searchValue,
- page: 1,
- limit: 10,
- projectId: [],
- addressType: [],
- fuzzy: true
- };
- if (localStorage.getItem("addrSearchTag") == 1) {
- params.fuzzy = true;
- } else {
- params.fuzzy = false;
- }
- // 开始搜索
- $.ajax({
- url: "http://10.235.245.226:7010/AddressCoreService/addrMatch/addrApi/searchAddrForGeo",
- type: 'POST',
- headers: {
- "Accesstoken": localStorage.getItem("Accesstoken")
- },
- data: params,
- })
- .done(function (res) {
- if (res.data.features.length > 0) {
- let resultDataList = res.data.features;
- showResultListBox(true, resultDataList, params.fuzzy);
- } else {
- ONEMAP.C.publisher.publish({
- type: 'warning',
- message: "关键词未搜索到结果!"
- }, 'noteBar::add');
- showResultListBox(false, [], false);
- }
- }).fail(function (error) {
- console.error("searchValueFun", error);
- showResultListBox(false, [], false);
- });
- } catch (error) {
- console.error("searchValueFun catch", error);
- showResultListBox(false, [], false);
- }
- }
- // 定位到指定的坐标
- ONEMAP.C.publisher.subscribe(function (data) {
- let localAddr = coordinate.shcj_to_wgs84(data.x, data.y);
- map23DControl.setView({
- center: {
- lat: localAddr[1],
- lng: localAddr[0]
- },
- zoom: 18
- })
- }, 'orientationToMap');
- // 根据条件渲染地名地址结果View - 刘梦祥 fuzzy:如果返回的结果是精准查找的话,点击Item后要有单独的处理事件并隐藏View
- function showResultListBox(status, resultList, fuzzy) {
- if ($(".resultItem")) {
- $(".resultItem").remove();
- }
- if (resultList.length > 0) {
- for (let i = 0; i < resultList.length; i++) {
- if (fuzzy) {
- $(`<div class="resultItem orientation" onclick="orientation('` + resultList[i].properties.x + `','` + resultList[i].properties.y + `')">` + (i + 1) + " : " + resultList[i].properties.addr + `</div>`).appendTo($("#resultListBox"));
- } else {
- $(`<div class="resultItem" onclick="searchAddrTure('` + resultList[i].properties.addr + `')">` + (i + 1) + " : " + resultList[i].properties.addr + `</div>`).appendTo($("#resultListBox"));
- }
- }
- }
- if (status) {
- $("#resultListBox").show();
- } else {
- localStorage.setItem("addrSearchTag", 0);
- $("#resultListBox").hide();
- }
- }
- function fullMap(option) {
- if (option) {
- $("#userContent").fadeOut('slow')
- } else {
- $("#userContent").fadeIn('slow')
- }
- }
- function change23D(options) {
- if (options == '2d') {
- $('#userContent').removeClass('class3d');
- // $("#userContent .userInfo .moreLink .linkList li.myBh").addClass('active');
- } else {
- $('#userContent').addClass('class3d');
- // $("#userContent .userInfo .moreLink .linkList li.myBh").removeClass('active');
- }
- }
- function remove() {
- ONEMAP.M.toolDraw.remove({ modName: 'cleanMap' });
- }
- function subscribe() {
- // ONEMAP.C.publisher.subscribe(remove,'tools:active');
- ONEMAP.C.publisher.subscribe(layoutesize, 'seitchNetwork');
- ONEMAP.C.publisher.subscribe(closeLeft, 'layout::closeLeft');
- ONEMAP.C.publisher.subscribe(change23D, 'change23D');
- ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap');
- };
- function bindEvents() {
- //用户左上面板开关
- $('#userContent .userLink').bind('click', function () {
- var userInfo = $("#userContent .userInfo");
- if (userInfo.hasClass("active")) {
- userInfo.removeClass("active");
- } else {
- userInfo.addClass("active");
- $("#searchresult").hide();
- }
- //关掉menu
- if ($("#menu").hasClass("moveOut")) {
- $("#menu").animate({
- left: "-340px"
- }, 200)
- $("#menu").removeClass("moveOut");
- var layer = $("#layerControlMenu");
- var layerLeft = parseFloat($("#layerControlMenu").css("left"));
- if (layerLeft <= 0) {
- layer.animate({
- left: "-340px"
- }, 200)
- }
- // $("#menu .arrow").removeClass("left");
- }
- })
- //用户面板中我的收藏
- $("#userContent .userInfo .moreLink .linkList li.collect").bind("click", function () {
- require(['modDir/user/userSideBar'], function (userSideBar) {
- userSideBar.init();
- });
- if ($("#toolsBar").hasClass('cur')) {
- $("#toolsBar p").click();
- }
- // $("#userContent .userInfo .moreLink .linkList li.myBh").addClass('uFavo').addClass('active');
- })
- $(".data-share-link").attr("href", onemapUrlConfig.shareUrl);
- $('#userContent .userLink').bind('click', function () {
- if (ONEMAP.D.isLoad) {
- $('#userContent .userInfo .moreLink,.lgtop').show();
- $('#userContent .popup-lt,#userContent .popup-lb,#userContent .popup-rt,#userContent .popup-rb').show();
- $('#userContent .username').html(ONEMAP.D.user.name);//填入用户名
- // $('#userContent .username').html();//疑惑操作
- // $("#userContent .userInfo .moreLink .collect").show();
- $("#userContent .mt10").show();//展示上次登录时间
- $("#userContent").removeClass("no-login");//无实际用途
- $("#userContent .quit").show();//展示退出登录
- $("#userContent .userInfo .login").hide();//隐藏提示登录信息
- $("#userContent .userInfo .moreLink .linkList li.myBh").addClass('uFavo').addClass('active');
- } else {
- $('#userContent .userInfo .login').show();//展示提示登录信息
- $("#userContent .mt10").hide();//隐藏上次登录时间
- // $("#userContent").addClass("no-login");//无实际用途
- // $('#userContent .userInfo .moreLink,.lgtop').show();//疑惑操作
- $("#userContent .userInfo .moreLink").hide();//隐藏用户中心
- $("#userContent .quit").hide();//隐藏退出登录
- $("#userContent .userInfo .moreLink .linkList li.myBh").removeClass('uFavo').removeClass('active');//隐藏我的标注
- }
- $('#userContent .userLink').addClass('active');
- status.userContentShow = true;
- })
- //登录
- $('#userContent .userInfo .login a').bind('click', function () {
- // ONEMAP.C.gotoLogin();
- // require(['modDir/user/userLogin'], function (userLogin) {
- // userLogin.init();
- // });
- $("#userLogin").show();
- })
- $("#userContent .userInfo .moreLink .linkList li").bind('click', function () {
- var curmid = $(this).attr('mid');
- if (curmid == 'logout') {
- ONEMAP.C.logout();
- } else if (curmid == 'setting') {
- require(['modDir/user/userSetting'], function (userSetting) {
- userSetting.init();
- });
- }
- // else if (curmid == 'userCenter') {
- // require(['modDir/user/userCenter'], function(userCenter) {
- // userCenter.init('userFav');
- // });
- // }
- else if (curmid == 'set') {
- require(['modDir/user/userSetting'], function (userSetting) {
- userSetting.init();
- });
- }
- })
- // 退出登录
- $("#userContent .quit").bind('click', function () {
- // ONEMAP.C.logout();
- // $("#userContent .mt10").hide();
- localStorage.removeItem('userInfo');
- localStorage.removeItem('systemToken');
- window.location.reload();
- })
- // 标注显隐
- $("#userContent .userInfo .moreLink .linkList li.myBh").unbind("click").bind("click", function () {
- if ($(this).hasClass('uFavo')) {
- // if(status.showhideAll){
- //加载全部
- ONEMAP.M.toolDraw.addAllCollect("show");
- // }
- //$(".leaflet-marker-pane,.leaflet-overlay-pane,.leaflet-shadow-pane").show(); // 二维
- $("#userContent .userInfo .moreLink .linkList li.myBh").removeClass("uFavo");
- // status.showhideAll = false;
- } else {
- ONEMAP.M.toolDraw.addAllCollect("hide");
- //$(".leaflet-marker-pane,.leaflet-overlay-pane,.leaflet-shadow-pane").hide(); // 二维
- $("#userContent .userInfo .moreLink .linkList li.myBh").addClass("uFavo");
- }
- })
- // 关闭左侧栏
- $("#userInfo .arrow").bind('click', function () {
- ONEMAP.M.user.closeLeft();
- })
- //切换网络
- $("#switchInter").bind('click', function () {
- if (status.netType == 1) {
- curNetType = 2;
- } else {
- curNetType = 1
- }
- require(['layoutDir/switchNetwork'], function (switchNetwork) {
- switchNetwork.init(curNetType);
- });
- })
- //新登录
- // $("#userInfo").bind('click',function(){
- // require(['modDir/user/userLogin'], function (userLogin) {
- // userLogin.init();
- // });
- // })
- };
- function layoutesize(type) {
- if (type == "network") {
- status.netType = 1;
- $("#userInfo .check-button").html("离线");
- $("#userContent .lgfooter .check-button").animate({ "left": "40px" }, 200);
- } else {
- status.netType = 2;
- $("#userInfo .check-button").html("在线");
- $("#userContent .lgfooter .check-button").animate({ "left": "8px" }, 200);
- }
- }
- function closeLeft() {
- $("#menu").animate({
- left: "-340px"
- }, 200)
- $("#menu").removeClass("moveOut");
- var layer = $("#layerControlMenu");
- var layerLeft = parseFloat($("#layerControlMenu").css("left"));
- if (layerLeft <= 0) {
- layer.animate({
- left: "-340px"
- }, 200)
- }
- }
- return ONEMAP.M.user = {
- init: init,
- closeLeft: closeLeft
- }
- })
|