Marcelo,
Thanks for taking to time to reply.
Those values would work just fine for me if I weren't such a Maps/JS
newb so I apologize. If I were writing this in PHP, it would go
something like
$location=$_POST['location'];
$location_type = results[0].geometry.location_type;
if($location_type == 'ROOFTOP') {
$zoom = 16;
$msg = 'here is '.$location;
}
elseif(location_type == 'GEOMETRIC_CENTER') {
$zoom = 3;
$msg = 'could not find '.$location. 'but here is the street';
}
But then I'm not sure how to set the zoom in myOptions from that
variable or how to echo out the message from the $msg variable.
Thanks for any help and for your patience.
On Mar 26, 3:12 am, Marcelo <[email protected]> wrote:
> On Mar 24, 8:40 pm, stacef <[email protected]> wrote:
>
> > I'm trying to figure out how to set some variables based on geocode
> > accuracy and can't seem to find a solution.
>
> The invalid address returns an aproximate match on the street, and it
> has the fields:
> <partial_match>true</partial_match>
> <location_type>GEOMETRIC_CENTER</location_type>http://maps.google.com/maps/api/geocode/xml?address=6600%20Valencia%2...
>
> The valid address has the fields:
> <type>street_number</type>
> <location_type>ROOFTOP</location_type>http://maps.google.com/maps/api/geocode/xml?address=400%20Valencia%20...
>
> Aside from that, both results have a suggested viewport. Are those
> geometry values not suitable for your
> purposes?http://code.google.com/apis/maps/documentation/v3/services.html#Geoco...
>
> --
> Marcelo -http://maps.forum.nu
> --
>
>
>
> > I'm also new to the
> > Google Maps API.
>
> > For my situation, if the accuracy is high, I would like to return a
> > high zoom level and text to indicate 'here is what you're looking
> > for.' And if the accuracy is low, return a low zoom setting and text
> > to indicate 'couldn't find what you wanted but here is something
> > close.'
>
> > I have a test site here:http://www.stacefelder.com/maptest
>
> > Entering "480 Valencia St, San Francisco" - a valid address - returns
> > the map with a marker at that point and my desired zoom. But entering
> > "4800 Valencia St, San Francisco" - an invalid address - currently
> > returns the map with the same zoom and a marker in the middle of the
> > length of Valencia St., making it appear to be the location of that
> > address. In this case I would prefer to set the zoom to a lower number
> > and somehow indicate that the marker is not at 4800 Valencia (or 480
> > Valencia, for that matter) because it doesn't exist and that the map
> > is for the next best match (in this case, just Valencia St).
>
> > Here is the script I'm currently using:
> > <script type="text/javascript">
> > var geocoder;
> > var map;
> > function initialize() {
> > geocoder = new google.maps.Geocoder();
> > 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: 16,
> > mapTypeId: google.maps.MapTypeId.ROADMAP
> > }
> > map = new
> > google.maps.Map(document.getElementById("map_canvas"),
> > myOptions);
> > }
> > </script>
>
> > All thoughts and suggestions welcomed.
> > Thanks very much,
> > Stace
--
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.