在使用传单GPX插件从GPX文件名更改为我创建的命名方案对象时,我试图更改弹出窗口的名称。
我创建了一个具有文件名和描述性名称的对象,如下所示:
gpxNamingScheme = {
'lexBowling.gpx': 'Lexington to Bowling Green',
'bowlinCheahaGPX.gpx': 'Bowling Green to Cheaha State Park',
'cheahaDestin.gpx': 'Cheaha State Park to Destin',
'destinNOLA.gpx': 'Destin to New Orleans',
'nolaDallas.gpx': 'New Orleans to Hickory Creek State Park, Dallas',
'dallasCapulin.gpx': 'Dallas to Capualin Volcano'}
然后我尝试使用GPX插件
中的此功能添加它.on('addpoint', function(e) {
if (e.point_type === 'start') {
// console.log(gpxNamingScheme[e.target._info.name]);
// var gpx = e.target.gpx
//console.log(gpx);
var name, textTitle,text;
var text = e.target._info.name
text = gpxNamingScheme;
console.log(text);
text += '<br/>Route Length: ' + (e.target._info.length/1000).toFixed(1) + ' km';
text += '<br/>Elevation Gain: ' + e.target._info.elevation.gain.toFixed(2) + ' m';
e.point.bindPopup(text, {offset: [0, -25]});
}
else if (e.point_type === 'end'){
map.removeLayer(e.point);
}
})
.addTo(map);
因此,当console.log(text)运行时,它会获取对象,但是弹出窗口中的“ text”变量只会填充“ object Object”