gmap_overlays: overlay disappears after page refresh
| Project: | GMap Addons |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
If you are using IE, please could you open http://maps.batgung.com/node/22 and let me know if:
- on the first view \you see a map with a red line overlay,
- if you press F5 to refresh you see the map but cannot see the overlay
Similarly if you are using the overlay module I'd like to know if your overlays display ok or disappear after an F5 refresh in IE.
Using a debgugger, the error is reported as "htmlfile: Unspecified error."
The line causing the problem is from Google's main.js:
function Nm(){var a=false;if(document.namespaces){for(var b=0;b<document.namespaces.length;b++){var c=document.namespaces(b);if(c.name=="v")if(c.urn==Lm)a=true;else return false}if(!a){a=true;document.namespaces.add("v",Lm)}}return a}
The problem is the 'document.namespaces' - if I inspect that variable, the value shows 'Unspecified error'. (If I look at the variable the first time we open the page (ie when the overlay displays), it has correct values).
On that test site, if I go back to thehome page, and then click the link to view the node, it displays ok again. Press F5 and we lose the overlay again.
First I thought it was a bug in IE or Google's code. So I created a simple non-drupal HTML file http://www.batgung.com/articles/mount-davis-map-overlay2.htm that does the basics of what is happening in gmap and gmap_overlays, ie use $(document).ready(); to run a few lines of google API calls to create a map, and add the overlay.
This works fine - I can refresh as many times as I want without any problems. I also note that on the problem page when I refresh there is a noticeable pause before the error, but on the simple non-drupal page it refreshes very quickly.
If other people can repeat this problem, any suggestions where I should look next for the cause of the problem?

#1
I just happened to run into this problem in another project of mine. It was caused by running some initialization code similar to Google's (with the document.namespaces stuff) too early. I moved my init code into the window.onload event and it fixed it right up.
I know this is some months after you posted your question, but in case anyone finds this post through a search, window.onload may be the key to fixing it.
#2
I had this same error as well and I registered for this forum just to thank Geary for the awesome advice. The error I was getting was:
Message: Unspecified error.
Line: 1173
Char: 69
Code: 0
URI: http://maps.gstatic.com/intl/en_us/mapfiles/176c/maps2.api/main.js
and after downloading the main.js from google maps I saw that it had to do with name spaces as well. I was loading some KML files straight from the the opening javascript of the page in stead of from the onload method that I was using. Once I changed where the KML files were being declared the IE gods smiled and did not throw up on me again.
Thank you again.