Thanks for explaining.  I like your fallback idea and I'm going to use
it.  I was just trying to get a better handle on how this code works.
In my trial and error, everything failed unless I had that line in
there.  I thought it had something to do with the 'new
google.maps.LatLng' call.  I realize now that the issue was not
deleting a required function but deleting a var that was called later
- 'center: latlng,'

Thanks for your help and patience,
Stace


On Mar 3, 8:29 pm, pete <[email protected]> wrote:
> Hi there,
>
> No problem.
>
> That variable is a failsafe for the else statement, if you don't want
> the back-up, feel free to remove it.
>
> It was just an example of being able to provide some type of fallback,
> what you do in that else statement is up to you.
>
> Pete
>
> On Mar 4, 1:50 pm, stacef <[email protected]> wrote:
>
>
>
> > Hey-
>
> > Thanks for the help - that seem to have done the trick!
>
> > And thanks, too, for the tip on providing a default map if the geocode
> > is unsuccessful.
>
> > But for the sake of argument, assuming I didn't have that back up, I'm
> > confused about the use or need for the
> >           var latlng = new google.maps.LatLng(-33.397, 150.644);
> > line.  Why am I providing what are essentially incorrect coordinates
> > right out of the gate?  I think the line needs to be there but I think
> > I should be putting something different in there.
>
> > Arguments aside, thanks again for the help!
> > Stace
>
> > On Mar 3, 2:11 pm, pete <[email protected]> wrote:
>
> > > Hi there,
>
> > > Remove "center:latlng" from the "myOptions" variable.
>
> > > As a backup incase the geocode is unsuccessful, set the map center to
> > > your latlng like so
>
> > > else {
> > > alert("Geocode was not successful for the following reason: " +
> > > status);
> > > map.setCenter(latlng);
>
> > > }
>
> > > That's it.
>
> > > Pete
>
> > > On Mar 4, 3:54 am, stacef <[email protected]> wrote:
>
> > > > I'm trying to use maps in my CMS but I'm very new to the Google Maps
> > > > API.  I'd like the map to load based on a an address geocoded from  a
> > > > PHP variable.  I've figured it out in v2 but I'd prefer to do it in
> > > > v3.  Based on the code found in <a href="http://code.google.com/apis/
> > > > maps/documentation/v3/services.html#Geocoding">this tutorial</a> ,
> > > > I've come up with the following which sort of works - it loads the
> > > > LatLng map first, then loads mine - but I know it's not right.
>
> > > > <script type="text/javascript">
> > > >         <?php
> > > >                 $address = '1 california'.'San Francisco, CA';
> > > >         ?>
>
> > > >         var geocoder;
> > > >         var map;
> > > >         var address = "<?php echo $address; ?>";
>
> > > >         function initialize() {
> > > >                 geocoder = new google.maps.Geocoder();
> > > >                 var latlng = new google.maps.LatLng(-33.397, 150.644);
> > > >                 geocoder.geocode( { 'address': address}, 
> > > > function(results, status) {
> > > >                         if (status == google.maps.GeocoderStatus.OK) {
> > > >                                 
> > > > map.setCenter(results[0].geometry.location);
> > > >                                 var marker = new google.maps.Marker({
> > > >                                         map: map,
> > > >                                         position: 
> > > > results[0].geometry.location
> > > >                                 });
> > > >                         } else {
> > > >                                 alert("Geocode was not successful for 
> > > > the following reason: " +
> > > > status);
> > > >                         }
> > > >                 });
> > > >                 var myOptions = {
> > > >                         zoom: 8,
> > > >                         center: latlng,
> > > >                         mapTypeId: google.maps.MapTypeId.ROADMAP
> > > >                 }
> > > >                 map = new 
> > > > google.maps.Map(document.getElementById("map_canvas"),
> > > > myOptions);
> > > >         }
> > > > </script>
>
> > > > And here's a link
> > > > <a href="http://stacefelder.com/maptest.php";>http://stacefelder.com/
> > > > maptest.php</a>
>
> > > > I'm guessing this is one of those stupid fixes but I think I've been
> > > > staring at it too long and I can't figure it out.  All thoughts and
> > > > suggestions welcomed.
> > > > Thanks

-- 
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