简体   繁体   English

B4A可以获取地理编码信息吗?

[英]Can B4A get geocode information?

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. 我想知道B4A中是否有一种方法来获取邮政地址的地理编码,然后为其分配一个唯一的编号。 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. 我认为它将需要访问一个网站并从那里获取地理编码,或者以某种方式使用Google Map API。

Thanks. 谢谢。

Once you have obtained coordinates, call the Google Geocoding API web service. 获取坐标后,请调用Google Geocoding API网络服务。

You will need to pass parameters latlng (latitude/longitude) and sensor=true to receive a result. 您将需要传递参数latlng(纬度/经度)和sensor = true来接收结果。 Other parameters can be included to filter results (http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests) 可以包含其他参数以过滤结果(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 调用示例为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 收到JSON响应后,即可使用B4A JSON库提取所需的数据

The only solution to this problem is to concatenate the LatLon numbers together as string. 解决此问题的唯一方法是将LatLon数字连接在一起作为字符串。 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. 如果要在数据库表中对它们进行排序,建议您增加一列AUTO INCREMENT并将其用作主键。 When you insert each postal address you will get a matching unique ID. 当您插入每个邮政地址时,您将获得一个匹配的唯一ID。

The issue of course would be the unique id would be meaningless in and of itself. 当然,问题是唯一的ID本身就毫无意义。 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. 因此,除非您想按插入记录的顺序进行排序,否则我看不到按此编号进行排序的效果如何,但我不知道您对信息的处理方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM