Question

I would like to know if there is a way in B4A to get the geocode for a postal address and then assign it a unique number. If this can be done, please show me the coding needed to obtain the geocode and unique number.

I assume it would need to go out to a web site and get the geocode from there or use the Google Map API in some way.

Thanks.

Was it helpful?

Solution

Once you have obtained coordinates, call the Google Geocoding API web service.

You will need to pass parameters latlng (latitude/longitude) and sensor=true to receive a result. Other parameters can be included to filter results (http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests)

An example call would be http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true

Once you get a JSON response you can use the B4A JSON library to extract the data you require

OTHER TIPS

The only solution to this problem is to concatenate the LatLon numbers together as string. You can compress the very very long result by many ways.. you can convert the string back to a number then convert the number to HEX so you can get a more shorter line.

If you are sorting them in a DB table I would suggest having an extra column that is AUTO INCREMENT and use that as the primary key. When you insert each postal address you will get a matching unique ID.

The issue of course would be the unique id would be meaningless in and of itself. So unless you want to sort by the order the records were inserted I don't see what good sorting by this number would be, but I don't know what you are doing with the info.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top