DOMParser Error with College Finder Example in IE8

121 views
Skip to first unread message

Doug

unread,
Apr 10, 2010, 11:59:24 AM4/10/10
to Google Maps JavaScript API v3
Good Morning All,

I am trying to learn the v3 API and was looking at the College Finder
example, but it does not work in IE 8. When I try to open the
examples in IE 8 I get the error "'DOMParser' is undefined". Has
anyone else encounted this and is the a way to make it work in IE8?


Thansks,
Doug

Esa

unread,
Apr 10, 2010, 6:47:20 PM4/10/10
to Google Maps JavaScript API v3
I would recommend inserting following meta tag in the <head> section:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

Doug

unread,
Apr 12, 2010, 9:20:07 PM4/12/10
to Google Maps JavaScript API v3
Thanks for the suggestion Esa.

It got me past the DOMParser error, but then had another error for
'getElementsByTagNameNS'. Gotta love IE I guess. I did some
searching and it was strange to read on the Microsoft site about all
the compatibility work they have done in IE..

I am thinking that I will just have to redo the code in a way that IE
likes. Are there any other examples to work from that do work in more
browsers?

Doug

Esa

unread,
Apr 13, 2010, 7:06:24 AM4/13/10
to Google Maps JavaScript API v3
IE6 support was dropped from v3. The official IE support is for
versions 7.0+. If you put that meta tag, you only have to test with
IE7. maps.google.com and even Bing Maps use that meta tag.

http://code.google.com/apis/maps/faq.html#browsersupport

Doug

unread,
Apr 13, 2010, 7:38:26 AM4/13/10
to Google Maps JavaScript API v3

The error is from the js files for the example (SearchService.js), no
the maps API.

William

unread,
Apr 13, 2010, 5:57:56 AM4/13/10
to Google Maps JavaScript API v3
v3 doesn't have the utility classes like GXml, so the authors of the
College Finder have tried to code it themselves by using the DOMParser
class, but this isn't available in Microsoft browsers.

The lack of utility classes in v3 has been reported in
http://code.google.com/p/gmaps-api-issues/issues/detail?id=1364

and the suggested solution is to use code from
http://gmaps-samples-v3.googlecode.com/svn/trunk/xmlparsing/downloadurl.html
http://gmaps-samples-v3.googlecode.com/svn/trunk/xmlparsing/util.js

so you need to include the "util.js" in the html

<script src="util.js" type="text/javascript"></script>

and comment out the DOMParser line in SearchService.js

// this.parser_ = new DOMParser();

and then use the xmlParse function to convert the KML string

// var kml = this.parser_.parseFromString(kmlString, 'text/xml');
var kml = xmlParse(kmlString);

Doug

unread,
Apr 13, 2010, 10:31:19 PM4/13/10
to Google Maps JavaScript API v3
Thanks William!

Is there a way to return all of the Elements of a given tag like the
code below in IE? If not, is the best approach to loop through the
XML and then build a new object to return?

Thanks,
Doug

/**
* Return all tags of the give type in an XML DOM node.
* @private
*/
google.code.mapsearch.SearchService.prototype.getTags_ =
function(node, tag) {
return node.getElementsByTagNameNS('http://www.opengis.net/kml/2.2',
tag);
}

On Apr 13, 4:57 am, William <william.g...@gmail.com> wrote:
> v3 doesn't have the utility classes like GXml, so the authors of the
> College Finder have tried to code it themselves by using the DOMParser
> class, but this isn't available in Microsoft browsers.
>

> The lack of utility classes in v3 has been reported inhttp://code.google.com/p/gmaps-api-issues/issues/detail?id=1364
>
> and the suggested solution is to use code fromhttp://gmaps-samples-v3.googlecode.com/svn/trunk/xmlparsing/downloadu...http://gmaps-samples-v3.googlecode.com/svn/trunk/xmlparsing/util.js

William

unread,
Apr 14, 2010, 1:55:03 AM4/14/10
to Google Maps JavaScript API v3
On Apr 14, 12:31 pm, Doug <doug...@gmail.com> wrote:
> /**
>  * Return all tags of the give type in an XML DOM node.
>  * @private
>  */
> google.code.mapsearch.SearchService.prototype.getTags_ =
> function(node, tag) {
>   return node.getElementsByTagNameNS('http://www.opengis.net/kml/2.2',
> tag);
>
> }
>

it looks like this KML doesn't have namespace prefixes (the tags are
like "placemark", not "kml:placemark"), so you can use the function
getElementsByTagName. I think this will work in all browsers.

replace:

return node.getElementsByTagNameNS('http://www.opengis.net/kml/2.2',
tag);

with:

return node.getElementsByTagName(tag);

Doug

unread,
Apr 14, 2010, 11:06:34 AM4/14/10
to Google Maps JavaScript API v3
Thank you! Hopefully I will know this much some day.

Doug

Reply all
Reply to author
Forward
0 new messages