I geolocate the user via the browser, display a map and populate country, 
state and city input boxes from the Google geocode object. When the user 
enters a specific address, I want to revise and re-display the map with a 
new mapCenter, more zoom, and eventually a marker and infowindow. Despite 
many hours of research and trials, I can't get the map to revise. As best I 
can tell from the Developer Tool in Chrome, the code fails/ceases in the 
geocoder.geocode line of the blur function, set out in bold below. Nothing 
below it has ever executed. This is localhost development, but here is 
relevant code.

    var map, geocoder, marker, infowindow; //global variables

    function initializeMap() {
    //initialize Google map, geolocate desktop user, and display after page 
loads
    //find country, state, and city for the user's location - populate 
their respective input boxes - this all works
    });

    //change the Google Map after a user enters a street address
    $("#streetAddress").blur(function() {
        //if state, city and street address locations are present
        if ( $(this).val().length > 0 && $("#state").val().length > 0 && 
$("#city3").val().length > 0  ) {
            var gAddress =  [$(this).val() + ", " + $("#city3").val() + ", 
" + $("#state").val()] ;
            //if no geocode object exists, create one
                if (!geocoder) {
                geocoder = new google.maps.Geocoder(); //create Geocoder 
object else use existing one from initializeMap() ?
                }
                //create a GeocoderRequest object
                var geoCoderRequest = {address:  gAddress}
                //make a Geocoder request
                geocoder.geocode( geoCoderRequest, function(results, 
status) {       * //this line fails, apparently*
                    //check if status is OK
                    if ( status === google.maps.GeocoderStatus.OK) {
                        //center existing map on location returned for this 
address
                        map.setCenter(results[0].geometry.location);
                        map.setZoom(14);
                        }    
                });            
        } else {
                return; //no action if gAddress is incomplete
            }
    });

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-maps-js-api-v3/-/bq_yFbZHKUEJ.
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