Can I get a google geocoder to tell me when a location cannot be found, and not just choose a city center?

I work with the google maps API and test a section that geocodes all addresses in the database that do not have coordinates, then generates a report that was successful and which failed.

If any of the places cannot be found, it should place the form at the top of the page so that the user can either change the address or specify the coordinates.

I know that a geocoder can return my code with a status code G_GEO_UNKNOWN_ADDRESS, but it never uses it. I put fake addresses in the database and got this:

The coordinates of 1337 Rawrmander Rd.
Were successfully set to:
    latitude: 49.170171
    longtitude: -123.136579

The coordinates of 5678 Imaginary Lane
Were successfully set to:
    latitude: 49.170171
    longtitude: -123.136579

He simply gave the city center (and continues to do so no matter what the address), instead of calling it an unknown address.

This is what I call a geocoder:

//in a for loop
setTimeout( "geocoder.getLocations(\"" +
    //address to send to google
    values[i]['house'] + " " +
    values[i]['street'] + " " +
    values[i]['streetType'] + ", " +
    "Richmond, BC, Canada\", " +
    //google returns to this function asynchronously
    "function(reply) { handleReply(processItem++, reply); } );"
    , 
    callTimeout);
callTimeout += 220;

I tried to change "Richmond, BC, Canada"only to "Richmond"in the hope that he would not know which city to choose and then return an unknown address, but instead he just chose the middle of Richmond, Virginia.

Does anyone know a way to "hint" on google to give me an unknown address, and not just pick something?

+3
source share
3 answers

I think you are looking for Accuracy Value . When you start the geocode, look at the accuracy value that is returned. Or are we talking about different things?

: , (5678 Imaginary Lane) :

200,4,44.9774820,-93.2643510

(701 1st Ave N), :

200,8,44.9782860,-93.2760830

(4 = TownLevel vs 8 = AddressLevel). , MN 2 = RegionLevel. 602 = G_GEO_UNKNOWN_ADDRESS ( 0 = ), , XX.

602,0,0,0
+4

, , : "1234 Imaginary St, Vancouver", : "Vancouver". , . , , .

+1

602, . , - . , . , , , .. , , .

0

Source: https://habr.com/ru/post/1716371/


All Articles