How do I make google maps api to read tags from a xml document?

ThisWay

New Member
Ok I've been trying for hours now and I get nothing! I'm trying use the Google Maps API to draw a line (a jogging course), using the polyline, from an XML document. What I have is this in an XML file:\[code\] <Activities><Activity Sport="Running"> <Id>2008-10-28T15:58:21Z</Id> <Lap StartTime="2008-10-28T15:58:21Z"> <TotalTimeSeconds>2477.8200000</TotalTimeSeconds> <DistanceMeters>6634.1645508</DistanceMeters> <MaximumSpeed>4.8631563</MaximumSpeed> <Calories>620</Calories> <AverageHeartRateBpm xsi:type="HeartRateInBeatsPerMinute_t"> <Value>167</Value> </AverageHeartRateBpm> <MaximumHeartRateBpm xsi:type="HeartRateInBeatsPerMinute_t"> <Value>179</Value> </MaximumHeartRateBpm> <Intensity>Active</Intensity> <TriggerMethod>Manual</TriggerMethod> <Track> <Trackpoint> <Time>2008-10-28T15:58:22Z</Time> <Position> <LatitudeDegrees>59.4111992</LatitudeDegrees> <LongitudeDegrees>13.5304104</LongitudeDegrees> </Position> <AltitudeMeters>85.6945801</AltitudeMeters> <DistanceMeters>0.2149343</DistanceMeters> <HeartRateBpm xsi:type="HeartRateInBeatsPerMinute_t"> <Value>116</Value> </HeartRateBpm> <SensorState>Absent</SensorState> <Extensions> <TPX xmlns="http://www.garmin.com/xmlschemas/ActivityExtension/v2" CadenceSensor="Footpod"/> </Extensions> </Trackpoint> <Trackpoint> <Time>2008-10-28T15:58:24Z</Time> <Position> <LatitudeDegrees>59.4112275</LatitudeDegrees> <LongitudeDegrees>13.5304043</LongitudeDegrees> </Position>\[/code\]etc........................................Then I have this code using the Google Maps API and this works. What it does is that it draws a course with the polyline and I want to replace that course with the one from the xml file:\[code\]<title>Google Maps JavaScript API v3 Example: Training route hardcoded XML</title><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script type="text/javascript"> function initialize() { var points = [ new google.maps.LatLng(59.4111992, 13.5304104), new google.maps.LatLng(59.4193453, 13.5311650), new google.maps.LatLng(59.4232704, 13.5318187), new google.maps.LatLng(59.4245685, 13.5335306), new google.maps.LatLng(59.4252481, 13.5342259), new google.maps.LatLng(59.4269343, 13.5346784), new google.maps.LatLng(59.4285858, 13.5314505), new google.maps.LatLng(59.4124066, 13.5303183) ]; var myLatlng = points[4]; var myOptions = { zoom: 13, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var path = new google.maps.Polyline({ path: points, strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 4 }); path.setMap(map); }\[/code\]What I've been trying to do (among other things) is something like this:\[code\]for (var i = 0; i < Position.length; i++) { var point = new google.maps.LatLng( parseFloat(Position.getAttribute("LatitudeDegrees")), parseFloat(Position.getAttribute("LongitudeDegrees")) );\[/code\]and then I try to make Google Maps draw it all out. First of all I'm sorry for my bad English but it's not my native language. Secondly this is just one of all the things I've tested without any success at all.
 
Back
Top