OK, I figured it out thanks to your little clue, which took me down a
road of figuring out where the undefined lat was occurring.

Turns out that trying to figure out the bounds with each marker is not
an efficient use of the function.

Rather it is better to wait until all markers have been placed,
followed by extending the bounds of an array of latlng.

0 errors -- still get warnings in Safari about Resource interpreted as
image but transferred with MIME type text/html, but I'll take that.

        function AutoCenter()
        {
                var bounds = new google.maps.LatLngBounds();
                for(var z=0; z<mObjArray.length; z++)
                {
                        if(typeof(locationList[z]) != "undefined")
                        {
                                bounds.extend(locationList[z]);
                        }
                }
                map.fitBounds(bounds);
                var mSum = 0;
                var mZoom = map.getZoom();
                if(mObjArray.length<=5)
                {
                        mSum = parseInt(mZoom) - 2;
                }
                else if(mObjArray.length>15)
                {
                        mSum = parseInt(mZoom) + 1;
                }
                else
                {
                        mSum = parseInt(mZoom) + 1;
                }
                map.setZoom(mSum);
        }

The if, else if, else conditional is something that I noticed is
necessary when a certain number of markers have to be displayed.

Thanks for pointing me in the right direction.

On Jan 2, 7:28 pm, Alan Pearce <[email protected]> wrote:
> Not sure if it helps but the error I see in Chrome is "Uncaught
> TypeError: Cannot call method 'lat' of undefined" in main.js line 15.
>
> On Jan 2, 1:41 pm, kronus <[email protected]> wrote:
>
>
>
> > Hi guys,
>
> > Thanks for being here to help.
>
> > I have an error coming from line 15 
> > onhttp://maps.gstatic.com/intl/en_us/mapfiles/api-3/7/5/main.js
>
> > If you go tohttp://kronusproductions.com/test_dg/first.phpandclick
> > on any of the school districts.
>
> > I usually click on Acton because it is a small school district
> > consisting of 5 schools.
>
> > I will receive the error of a is undefined main.js line 15 for the
> > first marker, but none of the rest of the markers.
>
> > This is with any of the school districts that I select.
>
> > I have read some of the posts and I am ensuring that the code to
> > create the markers is after the map_canvas div is available.
>
> > I have tried to set a default map center.
>
> > I have tried to set a default maptype.
>
> > Nothing seems to get rid of this error.
>
> > Please help

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to