Hello, I am developing a program with javascript that reads traffics
messages from a xml file ad shows them as markers o the map. the xml
file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="./STMDF.xsd">
<TMS>
<TM>
<Coordinates>11.575605,48.19637400000001</Coordinates>
<RoadName>A952</RoadName>
<Effect>Traffic</Effect>
<EventCode>1</EventCode>
</TM>
<TM>
<Coordinates>11.578555,48.196123 11.579921,48.196046</
Coordinates>
<RoadName>A8</RoadName>
<Effect>Traffic</Effect>
<EventCode>4</EventCode>
</TM>
</TMS>
</Example>
and I have to read the data from this file.With RoadName,Effect and
EventCode have I no problems. The problem is with the coordinates.
There can be one, two or more lat-lng pairs in the coordinates tag and
I have to put a marker at each of this positions. how can I do this?
Can somebody help me? My Code looks like this:
....
var request = GXmlHttp.create();
request.open("GET", "kot.xml", true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = GXml.parse(request.responseText);
// obtain the array of markers and loop through it
var markers = xmlDoc.documentElement.getElementsByTagName
("TrafficMessage");
for (var i = 0; i < markers.length; i++) {
var mar = markers[i];
var lng = ?????
var lat = ?????
var point = ????
var RoadName = mar.getElementsByTagName("RoadName")[0];
var label = RoadName.firstChild.data;
var Effect = mar.getElementsByTagName("Effect")[0];
var html = Effect.firstChild.data;
var EventCode = mar.getElementsByTagName("EventCode")[0];
var icon = EventCode.firstChild.data;
icon = new GIcon(baseIcon, "http://XXXXXXX/Icons/
accident.png");
// create the marker
var marker = createMarker(point,label,html,icon);
map.addOverlay(marker);
}
....................................
any Idea?
Thaks a lot
koko
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---