I've had another look through, I can't see a way around it (though my coding is far from expert!) as you need to initialize the map in order to pull in the geocoded locations. I would set the starting latlng to (0,0) as that will just flash blue (it's in the middle of the ocean off africa).
Then you can simplify and centralise your variables a little by changing it to this; if (status == google.maps.GeocoderStatus.OK) { var geoloc = results[0].geometry.location; map.setCenter(geoloc); var marker = new google.maps.Marker({ map: map, position: geoloc }); On Jul 25, 1:21 am, "geocode...@gmail.com" <geocode...@gmail.com> wrote: > On Jul 24, 5:10 pm, slindsey3000 <slindsey3...@gmail.com> wrote: > > > Thank you for responses. @William... tried that before didn't work. > > Seems it needs code in top part. > > > @Kesuke .. it is being developed on localhost right now and will be > > deployed when done... > > > map = new google.maps.Map(document.getElementById("map_canvas"), > > myOptions); > > > This is where it first builds map... centered in Australia... there > > must be a way to initialize map to address? > > No. You have to geocode the address (translate it to latitude/ > longitude), before you can use it to initialize the map. > > -- Larry > > > > > > > sigh... > > > On Jul 23, 8:47 pm, William <william.g...@gmail.com> wrote: > > > > On Jul 24, 10:38 am, slindsey3000 <slindsey3...@gmail.com> wrote: > > > > > Any cleanup suggestions? Thanks!! > > > > maybe create the map only once you know the geocode? > > > > function initialize() { > > > > geocoder = new google.maps.Geocoder(); > > > > var address = "10 Downing St,London,UK"; > > > > geocoder.geocode( { 'address': address}, function(results, status) > > > { > > > if (status == google.maps.GeocoderStatus.OK) { > > > > map = new > > > google.maps.Map(document.getElementById("map_canvas"), { > > > zoom: 12, > > > center: results[0].geometry.location, > > > mapTypeId: google.maps.MapTypeId.ROADMAP > > > }); > > > > var marker = new google.maps.Marker({ > > > map: map, > > > position: results[0].geometry.location > > > }); > > > > } else { > > > alert("Geocode was not successful for the following reason: " + > > > status); > > > } > > > }); > > > }- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - -- 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-maps-js-api...@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.