2011-12-14 13:05:57 +00:00
|
|
|
var loc_en =
|
|
|
|
{
|
|
|
|
"length" : "Length",
|
|
|
|
"altitude": "Altitude"
|
|
|
|
};
|
|
|
|
|
|
|
|
var loc_it =
|
|
|
|
{
|
|
|
|
"length" : "Lunghezza",
|
|
|
|
"altitude": "Altitudine"
|
|
|
|
};
|
|
|
|
|
|
|
|
var loc = loc_en;
|
|
|
|
|
2011-12-14 10:35:25 +00:00
|
|
|
function wpgpxmaps(targhetId,mapType,mapData,graphData)
|
|
|
|
{
|
|
|
|
var el = document.getElementById(targhetId);
|
|
|
|
var el_map = el.childNodes[0];
|
|
|
|
var el_chart = el.childNodes[1];
|
|
|
|
switch (mapType)
|
|
|
|
{
|
|
|
|
case 'TERRAIN': { mapType = google.maps.MapTypeId.TERRAIN; break;}
|
|
|
|
case 'SATELLITE': { mapType = google.maps.MapTypeId.SATELLITE; break;}
|
|
|
|
case 'ROADMAP': { mapType = google.maps.MapTypeId.ROADMAP; break;}
|
|
|
|
default: { mapType = google.maps.MapTypeId.HYBRID; break;}
|
|
|
|
}
|
|
|
|
var mapOptions = {
|
|
|
|
mapTypeId: mapType
|
|
|
|
};
|
|
|
|
var map = new google.maps.Map(el_map, mapOptions);
|
|
|
|
if (graphData!= '')
|
|
|
|
{
|
|
|
|
var data = new google.visualization.DataTable();
|
2011-12-14 13:05:57 +00:00
|
|
|
data.addColumn('number', loc['length']);
|
|
|
|
data.addColumn('number', loc['altitude']);
|
2011-12-14 10:35:25 +00:00
|
|
|
data.addRows(graphData);
|
|
|
|
var chart = new google.visualization.AreaChart(el_chart);
|
|
|
|
var options = { curveType: "function",
|
|
|
|
strictFirstColumnType: true,
|
2011-12-14 13:05:57 +00:00
|
|
|
hAxis : {format : '#,###m', title : loc['length']},
|
|
|
|
vAxis : {format : '#,###m', title : loc['altitude']},
|
2011-12-14 10:35:25 +00:00
|
|
|
legend : {position : 'none'},
|
|
|
|
chartArea: {left:70,top:10,width:"100%",height:"75%"}
|
|
|
|
};
|
|
|
|
chart.draw(data, options);
|
|
|
|
google.visualization.events.addListener(chart, 'onmouseover', function (e) {
|
|
|
|
var r = e['row'];
|
|
|
|
if (marker)
|
|
|
|
{
|
|
|
|
var point = getItemFromArray(mapData,r)
|
|
|
|
marker.setPosition(new google.maps.LatLng(point[0],point[1]));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
google.visualization.events.addListener(chart, 'onmouseout', function (e) {
|
|
|
|
if (marker)
|
|
|
|
{
|
|
|
|
if (chart.getSelection() != '')
|
|
|
|
{
|
|
|
|
var r = chart.getSelection()[0]['row'];
|
|
|
|
var point = getItemFromArray(mapData,r)
|
|
|
|
marker.setPosition(new google.maps.LatLng(point[0], point[1]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (mapData != '')
|
|
|
|
{
|
|
|
|
var points = [];
|
|
|
|
var bounds = new google.maps.LatLngBounds();
|
|
|
|
for(var i in mapData)
|
|
|
|
{
|
|
|
|
var p = new google.maps.LatLng(mapData[i][0], mapData[i][1]);
|
|
|
|
points.push(p);
|
|
|
|
bounds.extend(p);
|
|
|
|
}
|
|
|
|
var poly = new google.maps.Polyline({
|
|
|
|
path: points,
|
|
|
|
strokeColor: "#3366cc",
|
|
|
|
strokeOpacity: .7,
|
|
|
|
strokeWeight: 4
|
|
|
|
});
|
|
|
|
poly.setMap(map);
|
|
|
|
map.setCenter(bounds.getCenter());
|
|
|
|
map.fitBounds(bounds);
|
|
|
|
var first = getItemFromArray(mapData,0)
|
|
|
|
var marker = new google.maps.Marker({
|
|
|
|
position: new google.maps.LatLng(first[0], first[1]),
|
|
|
|
title:"Hello World!"
|
|
|
|
});
|
|
|
|
marker.setMap(map);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getItemFromArray(arr,index)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return arr[index];
|
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
return [0,0];
|
|
|
|
}
|
|
|
|
}
|