Compatibility with Internet Explorer ''google.gears.factory' is null or not an object'

205 views
Skip to first unread message

Christopher Watson

unread,
Aug 22, 2011, 2:54:58 PM8/22/11
to google-map...@googlegroups.com
the site works in firefox and chrome. 


it doesn't work in IE, no surprise!

how can i stop the function doGeolocation from trying to perform in IE, can i hide it from IE? are they if statements that will hide it? when i debug this is what shows up.
Message has been deleted

xelawho

unread,
Aug 22, 2011, 3:45:11 PM8/22/11
to Google Maps JavaScript API v3
> how can i stop the function doGeolocation from trying to perform in IE, can
> i hide it from IE? are they if statements that will hide it? when i debug
> this is what shows up.

it seems to me like you should do browser detection (there's plenty of
code examples available out there) and set up an alternative for IE to
use. Something like

if (IE) {
function that tracks user by IP address
} else {
doGeolocation();
}

(although it may be worth pointing out that in IE7 it works fine, and
firebug should detect an absence of gears as it is somewhat outdated
and has not been available to firefox for some time now)

en4ce

unread,
Aug 22, 2011, 6:35:32 PM8/22/11
to Google Maps JavaScript API v3
+1

but Christopher, what the hell this page is all about? everything is
all over the place... especially if you pan the map... wow, i never
was so confused with a map :D

geoco...@gmail.com

unread,
Aug 22, 2011, 6:54:40 PM8/22/11
to Google Maps JavaScript API v3
On Aug 22, 11:54 am, Christopher Watson
You need to make a copy of this:
http://gmaps-samples-v3.googlecode.com/svn/trunk/geolocate/geometa.js

and handle the error case:
=====================================================
Line: 63
Error: 'google.gears.factory' is null or not an object
=====================================================

-- Larry

geoco...@gmail.com

unread,
Aug 22, 2011, 6:58:05 PM8/22/11
to Google Maps JavaScript API v3
On Aug 22, 3:54 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
BTW - I get the same error in Firefox:
Error: google.gears is undefined
Source File: http://gmaps-samples-v3.googlecode.com/svn/trunk/geolocate/geometa.js
Line: 63

  -- Larry

xelawho

unread,
Aug 22, 2011, 8:17:25 PM8/22/11
to Google Maps JavaScript API v3
... or (being that geolocation sometimes fails, depending on browser
or user location and that google gears has to be installed and will no
longer be available as of Dec 2012 according to http://gears.google.com/
)

use something like this:
http://code.google.com/apis/maps/documentation/javascript/examples/map-geolocation.html

but in the "else" statement instead of just alerting an error, get it
to use something reliable but maybe not so accurate - I use the IP
lookup from maxmind, and it works quite well. You can compare some of
them here: http://xelawho.com/map/ip2.php (v2 map but the fundamentals
are the same)

Christopher Watson

unread,
Aug 23, 2011, 7:06:58 PM8/23/11
to google-map...@googlegroups.com
hey en4ce, 

i have an about link on there. i havent done browser shots or anything yet to check out how much it might 'break apart' in different versions. 


can you share a pritn screen of what it looks like? is it possible through here?

thanks

chris 

Christopher Watson

unread,
Aug 23, 2011, 7:17:22 PM8/23/11
to google-map...@googlegroups.com
i have it referenced through a script, would i need to copy it to my server ?

Christopher Watson

unread,
Aug 23, 2011, 7:39:38 PM8/23/11
to google-map...@googlegroups.com
hey xela, larry

thanks for the feedback. if google gears if being phased out, i will try turn the map-geolocation into an onclick and see if IE and the others can handle it. 

seems like google gears is going to be a prob. 

do you have a link to one map xela that uses an else to look up an IP from maxmind. i cant work out which parts of the code max mind is using in the examples you gave ip2.php?

the map looks fine in its structure on IE, Firefox & Chrome, does it pull apart or have panning problems on your browsers?

fyi larry, the four column horizontal spread works in chrome but only seeing one column in firefox, no probs... i'll just say 'optimum functionality, view in chrome'

i love that it works. the map and pins can be the minimum working functionality in the rest. 

again thanks for the help guys

geoco...@gmail.com

unread,
Aug 23, 2011, 8:05:02 PM8/23/11
to Google Maps JavaScript API v3
On Aug 23, 4:39 pm, Christopher Watson <chris.watso...@googlemail.com>
wrote:
> hey xela, larry
>
> thanks for the feedback. if google gears if being phased out, i will try
> turn the map-geolocation into an onclick and see if IE and the others can
> handle it.
>
> seems like google gears is going to be a prob.
>
> do you have a link to one map xela that uses an else to look up an IP from
> maxmind. i cant work out which parts of the code max mind is using in the
> examples you gave ip2.php?
>
> the map looks fine in its structure on IE, Firefox & Chrome, does it pull
> apart or have panning problems on your browsers?
>
> fyi larry, the four column horizontal spread works in chrome but only seeing
> one column in firefox, no probs... i'll just say 'optimum functionality,
> view in chrome'

What errors do you get in Firefox?

xelawho

unread,
Aug 23, 2011, 10:41:09 PM8/23/11
to Google Maps JavaScript API v3
> do you have a link to one map xela that uses an else to look up an IP from
> maxmind. i cant work out which parts of the code max mind is using in the
> examples you gave ip2.php?

maxmind is very simple to use. all you need to do is include this when
you are calling scripts:

<script type="text/javascript" src="http://j.maxmind.com/app/
geoip.js"></script>

and then within your else statement you can get the lat and lng by
doing this:

var Maxlat=geoip_latitude();
var Maxlng=geoip_longitude();
var latLng = new google.maps.LatLng(Maxlat, Maxlng);


the rest is basically the same as what you have got, you can just copy
it. give it a try.

Pil

unread,
Aug 24, 2011, 1:10:38 AM8/24/11
to Google Maps JavaScript API v3
There are certainly a lot of other companies that provide geo location
queries with more or less reliable results.

Here is an overview

http://ipinfo.info/html/geolocation_2.php

In addition to the mentioned service providers you try these

http://api.hostip.info/get_html.php

http://www.geody.com/geoip.php

http://api.wipmania.com

http://www.ipinfodb.com

You should be aware that the underlying technique of all these
offerings is basically outdated and never completely reliable, because
it's based on IP database queries. Internet Service Providers are
juggling constantly with their IP blocks, and when they fail to
release the new locations of any changed IP block the information in
the database is obsolete.


In contrast the Geolocation API is a reliable and modern technique.
Here is a good overview

http://diveintohtml5.org/geolocation.html

xelawho

unread,
Aug 24, 2011, 2:04:24 AM8/24/11
to Google Maps JavaScript API v3
> You should be aware that the underlying technique of all these
> offerings is basically outdated and never completely reliable, because
> it's based on IP database queries.  Internet Service Providers are
> juggling constantly with their IP blocks, and when they fail to
> release the new locations of any changed IP block the information in
> the database is obsolete.

absolutely.... which is why IP lookup should only be used as a
fallback, if geolocation fails - which it can for the reasons stated
above. My thinking is that it's better to get some result which may be
vaguely accurate than to just throw an alert saying "geez... we
couldn't find you... um..."

but fwiw, I've been testing both approaches as I travel around Latin
America and while neither has ever been spot on, maxmind tends to come
up with a location within a couple of hundred meters of the
geolocation one, and sometimes is *more* accurate, by up to a couple
of hundred kilometers.

I'm sure that results vary depending on a country's infrastructure,
but as a backup it seems fine, particularly being that it's free, and
simple to incorporate into your code...

Christopher Watson

unread,
Aug 24, 2011, 7:16:13 AM8/24/11
to google-map...@googlegroups.com
hmm, maybe i have an older version of firefox on my machine at home, but it works fine in firefox 6. 

will test on my machine at home again. but the 4 columns horizontal spread works in firefox 6

the geolocation (gears) doesnt work, but i will try and set up this geolocation mentioned by xela and the else backup of maxmind

the other error in firefox is:

Error: The stylesheet http://geoxml.googlecode.com/files/gmap2.css was not loaded because its MIME type, "text/x-c", is not "text/css".
Line: 0

doesn't appear hugely significant. 



--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Christopher Watson

unread,
Aug 24, 2011, 8:04:57 AM8/24/11
to google-map...@googlegroups.com
My thinking is that it's better to get some result which may be 
vaguely accurate than to just throw an alert saying "geez... we
couldn't find you... um..."


yeah, it never sat right with me that i was just putting a message up saying "geez..."


ok, i'm not on comp at home to test on server, but adapting this http://code.google.com/apis/maps/documentation/javascript/examples/map-geolocation.html

this performed on map initalize, i want to adapt it to an onclick, so i am trying to adapt it into its own function. 

does this look alright where i have added the maxmind code you suggested

    <!-- Include the maps javascript with sensor=true because this code is using a sensor (a GPS locator) to determine the user's location. See: http://code.google.com/apis/maps/documentation/javascript/basics.html#SpecifyingSensor --> 

 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script> 
 <script type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script> 

 function doGeolocation() { 

 // Try HTML5 geolocation 

 if(navigator.geolocation) { 

 navigator.geolocation.getCurrentPosition(function(position) { 
 var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 
 var infowindow = new google.maps.InfoWindow({ 

 map: map, 
 position: pos, 
 content: 'Location found using HTML5.' }); 
 map.setCenter(pos); 
 }, function() { 
 handleNoGeolocation(true); 
 }); 
 } else { 
 var Maxlat=geoip_latitude(); 
 var Maxlng=geoip_longitude(); 
 var latLng = new google.maps.LatLng(Maxlat, Maxlng);
 } 
 } 

then just use this in my <input>

 onclick="javascript: function doGeolocation()" 


as i say i will test this at home on a server. but does this code look about right?

is IE capable of reading maxmind then?


as you both say, the geolocation api is better, is it because its using html5? remem the prob with flash and apple.

xelawho

unread,
Aug 24, 2011, 9:14:03 AM8/24/11
to Google Maps JavaScript API v3
> as i say i will test this at home on a server. but does this code look about
> right?

not to me. I guess there is a variety of ways you could do this, but
if I understand what you're trying now, I would suggest scrapping the
external script that references gears and dropping a function like in
the example link I sent directly into your code, with the onclick and
else modifications added.
>

> is IE capable of reading maxmind then?

I've tested from 50 or so locations, from small towns to big cities
and haven't seen it fail in FF, chrome or IE7

>
> as you both say, the geolocation api is better, is it because its using
> html5? remem the prob with flash and apple.

I don't know what the problem with flash and apple is (but I can
imagine). Geolocation is "better" because it draws from a variety of
sources (one of them being IP address) to ascertain a position. It's
"worse" because it relies on html5, which is still in development and
is only supported by modern browsers, and version 9 was the first of
the IE's to recognise it (although this is where it gets funky,
because I have seen IE7 find a location using geolocation).

I hope that clarifies more than it confuses...
Reply all
Reply to author
Forward
0 new messages