/** * @fileoverview 打印 模块 * @author Song.Huang * @version 1.0.0 */ var routeSearchFDTT = function () { /** 必经点+规避点路线规划 * [getNaviPathPro description] * @param {[type]} options [viaAry(第一个为起点,最后一个为终点,中间的为必经点) avoidAry(规避点数组)] * @param {[type]} callbackFunc [description] * @return {[type]} [description] */ this.getNaviPath = function (options, callbackFunc) { var sUrl = onemapUrlConfig.routeSearchDataUrl + '?via=' + JSON.stringify(options.viaAry) + '&avoid=' + JSON.stringify((options.avoidAry || [])); $.ajax({ url: sUrl, type: 'GET', dataType: 'jsonp' }) .done(function (data) { callbackFunc(data); }) .fail(function () {}); } }; var routeSearchNew = function () { /** 必经点+规避点路线规划 * [getNaviPathPro description] * @param {[type]} options [viaAry(第一个为起点,最后一个为终点,中间的为必经点) avoidAry(规避点数组)] * @param {[type]} callbackFunc [description] * @return {[type]} [description] */ this.getNaviPath = function (options, callbackFunc) { var pointArr = []; for (var i = 0; i < options.viaAry.length; i++) { pointArr.push(L.latLng(options.viaAry[i][1], options.viaAry[i][0])); } window.routingControl = L.Routing.control( L.extend({}, { waypoints: pointArr, //geocoder: L.Control.Geocoder.nominatim(), routeWhileDragging: true, reverseWaypoints: true, showAlternatives: true, simplifyGeometry: false, geometryOnly: true, altLineOptions: { styles: [{ color: 'black', opacity: 0.15, weight: 9 }, { color: 'white', opacity: 0.8, weight: 6 }, { color: 'blue', opacity: 0.5, weight: 2 } ] }, callback: callbackFunc })) }; } // var routeSearchF = function () { // /** 必经点+规避点路线规划 // * [getNaviPathPro description] // * @param {[type]} options [viaAry(第一个为起点,最后一个为终点,中间的为必经点) avoidAry(规避点数组)] // * @param {[type]} callbackFunc [description] // * @return {[type]} [description] // */ // this.getNaviPath = function (options, callbackFunc) { // var orig, dest, mid, afUrl; // var viaAryLength = options.viaAry.length; // if (viaAryLength < 3) { // afUrl = '?token=25cc55a69ea7422182d00d6b7c0ffa93&source=1&sPoint=' + options.viaAry[0] + // '&ePoint=' + options.viaAry[1] + // '&st=' + options.searchType; // } else if (viaAryLength >= 3) { // var midData; { // for (var i = 1; i < viaAryLength - 1; i++) { // var curmidData = JSON.stringify(options.viaAry[i]).replace('[', '').replace(']', ''); // if (i === 1) { // midData = curmidData; // } else { // midData = midData + ";" + curmidData; // } // } // } // afUrl = '?token=25cc55a69ea7422182d00d6b7c0ffa93&source=1&sPoint=' + options.viaAry[0] + // '&ePoint=' + options.viaAry[viaAryLength - 1] + // '&wayPoints=' + midData + // '&st=' + options.searchType; // } // var sUrl = onemapUrlConfig.siWeiRouteDataUrl + '/service/route/driving2' + // afUrl; // $.ajax({ // url: sUrl, // type: 'GET', // dataType: 'json' // }) // .done(function (data) { // var segArr = new Array(); // var coorArr = new Array(); // var coors = ""; // var doorArr = new Array(); // if (data.data.rows.length > 0) { // for (var i = 0; i < data.data.rows[0].item.length; i++) { // if (data.data.rows[0].item[i].routelatlon) { // coorArr[i] = data.data.rows[0].item[i].routelatlon.replace(/;/g, ","); // } else { // coorArr[i] = data.data.rows[0].item[i].turnlatlon.replace(/;/g, ","); // } // var roadLength; // var roadOld = data.data.rows[0].item[i].distance; // roadLength = parseFloat(data.data.rows[0].item[i].distance); // segArr[i] = { // "accessorialInfo": "", // "action": "", // "coor": coorArr[i], // "coorAry": coorArr[i].split(","), // "direction": 0.0, // "driveTime": "", // "form": "", // "grade": "", // "roadLength": roadLength, // "roadName": data.data.rows[0].item[i].streetName, // "soundID": "", // "textInfo": data.data.rows[0].item[i].strguide, // "videoID": "" // } // if (data.data.rows[0].item[i].routelatlon) { // coors += data.data.rows[0].item[i].routelatlon.replace(/;/g, ","); // } else { // coors += data.data.rows[0].item[i].turnlatlon.replace(/;/g, ","); // } // } // var cbData = { // "code": 0, // "data": { // "bounds": options.viaAry[0] + "," + options.viaAry[viaAryLength - 1], // "cache": false, // "coors": coors, // "count": parseInt(data.data.rows[0].count), // "message": "ok", // //"searchtime": parseInt(data.lines.time), // "segmengList": segArr // } // } // } else { // callbackFunc({ // "code": 0, // "data": [] // }) // } // callbackFunc(cbData); // }) // .fail(function () {}); // } // }; var addressSearchF = function () { /** * 通过缩放等级和坐标查询位置信息 * @param {[type]} options [latLng(经纬度数组[纬度,经度]) zoom(地图缩放比例)] * @param {[type]} callbackFunc [description] * @return {[type]} [description] */ this.getAddressInfo = function (options, callbackFunc) { var sUrl = onemapUrlConfigNetwork.addressSearchDataUrl + '/v1.0/address/near/' + '?z=' + options.zoom + '&lon=' + options.latLng[1] + '&lat=' + options.latLng[0]; $.ajax({ url: sUrl, type: 'GET', dataType: 'jsonp' }) .done(function (data) { callbackFunc(data); }) .fail(function () {}); } }; /** * 打印 * @exports printer * @type {Object} */ var printer = { /** * 初始化 * @type {Function} */ init: function () { var _this = this; // if (map23DConfig.netType == 1) { // $.each(map23DConfigIntranet, function (i, t) { // map23DConfig[i] = t // }) // $.each(onemapUrlConfigIntranet, function (i, t) { // onemapUrlConfig[i] = t // }) // } else { // $.each(map23DConfigNetwork, function (i, t) { // map23DConfig[i] = t // }) // $.each(onemapUrlConfigNetwork, function (i, t) { // onemapUrlConfig[i] = t // }) // } //解析URL判断打印类型 _this._urlParse(); //系统初始化路径服务 // if (map23DConfig.routType == 'New') { // } routeSearchF = routeSearchNew }, /** * url解析 * @type {Function} * @private */ _urlParse: function () { var _this = this; switch (_this._getQueryString('m')) { case 'directions': //路线规划 directionsPrint.init({ mapType: _this._getQueryString('map').split('|')[0], mapZoom: parseFloat(_this._getQueryString('map').split('|')[1]), mapCenter: [parseFloat(_this._getQueryString('map').split('|')[2]), parseFloat(_this._getQueryString('map').split('|')[3])], zoom: parseFloat(_this._getQueryString('dir').split('|')[4]), startPoint: [parseFloat(_this._getQueryString('dir').split('|')[0]), parseFloat(_this._getQueryString('dir').split('|')[1])], stopPoint: [parseFloat(_this._getQueryString('dir').split('|')[2]), parseFloat(_this._getQueryString('dir').split('|')[3])], startName: _this._getQueryString('place').split('|')[0], stopName: _this._getQueryString('place').split('|')[1], acrossPoints: JSON.parse(_this._getQueryString('across')), searchType: JSON.parse(_this._getQueryString('searchType')), avoidPoints: JSON.parse(_this._getQueryString('avoid')), thematicUrl: _this._getQueryString('thematic') ? CryptoJS.enc.Base64.parse(_this._getQueryString('thematic')).toString(CryptoJS.enc.Utf8) : false, plan: JSON.parse(_this._getQueryString('plan')) ? Number(_this._getQueryString('plan')) : 0 //CryptoJS.enc.Base64.parse([_this._getQueryString('thematic')]).toString(CryptoJS.enc.Utf8) }); break; } }, /** * Url解析 * @type {Function} * @param name {String} 参数键 * @returns {string} 参数值 * @private */ _getQueryString: function (name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return decodeURI(r[2]); return ''; } }; /**路线打印 * @exports directionsPrint * @type {Object} */ //http://www.domain.com/print.html? // m=directions 模块类型 // &dir=39.99605985169435|116.24221801757812|39.916582935817154|116.4166259765625|15 起点坐标|终点坐标|坐标查询缩放比例 // &map=1|10|39.9|116.3 类型|缩放比例|lat|lon var directionsPrint = { /** * 默认参数 * @type {Object} */ options: { mapType: 1, //地图底图类型 mapZoom: 10, //地图缩放比 mapCenter: [0, 0], //地图中心点 zoom: 19, //起始点查点zoom startPoint: [0, 0], //起点 stopPoint: [0, 0], //终点 startName: '', stopName: '', acrossPoints: [], //途经点 avoidPoints: [], //规避点 searchType: 1, plan: 0 }, /**路径点集合 * @type {Object} * @default {} */ _markerObjs: {}, /** * 初始化 获取起点/终点坐标-查询起点/终点信息-查询路线信息-画路径-列表路径点 * @type {Function} * @param options {Object} * @see options */ init: function (options) { var _this = this; for (var o in options) { if (options[o] !== null) { _this.options[o] = options[o]; } } var _step = 0; //设置标题 _this.title = $('

' + options.startName + '' + options.stopName + '的路线

').appendTo($('#title')); //地图初始化 _this._mapShow(); //设置起始点图标 _this._setMarkers({ type: 'start', latLng: _this.options.startPoint }); _this._getPointAddress(_this.options.zoom, { lat: _this.options.startPoint[0], lng: _this.options.startPoint[1] }, function (data) { _this.startPointInfo = { region: data.region, address: _this.options.startName }; _this.startMarker.bindPopup(_this.startPointInfo.address, { maxWidth: 100, minWidth: 100 }); //_this.title.find('.f').append(data.address); _this._markerObjs[100001] = { actionType: 'ico_p_2', popInfo: _this.startPointInfo.address, center: [_this.startMarker.getLatLng().lat, _this.startMarker.getLatLng().lng] }; if (_step === 1) { //获取路线信息 _this._getDirectionsLine(); } else { _step++; } }); for (var i = 0, l = _this.options.acrossPoints.length; i < l; i++) { _this._setMarkers({ type: 'across', latLng: _this.options.acrossPoints[i] }); } for (var i = 0, l = _this.options.avoidPoints.length; i < l; i++) { _this._setMarkers({ type: 'avoid', latLng: _this.options.avoidPoints[i] }); } _this._setMarkers({ type: 'stop', latLng: _this.options.stopPoint }); _this._getPointAddress(_this.options.zoom, { lat: _this.options.stopPoint[0], lng: _this.options.stopPoint[1] }, function (data) { _this.stopPointInfo = { region: data.region, address: _this.options.stopName }; _this.stopMarker.bindPopup(_this.stopPointInfo.address, { maxWidth: 100, minWidth: 100 }); //_this.title.find('.t').append(data.address); _this._markerObjs[100002] = { actionType: 'ico_p_1', popInfo: _this.stopPointInfo.address, center: [_this.stopMarker.getLatLng().lat, _this.stopMarker.getLatLng().lng] }; if (_step === 1) { //获取路线信息 _this._getDirectionsLine(); } else { _step++; } }); //打印按钮事件 $('#btnPrint').removeAttr('disabled').removeClass('disabled').bind('click', function () { $('#remarks p').append($('#remarks textarea').val()); window.print(); }); // $('#printOption').empty().append('

为所有路段显示:仅文本 | 地图

'); $('#abtnHideAllPointMap').bind('click', function () { $('.abtn-show-text').each(function () { $(this).click(); }); }); $('#abtnShowAllPointMap').bind('click', function () { $('.abtn-show-map').each(function () { $(this).click(); }); }); $('#checkBigMapShow').bind('click', function () { if ($(this).is(':checked')) { $('#mapHolder').show(); $('#directionsResult').css({ pageBreakBefore: "always" }); } else { $('#mapHolder').hide(); $('#directionsResult').css({ pageBreakBefore: "auto" }); } }); }, /** * 显示专题图数据 * @private */ _setThematic: function () { var _this = this; if (_this.options.thematicUrl) { L.tileLayer(_this.options.thematicUrl).addTo(_this._map); } }, /** * 获取坐标对应的地名 * @type {Function} * @param zoom {Number} * @param latLng {Object} * @param callBack_func {Function} * @private */ _getPointAddress: function (zoom, latLng, callBack_func) { var addressSearch = new addressSearchF(); addressSearch.getAddressInfo({ zoom: zoom, latLng: [latLng.lat, latLng.lng] }, function (data) { data = data.data; if (data.hasOwnProperty('address')) { if (data.address.length == 0) { data.address = "未知地点"; } } callBack_func(data); }) }, /** * 获取路线 * @type {Function} * @private */ _getDirectionsLine: function () { var _this = this; var via = []; var avoid = []; via.push([_this.options.startPoint[1], _this.options.startPoint[0]]); for (var viaItem in _this.options.acrossPoints) { if (_this.options.acrossPoints.hasOwnProperty(viaItem)) { via.push([_this.options.acrossPoints[viaItem][1], _this.options.acrossPoints[viaItem][0]]); } } via.push([_this.options.stopPoint[1], _this.options.stopPoint[0]]); for (var avoidItem in _this.options.avoidPoints) { if (_this.options.avoidPoints.hasOwnProperty(avoidItem)) { avoid.push([_this.options.avoidPoints[avoidItem].latlng.lng, _this.options.avoidPoints[avoidItem].latlng.lat]); } } var searchOptions = { viaAry: via, searchType: _this.options.searchType }; var routeSearch = new routeSearchF(); routeSearch.getNaviPath(searchOptions, function (data) { // data = data.data; // if (!data.hasOwnProperty('segmengList')) { // alert('此线路无路径数据,无法规划路径!'); // return false; // } // _this._directionsDataResult = data; // _this._drawCarPolyline({ // opacity: 0.8, // lineNum: 0, // color: '#0099ff', // weight: 6 // }); //界面重置 if (data.length == 0) { setNotResultHtml('此线路无路径数据,无法规划路径!'); return false; } _this.navigationResult = []; for (var i = 0; i < data.length; i++) { var minlon = 0, maxlon = 0, minlat = 0, maxlat = 0; var polyline = '', allPolyline = ''; _this.navigationResult.push({}); //路径 全部点位(路径过长时,点位过多,渲染速度慢) for (var k = 0; k < data[i].coordinates.length; k++) { var lng = data[i].coordinates[k].lng var lat = data[i].coordinates[k].lat if (k == 0) { minlon = data[i].coordinates[k].lng maxlon = data[i].coordinates[k].lng minlat = data[i].coordinates[k].lat maxlat = data[i].coordinates[k].lat } else { if (lng < minlon) { minlon = lng } if (lng > maxlon) { maxlon = lng } if (lat < minlat) { minlat = lat } if (lat > maxlat) { maxlat = lat } } allPolyline += lng + ',' + lat + ","; } _this.navigationResult[i].coors = allPolyline; _this.navigationResult[i].coordinates = data[i].coordinates; _this.navigationResult[i].totalDistance = data[i].summary.totalDistance //米 _this.navigationResult[i].totalTime = data[i].summary.totalTime //秒 _this.navigationResult[i].segmengList = data[i].instructions //文字导航 _this.navigationResult[i].bounds = { minlon: minlon - (maxlon - minlon) / 5, maxlon: maxlon + (maxlon - minlon) / 5, minlat: minlat - (maxlat - minlat) / 5, maxlat: maxlat + (maxlat - minlat) / 5, }; //缩放范围 _this.navigationResult[i].center = { lon: (maxlon + minlon) / 2, lat: (maxlat + minlat) / 2 } } _this._directionsDataResult = _this.navigationResult[_this.options.plan] _this._drawCarPolyline({ opacity: 0.8, lineNum: 0, color: '#0099ff', weight: 6 }); _this._parseResultData(); }); }, /** * 地图初始化 * @type {Function} * @private */ _mapShow: function () { var _this = this; $('#mapHolder').css({ height: '800px' }); //默认为线划图 var layerName = 'gh'; //var layer2Name = 'satellite-address'; switch (_this.options.mapType) { case 'gm': //线划 layerName = 'gm'; break; case 'gh': //影像 layerName = 'gh'; break; case 'gr': //影像 layerName = 'gr'; break; case 'gt': //地形 layerName = 'gt'; break; } _this._mapOptions = { layers: [ L.tileLayer(map23DConfig.tileServerUrl + '/' + layerName + '?l={z}&x={x}&y={y}', { minZoom: 1, maxZoom: 19, subdomains: map23DConfig.tileSubdomains || '', noWrap: true }), // L.tileLayer(map23DConfig.tileServerUrl + '/go?l={z}&x={x}&y={y}', { // minZoom: 1, // maxZoom: 19, // subdomains: map23DConfig.tileSubdomains || '', // noWrap: true // }), ], //map23DConfig.tileServerUrl+'/'+layerName+'?l={z}&x={x}&y={y}', center: _this.options.mapCenter, zoom: _this.options.mapZoom, maxZoom: 19, minZoom: 1, zoomControl: false }; _this._map = new L.Map( 'mapHolder', _this._mapOptions ); //添加相应的专题图 _this._setThematic(); }, /** * @type {Object} * @param obj * @private */ _makeMarker: function (obj) { }, /** * 解析数据 填充节点 * @type {Function} * @private */ _parseResultData: function () { var _this = this; var list = $('
'); var directionsResult = $('
'); directionsResult.append(list); //填充起点 var startLi = $('' + '
' + '
' + '
' + '
' + '

' + _this.startPointInfo.address + '

' + '

' + _this.startPointInfo.region + '

' + '
' + '
' + '
' + '
' + '显示:仅文本 | 地图' + '
' + '
'); list.append(startLi); //填充规划点 var lineMeter = 0; for (var i = 0, l = _this._directionsDataResult.segmengList.length; i < l; i++) { var item = _this._directionsDataResult.segmengList[i]; var actionType = 'C'; if (!item.modifier || item.modifier == 'Straight') { //直行 actionType = 'C'; } if (item.modifier == 'Left') { //左转 actionType = 'TL'; } if (item.modifier == 'Right') { //右转 actionType = 'TR'; } if (item.modifier == 'Uturn') { actionType = 'TU'; } //item.coorAry = item.coor.split(','); lineMeter += item.distance; // var actionType = 'C'; // if (item.textInfo.indexOf('直行') >= 0) { // actionType = 'C'; // } // if (item.textInfo.indexOf('左转') >= 0) { // actionType = 'TL'; // } // if (item.textInfo.indexOf('稍向左转') >= 0) { // actionType = 'TSLL'; // } // if (item.textInfo.indexOf('向左急转') >= 0) { // actionType = 'TSHL'; // } // if (item.textInfo.indexOf('右转') >= 0) { // actionType = 'TR'; // } // if (item.textInfo.indexOf('稍向右转') >= 0) { // actionType = 'TSLR'; // } // if (item.textInfo.indexOf('向右急转') >= 0) { // actionType = 'TSHR'; // } // if (item.textInfo.indexOf('保持左行') >= 0) { // actionType = 'KL'; // } // if (item.textInfo.indexOf('保持右行') >= 0) { // actionType = 'KR'; // } // if (item.textInfo.indexOf('前方掉头') >= 0) { // actionType = 'TU'; // } // if (item.textInfo.indexOf('前方右侧掉头') >= 0) { // actionType = 'TRU'; // } // if (item.textInfo.indexOf('EXIT0') >= 0) { // actionType = 'EXIT'; // } var lng = _this.navigationResult[_this.options.plan].coordinates[item.index].lng var lat = _this.navigationResult[_this.options.plan].coordinates[item.index].lat var nlng = _this.formatDegree(lng); var nlat = _this.formatDegree(lat); //var nLatlng = L.Util.formatHMS([item.coorAry[1], item.coorAry[0]]); //var ge = (i % 2) ? 'ge' : ''; var ge = 'ge'; var li = $('' + '
' + '
' + '
' + '
' + (i + 1) + '.
' + '
' + '

' + item.text + '(' + nlng + ' , ' + nlat + ')

' + '

约' + Math.ceil(item.time / 60) + '分钟

' + '
' + '
' + '

移动 ' + Math.floor(item.distance / 1000 * 100) / 100 + '公里
总距离 ' + Math.floor(lineMeter / 1000 * 100) / 100 + '公里

' + '
' + '
' + '显示:仅文本 | 地图' + '
' + '
'); list.append(li); _this._markerObjs[i] = { actionType: 'ico_p_3-' + actionType, popInfo: item.text, center: [lat, lng] }; } //填充终点 var stopLi = $('' + '
' + '
' + '
' + '
' + '

' + _this.stopPointInfo.address + '

' + '

' + _this.stopPointInfo.region + '

' + '
' + '
' + '
' + '
' + '显示:仅文本 | 地图' + '
' + '
'); list.append(stopLi); $('#contentWrap').empty().append(directionsResult); $('#contentWrap').append('
' + '

实际情况会因道路施工、交通状况、天气或其他事件而与当前路径规划不同,请根据实际情况相应调整计划路线。同时请遵守关于您的路线的所有路标和指示牌。

' + '
'); $('#title').append('

总路程:' + Math.floor(lineMeter / 1000 * 100) / 100 + '公里

'); //绑定 文本|地图 切换事件 $('.abtn-show-text').bind('click', function () { $(this).parent().parent().find(".point-map").hide(); }); $('.abtn-show-map').bind('click', function () { if ($(this).attr('show') === 'true') { $(this).parent().parent().find(".point-map").show(); } else { $(this).parent().parent().find(".point-map").show(); _this._setPointMap({ pointNum: parseInt($(this).attr('pid')), mapWrap: 'pMap' + $(this).attr('pid') }); $(this).attr('show', 'true'); } }); $('.line-point').bind('mouseenter', function () { $(this).addClass('hover'); $(this).find('.op').show(); }).bind('mouseleave', function () { $(this).removeClass('hover'); $(this).find('.op').hide(); }); }, formatDegree: function (value) { value = Math.abs(value); var v1 = Math.floor(value); //度 var v2 = Math.floor((value - v1) * 60); //分 var v3 = Math.round((value - v1) * 3600 % 60); //秒 return v1 + '°' + v2 + '\'' + v3 + '"'; }, /** * 在地图上画出驾车路线 * @type {Function} * @param options {Object} * @private */ _drawCarPolyline: function (options) { var _this = this; var points = _this._directionsDataResult.coors; //转换为可用坐标 var pArray = points.split(','); var pointLatLng = []; var dDouble = true; var temp = []; for (var i = 0, l = pArray.length; i < l; i++) { if (dDouble) { temp = []; temp.push(pArray[i]); dDouble = false; } else { temp.unshift(pArray[i]); dDouble = true; temp = L.latLng(temp); pointLatLng.push(temp); } } _this.pointLatLng = pointLatLng; //划起点,终点连线 L.polyline([_this.options.startPoint, pointLatLng[0]], { color: '#FFFFFF', weight: options.weight + 2, opacity: 1 }).addTo(_this._map); L.polyline([_this.options.stopPoint, pointLatLng[pointLatLng.length - 1]], { color: '#FFFFFF', weight: options.weight + 2, opacity: 1 }).addTo(_this._map); L.polyline([_this.options.startPoint, pointLatLng[0]], { color: '#FF6600', weight: options.weight - 1, opacity: options.opacity, dashArray: '1,10' }).addTo(_this._map); L.polyline([_this.options.stopPoint, pointLatLng[pointLatLng.length - 1]], { color: '#FF6600', weight: options.weight - 1, opacity: options.opacity, dashArray: '1,10' }).addTo(_this._map); //划线 _this._roadPolylineBg = L.polyline(pointLatLng, { color: '#FFFFFF', weight: options.weight + 2, opacity: 1 }); _this._roadPolylineBg.addTo(_this._map); _this._roadPolyline = L.polyline(pointLatLng, { color: options.color, weight: options.weight, opacity: options.opacity }); _this._roadPolyline.addTo(_this._map); _this._map.fitBounds(_this._roadPolyline.getBounds()); }, /** * 在地图上描绘点 * @type {Function} * @param options {Object} * @private */ _setMarkers: function (options) { var _this = this; switch (options.type) { case 'start': var iconUrl = '/images/route/ico_p_2.png'; _this.startMarker = new L.Marker( options.latLng, { icon: L.icon({ iconUrl: iconUrl, iconSize: [25, 25], iconAnchor: [12, 24], popupAnchor: [0, -12] }) } ); _this.startMarker.addTo(_this._map); break; case 'across': var iconUrl = '/images/route/ico_p_4.png'; var acrossMarker = new L.Marker( options.latLng, { icon: L.icon({ iconUrl: iconUrl, iconSize: [25, 25], iconAnchor: [12, 24], popupAnchor: [0, -12] }) } ); acrossMarker.addTo(_this._map); break; case 'avoid': var iconUrl = '/images/route/ico_p_5.png'; var avoidMarker = new L.Marker( options.latLng, { icon: L.icon({ iconUrl: iconUrl, iconSize: [25, 25], iconAnchor: [12, 24], popupAnchor: [0, -12] }) } ); avoidMarker.addTo(_this._map); break; case 'stop': var iconUrl = '/images/route/ico_p_1.png'; _this.stopMarker = new L.Marker( options.latLng, { icon: L.icon({ iconUrl: iconUrl, iconSize: [25, 25], iconAnchor: [12, 24], popupAnchor: [0, -12] }) } ); _this.stopMarker.addTo(_this._map); break; } }, /** *设置路径点地图 初始化地图-添加规划路径-添加当前路径点信息(图标+文字提示) * @type {Function} * @param options {Object} {pointNum,mapWrap} * @private */ _setPointMap: function (options) { var _this = this; //地图初始化 var layerName = 'gh'; //var layer2Name = 'satellite-address'; switch (_this.options.mapType) { case 'gm': //线划 layerName = 'gm'; break; case 'gr': //影像 layerName = 'gr'; break; case 'gh': //影像 layerName = 'gh'; break; case 'gt': //地形 layerName = 'gt'; break; } var mapOptions = { layers: [ L.tileLayer(map23DConfig.tileServerUrl + '/' + layerName + '?l={z}&x={x}&y={y}', { minZoom: 1, maxZoom: 19, subdomains: map23DConfig.tileSubdomains || '', noWrap: true }) ], center: _this._markerObjs[options.pointNum].center, zoom: 16, maxZoom: 19, minZoom: 1, zoomControl: false }; var pointMap = new L.Map( options.mapWrap, mapOptions ); //如果是影像图,添加地名图层 // if(_this.options.mapType === '2'){ // L.tileLayer.builtIn.getTileLayer(layer2Name).addTo(pointMap); // } //添加缩放控件 L.control.zoom({ position: 'topright' }).addTo(pointMap); //添加相应的专题图 if (_this.options.thematicUrl) { L.tileLayer(_this.options.thematicUrl).addTo(pointMap); } //添加路径点 var marker = new L.Marker(_this._markerObjs[options.pointNum].center, { icon: L.icon({ iconUrl: '/images/route/' + _this._markerObjs[options.pointNum].actionType + '.png', iconSize: [16, 16], iconAnchor: [8, 8], popupAnchor: [0, -8] }) }) .bindPopup(_this._markerObjs[options.pointNum].popInfo, { closeButton: false, maxWidth: 100, minWidth: 100 }); marker.addTo(pointMap); //添加规划路径图 L.polyline(_this.pointLatLng, { color: '#0099ff', weight: 6, opacity: 0.8 }).addTo(pointMap); } };