XML Parsing Demos

6,372 views
Skip to first unread message

pamela (Google Employee)

unread,
Jul 12, 2009, 2:53:15 AM7/12/09
to google-map...@googlegroups.com
Hey folks-

I've written 2 demos that show how to do XML parsing with the v3 API.

The first uses a JS file that has a function similar to GDownloadUrl:
http://gmaps-samples-v3.googlecode.com/svn/trunk/xmlparsing/downloadurl.html

The second uses jQuery's get function:
http://gmaps-samples-v3.googlecode.com/svn/trunk/xmlparsing/jqueryget.html

Enjoy!

- pamela

Logan

unread,
Jul 17, 2009, 11:31:06 PM7/17/09
to Google Maps JavaScript API v3
This is great. I was curious if you had an example of using the XML to
also contain the data for overlay layers?

Thanks!

pamela (Google Employee)

unread,
Jul 18, 2009, 6:45:27 PM7/18/09
to google-map...@googlegroups.com
Hi Logan -

I'm not sure what you mean by overlay layers- what type of overlays?

- pamela

Logan

unread,
Jul 19, 2009, 9:14:46 AM7/19/09
to Google Maps JavaScript API v3
I was hoping for an example that can combine your examples above using
XML, to also add functionality like:
http://code.google.com/apis/maps/documentation/v3/examples/infowindow-simple.html

I would like to have my XML pass al the info for the marker and the
overlay window... For Example:

<markers>
<marker lat="37.427770" lng="-122.144841" id="1"
overlayTitle="Uluru" overlayData="Uluru, also referred to as Ayers
Rock, is..." />
<marker lat="37.413320" lng="-122.125604" id="2" overlayTitle="Bob"
overlayData="Just some text for Bob..."/>
<marker lat="37.433480" lng="-122.139062" id="3"
overlayTitle="Larry" overlayData="Just more text for Larry..."/>
<marker lat="37.445427" lng="-122.162307" id="4" overlayTitle="Jr"
overlayData="Jr is small..."/>
</markers>

These would appear as markers on the map, and be clickable to have the
box popup with the data inside it. This would allow for a single way
to get the data from the DB (output through the XML) and then be
displayed for the user.

THank you for your response and great help!

Logan.


On Jul 18, 6:45 pm, "pamela (Google Employee)" <pamela...@gmail.com>
wrote:

pamela (Google Employee)

unread,
Jul 22, 2009, 6:18:32 PM7/22/09
to google-map...@googlegroups.com

Logan

unread,
Jul 23, 2009, 9:56:36 AM7/23/09
to Google Maps JavaScript API v3
Awesome.

Thank you for the help Pamela. This works perfectly.

If I may, my next question is:

How can I link from outside the map to make the overlay open?
See my page here: http://www.orlandohomeguides.com/searchListings.htm?city=riverview

I want to link up the map it links next to each listing view.


Thank you again,
Logan



On Jul 22, 6:18 pm, "pamela (Google Employee)" <pamela...@gmail.com>
wrote:
> Sure, here you go:http://gmaps-samples-v3.googlecode.com/svn/trunk/xmlparsing/downloadu...
>
> - pamela
>
>
>
> On Sun, Jul 19, 2009 at 11:14 PM, Logan<logan.m...@gmail.com> wrote:
>
> > I was hoping for an example that can combine your examples above using
> > XML, to also add functionality like:
> >http://code.google.com/apis/maps/documentation/v3/examples/infowindow...

pamela (Google Employee)

unread,
Jul 28, 2009, 1:58:27 AM7/28/09
to google-map...@googlegroups.com
Hi Logan-

You can call a JavaScript method to open up the relevant marker. You
could stick your markers in a global array and then have a function
like openInfoWindowOverMarker(index).

- pamela

donzo

unread,
Aug 4, 2009, 1:09:41 PM8/4/09
to Google Maps JavaScript API v3
Hello Pamela

Could you expand on this a bit please. I have used your guidance and
code to build a map (http://www.donzo.net/dev/hogs/map/map.html) from
an xml file (thank you so much), and would really like the FOR loop to
also populate a list of links that open the info boxes, in the UL to
the side.

I'm sorry but I'm new to javascript and the API, so as clearly as
possible would be much appreciated.

Thanks


On Jul 28, 6:58 am, "pamela (Google Employee)" <pamela...@gmail.com>
wrote:
> Hi Logan-
>
> You can call a JavaScript method to open up the relevant marker. You
> could stick your markers in a global array and then have a function
> like openInfoWindowOverMarker(index).
>
> - pamela
>
>
>
> On Thu, Jul 23, 2009 at 11:56 PM, Logan<logan.m...@gmail.com> wrote:
>
> > Awesome.
>
> > Thank you for the help Pamela. This works perfectly.
>
> > If I may, my next question is:
>
> > How can I link from outside the map to make the overlay open?
> > See my page here:http://www.orlandohomeguides.com/searchListings.htm?city=riverview
>
> > I want to link up the map it links next to each listing view.
>
> > Thank you again,
> > Logan
>
> > On Jul 22, 6:18 pm, "pamela (Google Employee)" <pamela...@gmail.com>
> > wrote:
> >> Sure, here you go:http://gmaps-samples-v3.googlecode.com/svn/trunk/xmlparsing/downloadu...
>
> >> - pamela
>
> >> On Sun, Jul 19, 2009 at 11:14 PM, Logan<logan.m...@gmail.com> wrote:
>
> >> > I was hoping for an example that can combine your examples above using
> >> >XML, to also add functionality like:
> >> >http://code.google.com/apis/maps/documentation/v3/examples/infowindow...
>
> >> > I would like to have myXMLpass al the info for the marker and the
> >> > overlay window... For Example:
>
> >> > <markers>
> >> >  <marker lat="37.427770" lng="-122.144841" id="1"
> >> > overlayTitle="Uluru" overlayData="Uluru, also referred to as Ayers
> >> > Rock, is..." />
> >> >  <marker lat="37.413320" lng="-122.125604" id="2" overlayTitle="Bob"
> >> > overlayData="Just some text for Bob..."/>
> >> >  <marker lat="37.433480" lng="-122.139062" id="3"
> >> > overlayTitle="Larry" overlayData="Just more text for Larry..."/>
> >> >  <marker lat="37.445427" lng="-122.162307" id="4" overlayTitle="Jr"
> >> > overlayData="Jr is small..."/>
> >> > </markers>
>
> >> > These would appear as markers on the map, and be clickable to have the
> >> > box popup with the data inside it. This would allow for a single way
> >> > to get the data from the DB (output through theXML) and then be

Solo

unread,
Sep 16, 2009, 4:15:41 PM9/16/09
to Google Maps JavaScript API v3
Hello Pamela,

Your example source has link to util.js

What is a reason to use it here?
Should I consider it as a best practise?

pamela (Google Employee)

unread,
Sep 16, 2009, 9:25:12 PM9/16/09
to google-map...@googlegroups.com
Hi Solo-

You can use the functions in util.js, or you can use another library,
like jQuery, to do the XML parsing. If you think you will have use for
jQuery's other functions, then it would make sense to use that option.
If all you need is that one extra function, then it would make sense
to just use that function in util.js.

- pamela

Paul Kulchenko

unread,
Sep 17, 2009, 4:54:27 PM9/17/09
to Google Maps JavaScript API v3
Pamela,

It seems like the code for MSXML detection can be tweaked a bit per
this old, but detailed explanation:
http://blogs.msdn.com/xmlteam/archive/2006/10/23/using-the-right-version-of-msxml-in-internet-explorer.aspx

it should probably look like:

if (typeof ActiveXObject != 'undefined') {
try { return new ActiveXObject('MSXML2.XMLHTTP.6.0'); } catch (e)
{}
return new ActiveXObject('MSXML2.XMLHTTP');

These are the relevant fragments:

Version Independent ProgIDs – There’s a lot of confusion around the
“version-independent” ProgID for MSXML. The version-independent
ProgID is always bound to MSXML 3 (a lot of people think it picks up
the latest MSXML that is on the box).

MSXML2 vs. Microsoft namespace – I’ve also seen a lot of code that
instantiates the “Microsoft.XMLHTTP” ActiveX object rather than the
MSXML2.XMLHTTP.3.0 or MSXML2.XMLHTTP.6.0 if you’re using 6.0. The
“Microsoft” namespace is actually older and is only implemented in
MSXML3 for legacy support. It’s unfortunate we used the “better” name
on the older version, but stick to the “msxml2” namespace when
instantiating objects.

Paul.

pamela (Google Employee)

unread,
Sep 18, 2009, 3:05:26 AM9/18/09
to google-map...@googlegroups.com
Hey Paul-

Thanks for looking deeply into that.

That code is the same code used for GDownloadUrl in v2, and since
there are currently no logged issues with GDownloadUrl, I'm inclined
to keep the util.js function the way it is - even if it is less
up-to-date. I prefer the tried-and-true route. Does that make sense?

- pamela

Paul Kulchenko

unread,
Sep 19, 2009, 12:46:18 AM9/19/09
to Google Maps JavaScript API v3
Make sense. I was thinking you can at least change the example, but I
understand your reasons for not doing it.

Paul.

On Sep 18, 12:05 am, "pamela (Google Employee)" <pamela...@gmail.com>
wrote:
> Hey Paul-
>
> Thanks for looking deeply into that.
>
> That code is the same code used for GDownloadUrl in v2, and since
> there are currently no logged issues with GDownloadUrl, I'm inclined
> to keep the util.js function the way it is - even if it is less
> up-to-date. I prefer the tried-and-true route. Does that make sense?
>
> - pamela
>
> On Fri, Sep 18, 2009 at 6:54 AM, Paul Kulchenko <paulclin...@gmail.com> wrote:
>
> > Pamela,
>
> > It seems like the code for MSXML detection can be tweaked a bit per
> > this old, but detailed explanation:
> >http://blogs.msdn.com/xmlteam/archive/2006/10/23/using-the-right-vers...

sophie

unread,
Mar 7, 2011, 9:11:41 AM3/7/11
to google-map...@googlegroups.com
Hello I want to add this xml file to this html file...but it doesn't seem to work. Can you please help me?
test_corr.html
d1.xml
Reply all
Reply to author
Forward
0 new messages