Validating Google Maps

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
User avatar
Lou
Rank V - Professional
Posts: 295
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Validating Google Maps

Post by Lou »

I am playing with adding a GoogleMap to a website I am developing. Starting with maps.google.com/ using their API v2. From what I have read so far there documentation needs help (or I need more background) and their examples are buggie ie "&" where & should be etc.

But given that I have gotten it to work. My example is http://www.knob.com/ATG/Calendar/venture.html

In a javascript function in the header the line that is causing problems is:

Code: Select all

map.openInfoWindowHtml(map.getCenter(), "<img src='../jpg/Finian.jpg' width='64' height='80' alt='picture of Peter'><b>This is a picture of 951 Greene Street</b>");
As written the code works with all browsers I checked. The Goole Maps function openWindowHtml() gets 2 values; a point on the map and a string of HTML code which is the content of the balloon created.

The problem is that I can't figure out how to get the line to validate (CSE or W3C). The error is "[nsgmls] end tag for element "B" which is not open" pointing at the "</b>" sitting between the last char. If I change the closing tag to "/>" then it validates but what is displayed is "... Street/>"

Suggestions? Is it just a poorly formed function? poorly implemented? or did I miss something?

For context the map displays in a popup window if you start with /ATG/Calendar.html and click on the address. Forgive the foo picture.
Lou
Say what you will about Sisyphus. He always has work.
John Zeman
Rank III - Intermediate
Posts: 54
Joined: Sat Dec 11, 2004 2:17 pm

Re: Validating Google Maps

Post by John Zeman »

Hi Lou,

By coincidence I'm also developing a site that uses Google Maps. I'm a far cry from being an expert with Google Maps but I've been able to get it to do what I need with no validation problems. However that may be because I'm storing all my vital Google information in external .js files.

If you're curious how my maps set up is working out, here's the URL to the site (that's still being developed):

http://www.visitwesterniowa.com/new/lodging-nw.html

The following .js file holds the vital Google information for the above page.

http://www.visitwesterniowa.com/new/tools/lodging-nw.js

I picked up this technique by studying the following maps tutorial web site: http://econym.org.uk/gmap/index.htm

John
John Zeman
Rank III - Intermediate
Posts: 54
Joined: Sat Dec 11, 2004 2:17 pm

Re: Validating Google Maps

Post by John Zeman »

Hi again Lou,

I just opened your test page in the current beta version of CSE and it validates fine for me....

John
User avatar
Lou
Rank V - Professional
Posts: 295
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: Validating Google Maps

Post by Lou »

John Zeman wrote:I just opened your test page in the current beta version of CSE and it validates fine for me....
WHAT???!

John was that before or after I added your suggestion? try GI.html in the same dir. I'm using the Bata 9.9922 The 2 files do the same thing, different map locations.

The other suggestion I got was to change the DOCTYPE to <! DOCTYPE HTML> to force HTML 5. Don't know if that works with W3C but it doesn't work with CSE. Besides as Albert says, "implementation varies."

I do notices (I think) a slight delay with the serial file calls. Not much of issue really except one of the board members for this group does uses dialup. I do like your idea of separating the sheep from the goats, sort of.
Lou
Say what you will about Sisyphus. He always has work.
John Zeman
Rank III - Intermediate
Posts: 54
Joined: Sat Dec 11, 2004 2:17 pm

Re: Validating Google Maps

Post by John Zeman »

Lou it was both before and after, and it still validates fine for me. I haven't checked lately to see if I have any CSE flags set/disabled that might cause the difference between your CSE setup and mine, I'll have to check those.

I get a 404 error when I try to open:

http://www.knob.com/ATG/Calendar/gi.html

I'm using CSE version 9.9923

John
User avatar
Lou
Rank V - Professional
Posts: 295
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: Validating Google Maps

Post by Lou »

Sorry it is UPPER CASE and in GI.html It may be a flag your right.
Last edited by Lou on Thu Mar 18, 2010 5:34 pm, edited 1 time in total.
Lou
Say what you will about Sisyphus. He always has work.
John Zeman
Rank III - Intermediate
Posts: 54
Joined: Sat Dec 11, 2004 2:17 pm

Re: Validating Google Maps

Post by John Zeman »

Ah, I may have found the reason why my setup validated it and yours didn't. I didn't have Nsgmls messages enabled in Options/Validator Engine Options....

And now that I run my .js file code through CSE it also finds many errors, mostly due to missing semicolons. However since every error is in the code I copied from that tutorial site I'm a little reluctant to correct it, but I think I will (after doing a backup of course).
User avatar
Lou
Rank V - Professional
Posts: 295
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: Validating Google Maps

Post by Lou »

Have been having the same issue with Google documentation and an other maps tutorial I found. Sure makes the learning curve harder to clime. I'm working on the ragged edge of my understanding on several front and dumb syntax sure muddle understanding.
Lou
Say what you will about Sisyphus. He always has work.
User avatar
Lou
Rank V - Professional
Posts: 295
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: Validating Google Maps

Post by Lou »

Albert,

My personnel problem aside, John's solution raises an interesting question, "If the two parts validate separately, why don't they validate when properly combined?"
Lou
Say what you will about Sisyphus. He always has work.
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Validating Google Maps

Post by Albert Wiersch »

Lou wrote:Albert,

My personnel problem aside, John's solution raises an interesting question, "If the two parts validate separately, why don't they validate when properly combined?"
If doing a validation using only CSE's validation engine and it passes with no errors/warnings, and then using only nsgmls passes as well, then doing a combined validation that uses CSE's own engine and nsgmls should pass as well. Is this not the case? If not, then please give me more details. Thank you!
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
Lou
Rank V - Professional
Posts: 295
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: Validating Google Maps

Post by Lou »

Albert Wiersch wrote:If doing a validation using only CSE's validation engine and it passes with no errors/warnings, and then using only nsgmls passes as well, then doing a combined validation that uses CSE's own engine and nsgmls should pass as well. Is this not the case? If not, then please give me more details. Thank you!
The three files are available online in my domain http://www.knob.com in sub directory /ATG/Calendar/ - I don't mean to be cryptic. It is a work in progress and I am trying to avoid spiders creating links.
File names are: venture.html venture.js and CSE_test.html The "test" file shows the error. It was created by cutting and pasting the javascript function from the js file into the html file with required changed to the <script> tag (remove src="./venture.js")

As noted above I am using the current BETA. Validation resuls are:
Venture.html
[JavaScript] 1 message was not shown because it was for another document. JavaScript Lint will sometimes try to check other linked JavaScript documents and CSE HTML Validator filters these messages out.

0.25s, 0 errors, 0 warnings, 7 messages, 14 validator comments, 23 lines, 14 tags (7 closed), 2 document comments, 0 entities, 54 words spell checked (21 in comments), 47 programs run.

ventrue.js
[JavaScript] 0 error(s), 0 warning(s)

CSE_test.html
[nsgmls] end tag for element "B" which is not open
Lou
Say what you will about Sisyphus. He always has work.
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Validating Google Maps

Post by Albert Wiersch »

Lou wrote:The three files are available online in my domain http://www.knob.com in sub directory /ATG/Calendar/ - I don't mean to be cryptic. It is a work in progress and I am trying to avoid spiders creating links.
Hi Lou,

I suspect the issue is with nsgmls. In the .js file, CSE HTML Validator does not run nsgmls because it's a JavaScript file, but when you put the script in an HTML document, then nsgmls is run (if the option to enable/use nsgmls is set) and nsgmls generates the warning.

Technically, for nsgmls, you may need to change "</" to "</" if the script is embedded in the HTML document. I'm not sure if that will cause any problems. That's one of the reasons that it's better to use external javascript files... you avoid problems with embedding scripts in HTML documents.

Example:

Code: Select all

map.openInfoWindowHtml(map.getCenter(), "<img src='../jpg/Finian.jpg' width='64' height='80' alt='picture of Peter'><b>This is a picture of 951 Greene Street</b>");
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
Lou
Rank V - Professional
Posts: 295
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: Validating Google Maps

Post by Lou »

Albert Wiersch wrote: I suspect the issue is with nsgmls. In the .js file, CSE HTML Validator does not run nsgmls because it's a JavaScript file, but when you put the script in an HTML document, then nsgmls is run (if the option to enable/use nsgmls is set) and nsgmls generates the warning.

Technically, for nsgmls, you may need to change "</" to "</" if the script is embedded in the HTML document. I'm not sure if that will cause any problems. That's one of the reasons that it's better to use external javascript files... you avoid problems with embedding scripts in HTML documents.

Example:

Code: Select all

map.openInfoWindowHtml(map.getCenter(), "<img src='../jpg/Finian.jpg' width='64' height='80' alt='picture of Peter'><b>This is a picture of 951 Greene Street</b>");
When I try that, the error goes away but Google map displays "...Street</b>" Apparently the API doesn't see the char string as the end tag.

Not expecting a parser to understanding any/all parameters for a script functions, it would seem that a parser should at least skip over everything that looks like the function parameters i.e. inside the (). Of course it would be nice if it could correctly handle what looks like an html string i.e. inside the "".

Thoughts from someone who doesn't, about how someone that does, should. Still like the tool Albert.
Lou
Say what you will about Sisyphus. He always has work.
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Validating Google Maps

Post by Albert Wiersch »

Lou wrote:When I try that, the error goes away but Google map displays "...Street</b>" Apparently the API doesn't see the char string as the end tag.

Not expecting a parser to understanding any/all parameters for a script functions, it would seem that a parser should at least skip over everything that looks like the function parameters i.e. inside the (). Of course it would be nice if it could correctly handle what looks like an html string i.e. inside the "".

Thoughts from someone who doesn't, about how someone that does, should. Still like the tool Albert.
Nsgmls is a 3rd party strict SGML/DTD based parser so it must obey the rules. Real browsers don't use strictly conforming parsers or most pages wouldn't display. I integrated nsgmls into CSE HTML Validator because some people like to "play it strict", but I generally don't recommend people use it mainly because real-world user agents and browsers don't use 100% conforming SGML parsers. :)

Perhaps this would work though, if you are looking for an nsgmls compatible solution (I think this is better than my previous recommendation and suspect that it will work):

Code: Select all

map.openInfoWindowHtml(map.getCenter(), "<img src='../jpg/Finian.jpg' width='64' height='80' alt='picture of Peter'><b>This is a picture of 951 Greene Street<"+"/b>");
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
Lou
Rank V - Professional
Posts: 295
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: Validating Google Maps

Post by Lou »

Albert, I like it.

I admit I'm anal about validation. But I was abused early in my coding life. It is an interesting path, between the standards, validators, different implementations in several browsers and in this case using someone else's function. Your suggestion works all around, avoided malti-file calls and points out I have some documentation to read.
Lou
Say what you will about Sisyphus. He always has work.
Post Reply