Hello all,

I have been experimenting with the code but I'm still unable to get an
accurate result. Each address has an unique postal+house number so why can't
I search for postal + house number with google maps?

Greetings,
 Johan

On Fri, Sep 10, 2010 at 2:34 PM, Johan Arensman <[email protected]> wrote:

> Hello everyone,
>
> We have a system that allows you to add addresses by only using a postal
> code and a house number in the Netherlands.
>
> I got it working but it's not pretty and far from accurate because I'm
> using 3 geocode requests of which the first is impossible to do directly
> with the number.
>
> 1: geolocate postal + country such as "3267LP, The Netherlands"
> 2: reverse geolocate the coords from step 1 for the extra information such
> as street etc.
> 3: geolocate the extended address.
>
> But if I use the postal code in the above example, I end up on the
> 'Gebrokendijk', I should be on 'Oude Nieuwlandsedijk'. This probably happens
> because the first geolocation is done without a house number and the
> 'center' or 'start' of this postal zone is closer to that street instead of
> the correct one? (no expert here). Is there any way to create a working
> geolocation with all the information i have (postal+housenumber+country) ?
>
> Can you please tell me if there's another way to achieve this? I can't
> change the input, i only got postal + house number.
>
> Here is my code, I've removed any code not related to the geolocation and
> added comments. I've also saved this snippet to jsbin:
> http://jsbin.com/ugota3/edit for some highlighting
>
> try {
> // test input:
> var country = 'The Netherlands';
> var postal = '3267LP';
> var number = '7';
>
> // 1: geocode postal and country:
> var result = gc.geocode({address: postal+', '+country}, function(results,
> status) {
>     if(status == google.maps.GeocoderStatus.OK) {
>         // 2: reverse geocode the coordinates:
>         gc.geocode({latLng: results[0].geometry.location},
> function(results, status) {
>             if(results[0]) {
>                 // get the correctly formatted address:
>                 var address = results[0].formatted_address;
>                 if(results[0].types[0] == 'street_address') {
>                     address = results[0].address_components[1].long_name+'
> '+number+', '+postal+' '
>                        +results[0].address_components[2].long_name+'
> '+results[0].address_components[5].long_name;
>                 } else if(results[0].types[0] == 'route') {
>                     address = results[0].address_components[0].long_name+'
> '+number+', '+postal+' '
>                        +results[0].address_components[1].long_name+'
> '+results[0].address_components[4].long_name;
>                 }
>                 // 3: geocode the exact address:
>                 gc.geocode({address: address}, function(results, status) {
>                     if(results[0]) {
>                         // create marker:
>                         new google.maps.Marker({
>                             map: map.map,
>                             position: results[0].geometry.location,
>                             icon: tinyIcon,
>                             title: address
>                         });
>                         // show address
>                         addressElement.update(address);
>                     } else {
>                         //alert("Geocode 3 was not successful for the
> following reason: " + status);
>                         return false;
>                     }
>                 });
>             } else {
>                 //alert("Geocode 2 was not successful for the following
> reason: " + status);
>                 return false;
>             }
>         });
>         map.setCenter(results[0].geometry.location);
>         marker.setPosition(results[0].geometry.location);
>     } else {
>         //alert("Geocode was not successful for the following reason: " +
> status);
>         return false;
>     }
> });
> } catch(e) {
>     console.error(e);
> }
> // end
>
> I really hope you can help me make this script more accurate.
> Have i missed something? Am I thinking wrong? Or are these the limits of
> the geocoder?
>
> Greetings,
>  Johan Arensman
>

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