Problem with Loading PolyLine From XML by Function

269 views
Skip to first unread message

Behseini

unread,
Nov 22, 2010, 12:51:35 PM11/22/10
to Google Maps JavaScript API v3
Hi Guys,
I am trying to draw some PolyLine using an XML file.I tried to modify
the Mike's tutorial to rettrive my data from the XML file by a
function like this:

function addLines()
{
GDownloadUrl("line.xml", function(point, responseCode)
{
var xml = GXml.parse(point);
var lines = xmlDoc.documentElement.getElementsByTagName("line");

// read each line
for (var i = 0; i < lines.length; i++)
{
// get any line attributes
var colour = lines[a].getAttribute("colour");
var width = parseFloat(lines[a].getAttribute("width"));
// read each point on that line
var points = lines[a].getElementsByTagName("point");
var pts = [];

for (var i = 0; i < points.length; i++) {
pts[i] = new
GPoint(parseFloat(points[i].getAttribute("lat")),

parseFloat(points[i].getAttribute("lng")));
}
gmap.addOverlay(new GPolyline(pts,colour,width));
}
});
}
but it didn't go through!
my XML file is like below:

=========================================================
<markers>
<line colour="#00ffff" width="6" >
<tpoint lat="49.251" lng="-123.00" />
<tpoint lat="49.251" lng="-123.002" />
<tpoint lat="49.254" lng="-123.002" />
</line>

<line colour="#9933cc" width="6" >
<tpoint lat="49.245300" lng="-122.998423" />
<tpoint lat="49.245312" lng="-123.000826" />
<tpoint lat="49.245300" lng="-123.002886" />
</line>

<line colour="#9933cc" width="6" >
<tpoint lat="49.25182" lng="-123.003709" />
<tpoint lat="49.251792" lng="-122.999761" />
<tpoint lat="49.249299" lng="-122.999761" />
</line>

</markers>
========================================
Could you please let me know what I am doing wrong?
Best Regards

geoco...@gmail.com

unread,
Nov 22, 2010, 1:22:18 PM11/22/10
to Google Maps JavaScript API v3
On Nov 22, 9:51 am, Behseini <behseini.g...@gmail.com> wrote:
> Hi Guys,
> I am trying to draw some PolyLine using an XML file.I tried to modify
> the Mike's tutorial to rettrive my data from the XML file by a
> function like this:
>

Please read the posting guidelines and post a link to your map that
shows the problem, not code.

BTW - that is v2 code, the v2 group is:
http://groups.google.com/group/google-maps-api
This is the v3 group.


>
> but it didn't go through!
> my XML file is like below:
>

> Could you please let me know what I am doing wrong?

Not without a link to your map. This example may help:
http://www.geocodezip.com/GenericMapBrowser.asp?filename=I5Polyline.xml

-- Larry

> Best Regards

Behrouz Hosseini

unread,
Nov 23, 2010, 1:53:31 PM11/23/10
to google-map...@googlegroups.com
Thanks for your reply
Well,i was doing all task on my localhost but i tried to transfer them to web here is the address of the blog for Map:
http://www.vsbmap.blogspot.com/

I uploaded the map.js and line.XML file at following addresses:
http://geoca.persiangig.com/map.js

http://geoca.persiangig.com/line.xml

I could get the markers when I was working on my localhost but now I ca not get them two.There are just some polygons which has been hard coded.
thanks again for your help and any further sugestion


--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Rossko

unread,
Nov 23, 2010, 2:49:31 PM11/23/10
to Google Maps JavaScript API v3
> web here is the address of the blog for Map:http://www.vsbmap.blogspot.com/

It's still a v2 API map.
The group for v2 problems is still at
http://groups.google.com/group/Google-Maps-API

> I uploaded the map.js and line.XML file at following addresses:http://geoca.persiangig.com/map.js

The browser will not let you load XML from geoca.persiangig.com into a
webpage served from www.vsbmap.blogspot.com
http://developer.yahoo.com/javascript/howto-proxy.html
Reply all
Reply to author
Forward
0 new messages