Using Drupal 4.7.2, gmap.module v1.28 2006/05/22

My gmaps work great in Firefox & newer IE. They fail to show up in this IE browser 6.0.2800.1106
I get 4 javascript errors. The first 2 occur on all maps
(1)
Line: 8
Char: 3
Error: 'Glcon' is undefined
Code: 0
URL: http://mysite.com

(2)
same at line 81, char 1

(3) 1 map gives this this
Line: 2
Char: 1
Error: invalid character
Code: 0
URL: http://mysite.com

(4) another map gives this
Line: 254
Char: 25
Error: Expected Identifier
Code: 0
URL: http://mysite.com/places/page

Comments

webgeer’s picture

At work I actually have 6.0.2800.1106CO (which I believe is just a customized version of the same IE you have) without any problems.

Did you always have this problem, or was it caused by an upgrade to a newer version of gmap.module?

Any chance you can email me the url so I can see the problem myself? Send it to james at webgeer.com.

dado’s picture

Thanks for guidance. No answer yet. Mighty difficult to diagnose these IE Javascript problems. I am wondering whether the problem might relate to other JS. I see drupal.js loads before gmap.js in the page, and the
'GIcon' is undefined
messages are always preceded by the other messages: either
Expected identifier
or
Invalid character

Another theory is it could relate to the Clusterer2.js, but that loads after gmap.js

dado’s picture

Title: IE6.0: map fails, 'Glcon' is undefined javascript error » 'Glcon' is undefined javascript error

Looks like I am getting this error sporadically (not frequently) in Firefox 1.5.0.4
In all cases, map fails to display when the error occurs
Changing title

dado’s picture

also observing in intyermittently in this browser
IE 6.0.2900.2180.xpsp_sp2_gdr ...

Error: 'Glcon' is undefined
line 81 character 1

Error: 'Glcon' is undefined
line 9 character 3

dado’s picture

OK problem recurred in Firefox 1.5.0.4 and I was smart enough to use web developer plugin to diagnose. First JS error is this

Error: Expected ',' or '{' but found '*'.  Ruleset ignored due to bad selector.
Source File: http://localhost/delawarea/modules/gmap/gmap.css
Line: 1

and corresponding code is line 1 of this "gmap.css"

v\:* {
  behavior:url(#default#VML);
}

.gmap-popup{

}

.gmap-tooltip{
   padding: 2px;
   margin: 0;
   border: solid black 1px;
}

2nd error is this

Error: GIcon is not defined
Source File: http://localhost/delawarea/modules/gmap/gmap.js
Line: 8

and corresponding code is line 8 of gmap.js:

  baseIcon['standard'] = new GIcon();

Since all of these "GIcon is undefined" errors were preceded by another error, we can probably pin the blame on the first error. I am unfamiliar with this syntax in CSS:

v\:* {
  behavior:url(#default#VML);
}

Any chance this has an error?

For reference, here is all of gmap.js as seen by the browser

/* $Id: gmap.js,v 1.11 2006/06/17 06:13:22 webgeer Exp $ */

var baseIcon=new Array();
var geocoder = null;
 
function gmap_init() {
  baseIcon['standard'] = new GIcon();
  baseIcon['standard'].image = "http://www.google.com/mapfiles/marker.png";
  baseIcon['standard'].shadow = "http://www.google.com/mapfiles/shadow50.png"
  baseIcon['standard'].iconSize = new GSize(20, 34);
  baseIcon['standard'].shadowSize = new GSize(37, 34);
  baseIcon['standard'].iconAnchor = new GPoint(9, 34);
  baseIcon['standard'].infoWindowAnchor = new GPoint(9, 2);
  baseIcon['standard'].infoShadowAnchor = new GPoint(18, 25);
   
  baseIcon['big']=new GIcon();
  baseIcon['big'].image= gmapMarkerLocation + "/big/blue.png";
  baseIcon['big'].shadow=gmapMarkerLocation + "/big/shadow.png";
  baseIcon['big'].iconsize=new GSize(30,51);
  baseIcon['big'].shadowSize=new GSize(56,51);
  baseIcon['big'].iconAnchor=new GPoint(13,34);
  baseIcon['big'].infoWindowAnchor=new GPoint(13,3);
  baseIcon['big'].infoShadowAnchor=new GPoint(27,37);
   
  baseIcon['small'] = new GIcon();
  baseIcon['small'].image = gmapMarkerLocation + "/small/red.png";
  baseIcon['small'].shadow = gmapMarkerLocation + "/small/shadow.png";
  baseIcon['small'].iconSize = new GSize(12, 20);
  baseIcon['small'].shadowSize = new GSize(22, 20);
  baseIcon['small'].iconAnchor = new GPoint(6, 20);
  baseIcon['small'].infoWindowAnchor = new GPoint(5, 1);
  
  baseIcon['flat'] = new GIcon();
  baseIcon['flat'].image = gmapMarkerLocation + "/flat/x.png";
  baseIcon['flat'].shadow = "";
  baseIcon['flat'].iconSize = new GSize(16, 16);
  baseIcon['flat'].shadowSize = new GSize(0, 0);
  baseIcon['flat'].iconAnchor = new GPoint(8, 8);
  baseIcon['flat'].infoWindowAnchor = new GPoint(8, 8);

}

function createGMarker(point, htmltext, marker, tooltip, towebsite) {
  if (marker.length >0) {
    var re = /markers\/([a-zA-Z0-9]+)\//;
    var m = re.exec(marker);
    var bicon='standard' ;
    if (m) {
      if (baseIcon[m[1]]) {
        var bicon=m[1];
      }
    }
    var markerIcon = new GIcon(baseIcon[bicon]);
    markerIcon.image = marker;
    var returnMarker = new GMarker(point, {icon: markerIcon, title: tooltip});

  }
  else {
    var returnMarker = new GMarker(point, {title: tooltip});
  }
  if (!towebsite) towebsite='';
  // Show this htmltext  info window when it is clicked.
  if (towebsite.length>0 && markerlink){
    GEvent.addListener(returnMarker, 'click', function() {
      open(towebsite,'_self');
    });
  }
  else if (htmltext.length>0) {
    GEvent.addListener(returnMarker, 'click', function() {
      returnMarker.openInfoWindowHtml(htmltext);
    });
  }
  return returnMarker;
}

//moves thispoint based on the form with the id gmap-longitude and gmap-latitude
thispoint=false;

function gmap_textchange(thismap) {
  if (thispoint) {
    thismap.removeOverlay(thispoint);
  }
  thismap.panTo(newpoint=new GLatLng($("gmap-latitude").value, $("gmap-longitude").value));
  thismap.addOverlay(thispoint=new GMarker(newpoint));
}

function gmap_geocodeaddress(thismap, address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        alert(address + " not found");
      } else {
        if (thispoint) {
          thismap.removeOverlay(thispoint);
        }
        thismap.setCenter(point, 13);
        var thispoint = new GMarker(point);
        thismap.addOverlay(thispoint);

       $("gmap-latitude").value=point.lat();
       $("gmap-longitude").value=point.lng();
      }
    }
  );
  if (thispoint) {
    thismap.removeOverlay(thispoint);
  }
  thismap.panTo(newpoint=new GLatLng($("gmap-latitude").value, $("gmap-longitude").value));
  thismap.addOverlay(thispoint=new GMarker(newpoint));
}

function createMarkerFromRSS(item,icon) {
  var title = item.getElementsByTagName("title")[0].childNodes[0].nodeValue;

//  var description = item.getElementsByTagName("description")[0].childNodes[0].nodeValue;
  var link = item.getElementsByTagName("link")[0].childNodes[0].nodeValue;
//  alert('Link: ' +link);
  // namespaces are handled by spec in moz, not in ie  -- Looking for a better more universal parsing routine.
  if (navigator.userAgent.toLowerCase().indexOf("msie") < 0) {
    // Is there a geo:lat defined?
    if (item.getElementsByTagNameNS("http://www.w3.org/2003/01/geo/wgs84_pos#","lat").length>0) {
      item.getElementsByTagNameNS("http://www.w3.org/2003/01/geo/wgs84_pos#","lat")[0].normalize();
      // Is there a value for geo:lat
      if (item.getElementsByTagNameNS("http://www.w3.org/2003/01/geo/wgs84_pos#","lat")[0].hasChildNodes()) {
        // Then there probably is a geo:long too
        var lat = item.getElementsByTagNameNS("http://www.w3.org/2003/01/geo/wgs84_pos#","lat")[0].childNodes[0].nodeValue;
        var lng = item.getElementsByTagNameNS("http://www.w3.org/2003/01/geo/wgs84_pos#","long")[0].childNodes[0].nodeValue;
      }
    }
  } else {
    var lat = item.getElementsByTagName("geo:lat")[0].childNodes[0].nodeValue;
    if (lat == undefined) {
      lat = item.getElementsByTagName("icbm:lat")[0].childNodes[0].nodeValue;
    }
    var lng = item.getElementsByTagName("geo:long")[0].childNodes[0].nodeValue;
    if (lng == undefined) {
      lng = item.getElementsByTagName("icbm:long")[0].childNodes[0].nodeValue;
    }
  }
  //alert('Lat: '+lat);
  var point = new GLatLng(parseFloat(lat), parseFloat(lng));
  var html = "<a href=\"" + link + "\">" + title + "</a>";
  var marker=createGMarker(point, html, icon, title, link);

return marker;
}

function parseGeoRSS(map, rssurl,icon) {

  var request = GXmlHttp.create();
  request.open("GET", rssurl, true);
  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      var xmlDoc = request.responseXML;
      var items = xmlDoc.documentElement.getElementsByTagName("item");
      for (var i = 0; i < items.length; i++) {

        var marker = createMarkerFromRSS(items[i], icon);
        map.addOverlay(marker);
      }

    }
  }
  request.send(null);
}
webgeer’s picture

No the:

v\:* {
  behavior:url(#default#VML);
}

is straight from the Google Maps API and it is a little trick to make the behaviour one thing in IE, but ignore this css in Firefox (which sees this as an error and therefore ignores this.

If it is saying that GIcon is undefined, that means that for some reason it is not including the Google Maps API scripts (from the Google maps website.

I'm still not sure why it does it though...

yecarrillo’s picture

I'm getting the same error.

I think that Google develovers still playing with the code all the time, so including the "last" version of the api is a bad idea.

So I change line 805 of gmap.module from this

$js = '<script src="http://maps.google.com/maps?file=api&v=2.x&key='.variable_get('googlemap_api_key', '').'" type="text/javascript"></script>';

To

$js = '<script src="http://maps.google.com/maps?file=api&v=2&key='.variable_get('googlemap_api_key', '').'" type="text/javascript"></script>';

I just replace v=2.x with v=2

Apparently problems were solved. Can somebody test if this works too?

webgeer’s picture

Changing it to version 2 will make it so that the geocoding functions wont work. What I will do is see if there is a recent version that has the functionality gmap uses, but doesn't cause problems and set it to that.

I don't like the idea of introducing another setting that most users wont understand. I think what I will do is make this a constant that will be set at the top of the page, so if a user wants to change it they can edit the module quite easily.

Webgeer

webgeer’s picture

Status: Active » Fixed

I too had this problem. Changing the version to 2.55a seemed to corrected it. It also corrected a few other little problems with the way the Google Maps were working. I have set this to be the version number for the gmap.module.

I'm hoping that this fixed it and I am changing the status to fixed, but if you continue having this problem please change the status back to active.

Anonymous’s picture

Status: Fixed » Closed (fixed)