I'm really sorry, I'm working on a private site, however i'd be happy
to package up a zip file and send it to a single person if you're all
pretty sure the recursion is not occurring in the code i'm providing.

I have a page that allows users to change their address and trigger an
update to their latitude and longitude values by clicking a link.  In
MSIE 6 multiple changes to the values and clicks to the link will
trigger a stack overflow error that requires the task manager to get
out of.

I first thought it was too many links in too small a time, but i timed
myself and there are several seconds between even the fastest change
and click combination i can do.

my call to the api is as follows:
<script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;key=ABQIAAAAvPVEwip11UUBDyREqhzfFxRiZw2VGgwwZ_KMuQRZFBVA2H-
VHBQ9Do1-f1CMMeUBpW95pz4FJfM_GQ&sensor=true" type="text/javascript"></
script>

my functions are as follows:
<script type="text/javascript">


        var map = null;
        var propertyText = "";
        var geocoder = new GClientGeocoder();

        function showOnMap(plat, plng, displayhtml) {
                if (GBrowserIsCompatible()) {
                        map = new GMap2(document.getElementById("propertyMap"));
                        map.addControl(new GSmallMapControl());
                        var propertyIcon = new GIcon(G_DEFAULT_ICON);
                        // Set up our GMarkerOptions object
                        markerOptions = { icon:propertyIcon };
                        marker = new GMarker(new GLatLng(plat, plng), 
markerOptions);
                        map.addOverlay(marker);
                        map.setCenter(new GLatLng(plat, plng), 12);
                        marker.openInfoWindowHtml(displayhtml);

                }
        }

        function showAddress(address,displayhtml) {
                map = new GMap2(document.getElementById("propertyMap"));
                geocoder.getLatLng(
                    address,
                    function(point) {
                        if (!point) {
                                alert(address + " not found");
                              } else {
                map.setCenter(point, 13);
                        var marker = new GMarker(point);
                        map.addOverlay(marker);
                        map.addControl(new GSmallMapControl());
                                //map.enableGoogleBar();
                                marker.openInfoWindowHtml(displayhtml);
                        //marker.openInfoWindowHtml(address);
                      }
                }
                );
        }

        function viewHideMap(pDivID){
                if (document.getElementById(pDivID).style.visibility == 
'hidden'){
                        document.getElementById(pDivID).style.display == 
'inline';
                        document.getElementById(pDivID).style.visibility == 
'visibile';
                }
        }

        function updateLatLng(address1, address2, city, state, zip){
                var divID = 'lat_long_disp';
                var add1Length = (address1 ? address1.length : 0);
                var add2Length = (address2 ? address2.length : 0);
                var cityLength = (city ? city.length : 0);
                var stateLength = (state ? state.length : 0);
                var zipLength = (zip ? zip.length : 0);
                var addy = '';
                if (add1Length > 0){addy = addy + address1 + ', '}
                if (add2Length > 0){addy = addy + address2 + ', '}
                if (cityLength > 0){addy = addy + city + ', '}
                if (stateLength > 0){addy = addy + state + ' '}
                if (zipLength > 0){addy = addy + zip + ' USA'}
                geocoder.getLatLng(
                    addy,
                    function(point) {
                        if (!point) {
                                alert(addy + " not found");
                              } else {
                                var strPoint = String(point);
                        x = strPoint.indexOf(',');
                        z = strPoint.indexOf(')');
                        plat = strPoint.substring(1,x);
                        plong = strPoint.substring(x+1,z)
                        document.getElementById('latitude').value = plat;
                        document.getElementById('longitude').value = plong;
                                        // display the div
                                        if (document.getElementById) { // DOM3 
= IE5, NS6
                                                
document.getElementById(divID).style.display = 'block';
                                        } else {
                                                if (document.layers) { // 
Netscape 4
                                                        document.divID.display 
= 'block';
                                                } else { // IE 4
                                                        
document.all.divID.style.display = 'block';
                                                }
                                        }
                        displayhtml = 'Latitude: '+plat+'<br/>Longitude:'+plong
                        showOnMap(plat, plong, displayhtml);
                          }
                                }
                        );
        }

        function calcLatLong(){
                //ie does getelementbyid slightly wrong
                if (/msie/i.test (navigator.userAgent)) //only override IE
                        {
                          document.nativeGetElementById = 
document.getElementById;
                          document.getElementById = function(id)
                          {
                            var elem = document.nativeGetElementById(id);
                            if(elem)
                            {
                              //make sure that it is a valid match on id
                              if(elem.attributes['id'].value == id)
                              {
                                return elem;
                              }
                              else
                              {
                                //otherwise find the correct element
                                for(var i=1;i<document.all[id].length;i++)
                                {
                                  if(document.all[id][i].attributes['id'].value 
== id)
                                  {
                                    return document.all[id][i];
                                  }
                                }
                              }
                            }
                            return null;
                          }
                        }
                add1 = document.getElementById('address_1').value;
                add2 = document.getElementById('address_2').value;
                city = document.getElementById('city').value;
                //st = document.getElementById().value;
                zip = document.getElementById('zip').value;

                updateLatLng(add1,add2,city,'',zip);
        }


</script>

and my div contains the following information:
<div id="propertyMap" style="width: 300px; height: 300px;background-
color:#cccccc;">
                <script type="text/javascript">
                        var mylat = '42.946885';
                        var mylong = ' -85.714147';
                        var encoding = '2';
                        var addy = '1700 Butterworth Ave NW, Grand Rapids, MI 
49534';
                        var htmladdy = '1700 Butterworth Ave NW,<br/> Grand 
Rapids, MI
49534';
                        var htmllatlng = 'Latitude: 42.946885<br/>Longitude:  
-85.714147';
                        if (addy.length > 4)
                                {var useAddy = true;}
                        else {var useAddy = false;}

                        //if they are using NAD27 use the address for mapping 
(if it
exists)
                        if (encoding == 1)
                                {
                                if (useAddy)
                                        {showAddress(addy,htmladdy);}
                                }
                        else {
                                if (mylat != 0 && mylong != 0)
                                        {showOnMap(mylat,mylong, htmllatlng);}
                                else {
                                                if (useAddy)
                                                        
{showAddress(addy,htmladdy);}
                                        }
                                }

                </script>
                <p style="margin-top:100px;text-align:center;">Unable to Display
Map.</p>
        </div>


the link that calls the gmapi is
<a href="javaScript:calcLatLong();">Update Lattitude/Longitude below
based on address</a>

of course, when i pulled JUSt the relevant code out of the full page,
the problem stopped occurring, so it IS entirely possible that the
recursion is occurring elsewhere, but only being noticed when the link
is clicked with changes more than once...

any advice would be useful, i'm sorry, i tried to make a sample page,
but the error wasn't on it.  i'm still working on that if i get it
working i'll post it for y'all.

the first few lines of updatelatlng() and the first part of the
function in calclatlng() are items i originally got online to SOLVE
MSIE related issues, but they too could be the problem.

--

You received this message because you are subscribed to the Google Groups 
"Google Maps API" 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-api?hl=.


Reply via email to