SetZoom Error

1,110 views
Skip to first unread message

Ice

unread,
Feb 2, 2012, 3:02:34 AM2/2/12
to google-map...@googlegroups.com
Good Day

I've got a geolocation page that will load a predefined address,
co-ordinates and zoom level. I also have a reset button
on the page which goes to a default location and zooms out. My problem is
that after I click reset and then
click the find button again I get the error "Invalid Argument" in Internet
Explorer 8 or 9 also I see that if I remove
the setZoom from my GeoAddress function the error is gone. Thing is I need
to set the zoom to that level.

Would appreciate any help

Thanks

You may view my code here
http://www.sleeping-out.co.za/FindLocation.htm

Rossko

unread,
Feb 2, 2012, 4:49:26 AM2/2/12
to Google Maps JavaScript API v3
> http://www.sleeping-out.co.za/FindLocation.htm

Your resetGeo() function calls initialize() which will create a
completely new map and geocoder objects. I'm not sure what's going
wrong, perhaps there is a reference captured to the old map, but I
suspect all you really want to do is clear and reset the existing map.

Ice

unread,
Feb 2, 2012, 8:06:07 AM2/2/12
to google-map...@googlegroups.com
Thank you that sounds like the most logical error
I will try simply setting some default values instead of reloading
the default map.

Ice

unread,
Feb 3, 2012, 1:37:32 AM2/3/12
to google-map...@googlegroups.com
Hi

So I'm not calling a new map object anymore I've simply set default values
for my map but again as soon as I set the zoom I get my previous error

Is there something else I'm doing wrong
http://www.sleeping-out.co.za/FindLocation.htm

sb

unread,
Feb 3, 2012, 4:20:57 AM2/3/12
to Google Maps JavaScript API v3
Punctuation?

Ice

unread,
Feb 3, 2012, 4:25:42 AM2/3/12
to google-map...@googlegroups.com
Sorry if I wasn't being clear enough

In my reset function I am setting the default values. I am
not calling my initialize function like before so I'm still using the
same map object.

So now, even in the reset function, if I set the setZoom I get my error
and if I remove setZoom I don't get an error

davie

unread,
Feb 3, 2012, 5:38:18 AM2/3/12
to Google Maps JavaScript API v3
Hi
resetGeo() is doing what you have programmed it to do

var enteredLocation = new
google.maps.LatLng(-25.641526373065755,24.9169921875);
map.setCenter(enteredLocation);
map.setZoom(5);

These settings are not your default settings

var Lat=-33.9996283139187;
var Lng=25.3267693519592;
var zm=15;

Regards Davie

Ice

unread,
Feb 3, 2012, 6:07:57 AM2/3/12
to google-map...@googlegroups.com
My apologies the co-ordinates are not the problem like I said it is the map.setZoom that
brings up my error.

It doesn't matter what position I plot as soon as that setZoom is fired in my reset
it breaks.

davie

unread,
Feb 3, 2012, 6:28:35 AM2/3/12
to Google Maps JavaScript API v3
Hi
It works for me in firefox ie zooms to 5

Regards Davie

Andrew Leach

unread,
Feb 3, 2012, 6:28:09 AM2/3/12
to google-map...@googlegroups.com
On 3 February 2012 11:07, Ice <sup...@us.sleeping-out.com> wrote:
>
> It doesn't matter what position I plot as soon as that setZoom is fired in
> my reset it breaks.

Doesn't for me in Firefox 3.6.26. What browser are you using?

Ice

unread,
Feb 3, 2012, 6:36:19 AM2/3/12
to google-map...@googlegroups.com, andrew....@gmail.com
I don't get errors in Firefox it seems to be isolated only to IE I've seen it generate the error in IE 8 and 9

The zoom works but I'm getting the error "Invalid argument"

davie

unread,
Feb 3, 2012, 6:54:48 AM2/3/12
to Google Maps JavaScript API v3
Hi


> The zoom works but I'm getting the error "Invalid argument"

IE debugger is renowned for sending you to the wrong line ie setZoom
is not the invalid argument

I would look at your clearOverlays() function

Regards Davie

Ice

unread,
Feb 3, 2012, 8:17:33 AM2/3/12
to google-map...@googlegroups.com
Okay so I've removed all references to the clearOverlay() function but
I still get the error. And it's still the same error, same line.

Really stumped now because I was sure one of these suggestions was
going to work.

davie

unread,
Feb 3, 2012, 10:43:20 AM2/3/12
to Google Maps JavaScript API v3
Hi
The invalid argument shown by IE relates to a Google js file.

Your function GLoad() may be the problem

See http://code.google.com/apis/maps/documentation/javascript/tutorial.html
about loading maps asynchronously

Regards Davie

Alan Pearce

unread,
Feb 3, 2012, 7:03:32 PM2/3/12
to Google Maps JavaScript API v3
This is definitely an API bug.

When you call resetGeo, you recenter the map and set the zoom to 5.
Then in the GeoAddress function it centers the map on the result and
sets the zoom to 14. If you only set the zoom here to 10 you so not
get the error. 11 and you do. So zooming more than 5 levels in will
cause the error but only if the map has moved. If you don't recenter,
either thru code or moving the map, it's fine.

It looks like this is caused in some way by the overviewMapControl.
You have it set to true in your map options. Set it to false or just
removed the related options and the error no longer happens.

Hope this helps,
Alan

On Feb 3, 9:43 am, davie <daviestrac...@yahoo.co.uk> wrote:
> Hi
> The invalid argument shown by IE relates to  a Google js file.
>
>  Your function GLoad() may be the problem
>
> Seehttp://code.google.com/apis/maps/documentation/javascript/tutorial.html

davie

unread,
Feb 4, 2012, 6:51:14 AM2/4/12
to Google Maps JavaScript API v3

Hi

> This is definitely an API bug.
The error shows only in IE and with the API called asynchronously
using a method not suggested by Google.
If the error still shows after the recommended method it may be an API
bug

Regards Davie

Alan Pearce

unread,
Feb 4, 2012, 10:35:35 AM2/4/12
to Google Maps JavaScript API v3
The method of loading the API is exactly what Google recommends. He is
creating a script tag and injecting it into the head. See the loadjs
method of the loadAsync object.

However here is a test page I created to figure out what the error
was. It loads the API with a normal script tag.

http://alttag.org/ieZoomError.html

Alan

davie

unread,
Feb 4, 2012, 12:02:10 PM2/4/12
to Google Maps JavaScript API v3
Hi
> The method of loading the API is exactly what Google recommends.
not exactly
See http://code.google.com/speed/page-speed/docs/rtt.html
http://code.google.com/speed/page-speed … rLoadingJS)
http://code.google.com/apis/maps/documentation/javascript/tutorial.html

Regards Davie

Alan Pearce

unread,
Feb 4, 2012, 12:31:34 PM2/4/12
to Google Maps JavaScript API v3
If you look here: http://code.google.com/apis/maps/documentation/javascript/tutorial.html#asynch
he is doing the same thing.

We are getting off topic now.

Alan

Ice

unread,
Feb 7, 2012, 1:24:27 AM2/7/12
to google-map...@googlegroups.com
Thanks guys really appreciate the help. Learned a lot.

We've decided to just turn the overview map off since that has made
the error irrelevant.
Reply all
Reply to author
Forward
0 new messages